Skip to content

Commit ea4a79b

Browse files
committed
ref!: make TxUtils.toUint32LE(n) public
1 parent fb39a86 commit ea4a79b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

dashtx.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ var DashTx = ("object" === typeof module && exports) || {};
11531153
void Tx.serializeInputs(inputs, { _tx: tx, _sep: _sep });
11541154
void Tx.serializeOutputs(outputs, { _tx: tx, _sep: _sep });
11551155

1156-
let locktimeHex = TxUtils._toUint32LE(locktime);
1156+
let locktimeHex = TxUtils.toUint32LE(locktime);
11571157
tx.push(locktimeHex);
11581158

11591159
if (extraPayload) {
@@ -1165,7 +1165,7 @@ var DashTx = ("object" === typeof module && exports) || {};
11651165
let txHex = tx.join(_sep);
11661166

11671167
if (sigHashType) {
1168-
let sigHashTypeHex = TxUtils._toUint32LE(sigHashType);
1168+
let sigHashTypeHex = TxUtils.toUint32LE(sigHashType);
11691169
txHex = `${txHex}${sigHashTypeHex}`;
11701170
}
11711171

@@ -1215,7 +1215,7 @@ var DashTx = ("object" === typeof module && exports) || {};
12151215
`expected utxo property 'input[${i}]outputIndex' to be an integer representing this input's previous output index`,
12161216
);
12171217
}
1218-
let reverseVout = TxUtils._toUint32LE(voutIndex);
1218+
let reverseVout = TxUtils.toUint32LE(voutIndex);
12191219
tx.push(reverseVout);
12201220

12211221
//@ts-ignore - enum types not handled properly here
@@ -1817,12 +1817,12 @@ var DashTx = ("object" === typeof module && exports) || {};
18171817

18181818
//@ts-ignore
18191819
if (n <= MAX_U16) {
1820-
return "fd" + TxUtils._toUint32LE(n).slice(0, 4);
1820+
return "fd" + TxUtils.toUint32LE(n).slice(0, 4);
18211821
}
18221822

18231823
//@ts-ignore
18241824
if (n <= MAX_U32) {
1825-
return "fe" + TxUtils._toUint32LE(n);
1825+
return "fe" + TxUtils.toUint32LE(n);
18261826
}
18271827

18281828
//@ts-ignore
@@ -1850,7 +1850,7 @@ var DashTx = ("object" === typeof module && exports) || {};
18501850
* which is true in practice, and much simpler.
18511851
* @param {BigInt|Number} n - 32-bit positive int to encode
18521852
*/
1853-
TxUtils._toUint32LE = function (n) {
1853+
TxUtils.toUint32LE = function (n) {
18541854
// make sure n is uint32/int53, not int32
18551855
//n = n >>> 0;
18561856

@@ -1860,14 +1860,21 @@ var DashTx = ("object" === typeof module && exports) || {};
18601860
let hexLE = Tx.utils.reverseHex(hex);
18611861
return hexLE;
18621862
};
1863+
//@ts-ignore
1864+
TxUtils._toUint32LE = function (n) {
1865+
console.warn(
1866+
"warn: use public TxUtils.toUint32LE() instead of internal TxUtils._toUint32LE()",
1867+
);
1868+
return TxUtils.toUint32LE(n);
1869+
};
18631870

18641871
/**
18651872
* Just assumes that all target CPUs are Little-Endian,
18661873
* which is true in practice, and much simpler.
18671874
* @param {BigInt|Number} n - 16-bit positive int to encode
18681875
*/
18691876
TxUtils._toUint16LE = function (n) {
1870-
let hexLE = TxUtils._toUint32LE(n);
1877+
let hexLE = TxUtils.toUint32LE(n);
18711878
// ex: 03000800 => 0300
18721879
hexLE = hexLE.slice(0, 4);
18731880
return hexLE;

0 commit comments

Comments
 (0)