lian / bitcoin-ruby

bitcoin utils and protocol in ruby.
Other
922 stars 322 forks source link

prev_tx = Bitcoin::P::Tx.from_json(open("http://test.webbtc.com/tx/#{prev_hash}.json")) #280

Closed jfournier26 closed 5 years ago

jfournier26 commented 5 years ago

When I try to run the code in the instructions under Create Transactions it does not halt. I think this is because webbtc.com no longer works. So, I tried other sources:

prev_tx = Bitcoin::P::Tx.from_json(open("https://tchain.api.btc.com/v3/tx/#{prev_hash}")) This results in the following error: /home//.rvm/gems/ruby-2.2.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/protocol/tx.rb:404:in from_hash': undefined methodeach' for nil:NilClass (NoMethodError) from /home//.rvm/gems/ruby-2.2.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/protocol/tx.rb:425:in `from_json'

prev_tx = Bitcoin::P::Tx.from_json(open("https://api.blockcypher.com/v1/btc/test3/txs/#{prev_hash}")) This results in the following error: /home//.rvm/gems/ruby-2.2.2/gems/bitcoin-ruby-0.0.18/lib/bitcoin/protocol/txin.rb:99:in from_hash': undefined method[]' for nil:NilClass (NoMethodError)

I am using Ruby 2.2.2.

lian commented 5 years ago

don't use from_json anymore. get the binary or hex from any service and do Tx.new(binary) or Tx.new([hex].pack("H*"))