Skip to content

Commit 139fa52

Browse files
committed
fix: remove extra leading size byte when using pubKeyHash to recreate script on the sighashTx
1 parent 8b1048a commit 139fa52

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dashtx.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ var DashTx = ("object" === typeof module && exports) || {};
10631063
`signable input must have either 'pubKeyHash' or 'script'`,
10641064
);
10651065
}
1066-
lockScript = `${PKH_SCRIPT_SIZE}${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
1066+
lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
10671067
}
10681068
return {
10691069
txId: input.txId,
@@ -1259,8 +1259,8 @@ var DashTx = ("object" === typeof module && exports) || {};
12591259
}
12601260
assertHex(output.pubKeyHash, `output[${i}].pubKeyHash`);
12611261

1262-
//let lockScript = `${PKH_SCRIPT_SIZE}${OP_DUP}${OP_HASH160}${PKH_SIZE}${output.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
12631262
outputHex.push(PKH_SCRIPT_SIZE);
1263+
//let lockScript = `${OP_DUP}${OP_HASH160}${PKH_SIZE}${output.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
12641264
outputHex.push(`${OP_DUP}${OP_HASH160}`);
12651265
outputHex.push(PKH_SIZE);
12661266
outputHex.push(output.pubKeyHash);
@@ -1330,8 +1330,8 @@ var DashTx = ("object" === typeof module && exports) || {};
13301330

13311331
let lockScriptSizeHex = TxUtils.toVarInt(lockScriptSize);
13321332

1333-
//let lockScript = `${lockScriptSizeHex}${opReturn}${memoSizeHex}${memoHex}`;
13341333
outputHex.push(lockScriptSizeHex);
1334+
//let lockScript = `${opReturn}${memoSizeHex}${memoHex}`;
13351335
outputHex.push(opReturn);
13361336
outputHex.push(memoSizeHex);
13371337
outputHex.push(memoHex);

tests/memo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Zora.test("can create memo tx", async function (t) {
9999
let txInfoSigned = await dashTx.hashAndSignAll(txInfo, keys);
100100

101101
let rawtx =
102-
"03000000017777777777777777777777777777777777777777777777777777777777777777000000006a4730440220404c24dd8fff16b226c4795093b49e1060039c687120a9aaeca65cf321c593e00220180b160b3b2e937f9f5b9a8658a55c7511926b4631c421813c659e4f22b29140012103f808bdec4293bf12441ec9a9e61bc3b264c78fcc5ad499ce5f0799f2874e6856ffffffff0200000000000000000e6a0c48656c6c6f2c204461736821484d0000000000001976a91482754a9c935fbfcdda5995a32006a68a8156ee2b88ac00000000";
102+
"03000000017777777777777777777777777777777777777777777777777777777777777777000000006b483045022100888db2ea9388e2c29d2480fd3374250cb2242a7dfa0e4bc6d82ac01b58f99dfb02200fe878c74f58eebf234f31a43a17bc6ea1535de6f7f2329ac007107888a39199012103f808bdec4293bf12441ec9a9e61bc3b264c78fcc5ad499ce5f0799f2874e6856ffffffff0200000000000000000e6a0c48656c6c6f2c204461736821484d0000000000001976a91482754a9c935fbfcdda5995a32006a68a8156ee2b88ac00000000";
103103

104104
t.equal(txInfoSigned.transaction, rawtx, "created transaction with memo");
105105
});
@@ -129,7 +129,7 @@ Zora.test("can create donation tx via memo", async function (t) {
129129
let txHex = txInfoSigned.transaction;
130130

131131
let rawtx =
132-
"03000000017777777777777777777777777777777777777777777777777777777777777777000000006b483045022100d2a13920c4002ee76df3cd3a0afcebb12e71871c63bb49ba379de6d709f488b60220627252f66903c3dfa69ba86a581c09342721a15d75e2a455a2dff09187e7668e012103f808bdec4293bf12441ec9a9e61bc3b264c78fcc5ad499ce5f0799f2874e6856ffffffff010000000000000000066a04f09fa7a700000000";
132+
"03000000017777777777777777777777777777777777777777777777777777777777777777000000006a473044022031192f34981eee578bdd8a5347f6f2d78e466af0749865b785b260d9cd4202930220193cc65d5e430784f4a92dc6d2ae78ca382262379a465d254ecbc5134c20bded012103f808bdec4293bf12441ec9a9e61bc3b264c78fcc5ad499ce5f0799f2874e6856ffffffff010000000000000000066a04f09fa7a700000000";
133133

134134
t.equal(txHex, rawtx, "created donation transaction via memo");
135135
});

0 commit comments

Comments
 (0)