Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix encoding exception #665

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions server/services/src101/psbt/src101MultisigPSBTService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ export class SRC101MultisigPSBTService {

const transferData = JSON.parse(transferString);
console.log("transferData:", transferData)
const msgpackData = msgpack.encode(transferData);
const { compressedData, compressed } = await SRC101Service.CompressionService
.compressWithCheck(msgpackData);

transferDataBytes = compressed ? compressedData : new TextEncoder().encode(JSON.stringify(transferData));
transferDataBytes = new TextEncoder().encode(JSON.stringify(transferData));
console.log("transferDataBytes:", bin2hex(transferDataBytes))

// Add stamp prefix and length prefix
const dataWithPrefix = new Uint8Array([...stampPrefixBytes, ...transferDataBytes]);
Expand All @@ -82,7 +80,6 @@ export class SRC101MultisigPSBTService {

const lengthPrefix = new Uint8Array([(dataLength >> 8) & 0xff, dataLength & 0xff]);
let payloadBytes = new Uint8Array([...lengthPrefix, ...dataWithPrefix]);

// Pad data
const padLength = (62 - (payloadBytes.length % 62)) % 62;
if (padLength > 0) {
Expand Down
Loading