{"action":"created","issue":{"url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/172","labels_url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/172/comments","events_url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/172/events","html_url":"https://github.com/lian/bitcoin-ruby/issues/172","id":97361026,"number":172,"title":"Having issue with Bitcoin::P::Tx.from_json","user":{"login":"njmurarka","id":471362,"avatar_url":"https://avatars.githubusercontent.com/u/471362?v=3","gravatar_id":"","url":"https://api.github.com/users/njmurarka","html_url":"https://github.com/njmurarka","followers_url":"https://api.github.com/users/njmurarka/followers","following_url":"https://api.github.com/users/njmurarka/following{/other_user}","gists_url":"https://api.github.com/users/njmurarka/gists{/gist_id}","starred_url":"https://api.github.com/users/njmurarka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njmurarka/subscriptions","organizations_url":"https://api.github.com/users/njmurarka/orgs","repos_url":"https://api.github.com/users/njmurarka/repos","events_url":"https://api.github.com/users/njmurarka/events{/privacy}","received_events_url":"https://api.github.com/users/njmurarka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-27T00:14:26Z","updated_at":"2015-07-27T06:49:39Z","closed_at":null,"body":"Hi.\r\n\r\nI have been having alot of trouble trying to use this function as part of the process of creating and signing a new tx.\r\n\r\nI tried to do the following:\r\n\r\nprev_tx = Bitcoin::P::Tx.from_json(open(\"https://blockchain.info/rawtx/096cfd9c805b3d1c6881c988a0bbb73fd0ccf612205ec88909a9a4a24d27236d\"))\r\n\r\nAnd got back the following:\r\n\r\nNoMethodError: undefined method `gsub' for 480990:Fixnum\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/txout.rb:69:in `from_hash'\r\n\r\nI also tried the following instead:\r\n\r\nprev_tx = Bitcoin::P::Tx.from_json(open(\"https://api.chain.com/v2/bitcoin/transactions/096cfd9c805b3d1c6881c988a0bbb73fd0ccf612205ec88909a9a4a24d27236d?api-key-id=DEMO-4a5e1e4\"))\r\n\r\nAnd got back the following:\r\n\r\nprev_tx = Bitcoin::P::Tx.from_json(open(\"https://api.chain.com/v2/bitcoin/transactions/096cfd9c805b3d1c6881c988a0bbb73fd0ccf612205ec88909a9a4a24d27236d?api-key-id=DEMO-4a5e1e4\"))\r\nNoMethodError: undefined method `[]' for nil:NilClass\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/txin.rb:88:in `from_hash'\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/tx.rb:248:in `block in from_hash'\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/tx.rb:248:in `each'\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/tx.rb:248:in `from_hash'\r\n\tfrom /Users/loquitus/.rvm/gems/ruby-2.1.2/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/tx.rb:258:in `from_json'\r\n\r\n\r\nIs there a specific service I can get tx hashes from that will work with the library? I am assuming each of these services (chain.com and blockchain.info) are returning varying formats that are both unexpected...\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/comments/125105595","html_url":"https://github.com/lian/bitcoin-ruby/issues/172#issuecomment-125105595","issue_url":"https://api.github.com/repos/lian/bitcoin-ruby/issues/172","id":125105595,"user":{"login":"se3000","id":573827,"avatar_url":"https://avatars.githubusercontent.com/u/573827?v=3","gravatar_id":"","url":"https://api.github.com/users/se3000","html_url":"https://github.com/se3000","followers_url":"https://api.github.com/users/se3000/followers","following_url":"https://api.github.com/users/se3000/following{/other_user}","gists_url":"https://api.github.com/users/se3000/gists{/gist_id}","starred_url":"https://api.github.com/users/se3000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/se3000/subscriptions","organizations_url":"https://api.github.com/users/se3000/orgs","repos_url":"https://api.github.com/users/se3000/repos","events_url":"https://api.github.com/users/se3000/events{/privacy}","received_events_url":"https://api.github.com/users/se3000/received_events","type":"User","site_admin":false},"created_at":"2015-07-27T06:49:39Z","updated_at":"2015-07-27T06:49:39Z","body":"Try using a [transaction hex endpoint](https://chain.com/docs#bitcoin-transaction-hex), it's a standardized format across APIs.\r\n\r\n```\r\nprev_tx = Bitcoin::Protocol::Tx.new.tap do |tx|\r\n  tx.parse_data hex.htb\r\nend\r\n```"}}