From 914b1061d49c98b7966a7c6f75dddf2bed159f52 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 2 May 2019 09:01:40 +0000 Subject: [PATCH 1/2] wallet_rpc_server: use original addresses in destinations in get_transfers And add them for pending transfers, where they were missing --- src/wallet/wallet_rpc_server.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp index 4076ae957..5030c0be5 100644 --- a/src/wallet/wallet_rpc_server.cpp +++ b/src/wallet/wallet_rpc_server.cpp @@ -385,7 +385,7 @@ namespace tools entry.destinations.push_back(wallet_rpc::transfer_destination()); wallet_rpc::transfer_destination &td = entry.destinations.back(); td.amount = d.amount; - td.address = get_account_address_as_str(m_wallet->nettype(), d.is_subaddress, d.addr); + td.address = d.original.empty() ? get_account_address_as_str(m_wallet->nettype(), d.is_subaddress, d.addr) : d.original; } entry.type = "out"; @@ -410,6 +410,14 @@ namespace tools entry.amount = pd.m_amount_in - pd.m_change - entry.fee; entry.unlock_time = pd.m_tx.unlock_time; entry.note = m_wallet->get_tx_note(txid); + + for (const auto &d: pd.m_dests) { + entry.destinations.push_back(wallet_rpc::transfer_destination()); + wallet_rpc::transfer_destination &td = entry.destinations.back(); + td.amount = d.amount; + td.address = d.original.empty() ? get_account_address_as_str(m_wallet->nettype(), d.is_subaddress, d.addr) : d.original; + } + entry.type = is_failed ? "failed" : "pending"; entry.subaddr_index = { pd.m_subaddr_account, 0 }; for (uint32_t i: pd.m_subaddr_indices) From da694d418a7f3152425aa17a7e26c54a20c38283 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Thu, 2 May 2019 09:03:54 +0000 Subject: [PATCH 2/2] functional_tests: add tests for pending/out transfer addresses --- tests/functional_tests/transfer.py | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/functional_tests/transfer.py b/tests/functional_tests/transfer.py index 1ff641d1f..a93ef886c 100755 --- a/tests/functional_tests/transfer.py +++ b/tests/functional_tests/transfer.py @@ -46,6 +46,7 @@ class TransferTest(): self.check_get_bulk_payments() self.check_double_spend_detection() self.sweep_single() + self.check_destinations() def reset(self): print 'Resetting blockchain' @@ -626,6 +627,64 @@ class TransferTest(): res = self.wallet[0].incoming_transfers(transfer_type = 'unavailable') assert len([t for t in res.transfers if t.key_image == ki]) == 1 + def check_destinations(self): + daemon = Daemon() + + print("Checking transaction destinations") + + dst = {'address': '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + dst = {'address': '8AsN91rznfkBGTY8psSNkJBg9SZgxxGGRUhGwRptBhgr5XSQ1XzmA9m8QAnoxydecSh5aLJXdrgXwTDMMZ1AuXsN1EX5Mtm', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '8AsN91rznfkBGTY8psSNkJBg9SZgxxGGRUhGwRptBhgr5XSQ1XzmA9m8QAnoxydecSh5aLJXdrgXwTDMMZ1AuXsN1EX5Mtm' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + dst = {'address': '4BxSHvcgTwu25WooY4BVmgdcKwZu5EksVZSZkDd6ooxSVVqQ4ubxXkhLF6hEqtw96i9cf3cVfLw8UWe95bdDKfRQeYtPwLm1Jiw7AKt2LY', 'amount': 1000000000000} + res = self.wallet[0].transfer([dst]) + assert len(res.tx_hash) == 64 + tx_hash = res.tx_hash + for i in range(2): + res = self.wallet[0].get_transfers(pending = True, out = True) + l = [x for x in (res.pending if i == 0 else res.out) if x.txid == tx_hash] + assert len(l) == 1 + e = l[0] + assert len(e.destinations) == 1 + assert e.destinations[0].amount == 1000000000000 + assert e.destinations[0].address == '4BxSHvcgTwu25WooY4BVmgdcKwZu5EksVZSZkDd6ooxSVVqQ4ubxXkhLF6hEqtw96i9cf3cVfLw8UWe95bdDKfRQeYtPwLm1Jiw7AKt2LY' + + if i == 0: + daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1) + self.wallet[0].refresh() + + + if __name__ == '__main__': TransferTest().run_test()