Author

Topic: Move p2pk balance (Read 142 times)

jr. member
Activity: 15
Merit: 0
January 30, 2024, 11:42:16 PM
#5
In the end I've written Python script to create raw TX for p2pk:

Code:
#!/usr/bin/env python3

import sys
import struct
import json
import binascii

txid="4e9e28b2e7d9b28824ab19f02ace19dff86aed90d8fb422c640279a6fe82e0af"
vout=0
pubkey="02396543d7ab32e75c6682b4fca35c0e68f0694b0dde355de5cc2a7f8fa4affc62"
amount=0.067

tx = bytearray()
tx = tx + binascii.unhexlify('0100000001') # one input tx - last digit
txb = bytes.fromhex(txid)
seqno = 1
txb=txb[::-1]
tx = tx + bytes(txb)
tx = tx + struct.pack('tx = tx + b'\x00'
tx = tx + struct.pack('tx = tx + bytes([1]) # ?
pk = pubkey
v = amount
if len(pk) != 66:
    raise ValueError("pk not 33 bytes (66 hex digits) - it has bytes: "+str(len(pk)/2))
v = int(100000000 * v)
tx = tx + struct.pack('tx = tx + b'\x23'
tx = tx + b'\x21'
tx = tx + binascii.unhexlify(pk)
tx = tx + b'\xac'
tx = tx + binascii.unhexlify('00000000')
print(binascii.hexlify(tx))

Obviously to sign the TX you need to have private key in Base58Check form already to provide while signing TX in Bitcoin Core or this UTXO in wallet.

Or can be done by this way,

Code:
import binascii

txid="4e9e28b2e7d9b28824ab19f02ace19dff86aed90d8fb422c640279a6fe82e0af"
vout=0
pubkey="02396543d7ab32e75c6682b4fca35c0e68f0694b0dde355de5cc2a7f8fa4affc62"
amount=0.067

tx = bytearray.fromhex(f'0100000001{txid[::-1]}{vout:08x}00{1:08x}{int(1e8*amount):016x}2321{pubkey}ac00000000')

print(binascii.hexlify(tx).decode())

full member
Activity: 297
Merit: 133
December 24, 2023, 07:11:46 AM
#4
In the end I've written Python script to create raw TX for p2pk:

Code:
#!/usr/bin/env python3

import sys
import struct
import json
import binascii

txid="4e9e28b2e7d9b28824ab19f02ace19dff86aed90d8fb422c640279a6fe82e0af"
vout=0
pubkey="02396543d7ab32e75c6682b4fca35c0e68f0694b0dde355de5cc2a7f8fa4affc62"
amount=0.067

tx = bytearray()
tx = tx + binascii.unhexlify('0100000001') # one input tx - last digit
txb = bytes.fromhex(txid)
seqno = 1
txb=txb[::-1]
tx = tx + bytes(txb)
tx = tx + struct.pack('tx = tx + b'\x00'
tx = tx + struct.pack('tx = tx + bytes([1]) # ?
pk = pubkey
v = amount
if len(pk) != 66:
    raise ValueError("pk not 33 bytes (66 hex digits) - it has bytes: "+str(len(pk)/2))
v = int(100000000 * v)
tx = tx + struct.pack('tx = tx + b'\x23'
tx = tx + b'\x21'
tx = tx + binascii.unhexlify(pk)
tx = tx + b'\xac'
tx = tx + binascii.unhexlify('00000000')
print(binascii.hexlify(tx))

Obviously to sign the TX you need to have private key in Base58Check form already to provide while signing TX in Bitcoin Core or this UTXO in wallet.
legendary
Activity: 3374
Merit: 3095
Playbet.io - Crypto Casino and Sportsbook
December 24, 2023, 02:44:05 AM
#3
It seems you can only move your balance out from P2PK if you using a Bitcoin core wallet and import it and send them via Bitcoin cli(RPC) commands.

Check this link below

- https://bitcoin.stackexchange.com/questions/118127/how-to-recover-and-sweep-p2pk-coins
full member
Activity: 297
Merit: 133
December 24, 2023, 02:13:19 AM
#1
What would be the easiest way to move balance from a p2pk address?

If it is pay to public key then only public key would be needed only, right?

Can I build a raw transaction to move such funds? How?
Jump to: