@@ -231,16 +231,9 @@ var DashTx = ("object" === typeof module && exports) || {};
231
231
let txInst = { } ;
232
232
233
233
/** @type {TxHashAndSignAll } */
234
- txInst . hashAndSignAll = async function ( txInfo , keys ) {
234
+ txInst . hashAndSignAll = async function ( txInfo ) {
235
235
let privUtils = keyUtils ;
236
- if ( keys ) {
237
- if ( keys . length !== txInfo . inputs . length ) {
238
- let msg = `the number and order of 'keys' must match number of 'inputs' - each 'utxo' of the provided private key must be matched to that private key` ;
239
- throw new Error ( msg ) ;
240
- }
241
- privUtils = Object . assign ( { } , keyUtils ) ;
242
- }
243
- void Tx . _addPrivKeyUtils ( privUtils , keys ) ;
236
+ void Tx . _addPrivKeyUtils ( privUtils ) ;
244
237
245
238
return await Tx . _hashAndSignAll ( txInfo , privUtils ) ;
246
239
} ;
@@ -323,19 +316,18 @@ var DashTx = ("object" === typeof module && exports) || {};
323
316
324
317
/**
325
318
* @param {TxDraft } txDraft
326
- * @param {Array<TxPrivateKey> } keys
327
319
* @returns {Promise<TxSummary> }
328
320
*/
329
- txInst . legacy . finalizePresorted = async function ( txDraft , keys ) {
321
+ txInst . legacy . finalizePresorted = async function ( txDraft ) {
330
322
/** @type {TxInfoSigned } */
331
323
let txSigned = await txInst . legacy
332
- . _signToTarget ( txDraft , keys )
324
+ . _signToTarget ( txDraft )
333
325
. catch ( async function ( e ) {
334
326
if ( "E_NO_ENTROPY" !== e . code ) {
335
327
throw e ;
336
328
}
337
329
338
- let _txSigned = await txInst . legacy . _signFeeWalk ( txDraft , keys ) ;
330
+ let _txSigned = await txInst . legacy . _signFeeWalk ( txDraft ) ;
339
331
return _txSigned ;
340
332
} ) ;
341
333
@@ -345,10 +337,9 @@ var DashTx = ("object" === typeof module && exports) || {};
345
337
346
338
/**
347
339
* @param {TxDraft } txDraft
348
- * @param {Array<Uint8Array> } keys
349
340
* @returns {Promise<TxInfoSigned> }
350
341
*/
351
- txInst . legacy . _signToTarget = async function ( txDraft , keys ) {
342
+ txInst . legacy . _signToTarget = async function ( txDraft ) {
352
343
let limit = 128 ;
353
344
let lastTx = "" ;
354
345
let hasEntropy = true ;
@@ -358,7 +349,7 @@ var DashTx = ("object" === typeof module && exports) || {};
358
349
let fee ;
359
350
360
351
for ( let n = 0 ; true ; n += 1 ) {
361
- txSigned = await txInst . hashAndSignAll ( txDraft , keys ) ;
352
+ txSigned = await txInst . hashAndSignAll ( txDraft ) ;
362
353
363
354
fee = txSigned . transaction . length / 2 ;
364
355
if ( fee <= txDraft . feeTarget ) {
@@ -391,10 +382,9 @@ var DashTx = ("object" === typeof module && exports) || {};
391
382
* Strategy for signing transactions when a non-entropy signing method is used -
392
383
* exhaustively walk each possible signature until one that works is found.
393
384
* @param {TxDraft } txDraft
394
- * @param {Array<Uint8Array> } keys
395
385
* @returns {Promise<TxInfoSigned> }
396
386
*/
397
- txInst . legacy . _signFeeWalk = async function ( txDraft , keys ) {
387
+ txInst . legacy . _signFeeWalk = async function ( txDraft ) {
398
388
//@ts -ignore - TODO should have satoshis by now
399
389
let totalIn = DashTx . sum ( txDraft . inputs ) ;
400
390
let totalOut = DashTx . sum ( txDraft . outputs ) ;
@@ -424,7 +414,7 @@ var DashTx = ("object" === typeof module && exports) || {};
424
414
txDraft . outputs [ outIndex ] . satoshis -= 1 ;
425
415
totalFee += 1 ;
426
416
427
- txSigned = await txInst . hashAndSignAll ( txDraft , keys ) ;
417
+ txSigned = await txInst . hashAndSignAll ( txDraft ) ;
428
418
429
419
let byteFee = txSigned . transaction . length / 2 ;
430
420
if ( byteFee <= totalFee ) {
@@ -627,8 +617,8 @@ var DashTx = ("object" === typeof module && exports) || {};
627
617
* - ASC `outputIndex` (a.k.a. `output_index`, `vout`)
628
618
*/
629
619
Tx . sortInputs = function ( a , b ) {
630
- let aTxid = a . txid || a . txId ;
631
- let bTxid = b . txid || b . txId ;
620
+ let aTxid = a . txId || a . txid ;
621
+ let bTxid = b . txId || b . txid ;
632
622
// Ascending Lexicographical on TxId (prev-hash) in-memory (not wire) byte order
633
623
if ( aTxid > bTxid ) {
634
624
return 1 ;
@@ -735,19 +725,10 @@ var DashTx = ("object" === typeof module && exports) || {};
735
725
736
726
/**
737
727
* @param {TxDeps } privUtils
738
- * @param {Array<TxPrivateKey> } keys
739
728
*/
740
- Tx . _addPrivKeyUtils = function ( privUtils , keys ) {
729
+ Tx . _addPrivKeyUtils = function ( privUtils ) {
741
730
if ( ! privUtils . getPrivateKey ) {
742
- if ( ! keys ) {
743
- throw new Error ( `you must create with 'getPrivateKey()'` ) ;
744
- }
745
- /** @type {TxGetPrivateKey } */
746
- privUtils . getPrivateKey = async function ( _ , i ) {
747
- //@ts -ignore - keys *is* defined, see above
748
- let privKey = keys [ i ] ;
749
- return privKey ;
750
- } ;
731
+ throw new Error ( `you must create with 'opts.getPrivateKey()'` ) ;
751
732
}
752
733
753
734
if ( ! privUtils . getPublicKey ) {
@@ -1619,7 +1600,7 @@ if ("object" === typeof module) {
1619
1600
1620
1601
/**
1621
1602
* @typedef CoreUtxo
1622
- * @property {String } txId
1603
+ * @property {String } txid
1623
1604
* @property {Number } outputIndex
1624
1605
* @property {String } address
1625
1606
* @property {String } script
@@ -1685,7 +1666,8 @@ if ("object" === typeof module) {
1685
1666
/**
1686
1667
* @typedef TxInput
1687
1668
* @prop {String } [address] - BaseCheck58-encoded pubKeyHash
1688
- * @prop {String } txId - hex (not pre-reversed)
1669
+ * @prop {String } [txId] - deprecated
1670
+ * @prop {String } txid - hex (not pre-reversed)
1689
1671
* @prop {Uint32 } outputIndex - index in previous tx's output (vout index)
1690
1672
* @prop {String } signature - hex-encoded ASN.1 (DER) signature (starts with 0x30440220 or 0x30440221)
1691
1673
* @prop {String } [script] - the previous lock script (default: derived from public key as p2pkh)
@@ -1712,21 +1694,24 @@ if ("object" === typeof module) {
1712
1694
* @typedef TxInputRaw
1713
1695
* @prop {String } [address] - BaseCheck58-encoded pubKeyHash
1714
1696
* @prop {Uint53 } [satoshis] - for convenience
1715
- * @prop {String } txId - hex (not pre-reversed)
1697
+ * @prop {String } [txId] - deprecated
1698
+ * @prop {String } txid - hex (not pre-reversed)
1716
1699
* @prop {Uint32 } outputIndex - index in previous tx's output (vout index)
1717
1700
*/
1718
1701
1719
1702
/**
1720
1703
* @typedef TxInputUnspent
1721
1704
* @prop {String } [address] - BaseCheck58-encoded pubKeyHash
1722
1705
* @prop {Uint53 } satoshis
1723
- * @prop {String } txId - hex (not pre-reversed)
1706
+ * @prop {String } [txId] - deprecated
1707
+ * @prop {String } txid - hex (not pre-reversed)
1724
1708
* @prop {Uint32 } outputIndex - index in previous tx's output (vout index)
1725
1709
*/
1726
1710
1727
1711
/**
1728
1712
* @typedef TxInputSortable
1729
- * @prop {String } txId
1713
+ * @prop {String } [txId] - deprecated
1714
+ * @prop {String } txid
1730
1715
* @prop {Uint32 } outputIndex
1731
1716
*/
1732
1717
@@ -1736,7 +1721,7 @@ if ("object" === typeof module) {
1736
1721
*/
1737
1722
1738
1723
/**
1739
- * @typedef {Pick<TxInput, "txId"|"outputIndex"|"signature"|"publicKey"|"sigHashType"> } TxInputSigned
1724
+ * @typedef {Pick<TxInput, "txid"|" txId"|"outputIndex"|"signature"|"publicKey"|"sigHashType"> } TxInputSigned
1740
1725
*/
1741
1726
1742
1727
/**
@@ -1848,7 +1833,6 @@ if ("object" === typeof module) {
1848
1833
/**
1849
1834
* @callback TxHashAndSignAll
1850
1835
* @param {TxInfo } txInfo
1851
- * @param {Array<TxPrivateKey> } [keys]
1852
1836
*/
1853
1837
1854
1838
/**
0 commit comments