uncooked transaction – Ought to an offline tackle generated from personal key ship funds to pockets?

on

|

views

and

comments


I am making an attempt to make use of the python package deal python-bitcoinlib to ship a timelock transaction on testnet. The github has two examples to create an tackle, after which use that tackle to ship the bitcoin to a different tackle.

The issue is, once I ship bitcoin to the generated tackle utilizing my very own personal key, I by no means obtain the bitcoin in my pockets. I will broadcast the transaction to the second tackle, however I wish to have entry to the bitcoin in case I alter my thoughts earlier than the timelock arrives. Right here is the code:

from bitcoinutils.setup import setup
from bitcoinutils.transactions import Transaction, TxInput, TxOutput, Sequence
from bitcoinutils.keys import P2pkhAddress, P2shAddress, PrivateKey
from bitcoinutils.script import Script
from bitcoinutils.constants import TYPE_RELATIVE_TIMELOCK


def important():
    # at all times bear in mind to setup the community
    setup('testnet')

    #
    # This script creates a P2SH tackle containing a CHECKSEQUENCEVERIFY plus
    # a P2PKH locking funds with a key in addition to for 20 blocks
    #

    # set values
    relative_blocks = 20

    seq = Sequence(TYPE_RELATIVE_TIMELOCK, relative_blocks)

    # secret key equivalent to the pubkey wanted for the P2SH (P2PKH) transaction
    p2pkh_sk = PrivateKey('cRvyLwCPLU88jsyj94L7iJjQX5C2f8koG4G2gevN4BeSGcEvfKe9')

    # get the tackle (from the general public key)
    p2pkh_addr = p2pkh_sk.get_public_key().get_address()

    # create the redeem script
    redeem_script = Script([seq.for_script(), 'OP_CHECKSEQUENCEVERIFY', 'OP_DROP', 'OP_DUP', 'OP_HASH160', p2pkh_addr.to_hash160(), 'OP_EQUALVERIFY', 'OP_CHECKSIG'])

    # create a P2SH tackle from a redeem script
    addr = P2shAddress.from_script(redeem_script)
    print(addr.to_string())

if __name__ == "__main__":
    important()

After I run this code with my very own personal key, I get an tackle like:

2N3M2ZnDsw4FMDYTyMmtk6k12pBzbyKJvBR

From what I perceive, that tackle is created from my personal key, so should not the funds I ship to it go straight again to my pockets?

Share this
Tags

Must-read

Constructing the Torc Driverless Security Case

At Torc, we’ve structured our security case on three foundational pillars: Engineer It to Be Secure, Function It to Be Secure, and the...

What’s DL+S? Unlocking the Huge Information Required to Develop Autonomous Vans

Breakthroughs in AI for autonomous driving don't occur in isolation. They occur when information, simulation, machine studying, infrastructure, and car testing work as...

Why I can’t wait to get right into a driverless automotive | Self-driving automobiles

Adrian Chiles (Driverless automobiles are taking us on a street to nowhere, 10 September) needs to know who requested for driverless automobiles. I...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here