Skip to content

Commit 7b319d4

Browse files
authored
Update address.js
1 parent 44a3c52 commit 7b319d4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/address.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const FUTURE_SEGWIT_VERSION_WARNING =
2323
'End users MUST be warned carefully in the GUI and asked if they wish to proceed ' +
2424
'with caution. Wallets should verify the segwit version from the output of fromBech32, ' +
2525
'then decide when it is safe to use which version of segwit.';
26+
const WARNING_STATES = [false, false];
2627
function _toFutureSegwitAddress(output, network) {
2728
const data = output.slice(2);
2829
if (
@@ -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
/**
@@ -167,7 +171,10 @@ function toOutputScript(address, network) {
167171
decodeBech32.data.length >= FUTURE_SEGWIT_MIN_SIZE &&
168172
decodeBech32.data.length <= FUTURE_SEGWIT_MAX_SIZE
169173
) {
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+
}
171178
return bscript.compile([
172179
decodeBech32.version + FUTURE_SEGWIT_VERSION_DIFF,
173180
decodeBech32.data,

0 commit comments

Comments
 (0)