62
62
* @prop {TxHexToBytes } hexToBytes
63
63
* @prop {TxBytesToHex } bytesToHex
64
64
* @prop {TxStringToHex } strToHex
65
+ * @prop {TxToUint32LE } toUint32LE
65
66
*/
66
67
67
68
/**
@@ -1153,7 +1154,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1153
1154
void Tx . serializeInputs ( inputs , { _tx : tx , _sep : _sep } ) ;
1154
1155
void Tx . serializeOutputs ( outputs , { _tx : tx , _sep : _sep } ) ;
1155
1156
1156
- let locktimeHex = TxUtils . _toUint32LE ( locktime ) ;
1157
+ let locktimeHex = TxUtils . toUint32LE ( locktime ) ;
1157
1158
tx . push ( locktimeHex ) ;
1158
1159
1159
1160
if ( extraPayload ) {
@@ -1165,7 +1166,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1165
1166
let txHex = tx . join ( _sep ) ;
1166
1167
1167
1168
if ( sigHashType ) {
1168
- let sigHashTypeHex = TxUtils . _toUint32LE ( sigHashType ) ;
1169
+ let sigHashTypeHex = TxUtils . toUint32LE ( sigHashType ) ;
1169
1170
txHex = `${ txHex } ${ sigHashTypeHex } ` ;
1170
1171
}
1171
1172
@@ -1215,7 +1216,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1215
1216
`expected utxo property 'input[${ i } ]outputIndex' to be an integer representing this input's previous output index` ,
1216
1217
) ;
1217
1218
}
1218
- let reverseVout = TxUtils . _toUint32LE ( voutIndex ) ;
1219
+ let reverseVout = TxUtils . toUint32LE ( voutIndex ) ;
1219
1220
tx . push ( reverseVout ) ;
1220
1221
1221
1222
//@ts -ignore - enum types not handled properly here
@@ -1817,12 +1818,12 @@ var DashTx = ("object" === typeof module && exports) || {};
1817
1818
1818
1819
//@ts -ignore
1819
1820
if ( n <= MAX_U16 ) {
1820
- return "fd" + TxUtils . _toUint32LE ( n ) . slice ( 0 , 4 ) ;
1821
+ return "fd" + TxUtils . toUint32LE ( n ) . slice ( 0 , 4 ) ;
1821
1822
}
1822
1823
1823
1824
//@ts -ignore
1824
1825
if ( n <= MAX_U32 ) {
1825
- return "fe" + TxUtils . _toUint32LE ( n ) ;
1826
+ return "fe" + TxUtils . toUint32LE ( n ) ;
1826
1827
}
1827
1828
1828
1829
//@ts -ignore
@@ -1850,7 +1851,7 @@ var DashTx = ("object" === typeof module && exports) || {};
1850
1851
* which is true in practice, and much simpler.
1851
1852
* @param {BigInt|Number } n - 32-bit positive int to encode
1852
1853
*/
1853
- TxUtils . _toUint32LE = function ( n ) {
1854
+ TxUtils . toUint32LE = function ( n ) {
1854
1855
// make sure n is uint32/int53, not int32
1855
1856
//n = n >>> 0;
1856
1857
@@ -1860,14 +1861,21 @@ var DashTx = ("object" === typeof module && exports) || {};
1860
1861
let hexLE = Tx . utils . reverseHex ( hex ) ;
1861
1862
return hexLE ;
1862
1863
} ;
1864
+ //@ts -ignore
1865
+ TxUtils . _toUint32LE = function ( n ) {
1866
+ console . warn (
1867
+ "warn: use public TxUtils.toUint32LE() instead of internal TxUtils._toUint32LE()" ,
1868
+ ) ;
1869
+ return TxUtils . toUint32LE ( n ) ;
1870
+ } ;
1863
1871
1864
1872
/**
1865
1873
* Just assumes that all target CPUs are Little-Endian,
1866
1874
* which is true in practice, and much simpler.
1867
1875
* @param {BigInt|Number } n - 16-bit positive int to encode
1868
1876
*/
1869
1877
TxUtils . _toUint16LE = function ( n ) {
1870
- let hexLE = TxUtils . _toUint32LE ( n ) ;
1878
+ let hexLE = TxUtils . toUint32LE ( n ) ;
1871
1879
// ex: 03000800 => 0300
1872
1880
hexLE = hexLE . slice ( 0 , 4 ) ;
1873
1881
return hexLE ;
@@ -2446,3 +2454,9 @@ if ("object" === typeof module) {
2446
2454
* @param {String } utf8
2447
2455
* @returns {String } - encoded bytes as hex
2448
2456
*/
2457
+
2458
+ /**
2459
+ * @callback TxToUint32LE
2460
+ * @param {Uint32 } n
2461
+ * @returns {Hex }
2462
+ */
0 commit comments