當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。