Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitcoin::Script.parse_from_addr("tb1qft3tvl3nu7zzggg5unpvwzyg7y6tnwhpm546xt") in Ruby 3.0.2 (ArgumentError) #61

Open
ShigeichiroYamasaki opened this issue Oct 18, 2021 · 2 comments

Comments

@ShigeichiroYamasaki
Copy link

Bitcoin :: Script.parse_from_addr ("tb1qft3tvl3nu7zzggg5unpvwzyg7y6tnwhpm546xt") works fine in Ruby 3.0.1. but, in Ruby 3.0.2 it causes an error

home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:96:in rescue in rescue in parse_from_addr': Invalid address. (ArgumentError) from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:93:in rescue in parse_from_addr'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:87:in parse_from_addr' from (irb):43:in

'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/exe/irb:11:in <top (required)>' from /home/yamasaki/.rbenv/versions/3.0.2/bin/irb:25:in load'
from /home/yamasaki/.rbenv/versions/3.0.2/bin/irb:25:in <main>' /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/base58.rb:27:in block in decode': Value passed not a valid Base58 String. (ArgumentError)
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/base58.rb:26:in each' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/base58.rb:26:in each_with_index'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/base58.rb:26:in decode' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/util.rb:121:in decode_base58_address'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:94:in rescue in parse_from_addr' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:87:in parse_from_addr'
from (irb):43:in <main>' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/exe/irb:11:in <top (required)>'
from /home/yamasaki/.rbenv/versions/3.0.2/bin/irb:25:in load' from /home/yamasaki/.rbenv/versions/3.0.2/bin/irb:25:in '
/home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/class_loader.rb:99:in find': Tried to load unspecified class: Bitcoin::ChainParams (Psych::DisallowedClass) from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/class_loader.rb:28:in load'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/to_ruby.rb:424:in resolve_class' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/to_ruby.rb:213:in visit_Psych_Nodes_Mapping'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/visitor.rb:30:in visit' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/visitor.rb:6:in accept'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/to_ruby.rb:35:in accept' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/to_ruby.rb:318:in visit_Psych_Nodes_Document'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/visitor.rb:30:in visit' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/visitor.rb:6:in accept'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych/visitors/to_ruby.rb:35:in accept' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych.rb:335:in safe_load'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/psych-4.0.1/lib/psych.rb:370:in load' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/chain_params.rb:83:in init'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/chain_params.rb:56:in signet' from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin.rb:91:in chain_params'
from /home/yamasaki/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bitcoinrb-0.8.0/lib/bitcoin/script/script.rb:90:in `parse_from_addr'
... 4 levels...
i

@azuchi
Copy link
Contributor

azuchi commented Oct 19, 2021

It seems to work with Ruby 3.0.2 in my environment. Is the network specified as mainnet?
I think it works if you do the following.

Bitcoin.chain_params = :testnet
s = Bitcoin::Script.parse_from_addr('tb1qft3tvl3nu7zzggg5unpvwzyg7y6tnwhpm546xt')

@ShigeichiroYamasaki
Copy link
Author

ShigeichiroYamasaki commented Oct 19, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants