Skip to content

Commit

Permalink
wallet: fetch pool txs in pruned form [RELEASE]
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Jun 20, 2024
1 parent 24ccaba commit 4d41d36
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/wallet/wallet2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,7 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction,

req.requested_info = COMMAND_RPC_GET_BLOCKS_FAST::POOL_ONLY;
req.pool_info_since = m_pool_info_query_time;
req.prune = true;

{
const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
Expand Down
40 changes: 40 additions & 0 deletions tests/functional_tests/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def run_test(self):
self.create()
self.mine()
self.transfer()
self.pool_refresh()
self.check_get_bulk_payments()
self.check_get_payments()
self.check_double_spend_detection()
Expand Down Expand Up @@ -507,6 +508,45 @@ def transfer(self):
assert res.unlocked_balance <= res.balance
assert res.blocks_to_unlock == 7

def pool_refresh(self):
print('Checking that the wallet processes transactions in the pool')

daemon = Daemon()

# get txids in the pool at the beginning
res = daemon.get_transaction_pool_hashes()
pool_txids_before = set(res.tx_hashes) if 'tx_hashes' in res else set()

# transfer funds from wallet 0 to wallet1
dst1 = {'address': '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW', 'amount': 1100000000000}
self.wallet[0].refresh()
res = self.wallet[0].transfer([dst1])
assert len(res.tx_hash) == 32*2
new_pool_txid = res.tx_hash
new_pool_tx_fee = res.fee

# BEFORE MINING A BLOCK, refresh wallet1 and check that the incoming transfer is recognized
self.wallet[1].refresh()
res = self.wallet[1].get_transfers()
e = [o for o in res['pool'] if o.txid == new_pool_txid]
assert len(e) == 1
e = e[0]
assert e.txid == new_pool_txid
assert e.payment_id in ["", "0000000000000000"] # long payment IDs are now ignored
assert e.type == 'pool'
assert e.unlock_time == 0
assert e.subaddr_index.major == 0
assert e.subaddr_indices == [{'major': 0, 'minor': 0}]
assert e.address == '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW'
assert e.double_spend_seen == False
assert 'confirmations' not in e or e.confirmations == 0
assert e.amount == 1100000000000
assert e.fee == new_pool_tx_fee

# sanity check the pools contents: old txids + new txid
res = daemon.get_transaction_pool_hashes()
pool_txids_after = set(res.tx_hashes) if 'tx_hashes' in res else set()
assert pool_txids_after - pool_txids_before == set([new_pool_txid])

def check_get_bulk_payments(self):
print('Checking get_bulk_payments')
Expand Down

0 comments on commit 4d41d36

Please sign in to comment.