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

Self-driving taxis are coming to London – ought to we be anxious? | Jack Stilgoe

At the top of the nineteenth century, the world’s main cities had an issue. The streets had been flooded with manure, the unintended...

US regulators open inquiry into Waymo self-driving automobile that struck youngster in California | Expertise

The US’s federal transportation regulator stated Thursday it had opened an investigation after a Waymo self-driving car struck a toddler close to an...

US robotaxis bear coaching for London’s quirks earlier than deliberate rollout this yr | London

American robotaxis as a consequence of be unleashed on London’s streets earlier than the tip of the yr have been quietly present process...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here