Esempio n. 1
0
    def test_idempotence(self):
        a = Address(self.addr)
        a_idem = Address(a)
        self.assertEqual(a, a_idem)
        a_idem = Address(str(a))
        self.assertEqual(a, a_idem)
        a_idem = address(a)
        self.assertEqual(a, a_idem)

        ia = IntegratedAddress(self.iaddr)
        ia_idem = IntegratedAddress(ia)
        self.assertEqual(ia, ia_idem)
        ia_idem = IntegratedAddress(str(ia))
        self.assertEqual(ia, ia_idem)
        ia_idem = address(ia)
        self.assertEqual(ia, ia_idem)
Esempio n. 2
0
    def test_recognition_and_comparisons(self):
        a = Address(self.addr)
        a2 = address(self.addr)
        self.assertIsInstance(a2, Address)
        self.assertEqual(a, a2)
        self.assertEqual(a, self.addr)
        self.assertEqual(self.addr, a)
        self.assertEqual(a.is_mainnet(), self.mainnet)
        self.assertEqual(a.is_testnet(), self.testnet)
        self.assertEqual(a.is_stagenet(), self.stagenet)
        self.assertEqual(a2.is_mainnet(), self.mainnet)
        self.assertEqual(a2.is_testnet(), self.testnet)
        self.assertEqual(a2.is_stagenet(), self.stagenet)

        ia = IntegratedAddress(self.iaddr)
        ia2 = address(self.iaddr)
        self.assertIsInstance(ia, IntegratedAddress)
        self.assertEqual(ia, ia2)
        self.assertEqual(ia, self.iaddr)
        self.assertEqual(self.iaddr, ia)
        self.assertEqual(ia.is_mainnet(), self.mainnet)
        self.assertEqual(ia.is_testnet(), self.testnet)
        self.assertEqual(ia.is_stagenet(), self.stagenet)
        self.assertEqual(ia2.is_mainnet(), self.mainnet)
        self.assertEqual(ia2.is_testnet(), self.testnet)
        self.assertEqual(ia2.is_stagenet(), self.stagenet)
        self.assertEqual(ia2.base_address(), a)

        self.assertEqual(ia.view_key(), a.view_key())
        self.assertEqual(ia.spend_key(), a.spend_key())

        sa = SubAddress(self.subaddr)
        sa2 = address(self.subaddr)
        self.assertIsInstance(sa2, SubAddress)
        self.assertEqual(sa, sa2)
        self.assertEqual(sa, self.subaddr)
        self.assertEqual(self.subaddr, sa)
        self.assertEqual(sa.is_mainnet(), self.mainnet)
        self.assertEqual(sa.is_testnet(), self.testnet)
        self.assertEqual(sa.is_stagenet(), self.stagenet)
        self.assertEqual(sa2.is_mainnet(), self.mainnet)
        self.assertEqual(sa2.is_testnet(), self.testnet)
        self.assertEqual(sa2.is_stagenet(), self.stagenet)

        self.assertNotEqual(a, 0)
Esempio n. 3
0
 def setUp(self):
     self.tx1 = Transaction(
         timestamp=datetime(2018, 1, 29, 15, 0, 25),
         height=1087606,
         hash='a0b876ebcf7c1d499712d84cedec836f9d50b608bb22d6cb49fd2feae3ffed14',
         fee=Decimal('0.00352891'))
     self.pm1 = IncomingPayment(
         amount=Decimal('1'),
         local_address=address('Bf6ngv7q2TBWup13nEm9AjZ36gLE6i4QCaZ7XScZUKDUeGbYEHmPRdegKGwLT8tBBK7P6L32RELNzCR6QzNFkmogDjvypyV'),
         payment_id=PaymentID('0166d8da6c0045c51273dd65d6f63734beb8a84e0545a185b2cfd053fced9f5d'),
         transaction=self.tx1)
Esempio n. 4
0
 def test_filter_address(self):
     pmts = self.wallet.incoming(
         local_address=
         'BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejrMfpHeNXoX8MjY8q8prW1PEALgr1En'
     )
     self.assertEqual(len(pmts), 2)
     self.assertEqual(
         pmts,
         self.wallet.incoming(local_address=address(
             'BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejrMfpHeNXoX8MjY8q8prW1PEALgr1En'
         )))
     pmts = self.wallet.incoming(local_address=(
         'BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejrMfpHeNXoX8MjY8q8prW1PEALgr1En',
         'Bf6ngv7q2TBWup13nEm9AjZ36gLE6i4QCaZ7XScZUKDUeGbYEHmPRdegKGwLT8tBBK7P6L32RELNzCR6QzNFkmogDjvypyV'
     ))
     self.assertEqual(len(pmts), 3)
Esempio n. 5
0
    def public_address(self, net='mainnet'):
        """Returns the master :class:`Address <uplexa.address.Address>` represented by the seed.

        :param net: the network, one of 'mainnet', 'testnet', 'stagenet'. Default is 'mainnet'.

        :rtype: :class:`Address <uplexa.address.Address>`
        """
        if net not in ('mainnet', 'testnet', 'stagenet'):
            raise ValueError(
                "Invalid net argument. Must be one of ('mainnet', 'testnet', 'stagenet')."
            )
        netbyte = 18 if net == 'mainnet' else 53 if net == 'testnet' else 24
        data = "{:x}{:s}{:s}".format(netbyte, self.public_spend_key(),
                                     self.public_view_key())
        h = keccak_256()
        h.update(unhexlify(data))
        checksum = h.hexdigest()
        return address(base58.encode(data + checksum[0:8]))
