@@ -16,6 +16,7 @@ const FUTURE_SEGWIT_VERSION_WARNING =
1616 'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
1717 'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
1818 'then decide when it is safe to use which version of segwit.' ;
19+ const WARNING_STATES = [ false , false ] ;
1920/**
2021 * Converts an output buffer to a future segwit address.
2122 * @param output - The output buffer.
@@ -38,7 +39,10 @@ function _toFutureSegwitAddress(output, network) {
3839 throw new TypeError ( 'Invalid version for segwit address' ) ;
3940 if ( output [ 1 ] !== data . length )
4041 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+ }
4246 return toBech32 ( data , version , network . bech32 ) ;
4347}
4448/**
@@ -181,7 +185,10 @@ export function toOutputScript(address, network) {
181185 decodeBech32 . data . length >= FUTURE_SEGWIT_MIN_SIZE &&
182186 decodeBech32 . data . length <= FUTURE_SEGWIT_MAX_SIZE
183187 ) {
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+ }
185192 return bscript . compile ( [
186193 decodeBech32 . version + FUTURE_SEGWIT_VERSION_DIFF ,
187194 decodeBech32 . data ,
0 commit comments