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

RuntimeError: Script type must be hash160, pubkey, p2wpkh or multisig #287

Open
yegor256 opened this issue Apr 9, 2019 · 1 comment
Open

Comments

@yegor256
Copy link

@yegor256 yegor256 commented Apr 9, 2019

What is wrong with my code?

    txn = build_tx do |tx|
      tx.input do |i|
        i.prev_out(txn)
        i.prev_out_index(0)
        i.signature_key(key)
      end
      tx.output do |o|
        o.value(satoshi)
        o.script { |s| s.recipient('1GzqkR2zNQUzHLpE7PLPjVNJ51FHC3bpDH') }
      end
    end

I'm getting:

RuntimeError: Script type must be hash160, pubkey, p2wpkh or multisig
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:239:in `sig_hash_and_all_keys_exist?'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:308:in `sign_input'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:208:in `block in tx'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:207:in `each'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:207:in `each_with_index'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:207:in `tx'
    /Users/yegor/.rvm/gems/ruby-2.6.0/gems/bitcoin-ruby-0.0.19/lib/bitcoin/builder.rb:21:in `build_tx'

I suspect there is something wrong with the format of the signature key but would be great to get a more meaningful message or at least fail sometime earlier when I'm building the transaction.

Cross-posted to SO: https://stackoverflow.com/questions/55595070/why-i-cant-sign-a-bitcoin-transaction-in-ruby

@yegor256

This comment has been minimized.

Copy link
Author

@yegor256 yegor256 commented Apr 10, 2019

I guess I know what's wrong. The tx['script'] is not a text, but a hash. That's why it can't be parsed. How do I convert hash160 script into its text format?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.