本文整理汇总了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)
示例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)
示例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))
示例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'])
示例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
示例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')
示例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)
示例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)
示例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)
示例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))