Skip to content

Commit d2d194b

Browse files
committed
doc+ref: fully deprecate .txId in favor of .txid
1 parent 917ad95 commit d2d194b

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

dashtx.js

+23-17
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ 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;
630+
let aTxid = a.txId || a.txid;
631+
let bTxid = b.txId || b.txid;
632632
// Ascending Lexicographical on TxId (prev-hash) in-memory (not wire) byte order
633633
if (aTxid > bTxid) {
634634
return 1;
@@ -988,8 +988,8 @@ var DashTx = ("object" === typeof module && exports) || {};
988988

989989
/** @type TxInputSigned */
990990
let txInputSigned = {
991-
txId: txInput.txId || txInput.txid,
992991
txid: txInput.txId || txInput.txid,
992+
txId: txInput.txId || txInput.txid,
993993
outputIndex: txInput.outputIndex,
994994
signature: sigHex,
995995
publicKey: pubKeyHex,
@@ -1027,6 +1027,7 @@ var DashTx = ("object" === typeof module && exports) || {};
10271027
return {
10281028
//@ts-ignore - workaround for txId (insight) vs txid (dashcore rpc utxo) issue
10291029
// (picking 'txId' over 'txid' may have been a mistake in a recent update)
1030+
txid: input.txId || input.txid,
10301031
txId: input.txId || input.txid,
10311032
outputIndex: input.outputIndex,
10321033
};
@@ -1042,8 +1043,8 @@ var DashTx = ("object" === typeof module && exports) || {};
10421043
txInfoHashable.inputs = txInfo.inputs.map(function (input, i) {
10431044
if (inputIndex !== i) {
10441045
return {
1045-
txId: input.txId || input.txid,
10461046
txid: input.txId || input.txid,
1047+
txId: input.txId || input.txid,
10471048
outputIndex: input.outputIndex,
10481049
};
10491050
}
@@ -1127,20 +1128,20 @@ var DashTx = ("object" === typeof module && exports) || {};
11271128
for (let input of inputs) {
11281129
let inputHex = [];
11291130

1130-
let txId = input.txId || input.txid;
1131-
if (!txId) {
1132-
throw new Error("missing required utxo property 'txId'");
1131+
let txid = input.txId || input.txid;
1132+
if (!txid) {
1133+
throw new Error("missing required utxo property 'txid'");
11331134
}
11341135

1135-
if (64 !== txId.length) {
1136+
if (64 !== txid.length) {
11361137
throw new Error(
1137-
`expected uxto property 'txId' to be a valid 64-character (32-byte) hex string, but got '${txId}' (size ${txId.length})`,
1138+
`expected uxto property 'txid' to be a valid 64-character (32-byte) hex string, but got '${txid}' (size ${txid.length})`,
11381139
);
11391140
}
11401141

1141-
assertHex(txId, "txId");
1142+
assertHex(txid, "txid");
11421143

1143-
let reverseTxId = Tx.utils.reverseHex(txId);
1144+
let reverseTxId = Tx.utils.reverseHex(txid);
11441145
inputHex.push(reverseTxId);
11451146

11461147
let voutIndex = input.outputIndex;
@@ -1619,7 +1620,8 @@ if ("object" === typeof module) {
16191620

16201621
/**
16211622
* @typedef CoreUtxo
1622-
* @property {String} txId
1623+
* @property {String} [txId] - deprecated
1624+
* @property {String} txid
16231625
* @property {Number} outputIndex
16241626
* @property {String} address
16251627
* @property {String} script
@@ -1685,7 +1687,8 @@ if ("object" === typeof module) {
16851687
/**
16861688
* @typedef TxInput
16871689
* @prop {String} [address] - BaseCheck58-encoded pubKeyHash
1688-
* @prop {String} txId - hex (not pre-reversed)
1690+
* @prop {String} [txId] - deprecated
1691+
* @prop {String} txid - hex (not pre-reversed)
16891692
* @prop {Uint32} outputIndex - index in previous tx's output (vout index)
16901693
* @prop {String} signature - hex-encoded ASN.1 (DER) signature (starts with 0x30440220 or 0x30440221)
16911694
* @prop {String} [script] - the previous lock script (default: derived from public key as p2pkh)
@@ -1712,21 +1715,24 @@ if ("object" === typeof module) {
17121715
* @typedef TxInputRaw
17131716
* @prop {String} [address] - BaseCheck58-encoded pubKeyHash
17141717
* @prop {Uint53} [satoshis] - for convenience
1715-
* @prop {String} txId - hex (not pre-reversed)
1718+
* @prop {String} [txId] - deprecated
1719+
* @prop {String} txid - hex (not pre-reversed)
17161720
* @prop {Uint32} outputIndex - index in previous tx's output (vout index)
17171721
*/
17181722

17191723
/**
17201724
* @typedef TxInputUnspent
17211725
* @prop {String} [address] - BaseCheck58-encoded pubKeyHash
17221726
* @prop {Uint53} satoshis
1723-
* @prop {String} txId - hex (not pre-reversed)
1727+
* @prop {String} [txId] - deprecated
1728+
* @prop {String} txid - hex (not pre-reversed)
17241729
* @prop {Uint32} outputIndex - index in previous tx's output (vout index)
17251730
*/
17261731

17271732
/**
17281733
* @typedef TxInputSortable
1729-
* @prop {String} txId
1734+
* @prop {String} [txId] - deprecated
1735+
* @prop {String} txid
17301736
* @prop {Uint32} outputIndex
17311737
*/
17321738

@@ -1736,7 +1742,7 @@ if ("object" === typeof module) {
17361742
*/
17371743

17381744
/**
1739-
* @typedef {Pick<TxInput, "txId"|"outputIndex"|"signature"|"publicKey"|"sigHashType">} TxInputSigned
1745+
* @typedef {Pick<TxInput, "txId"|"txid"|"outputIndex"|"signature"|"publicKey"|"sigHashType">} TxInputSigned
17401746
*/
17411747

17421748
/**

0 commit comments

Comments
 (0)