From d2d194b20c3a24b8dc7ac70320ef4c1b05d7e65a Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 26 Apr 2024 23:42:22 -0600 Subject: [PATCH] doc+ref: fully deprecate .txId in favor of .txid --- dashtx.js | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/dashtx.js b/dashtx.js index 9dfddf1..18a7656 100644 --- a/dashtx.js +++ b/dashtx.js @@ -627,8 +627,8 @@ var DashTx = ("object" === typeof module && exports) || {}; * - ASC `outputIndex` (a.k.a. `output_index`, `vout`) */ Tx.sortInputs = function (a, b) { - let aTxid = a.txid || a.txId; - let bTxid = b.txid || b.txId; + let aTxid = a.txId || a.txid; + let bTxid = b.txId || b.txid; // Ascending Lexicographical on TxId (prev-hash) in-memory (not wire) byte order if (aTxid > bTxid) { return 1; @@ -988,8 +988,8 @@ var DashTx = ("object" === typeof module && exports) || {}; /** @type TxInputSigned */ let txInputSigned = { - txId: txInput.txId || txInput.txid, txid: txInput.txId || txInput.txid, + txId: txInput.txId || txInput.txid, outputIndex: txInput.outputIndex, signature: sigHex, publicKey: pubKeyHex, @@ -1027,6 +1027,7 @@ var DashTx = ("object" === typeof module && exports) || {}; return { //@ts-ignore - workaround for txId (insight) vs txid (dashcore rpc utxo) issue // (picking 'txId' over 'txid' may have been a mistake in a recent update) + txid: input.txId || input.txid, txId: input.txId || input.txid, outputIndex: input.outputIndex, }; @@ -1042,8 +1043,8 @@ var DashTx = ("object" === typeof module && exports) || {}; txInfoHashable.inputs = txInfo.inputs.map(function (input, i) { if (inputIndex !== i) { return { - txId: input.txId || input.txid, txid: input.txId || input.txid, + txId: input.txId || input.txid, outputIndex: input.outputIndex, }; } @@ -1127,20 +1128,20 @@ var DashTx = ("object" === typeof module && exports) || {}; for (let input of inputs) { let inputHex = []; - let txId = input.txId || input.txid; - if (!txId) { - throw new Error("missing required utxo property 'txId'"); + let txid = input.txId || input.txid; + if (!txid) { + throw new Error("missing required utxo property 'txid'"); } - if (64 !== txId.length) { + if (64 !== txid.length) { throw new Error( - `expected uxto property 'txId' to be a valid 64-character (32-byte) hex string, but got '${txId}' (size ${txId.length})`, + `expected uxto property 'txid' to be a valid 64-character (32-byte) hex string, but got '${txid}' (size ${txid.length})`, ); } - assertHex(txId, "txId"); + assertHex(txid, "txid"); - let reverseTxId = Tx.utils.reverseHex(txId); + let reverseTxId = Tx.utils.reverseHex(txid); inputHex.push(reverseTxId); let voutIndex = input.outputIndex; @@ -1619,7 +1620,8 @@ if ("object" === typeof module) { /** * @typedef CoreUtxo - * @property {String} txId + * @property {String} [txId] - deprecated + * @property {String} txid * @property {Number} outputIndex * @property {String} address * @property {String} script @@ -1685,7 +1687,8 @@ if ("object" === typeof module) { /** * @typedef TxInput * @prop {String} [address] - BaseCheck58-encoded pubKeyHash - * @prop {String} txId - hex (not pre-reversed) + * @prop {String} [txId] - deprecated + * @prop {String} txid - hex (not pre-reversed) * @prop {Uint32} outputIndex - index in previous tx's output (vout index) * @prop {String} signature - hex-encoded ASN.1 (DER) signature (starts with 0x30440220 or 0x30440221) * @prop {String} [script] - the previous lock script (default: derived from public key as p2pkh) @@ -1712,7 +1715,8 @@ if ("object" === typeof module) { * @typedef TxInputRaw * @prop {String} [address] - BaseCheck58-encoded pubKeyHash * @prop {Uint53} [satoshis] - for convenience - * @prop {String} txId - hex (not pre-reversed) + * @prop {String} [txId] - deprecated + * @prop {String} txid - hex (not pre-reversed) * @prop {Uint32} outputIndex - index in previous tx's output (vout index) */ @@ -1720,13 +1724,15 @@ if ("object" === typeof module) { * @typedef TxInputUnspent * @prop {String} [address] - BaseCheck58-encoded pubKeyHash * @prop {Uint53} satoshis - * @prop {String} txId - hex (not pre-reversed) + * @prop {String} [txId] - deprecated + * @prop {String} txid - hex (not pre-reversed) * @prop {Uint32} outputIndex - index in previous tx's output (vout index) */ /** * @typedef TxInputSortable - * @prop {String} txId + * @prop {String} [txId] - deprecated + * @prop {String} txid * @prop {Uint32} outputIndex */ @@ -1736,7 +1742,7 @@ if ("object" === typeof module) { */ /** - * @typedef {Pick} TxInputSigned + * @typedef {Pick} TxInputSigned */ /**