def create_transaction(cls, text): p1 = PaymentID(cls.to_hex(text)) if p1.is_short(): sender = cls.wallet.addresses()[0] sender = sender.with_payment_id(p1) transaction = cls.wallet.transfer(sender, Decimal('0.000000000001')) return transaction
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) # setup for one-time output tests self.json1 = { # Actual as_json response from TX ee5bcb6430c39757ff27f8d607287572f3956a0ee16bb1d2378891f93746c8f9 'version': 2, 'unlock_time': 0, 'vin': [{'key': {'amount': 0, 'key_offsets': [25471133, 261981, 36602, 18967, 13096, 16260, 54279, 3105, 5403, 786, 555], 'k_image': '4b48346e954a74be9a334b03cadf8aa020542d201fb6ae7416246d19fd04fdb7'}}], 'vout': [{'amount': 0, 'target': {'key': 'c55e793b4d673dcf73587e5141b777ef24e255d48826c75ce110ffc23ff762b9'}}, {'amount': 0, 'target': {'key': '93b263454cd3cc349245ad60c9c248332b885a1f2d7b5792cfc24fd87434d62a'}}], 'extra': [1, 209, 170, 43, 245, 190, 68, 82, 131, 116, 79, 134, 175, 104, 216, 127, 99, 49, 127, 141, 255, 65, 204, 101, 81, 244, 111, 253, 155, 75, 111, 14, 159, 2, 9, 1, 24, 56, 108, 94, 20, 88, 150, 94], 'rct_signatures': {'type': 5, 'txnFee': 58560000, 'ecdhInfo': [{'amount': '6c13cf459cb9ed96'}, {'amount': '373bc40c7f600bf4'}], 'outPk': ['80521a77ebe954a5daa6f14b13cc74337f999bc68177a58e76f768c18f2fa421', '5997e64b90d59f7f810ddbc801f747c4fa43e2de593e4ea48531e16d776c00fd']}} self.outind1 = [25884175, 25884176] self.tx2 = Transaction(json=self.json1, output_indices=self.outind1) self.oto1 = Output(index=25973289, amount=Decimal('0.000000000000')) self.oto2 = Output(pubkey='0faff18f7149a0db5aa0dc3c9116887740ccbb5dc4d1eeff87895288e55e5052')
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)
def test_filter_payment_id(self): pmts = self.wallet.incoming(payment_id='cb248105ea6a9189') self.assertEqual(len(pmts), 1) self.assertEqual( pmts[0].transaction.hash, 'e9a71c01875bec20812f71d155bfabf42024fde3ec82475562b817dcc8cbf8dc') pmts = self.wallet.incoming(payment_id='f75ad90e25d71a12') self.assertEqual(len(pmts), 3) pmts = self.wallet.incoming(payment_id=('cb248105ea6a9189', 'f75ad90e25d71a12')) self.assertEqual(len(pmts), 4) self.assertEqual( pmts, self.wallet.incoming(payment_id=(PaymentID('cb248105ea6a9189'), 'f75ad90e25d71a12')))
def test_filter_payment_id(self): pmts = self.wallet.incoming(payment_id="cb248105ea6a9189") self.assertEqual(len(pmts), 1) self.assertEqual( pmts[0].transaction.hash, "e9a71c01875bec20812f71d155bfabf42024fde3ec82475562b817dcc8cbf8dc", ) pmts = self.wallet.incoming(payment_id="f75ad90e25d71a12") self.assertEqual(len(pmts), 3) pmts = self.wallet.incoming(payment_id=("cb248105ea6a9189", "f75ad90e25d71a12")) self.assertEqual(len(pmts), 4) self.assertEqual( pmts, self.wallet.incoming( payment_id=(PaymentID("cb248105ea6a9189"), "f75ad90e25d71a12") ), )
def __init__(self, **kwargs): self.transfers = [] tx = Transaction( timestamp=datetime(2018, 1, 29, 15, 0, 25), height=1087606, hash= "a0b876ebcf7c1d499712d84cedec836f9d50b608bb22d6cb49fd2feae3ffed14", fee=Decimal("0.00352891"), confirmations=3, ) pm = IncomingPayment( amount=Decimal("1"), local_address=address( "Bf6ngv7q2TBWup13nEm9AjZ36gLE6i4QCaZ7XScZUKDUeGbYEHmPRdegKGwLT8tBBK" "7P6L32RELNzCR6QzNFkmogDjvypyV"), payment_id=PaymentID( "0166d8da6c0045c51273dd65d6f63734beb8a84e0545a185b2cfd053fced9f5d" ), 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( "9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6" "K3fhq3scsyY88tdB1MqucULcKzWZC"), payment_id=PaymentID("f75ad90e25d71a12"), transaction=tx, ) self.transfers.append(pm) tx = Transaction( timestamp=datetime(2018, 1, 29, 13, 17, 18), height=1087608, hash= "4ea70add5d0c7db33557551b15cd174972fcfc73bf0f6a6b47b7837564b708d3", fee=Decimal("0.000962550000"), confirmations=1, ) pm = IncomingPayment( amount=Decimal("4.000000000000"), local_address=address( "9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6" "K3fhq3scsyY88tdB1MqucULcKzWZC"), 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( "9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6" "K3fhq3scsyY88tdB1MqucULcKzWZC"), 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("1240.0000000"), local_address=address( "BhE3cQvB7VF2uuXcpXp28Wbadez6GgjypdRS1F1Mzqn8Advd6q8VfaX8ZoEDobjejr" "MfpHeNXoX8MjY8q8prW1PEALgr1En"), payment_id=PaymentID("0000000000000000"), transaction=tx, ) self.transfers.append(pm) tx = Transaction( timestamp=datetime(2018, 1, 29, 13, 17, 18), height=1087606, hash= "cc44568337a186c2e1ccc080b43b4ae9db26a07b7afd7edeed60ce2fc4a6477f", fee=Decimal("0.000962550000"), ) pm = IncomingPayment( amount=Decimal("10.000000000000"), local_address=address( "9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6" "K3fhq3scsyY88tdB1MqucULcKzWZC"), 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( "9tQoHWyZ4yXUgbz9nvMcFZUfDy5hxcdZabQCxmNCUukKYicXegsDL7nQpcUa3A1pF6" "K3fhq3scsyY88tdB1MqucULcKzWZC"), payment_id=PaymentID("03f6649304ea4cb2"), transaction=tx, ) self.transfers.append(pm)
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)
help="Source account index") argsparser.add_argument( '-p', dest='prio', choices=['unimportant', 'normal', 'elevated', 'priority'], default='normal') argsparser.add_argument('-r', dest='ring_size', type=int, default=5, help="Ring size") argsparser.add_argument('-i', dest='payment_id', nargs='?', type=PaymentID, const=PaymentID(random.randint(0, 2**256)), help="Payment ID") argsparser.add_argument( '--save', dest='outdir', nargs='?', default=None, const='.', help= "Save to file, optionally follow by destination directory (default is .)\n" "Transaction will be not relayed to the network.") argsparser.add_argument( 'destinations', metavar='address:amount', nargs='+', type=destpair,
import sys from monero.address import address from monero.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))
def test_payment_id(self): pid = PaymentID("0") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0) self.assertEqual(pid, "0000000000000000") self.assertEqual(PaymentID(pid), pid) self.assertNotEqual(pid, None) pid = PaymentID("abcdef") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0xABCDEF) self.assertEqual(pid, "0000000000abcdef") self.assertEqual(PaymentID(pid), pid) pid = PaymentID("1234567812345678") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0x1234567812345678) self.assertEqual(pid, "1234567812345678") self.assertEqual(PaymentID(pid), pid) pid = PaymentID("a1234567812345678") self.assertFalse(pid.is_short()) self.assertEqual(pid, 0xA1234567812345678) self.assertEqual( pid, "00000000000000000000000000000000000000000000000a1234567812345678") self.assertEqual(PaymentID(pid), pid) self.assertRaises(ValueError, PaymentID, 2**256 + 1)
def test_payment_id(self): pid = PaymentID('0') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0) self.assertEqual(pid, '0000000000000000') self.assertEqual(PaymentID(pid), pid) self.assertNotEqual(pid, None) pid = PaymentID('abcdef') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0xabcdef) self.assertEqual(pid, '0000000000abcdef') self.assertEqual(PaymentID(pid), pid) pid = PaymentID('1234567812345678') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0x1234567812345678) self.assertEqual(pid, '1234567812345678') self.assertEqual(PaymentID(pid), pid) pid = PaymentID('a1234567812345678') self.assertFalse(pid.is_short()) self.assertEqual(pid, 0xa1234567812345678) self.assertEqual( pid, '00000000000000000000000000000000000000000000000a1234567812345678') self.assertEqual(PaymentID(pid), pid) self.assertRaises(ValueError, PaymentID, 2**256 + 1)