@@ -23,6 +23,7 @@ const FUTURE_SEGWIT_VERSION_WARNING =
23
23
'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
24
24
'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
25
25
'then decide when it is safe to use which version of segwit.' ;
26
+ const WARNING_STATES = [ false , false ] ;
26
27
function _toFutureSegwitAddress ( output , network ) {
27
28
const data = output . slice ( 2 ) ;
28
29
if (
@@ -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
/**
@@ -167,7 +171,10 @@ function toOutputScript(address, network) {
167
171
decodeBech32 . data . length >= FUTURE_SEGWIT_MIN_SIZE &&
168
172
decodeBech32 . data . length <= FUTURE_SEGWIT_MAX_SIZE
169
173
) {
170
- console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
174
+ if ( WARNING_STATES [ 1 ] === false ) {
175
+ console . warn ( FUTURE_SEGWIT_VERSION_WARNING ) ;
176
+ WARNING_STATES [ 1 ] = true ;
177
+ }
171
178
return bscript . compile ( [
172
179
decodeBech32 . version + FUTURE_SEGWIT_VERSION_DIFF ,
173
180
decodeBech32 . data ,
0 commit comments