OP_CSV(bitcoinrb)
code:ruby
> require 'bitcoin'
> Bitcoin.chain_params = :regtest
> key = Bitcoin::Key.generate
> lock_block = 5
> redeem_script = Bitcoin::Script.from_string("#{lock_block} OP_NOP3 OP_DROP #{key.pubkey} OP_CHECKSIG") > redeem_script.to_p2sh.to_h
$ bitcoin-cli sendtoaddress "p2shアドレス" 1
code:transaction
> tx = Bitcoin::Tx.new
> tx.version = 2
> tx_in = Bitcoin::TxIn.new(out_point: out_point)
> out_point = Bitcoin::OutPoint.from_txid("txid", "index")
> tx_in.sequence = lock_block
> tx.in << tx_in
> tx_out = Bitcoin::TxOut.new(value: value, script_pubkey: script_pubkey)
> value = 99_990_000
> script_pubkey = Bitcoin::Script.parse_from_addr("address")
> tx.out << tx_out
> sign_tx = Marshal.load(Marshal.dump(tx))
> sign_tx.inputs0.script_sig = Bitcoin::Script.new << redeem_script.to_payload > sig_hash = sign_tx.sighash_for_input(0, redeem_script)
> sig = key.sign(sig_hash, false) + [Bitcoin::SIGHASH_TYPE:all].pack("C") > script_sig = Bitcoin::Script.new << sig << redeem_script.to_payload
> tx.in0.script_sig = script_sig > tx.to_hex
=> raw_transaction
$ bitcoin-cli sendrawtransaction “raw_transaction”