Skip to content

Commit d71175e

Browse files
committed
fix: accept txid (canonical) or txId (deprecated, from insight)
1 parent d7a4ee0 commit d71175e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

dashtx.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,13 @@ var DashTx = ("object" === typeof module && exports) || {};
627627
* - ASC `outputIndex` (a.k.a. `output_index`, `vout`)
628628
*/
629629
Tx.sortInputs = function (a, b) {
630+
let aTxid = a.txid || a.txId;
631+
let bTxid = b.txid || b.txId;
630632
// Ascending Lexicographical on TxId (prev-hash) in-memory (not wire) byte order
631-
if (a.txId > b.txId) {
633+
if (aTxid > bTxid) {
632634
return 1;
633635
}
634-
if (a.txId < b.txId) {
636+
if (aTxid < bTxid) {
635637
return -1;
636638
}
637639

@@ -986,7 +988,8 @@ var DashTx = ("object" === typeof module && exports) || {};
986988

987989
/** @type TxInputSigned */
988990
let txInputSigned = {
989-
txId: txInput.txId,
991+
txId: txInput.txId || txInput.txid,
992+
txid: txInput.txId || txInput.txid,
990993
outputIndex: txInput.outputIndex,
991994
signature: sigHex,
992995
publicKey: pubKeyHex,
@@ -1039,7 +1042,8 @@ var DashTx = ("object" === typeof module && exports) || {};
10391042
txInfoHashable.inputs = txInfo.inputs.map(function (input, i) {
10401043
if (inputIndex !== i) {
10411044
return {
1042-
txId: input.txId,
1045+
txId: input.txId || input.txid,
1046+
txid: input.txId || input.txid,
10431047
outputIndex: input.outputIndex,
10441048
};
10451049
}
@@ -1054,7 +1058,8 @@ var DashTx = ("object" === typeof module && exports) || {};
10541058
lockScript = `${PKH_SCRIPT_SIZE}${OP_DUP}${OP_HASH160}${PKH_SIZE}${input.pubKeyHash}${OP_EQUALVERIFY}${OP_CHECKSIG}`;
10551059
}
10561060
return {
1057-
txId: input.txId,
1061+
txId: input.txId || input.txid,
1062+
txid: input.txId || input.txid,
10581063
outputIndex: input.outputIndex,
10591064
pubKeyHash: input.pubKeyHash,
10601065
sigHashType: input.sigHashType,
@@ -1122,7 +1127,7 @@ var DashTx = ("object" === typeof module && exports) || {};
11221127
for (let input of inputs) {
11231128
let inputHex = [];
11241129

1125-
let txId = input.txId;
1130+
let txId = input.txId || input.txid;
11261131
if (!txId) {
11271132
throw new Error("missing required utxo property 'txId'");
11281133
}

0 commit comments

Comments
 (0)