@@ -79,7 +79,6 @@ class Psbt {
79
79
// We will disable exporting the Psbt when unsafe sign is active.
80
80
// because it is not BIP174 compliant.
81
81
__UNSAFE_SIGN_NONSEGWIT : false ,
82
- __EC_LIB : opts . eccLib ,
83
82
} ;
84
83
if ( this . data . inputs . length === 0 ) this . setVersion ( 2 ) ;
85
84
// Make data hidden when enumerating
@@ -134,7 +133,6 @@ class Psbt {
134
133
address = ( 0 , address_1 . fromOutputScript ) (
135
134
output . script ,
136
135
this . opts . network ,
137
- this . __CACHE . __EC_LIB ,
138
136
) ;
139
137
} catch ( _ ) { }
140
138
return {
@@ -237,11 +235,7 @@ class Psbt {
237
235
const { address } = outputData ;
238
236
if ( typeof address === 'string' ) {
239
237
const { network } = this . opts ;
240
- const script = ( 0 , address_1 . toOutputScript ) (
241
- address ,
242
- network ,
243
- this . __CACHE . __EC_LIB ,
244
- ) ;
238
+ const script = ( 0 , address_1 . toOutputScript ) ( address , network ) ;
245
239
outputData = Object . assign ( outputData , { script } ) ;
246
240
}
247
241
const c = this . __CACHE ;
@@ -297,7 +291,6 @@ class Psbt {
297
291
isP2SH ,
298
292
isP2WSH ,
299
293
isTapscript ,
300
- this . __CACHE . __EC_LIB ,
301
294
) ;
302
295
if ( finalScriptSig ) this . data . updateInput ( inputIndex , { finalScriptSig } ) ;
303
296
if ( finalScriptWitness ) {
@@ -326,13 +319,9 @@ class Psbt {
326
319
input . redeemScript || redeemFromFinalScriptSig ( input . finalScriptSig ) ,
327
320
input . witnessScript ||
328
321
redeemFromFinalWitnessScript ( input . finalScriptWitness ) ,
329
- this . __CACHE ,
330
322
) ;
331
323
const type = result . type === 'raw' ? '' : result . type + '-' ;
332
- const mainType = classifyScript (
333
- result . meaningfulScript ,
334
- this . __CACHE . __EC_LIB ,
335
- ) ;
324
+ const mainType = classifyScript ( result . meaningfulScript ) ;
336
325
return type + mainType ;
337
326
}
338
327
inputHasPubkey ( inputIndex , pubkey ) {
@@ -769,9 +758,9 @@ function isFinalized(input) {
769
758
return ! ! input . finalScriptSig || ! ! input . finalScriptWitness ;
770
759
}
771
760
function isPaymentFactory ( payment ) {
772
- return ( script , eccLib ) => {
761
+ return script => {
773
762
try {
774
- payment ( { output : script } , { eccLib } ) ;
763
+ payment ( { output : script } ) ;
775
764
return true ;
776
765
} catch ( err ) {
777
766
return false ;
@@ -935,9 +924,8 @@ function getFinalScripts(
935
924
isP2SH ,
936
925
isP2WSH ,
937
926
isTapscript = false ,
938
- eccLib ,
939
927
) {
940
- const scriptType = classifyScript ( script , eccLib ) ;
928
+ const scriptType = classifyScript ( script ) ;
941
929
if ( isTapscript || ! canFinalize ( input , script , scriptType ) )
942
930
throw new Error ( `Can not finalize input #${ inputIndex } ` ) ;
943
931
return prepareFinalScripts (
@@ -1053,7 +1041,6 @@ function getHashForSig(
1053
1041
'input' ,
1054
1042
input . redeemScript ,
1055
1043
input . witnessScript ,
1056
- cache ,
1057
1044
) ;
1058
1045
if ( [ 'p2sh-p2wsh' , 'p2wsh' ] . indexOf ( type ) >= 0 ) {
1059
1046
hash = unsignedTx . hashForWitnessV0 (
@@ -1072,7 +1059,7 @@ function getHashForSig(
1072
1059
prevout . value ,
1073
1060
sighashType ,
1074
1061
) ;
1075
- } else if ( isP2TR ( prevout . script , cache . __EC_LIB ) ) {
1062
+ } else if ( isP2TR ( prevout . script ) ) {
1076
1063
const prevOuts = inputs . map ( ( i , index ) =>
1077
1064
getScriptAndAmountFromUtxo ( index , i , cache ) ,
1078
1065
) ;
@@ -1204,7 +1191,7 @@ function getScriptFromInput(inputIndex, input, cache) {
1204
1191
} else {
1205
1192
res . script = utxoScript ;
1206
1193
}
1207
- const isTaproot = utxoScript && isP2TR ( utxoScript , cache . __EC_LIB ) ;
1194
+ const isTaproot = utxoScript && isP2TR ( utxoScript ) ;
1208
1195
// Segregated Witness versions 0 or 1
1209
1196
if ( input . witnessScript || isP2WPKH ( res . script ) || isTaproot ) {
1210
1197
res . isSegwit = true ;
@@ -1410,7 +1397,6 @@ function pubkeyInInput(pubkey, input, inputIndex, cache) {
1410
1397
'input' ,
1411
1398
input . redeemScript ,
1412
1399
input . witnessScript ,
1413
- cache ,
1414
1400
) ;
1415
1401
return pubkeyInScript ( pubkey , meaningfulScript ) ;
1416
1402
}
@@ -1422,7 +1408,6 @@ function pubkeyInOutput(pubkey, output, outputIndex, cache) {
1422
1408
'output' ,
1423
1409
output . redeemScript ,
1424
1410
output . witnessScript ,
1425
- cache ,
1426
1411
) ;
1427
1412
return pubkeyInScript ( pubkey , meaningfulScript ) ;
1428
1413
}
@@ -1471,12 +1456,11 @@ function getMeaningfulScript(
1471
1456
ioType ,
1472
1457
redeemScript ,
1473
1458
witnessScript ,
1474
- cache ,
1475
1459
) {
1476
1460
const isP2SH = isP2SHScript ( script ) ;
1477
1461
const isP2SHP2WSH = isP2SH && redeemScript && isP2WSHScript ( redeemScript ) ;
1478
1462
const isP2WSH = isP2WSHScript ( script ) ;
1479
- const isP2TRScript = isP2TR ( script , cache && cache . __EC_LIB ) ;
1463
+ const isP2TRScript = isP2TR ( script ) ;
1480
1464
if ( isP2SH && redeemScript === undefined )
1481
1465
throw new Error ( 'scriptPubkey is P2SH but redeemScript missing' ) ;
1482
1466
if ( ( isP2WSH || isP2SHP2WSH ) && witnessScript === undefined )
@@ -1539,12 +1523,12 @@ function isTaprootSpend(scriptType) {
1539
1523
! ! scriptType && ( scriptType === 'taproot' || scriptType . startsWith ( 'p2tr-' ) )
1540
1524
) ;
1541
1525
}
1542
- function classifyScript ( script , eccLib ) {
1526
+ function classifyScript ( script ) {
1543
1527
if ( isP2WPKH ( script ) ) return 'witnesspubkeyhash' ;
1544
1528
if ( isP2PKH ( script ) ) return 'pubkeyhash' ;
1545
1529
if ( isP2MS ( script ) ) return 'multisig' ;
1546
1530
if ( isP2PK ( script ) ) return 'pubkey' ;
1547
- if ( isP2TR ( script , eccLib ) ) return 'taproot' ;
1531
+ if ( isP2TR ( script ) ) return 'taproot' ;
1548
1532
return 'nonstandard' ;
1549
1533
}
1550
1534
function range ( n ) {
0 commit comments