def verify_input_sig(input_index, script_pubkey, amount: nil, flags: STANDARD_SCRIPT_VERIFY_FLAGS)
      script_sig = inputs[input_index].script_sig
      has_witness = inputs[input_index].has_witness?

      if script_pubkey.p2sh?
        flags << SCRIPT_VERIFY_P2SH
        redeem_script = Script.parse_from_payload(script_sig.chunks.last)
        script_pubkey = redeem_script if redeem_script.p2wpkh?
      end

      if has_witness || Bitcoin.chain_params.fork_chain?
        verify_input_sig_for_witness(input_index, script_pubkey, amount, flags)
      else
        verify_input_sig_for_legacy(input_index, script_pubkey, flags)
      end
    end
def verify_input_sig(input_index, script_pubkey, amount: nil, flags: STANDARD_SCRIPT_VERIFY_FLAGS)
      script_sig = inputs[input_index].script_sig
      has_witness = inputs[input_index].has_witness?

      if script_pubkey.p2sh?
        flags << SCRIPT_VERIFY_P2SH
        redeem_script = Script.parse_from_payload(script_sig.chunks.last)
        script_pubkey = redeem_script if redeem_script.p2wpkh?
      end

      if has_witness || Bitcoin.chain_params.fork_chain?
        verify_input_sig_for_witness(input_index, script_pubkey, amount, flags)
      else
        verify_input_sig_for_legacy(input_index, script_pubkey, flags)
      end
    end
verify input signature.
 @param [Integer] input_index
 @param [Bitcoin::Script] script_pubkey the script pubkey for target input.
 @param [Integer] amount the amount of bitcoin, require for witness program only.
 @param [Array] flags the flags used when execute script interpreter.