@@ -152,6 +152,7 @@ export class Psbt {
152152 // We will disable exporting the Psbt when unsafe sign is active.
153153 // because it is not BIP174 compliant.
154154 __UNSAFE_SIGN_NONSEGWIT : false ,
155+ __WARN_UNSAFE_SIGN_NONSEGWIT : true ,
155156 __TX_FROM_BUFFER : buf =>
156157 ( this . constructor as typeof Psbt ) . transactionFromBuffer (
157158 buf ,
@@ -775,6 +776,7 @@ interface PsbtCache {
775776 __FEE ?: bigint ;
776777 __EXTRACTED_TX ?: Transaction < bigint > ;
777778 __UNSAFE_SIGN_NONSEGWIT : boolean ;
779+ __WARN_UNSAFE_SIGN_NONSEGWIT : boolean ;
778780 __TX_FROM_BUFFER : ( buf : Buffer ) => Transaction < bigint > ;
779781}
780782
@@ -1363,15 +1365,17 @@ function getHashForSig(
13631365 `${ meaningfulScript . toString ( 'hex' ) } ` ,
13641366 ) ;
13651367 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+ }
13751379 hash = unsignedTx . hashForSignature (
13761380 inputIndex ,
13771381 meaningfulScript ,
0 commit comments