当前位置: 首页>>代码示例>>Python>>正文


Python Address.fromPrivkey方法代码示例

本文整理汇总了Python中address.Address.fromPrivkey方法的典型用法代码示例。如果您正苦于以下问题:Python Address.fromPrivkey方法的具体用法?Python Address.fromPrivkey怎么用?Python Address.fromPrivkey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在address.Address的用法示例。


在下文中一共展示了Address.fromPrivkey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fake_transaction

# 需要导入模块: from address import Address [as 别名]
# 或者: from address.Address import fromPrivkey [as 别名]
def fake_transaction(model=None):
    key = ecdsa.SigningKey.from_string(
        "\xe8\x00\xb8\xd4\xa1b\xb7o\x0f;\xf2\xcf\xca\xfd\x1a$\xb9\xa9"
        "\xeb\x0b\x08X\x9f}9C\xe4\x88\xfdD\x11b", curve=ecdsa.curves.SECP256k1)

    address = Address.fromPrivkey(key)
    script = tools.compile(
        "OP_DUP OP_HASH160 {0} OP_EQUALVERIFY OP_CHECKSIG".format(
            address.rawPubkey()[1:-4].encode("hex"))).encode("hex")
    utxo = utxodb.UTXO("D34DB33F", 0, 1, script)
    utxo.address_rec = object()
    utxo.address_rec = AddressRec(address)
    txin = txspec.ComposedTxSpec.TxIn(utxo)
    txout = txspec.ComposedTxSpec.TxOut(1, address.pubkey)
    composed = txspec.ComposedTxSpec([txin], [txout])
    return txcons.SignedTxSpec(model, composed, False), address
开发者ID:amidvidy,项目名称:ngcccbase,代码行数:18,代码来源:test_txdb.py

示例2: test_ecdsa_key

# 需要导入模块: from address import Address [as 别名]
# 或者: from address.Address import fromPrivkey [as 别名]
 def test_ecdsa_key(self):
     address = Address(*self.keys)
     ecdsa_key = address.ecdsaPrivkey()
     address2 = Address.fromPrivkey(ecdsa_key)
     self.assertEqual(address.privkey, address2.privkey)
开发者ID:hankhero,项目名称:ngcccbase,代码行数:7,代码来源:address_test.py


注:本文中的address.Address.fromPrivkey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。