简体   繁体   English

有没有办法用python离线签署交易十六进制?

[英]Is there a way to offline sign transaction hex with python?

我一直在寻找一个函数,该函数接受原始事务十六进制,私钥并给出签名的事务十六进制。

Take a loot at pybitcointools, or have a look at this article with the same toppic. 抢劫pybitcointools,或以相同的话题看一下这篇文章

Hope this helps 希望这可以帮助

You could do it with BitcoinLib . 您可以使用BitcoinLib做到这一点 Import the raw transaction hex as Transaction object and then sign it with the private key. 将原始事务十六进制作为导入对象导入,然后使用私钥对其进行签名。

private = "5c1a005d669f8521036f7c13138830f15b2d6a016facf9c6361362573e41a083"
raw_tx = ""  # Insert your raw tx in Hex format
t = Transaction.import_raw(raw_tx)
t.sign(private)

In this example the private key is in hex format, but bytes, key objects or WIF encoded strings are accepted as well. 在此示例中,私钥采用十六进制格式,但是也接受字节,密钥对象或WIF编码的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Python中为正十六进制数字给出符号+ - How to give sign + for positive hex numbers in python 在PowerShell中以十六进制为字符串,即python方式 - Hex to string, the python way, in powershell 为什么python以不同的方式解释十六进制字符串? - Why python interprets hex strings in different way? 在 python 中将变量转换为十六进制的任何方法 - Any way to make a variable into hex in python 有什么方法可以在Python中提取数字的符号吗? - Any way to extract the sign of a number in Python? Python - 将字符串和转义的十六进制字符串数据转换为整数的更好方法? - Python - Better way to convert string and escaped hex string data to integers? 在Python 3中将字节转换为十六进制字符串的正确方法是什么? - What is the correct way to convert bytes to a hex string in Python 3? 在 Python 3 中将字节转换为十六进制字符串的正确方法是什么? - What's the correct way to convert bytes to a hex string in Python 3? 在 Python 中编写这个十六进制格式 function 的更好方法是什么? - What's a less bad way to write this hex formatting function in Python? 在离线环境中分发Python应用和解释器的最佳方法是什么? - What is the best way to distribute Python apps and interpreters in an offline environment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM