0
0
0ralo2021-07-27 13:29:29
Cryptocurrency
0ralo, 2021-07-27 13:29:29

How to create and sign a transaction?

I need to send crypto to an address. There is an address, there is all the data from the sender's account and there is network data

like this

wif_prefix_hex, address_prefix_hex,
pay_to_script_prefix_hex, bip32_prv_prefix_hex,
bip32_pub_prefix_hex, bech32_hrp etc

how do I collect a network from this, sign and get the hex of this whole horror.
I use pycoin, tell me at least a class to collect network from data

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
calcium, 2021-08-06
@0ralo

If still relevant, it seems you can import

from pycoin.networks.bitcoinish import create_bitcoinish_network
network = create_bitcoinish_network(symbol = '', network_name = '', subnet_name = '', 
    wif_prefix_hex="", address_prefix_hex="", pay_to_script_prefix_hex="",
    bip32_prv_prefix_hex="", bip32_pub_prefix_hex="", bech32_hrp="",
    bip49_prv_prefix_hex="", bip49_pub_prefix_hex="",
    bip84_prv_prefix_hex="", bip84_pub_prefix_hex="",
    magic_header_hex="", default_port=)

and build a network. Well, then with the help of the network class, it seems that transactions can be sent and blocks can be formed.

D
Daniil Kotyashkin, 2021-07-27
@ErVinTract

If, as I understand it, you can use this code ( Source )

pip install bit.

from bit import PrivateKey

# Приватный ключ из wif
my_key = PrivateKey(wif='L46ixenNSu8Bqk899ZrH8Y96t8DHqJ1ZyxzQBGFTbh38rLHLaPoY')

# Количество долларов перевода, можно поменять на btc
money=0.1

# Кошелек куда будут переведены деньги
wallet='17ya3bCpPioyPH8kAyFkEDBUqdjF6wwPxo'

# Коммисия перевода, если поставить слишком маленькую, то транзакцию не примут
# И чем больше коммисия, тем быстрее пройдет перевод
fee=2000

# Генерация транзакции
tx_hash = my_key.create_transaction([(wallet, money, 'usd')],fee=fee,absolute_fee=True)

print(tx_hash)

# Потом делаём это 

import requests

url = 'https://blockchain.info/pushtx'
tx='0100000001fe64490fce5e85d5eb00865663a3d44f4108549fdb2840b086cfc781390d4a2d010000006a47304402202dc1496d28bb10d50d94d70870e2a79ea472c5960de8f7418bb30f9b96643efc02204691547c98edad3181a056bf6404601efe289200ba8e3073a2f5b7c0c7f4fec10121026516c551584b484ce3ca7bb71bbf24cce133bf40bdf4e2ce5a3936bc7e66a2abffffffff02e3020000000000001976a9144c83a20250ccb62ce2b3b1ea80c6082b634fdf9f88ac08f40200000000001976a9144c83a20250ccb62ce2b3b1ea80c6082b634fdf9f88ac00000000'
x = requests.post(url, data = {'tx':tx})
result = x.text

print(result)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question