@@ -16,6 +16,7 @@ const FUTURE_SEGWIT_VERSION_WARNING =
16
16
'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
17
17
'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
18
18
'then decide when it is safe to use which version of segwit.' ;
19
+ const WARNING_STATES = [ false , false ] ;
19
20
/**
20
21
* Converts an output buffer to a future segwit address.
21
22
* @param output - The output buffer.
@@ -38,7 +39,10 @@ function _toFutureSegwitAddress(output, network) {
38
39
throw new TypeError ( 'Invalid version for segwit address' ) ;
39
40
if ( output [ 1 ] !== data . length )
40
41
throw new TypeError ( 'Invalid script for segwit address' ) ;
41
- console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
42
+ if ( WARNING_STATES [ 0 ] === false ) {
43
+ console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
44
+ WARNING_STATES [ 0 ] = true ;
45
+ }
42
46
return toBech32 ( data , version , network . bech32 ) ;
43
47
}
44
48
/**
@@ -181,7 +185,10 @@ export function toOutputScript(address, network) {
181
185
decodeBech32 . data . length >= FUTURE_SEGWIT_MIN_SIZE &&
182
186
decodeBech32 . data . length <= FUTURE_SEGWIT_MAX_SIZE
183
187
) {
184
- console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
188
+ if ( WARNING_STATES [ 1 ] === false ) {
189
+ console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
190
+ WARNING_STATES [ 1 ] = true ;
191
+ }
185
192
return bscript . compile ( [
186
193
decodeBech32 . version + FUTURE_SEGWIT_VERSION_DIFF ,
187
194
decodeBech32 . data ,
0 commit comments