Esempio n. 6
0
def destpair(s):
    addr, amount = s.split(':')
    return (address(addr), as_uplexa(amount))
Esempio n. 7
0
#!/usr/bin/python
import sys
from uplexa.address import address
from uplexa.numbers import PaymentID

USAGE = "{0} <address> <payment_id>"

try:
    addr = address(sys.argv[1])
    pid = PaymentID(sys.argv[2])
except IndexError:
    print(USAGE.format(*sys.argv), file=sys.stderr)
    sys.exit(-1)

print(addr.with_payment_id(pid))
Esempio n. 8
0
 def __init__(self):
     self.transfers = []
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 15, 0, 25),
         height=1087606,
         hash=
         'a0b876ebcf7c1d499712d84cedec836f9d50b608bb22d6cb49fd2feae3ffed14',
         fee=Decimal('0.00352891'))
     pm = IncomingPayment(
         amount=Decimal('1'),
         local_address=address(
             'Bf6ngv7q2TBWup13nEm9AjZ36gLE6i4QCaZ7XScZUKDUeGbYEHmPRdegKGwLT8tBBK7P6L32RELNzCR6QzNFkmogDjvypyV'
         ),
         payment_id=PaymentID(
             '0166d8da6c0045c51273dd65d6f63734beb8a84e0545a185b2cfd053fced9f5d'
         ),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 14, 57, 47),
         height=1087601,
         hash=
         'f34b495cec77822a70f829ec8a5a7f1e727128d62e6b1438e9cb7799654d610e',
         fee=Decimal('0.008661870000'))
     pm = IncomingPayment(
         amount=Decimal('3.000000000000'),
         local_address=address(
             'BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejrMfpHeNXoX8MjY8q8prW1PEALgr1En'
         ),
         payment_id=PaymentID('f75ad90e25d71a12'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 13, 17, 18),
         height=1087530,
         hash=
         '5c3ab739346e9d98d38dc7b8d36a4b7b1e4b6a16276946485a69797dbf887cd8',
         fee=Decimal('0.000962550000'))
     pm = IncomingPayment(
         amount=Decimal('10.000000000000'),
         local_address=address(
             '9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6K3fhq3scsyY88tdB1MqucULcKzWZC'
         ),
         payment_id=PaymentID('f75ad90e25d71a12'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 13, 17, 18),
         height=1087530,
         hash=
         '4ea70add5d0c7db33557551b15cd174972fcfc73bf0f6a6b47b7837564b708d3',
         fee=Decimal('0.000962550000'))
     pm = IncomingPayment(
         amount=Decimal('4.000000000000'),
         local_address=address(
             '9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6K3fhq3scsyY88tdB1MqucULcKzWZC'
         ),
         payment_id=PaymentID('f75ad90e25d71a12'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 13, 17, 18),
         height=1087530,
         hash=
         'e9a71c01875bec20812f71d155bfabf42024fde3ec82475562b817dcc8cbf8dc',
         fee=Decimal('0.000962550000'))
     pm = IncomingPayment(
         amount=Decimal('2.120000000000'),
         local_address=address(
             '9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6K3fhq3scsyY88tdB1MqucULcKzWZC'
         ),
         payment_id=PaymentID('cb248105ea6a9189'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 14, 57, 47),
         height=1087601,
         hash=
         '5ef7ead6a041101ed326568fbb59c128403cba46076c3f353cd110d969dac808',
         fee=Decimal('0.000962430000'))
     pm = IncomingPayment(
         amount=Decimal('7.000000000000'),
         local_address=address(
             'BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejrMfpHeNXoX8MjY8q8prW1PEALgr1En'
         ),
         payment_id=PaymentID('0000000000000000'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 13, 17, 18),
         height=1087530,
         hash=
         'cc44568337a186c2e1ccc080b43b4ae9db26a07b7afd7edeed60ce2fc4a6477f',
         fee=Decimal('0.000962550000'))
     pm = IncomingPayment(
         amount=Decimal('10.000000000000'),
         local_address=address(
             '9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6K3fhq3scsyY88tdB1MqucULcKzWZC'
         ),
         payment_id=PaymentID('0000000000000000'),
         transaction=tx)
     self.transfers.append(pm)
     tx = Transaction(
         timestamp=datetime(2018, 1, 29, 21, 13, 28),
         height=None,
         hash=
         'd29264ad317e8fdb55ea04484c00420430c35be7b3fe6dd663f99aebf41a786c',
         fee=Decimal('0.000961950000'))
     pm = IncomingPayment(
         amount=Decimal('3.140000000000'),
         local_address=address(
             '9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6K3fhq3scsyY88tdB1MqucULcKzWZC'
         ),
         payment_id=PaymentID('03f6649304ea4cb2'),
         transaction=tx)
     self.transfers.append(pm)