@@ -152,6 +152,7 @@ export class Psbt {
152
152
// We will disable exporting the Psbt when unsafe sign is active.
153
153
// because it is not BIP174 compliant.
154
154
__UNSAFE_SIGN_NONSEGWIT : false ,
155
+ __WARN_UNSAFE_SIGN_NONSEGWIT : true ,
155
156
__TX_FROM_BUFFER : buf =>
156
157
( this . constructor as typeof Psbt ) . transactionFromBuffer (
157
158
buf ,
@@ -775,6 +776,7 @@ interface PsbtCache {
775
776
__FEE ?: bigint ;
776
777
__EXTRACTED_TX ?: Transaction < bigint > ;
777
778
__UNSAFE_SIGN_NONSEGWIT : boolean ;
779
+ __WARN_UNSAFE_SIGN_NONSEGWIT : boolean ;
778
780
__TX_FROM_BUFFER : ( buf : Buffer ) => Transaction < bigint > ;
779
781
}
780
782
@@ -1363,15 +1365,17 @@ function getHashForSig(
1363
1365
`${ meaningfulScript . toString ( 'hex' ) } ` ,
1364
1366
) ;
1365
1367
if ( ! forValidate && cache . __UNSAFE_SIGN_NONSEGWIT !== false )
1366
- console . warn (
1367
- 'Warning: Signing non-segwit inputs without the full parent transaction ' +
1368
- 'means there is a chance that a miner could feed you incorrect information ' +
1369
- "to trick you into paying large fees. This behavior is the same as Psbt's predecesor " +
1370
- '(TransactionBuilder - now removed) when signing non-segwit scripts. You are not ' +
1371
- 'able to export this Psbt with toBuffer|toBase64|toHex since it is not ' +
1372
- 'BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n' +
1373
- '*********************' ,
1374
- ) ;
1368
+ if ( cache . __WARN_UNSAFE_SIGN_NONSEGWIT ) {
1369
+ console . warn (
1370
+ 'Warning: Signing non-segwit inputs without the full parent transaction ' +
1371
+ 'means there is a chance that a miner could feed you incorrect information ' +
1372
+ "to trick you into paying large fees. This behavior is the same as Psbt's predecesor " +
1373
+ '(TransactionBuilder - now removed) when signing non-segwit scripts. You are not ' +
1374
+ 'able to export this Psbt with toBuffer|toBase64|toHex since it is not ' +
1375
+ 'BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n' +
1376
+ '*********************' ,
1377
+ ) ;
1378
+ }
1375
1379
hash = unsignedTx . hashForSignature (
1376
1380
inputIndex ,
1377
1381
meaningfulScript ,
0 commit comments