@@ -43,6 +43,7 @@ const FUTURE_SEGWIT_VERSION_WARNING: string =
4343 'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
4444 'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
4545 'then decide when it is safe to use which version of segwit.' ;
46+ let WARNING_STATES : boolean [ ] = [ false , false ] ;
4647
4748function _toFutureSegwitAddress ( output : Buffer , network : Network ) : string {
4849 const data = output . slice ( 2 ) ;
@@ -64,7 +65,10 @@ function _toFutureSegwitAddress(output: Buffer, network: Network): string {
6465 if ( output [ 1 ] !== data . length )
6566 throw new TypeError ( 'Invalid script for segwit address' ) ;
6667
67- console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
68+ if ( WARNING_STATES [ 0 ] === false ) {
69+ console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
70+ WARNING_STATES [ 0 ] = true ;
71+ }
6872
6973 return toBech32 ( data , version , network . bech32 ) ;
7074}
@@ -210,7 +214,10 @@ export function toOutputScript(address: string, network?: Network): Buffer {
210214 decodeBech32 . data . length >= FUTURE_SEGWIT_MIN_SIZE &&
211215 decodeBech32 . data . length <= FUTURE_SEGWIT_MAX_SIZE
212216 ) {
213- console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
217+ if ( WARNING_STATES [ 1 ] === false ) {
218+ console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
219+ WARNING_STATES [ 1 ] = true ;
220+ }
214221
215222 return bscript . compile ( [
216223 decodeBech32 . version + FUTURE_SEGWIT_VERSION_DIFF ,
0 commit comments