MoveAndUp

Here is a step -by -step guide to buy a raw transaction using Python Ecdsa (or OpenSL) for Ethereum:

Pass 15-17: Concatenatura of the structure of the raw transaction and hashs

These steps ensure the reception of the linked harsh structure of the rough transaction (TXID, VSIZE, VIN, VOUT) and hashs with the SHA-256. We will subsequently sign the resulting hash with the help of ECDSA.

Pass 15: Connected structure of rough transaction

`Python

Matters Hashlib

by Ethereum Import EC

Get data on raw transactions from a file or database

TXID = ‘0X … Your TXID here …’

Replace with your real TXID

Vsize = 1000

Replace with your vsize

vin = [(txid, 0)] * vsize

replaced with actual vin

Concatena the structure of the raw transaction

raw_tx = ec.from_raw_data (vin, vsize)

`

Passage 16: The Hash Conchatal Structure of the Raw Transaction

Python

Create a new Hash Sha-256 object

hash_object = hashlib.sha256 ()

Update hash with the concrete structure of raw transactions

hash_object.update (RAW_TX.TO_BYTES ())

Get hexach presentation of hash

Tx_hash = hash_object.hexdigest ()

`

Pass 17: Sign Hasha with ECDSA

Python

by Ethereum Import EC

Create a new pair of ECDSA keys

Key = ec.ckey.from_row_data (‘Your raw key here …’)

Sign a hash with the public key ECDSA

Signed_tx_hash = Key.sign (TX_Hash, E = Ec.SECP256R1, Digestmod = Hashlib.sha256)

Print (signed_tx_hash)

`

Replaceyour txid here ... '1000is your rough key here ...' with your actual values.

Full code

Python

Matters Hashlib

by Ethereum Import EC

Def redeem_raw_tx (txid, vsize, vin):

Create a new Hash Sha-256 object

hash_object = hashlib.sha256 ()

Update hash with the concrete structure of raw transactions

hash_object.update ((TXID, VSIZE) + List (VIN))

Get hexach presentation of hash

Tx_hash = hash_object.hexdigest ()

Create a new pair of ECDSA keys

Key = ec.ckey.from_row_data (‘Your raw key here …’)

Sign a hash with the public key ECDSA

Signed_tx_hash = Key.sign (TX_Hash, E = Ec.SECP256R1, Digestmod = Hashlib.sha256)

Return (TXID, VSIZE, VIN, TX_HASH, Signed_tx_hash)

Example of use:

txid = ‘0x … your txid here …’

Vsize = 1000

vin = [(txid, 0)] * vsize

raw_tx = ec.from_raw_data (vin, vsize)

Signed_tx_hash = REDEEM_RAW_TX (TXID, VSIZE, VIN)

Print (signed_tx_hash)

``

Be sure to replace replacement values ​​with actual data. This is just a major example of how to buy a raw transaction using Python ECDSA (or OpenSSl). You may need to change it in accordance with the specific requirements and the case of use.