Example #1
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 == []
Example #2
0
    def from_private_key(cls,private_key):
        """
        Return a memo user from private key.

        :param private_key:
        :type private_key: ``str`` or ``PrivateKey``
        :rtype ``MemoUser''
        """
        if not isinstance(private_key,PrivateKey):
            pk=PrivateKey(private_key)
        else:
            pk=private_key
        memouser=MemoUser(pk.address)
        memouser.private_key=pk.to_wif()
        return memouser
Example #3
0
 def test_repr(self):
     assert (
         repr(PrivateKey(WALLET_FORMAT_MAIN)) ==
         "<PrivateKey: bitcoincash:qzfyvx77v2pmgc0vulwlfkl3uzjgh5gnmqk5hhyaa6>"
     )
Example #4
0
 def test_get_transactions(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     transactions = private_key.get_transactions()
     assert transactions == private_key.transactions
Example #5
0
 def test_get_unspent(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     unspent = private_key.get_unspents()
     assert unspent == private_key.unspents
Example #6
0
 def test_get_balance(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     balance = int(private_key.get_balance())
     assert balance == private_key.balance
Example #7
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
Example #8
0
 def test_address(self):
     private_key = PrivateKey(WALLET_FORMAT_MAIN)
     assert private_key.address == BITCOIN_CASHADDRESS
Example #9
0
 def private_key(self,private_key):
     pk=PrivateKey(private_key)
     if pk.address != self._address:
         raise ValueError('Wrong private key!')
     self._private_key=private_key
Example #10
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:]
Example #11
0
 def test_repr(self):
     assert repr(PrivateKey(WALLET_FORMAT_MAIN)
                 ) == '<PrivateKey: 1ELReFsTCUY2mfaDTy32qxYiT49z786eFg>'