bitcoinjs-lib
bitcoinjs-lib copied to clipboard
Reduce warnings about future segwit version when parsing output scripts
https://github.com/bitcoinjs/bitcoinjs-lib/blob/93af5afe67dbc491e36bdfc8d48a00179093f7d1/ts_src/address.ts#L52
I'm writing an app that continuously parses lots of transactions (for analysis purposes) This warning is printed every time such output-script is parsed, and it really spams my logs.
Please make it possible to avoid this warning, maybe via an environment variable. Another reasonable option is to print the warning only after the first time such an output-script is found, and not in following occurrences.
Thanks!
A few thoughts:
- This will be fixed for segwit v1 addresses in an upcoming release (once we finish taproot support)
- That said, console.warn was meant primarily for wallet developers to be sure that they don't show versions they can't guarantee are safe.
- However, we have no way programmatically to relay that info back to the program, and the program has no way to tell us "ok, I made my GUI understandable so the end user is not in danger".
- Also, we want to respect the BIP and DO NOT THROW on parsing unknown segwit versions.
Perhaps we should add a new set of functions for to/fromOutputScript and deprecate the current ones for removal in the next major version bump?
As a temporary solution, though super hackey, the consuming app could do something like:
function wrappedFromOutputScript(script, network) {
const oldWarn = console.warn
console.warn = () => {}
const result = fromOutputScript(script, network)
console.warn = oldWarn
return result
}
As a temporary solution, though super hackey, the consuming app could do something like:
function wrappedFromOutputScript(script, network) { const oldWarn = console.warn console.warn = () => {} const result = fromOutputScript(script, network) console.warn = oldWarn return result }

Is there an ETA on this at all?
Is there an ETA on this at all?
Please help review this PR https://github.com/bitcoinjs/bitcoinjs-lib/pull/1742, and the rest will follow 🎵
This also happens when parsing some Litecoin transactions.
Maybe adding an optional argument in fromOutputScript to disable these warnings?
I guess we can just do it once. See PR.