示例#1
0
 def test_address(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     assert private_key.address == BITCOIN_ADDRESS
     private_key = PrivateKey(WALLET_FORMAT_TEST, network='test')
     assert private_key.address == BITCOIN_ADDRESS_TEST
     private_key = PrivateKey(WALLET_FORMAT_STN, network='stn')
     assert private_key.address == BITCOIN_ADDRESS_STN
示例#2
0
    def test_init_default(self):
        private_key = PrivateKey()

        assert private_key._address is None
        assert private_key.balance == 0
        assert private_key.unspents == []
        assert private_key.transactions == []
示例#3
0
 def test_from_der_testnet(self):
     key = PrivateKey.from_der(PRIVATE_KEY_DER, network='test')
     assert isinstance(key, PrivateKey)
     assert key.network == 'test'
     assert key.to_der() == PRIVATE_KEY_DER
示例#4
0
 def test_from_hex_testnet(self):
     key = PrivateKey.from_hex(PRIVATE_KEY_HEX, network='test')
     assert isinstance(key, PrivateKey)
     assert key.network == 'test'
     assert key.to_hex() == PRIVATE_KEY_HEX
示例#5
0
 def test_from_int(self):
     key = PrivateKey.from_int(PRIVATE_KEY_NUM)
     assert isinstance(key, PrivateKey)
     assert key.to_int() == PRIVATE_KEY_NUM
示例#6
0
 def test_from_pem(self):
     key = PrivateKey.from_pem(PRIVATE_KEY_PEM)
     assert isinstance(key, PrivateKey)
     assert key.to_pem() == PRIVATE_KEY_PEM
示例#7
0
 def test_from_der(self):
     key = PrivateKey.from_der(PRIVATE_KEY_DER)
     assert isinstance(key, PrivateKey)
     assert key.to_der() == PRIVATE_KEY_DER
示例#8
0
 def test_repr(self):
     assert repr(
         PrivateKey(WALLET_FORMAT_MAIN)
     ) == '<PrivateKey: bitcoincash:qzfyvx77v2pmgc0vulwlfkl3uzjgh5gnmqk5hhyaa6>'
示例#9
0
 def test_repr(self):
     assert repr(PrivateKey(WALLET_FORMAT_MAIN)
                 ) == '<PrivateKey: 1ELReFsTCUY2mfaDTy32qxYiT49z786eFg>'
示例#10
0
 def test_get_unspent(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     unspent = private_key.get_unspents()
     assert unspent == private_key.unspents
示例#11
0
 def test_get_balance(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     balance = int(private_key.get_balance())
     assert balance == private_key.balance
示例#12
0
    def test_to_wif(self):
        private_key = PrivateKey(WALLET_FORMAT_MAIN)
        assert private_key.to_wif() == WALLET_FORMAT_MAIN

        private_key = PrivateKey(WALLET_FORMAT_COMPRESSED_MAIN)
        assert private_key.to_wif() == WALLET_FORMAT_COMPRESSED_MAIN
示例#13
0
 def test_address(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     assert private_key.address == BITCOIN_ADDRESS
     private_key = PrivateKeyTestnet(WALLET_FORMAT_TEST)
     assert private_key.address == BITCOIN_ADDRESS_TEST
示例#14
0
 def test_from_pem_testnet(self):
     key = PrivateKey.from_pem(PRIVATE_KEY_PEM, network='test')
     assert isinstance(key, PrivateKey)
     assert key.network == 'test'
     assert key.to_pem() == PRIVATE_KEY_PEM
示例#15
0
 def test_get_transactions(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     transactions = private_key.get_transactions()
     assert transactions == private_key.transactions
示例#16
0
 def test_from_int_testnet(self):
     key = PrivateKey.from_int(PRIVATE_KEY_NUM, network='test')
     assert isinstance(key, PrivateKey)
     assert key.network == 'test'
     assert key.to_int() == PRIVATE_KEY_NUM
示例#17
0
 def test_from_hex(self):
     key = PrivateKey.from_hex(PRIVATE_KEY_HEX)
     assert isinstance(key, PrivateKey)
     assert key.to_hex() == PRIVATE_KEY_HEX
示例#18
0
 def test_matching(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     tx = create_p2pkh_transaction(private_key, UNSPENTS, OUTPUTS)
     print(tx)
     assert tx[-288:] == FINAL_TX_1[-288:]
示例#19
0
 def test_address(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     assert private_key.address == BITCOIN_CASHADDRESS