def sig_hash(input, script=nil)
      # We only allow SIGHASH_ALL at this time
      # https://en.bitcoin.it/wiki/OP_CHECKSIG#Hashtype_SIGHASH_ALL_.28default.29

      prev_out = input.output
      script ||= prev_out.script

      @native.signature_hash_for_input(input.index, script.to_blob)
    end
def sig_hash(input, script=nil)
      # We only allow SIGHASH_ALL at this time
      # https://en.bitcoin.it/wiki/OP_CHECKSIG#Hashtype_SIGHASH_ALL_.28default.29

      prev_out = input.output
      script ||= prev_out.script

      @native.signature_hash_for_input(input.index, script.to_blob)
    end
Compute the digest for a given input.  This is the value that is actually
 signed in a transaction.
 e.g. I want to spend UTXO0 - I provide the UTXO0 as an input.
      I provide as a script the script to which UTXO0 was paid.
 If UTX0 was paid to a P2SH address, the script here needs to be the correct
 m-of-n structure, which may well not be part of the input.output object
 - This works here because we default to 2-of-3 and have consistent ordering
 When we support multiple m-of-n's, this may become a prollem.