4-mavzu: Bitcoin protokoli
Download 0.54 Mb. Pdf ko'rish
|
Tranzaksiyani yaratish
Tranzaksiya yaratishdan oldin, spetsifikatsiyani ochib, uni diqqat bilan tushunib olish kerak. 1 bayt noto’g’ri yozilganda ham allaqachon tranzaksiyani ishlatib bo’lmaydigan holga olib keladi, shuning uchun juda ehtiyot bo'lish kerak. Birinchidan, adres, yopiq kalit va biz havola etadigan tranzaksiyaning xeshini aniqlab olaylik: previous_output = "60ee91bc1563e44866c66937b141e9ef4615a272fa9d764b9468c2a673c55e01" receiver_address = "1C29gpF5MkEPrECiGtkVXwWdAmNiQ4PBMH" my_address = "1LwPhYQi4BRBuuyWSGVeb6kPrTqpSVmoYz" private_key = "28da5896199b85a7d49b0736597dd8c0d0c0293f130bf3e3e1d102e0041b1293"
Keyin, imzolanmagan shaklda tranzaksiyani yaratamiz. Buning uchun shunchaki spetsifikatsiyaga ko’rsatmalarini bajaring: def txnMessage(previous_output, receiver_address, my_address, private_key): receiver_hashed_pubkey= base58.b58decode_check(receiver_address)[1:].encode("hex") my_hashed_pubkey = base58.b58decode_check(my_address)[1:].encode("hex") # Transaction stuff version = struct.pack(" lock_time = struct.pack(" hash_code = struct.pack(" # Transactions input tx_in_count = struct.pack(" tx_in = {} tx_in["outpoint_hash"] = previous_output.decode('hex')[::-1] tx_in["outpoint_index"] = struct.pack(" tx_in["script"] = ("76a914%s88ac" % my_hashed_pubkey).decode("hex") tx_in["script_bytes"] = struct.pack(" tx_in["sequence"] = "ffffffff".decode("hex") # Transaction output tx_out_count = struct.pack(" tx_out = {} tx_out["value"]= struct.pack("
|
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling