bitcoinjs-lib icon indicating copy to clipboard operation
bitcoinjs-lib copied to clipboard

Reduce warnings about future segwit version when parsing output scripts

Open woofbotapp opened this issue 3 years ago • 8 comments
trafficstars

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!

woofbotapp avatar May 13 '22 20:05 woofbotapp

A few thoughts:

  1. This will be fixed for segwit v1 addresses in an upcoming release (once we finish taproot support)
  2. 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.
  3. 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".
  4. 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?

junderw avatar May 14 '22 03:05 junderw

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
}

junderw avatar May 14 '22 03:05 junderw

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
}

giphy

woofbotapp avatar May 14 '22 17:05 woofbotapp

Is there an ETA on this at all?

PatrickGeyer avatar Oct 26 '22 14:10 PatrickGeyer

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 🎵

motorina0 avatar Oct 26 '22 14:10 motorina0

This also happens when parsing some Litecoin transactions. Maybe adding an optional argument in fromOutputScript to disable these warnings?

pedrobranco avatar Apr 04 '24 11:04 pedrobranco

I guess we can just do it once. See PR.

junderw avatar Apr 04 '24 13:04 junderw