1
I am new in Bitcoin and I try to create an address in Bitcoind and send a transaction that the amount will be spendable in a specific height of the blockchain.
Here is what I have done:
privateKey = 'cS5bZo8D1PBXwLbpGwYpb3CPvev5FYA7zPpftXAc6vzvbXt3aAa4'
absolute_time = 150
addr = getAddressFromPriv(privateKey) #customFunction
seq = Sequence(TYPE_ABSOLUTE_TIMELOCK, absolute_time)
script = Script([seq.for_script(),
'OP_CHECKLOCKTIMEVERIFY',
'OP_DROP',
'OP_DUP',
'OP_HASH160',
p2pkh_addr.to_hash160(),
'OP_EQUALVERIFY',
'OP_CHECKSIG'])
addr2 = convertScriptToAddress(script)
Then in bitcoin-cli I use that addr2 to bitcoin-cli sendtoaddress <addr2> 10
However, when I inspect the transaction it says that it is spendable in the current block height. Any idea?
1Shouldn't you add the <absolute time/blockheight> before OP_CHECKLOCKTIMEVERIFY in the script? Also you are using 150 as the block height, which means it should be spendable immediately. – Ugam Kamat – 2019-04-12T10:43:38.753
@UgamKamat: I think you're on to it, but please don't use comments to answer a question, rather post an answer. You can always edit your answer as the topic evolves. – Murch – 2019-04-12T14:02:37.217
Yeah, wasn't totally sure. So wanted @Tasos to check if that works. Writing it as an answer. – Ugam Kamat – 2019-04-12T14:41:01.270