56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/bitcoin/ffi/bitcoinconsensus.rb', line 56
def self.verify_script(input_index, script_pubkey, tx_payload, script_flags)
init
script_pub_key = FFI::MemoryPointer.new(
:uchar, script_pubkey.bytesize
).put_bytes(0, script_pubkey)
tx_to = FFI::MemoryPointer.new(:uchar, tx_payload.bytesize).put_bytes(0, tx_payload)
error_ret = FFI::MemoryPointer.new(:uint)
ret = bitcoinconsensus_verify_script(
script_pub_key, script_pub_key.size, tx_to, tx_to.size, input_index, script_flags, error_ret
)
case ret
when 0
false
when 1
ERR_CODES[error_ret.read_int] == :ok
else
raise 'error invalid result'
end
end
|