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


Python wallet.CBitcoinSecret方法代码示例

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


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

示例1: test_get_coinbase_variables

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def test_get_coinbase_variables(self, m_execute_rpc):
        m_execute_rpc.side_effect = [
            [
                {"txid": 'tx_hash_1', 'address': 'address_hash_1', 'amount': 50},
                {"txid": 'tx_hash_2', 'address': 'address_hash_2', 'amount': 25}
            ],
            'cTCrrgVLfBqEZ1dxmCnEwmiEWzeZHU8uw3CNvLVvbT4CrBeDdTqc',
            'cTCrrgVLfBqEZ1dxmCnEwmiEWzeZHU8uw3CNvLVvbT4CrBeDdTqc'
        ]

        self.node.create_tx_chains()

        self.assertEqual(m_execute_rpc.call_count, 3)
        self.assertEqual(len(self.node._tx_chains), 2)

        chain_1 = self.node._tx_chains[0]
        self.assertEqual(chain_1.current_unspent_tx, 'tx_hash_1')
        self.assertEqual(chain_1.address, 'address_hash_1')
        self.assertEqual(chain_1.seckey,  CBitcoinSecret('cTCrrgVLfBqEZ1dxmCnEwmiEWzeZHU8uw3CNvLVvbT4CrBeDdTqc'))
        self.assertEqual(chain_1.amount, 5000000000)

        chain_2 = self.node._tx_chains[1]
        self.assertEqual(chain_2.current_unspent_tx, 'tx_hash_2')
        self.assertEqual(chain_2.address, 'address_hash_2')
        self.assertEqual(chain_2.amount, 2500000000) 
开发者ID:sbaresearch,项目名称:simcoin,代码行数:27,代码来源:test_node.py

示例2: dumpprivkey

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def dumpprivkey(self, addr):
        """Return the private key matching an address
        """
        r = self._call('dumpprivkey', str(addr))

        return CBitcoinSecret(r) 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:8,代码来源:rpc.py

示例3: test_sign_message_simple

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def test_sign_message_simple(self):
        key = CBitcoinSecret("L4vB5fomsK8L95wQ7GFzvErYGht49JsCPJyJMHpB4xGM6xgi2jvG")
        address = "1F26pNMrywyZJdr22jErtKcjF8R3Ttt55G"
        message = address

        message = BitcoinMessage(message)
        signature = SignMessage(key, message)

        self.assertTrue(signature)
        self.assertTrue(VerifyMessage(address, message, signature)) 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:12,代码来源:test_signmessage.py

示例4: test_sign_message_vectors

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def test_sign_message_vectors(self):
        for vector in load_test_vectors('signmessage.json'):
            key = CBitcoinSecret(vector['wif'])
            message = BitcoinMessage(vector['address'])

            signature = SignMessage(key, message)

            self.assertTrue(signature, "Failed to sign for [%s]" % vector['address'])
            self.assertTrue(VerifyMessage(vector['address'], message, vector['signature']), "Failed to verify signature for [%s]" % vector['address']) 
开发者ID:petertodd,项目名称:checklocktimeverify-demos,代码行数:11,代码来源:test_signmessage.py

示例5: test_bitcoin_wallet

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def test_bitcoin_wallet(wallet):
    assert isinstance(wallet.private_key, CBitcoinSecret)
    assert isinstance(wallet.public_key, CPubKey)
    assert isinstance(wallet.address, str)
    assert isinstance(wallet.get_private_key(), str)
    assert wallet.public_key == wallet.get_public_key()
    assert wallet.private_key.pub == wallet.public_key 
开发者ID:Lamden,项目名称:clove,代码行数:9,代码来源:test_wallet.py

示例6: sign_message

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def sign_message(self, wif, message_to_sign):
        secret_key = CBitcoinSecret(wif)
        message = BitcoinMessage(message_to_sign)
        signature = SignMessage(secret_key, message)
        return str(signature, 'utf-8') 
开发者ID:blockchain-certificates,项目名称:cert-issuer,代码行数:7,代码来源:signer.py

示例7: generate_spent_to_address

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def generate_spent_to_address(self):
        address = self.execute_rpc('getnewaddress')
        seckey = CBitcoinSecret(self.execute_rpc('dumpprivkey', address))
        self._spent_to = SpentToAddress(address, seckey) 
开发者ID:sbaresearch,项目名称:simcoin,代码行数:6,代码来源:node.py

示例8: create_tx_chains

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def create_tx_chains(self):
        for unspent_tx in self.execute_rpc('listunspent'):
            seckey = CBitcoinSecret(
                self.execute_rpc('dumpprivkey', unspent_tx['address'])
            )
            tx_chain = TxChain(
                unspent_tx['txid'],
                unspent_tx['address'],
                seckey,
                unspent_tx['amount'] * 100000000
            )

            self._tx_chains.append(tx_chain) 
开发者ID:sbaresearch,项目名称:simcoin,代码行数:15,代码来源:node.py

示例9: sign_message

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def sign_message(key, msg):
    secret = CBitcoinSecret(key)
    message = BitcoinMessage(msg)
    return SignMessage(secret, message) 
开发者ID:petertodd,项目名称:replace-by-fee-tools,代码行数:6,代码来源:sign-message.py

示例10: print_verbose

# 需要导入模块: from bitcoin import wallet [as 别名]
# 或者: from bitcoin.wallet import CBitcoinSecret [as 别名]
def print_verbose(signature, key, msg):
    secret = CBitcoinSecret(key)
    address = P2PKHBitcoinAddress.from_pubkey(secret.pub)
    message = BitcoinMessage(msg)
    print('Address: %s' % address)
    print('Message: %s' % msg)
    print('Signature: %s' % signature)
    print('Verified: %s' % VerifyMessage(address, message, signature))
    print('\nTo verify using bitcoin core:')
    print('\n`bitcoin-cli verifymessage %s \'%s\' \'%s\'`\n' % (address, signature.decode('ascii'), msg)) 
开发者ID:petertodd,项目名称:replace-by-fee-tools,代码行数:12,代码来源:sign-message.py


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