mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-08-02 00:31:24 +00:00
Second part ... refresh timestamp when confirming a spend to the wallet.
This commit is contained in:
@@ -429,6 +429,8 @@ public class Wallet implements Serializable {
|
|||||||
connectedOutput.markAsSpent(input);
|
connectedOutput.markAsSpent(input);
|
||||||
maybeMoveTxToSpent(connectedTx, "spent tx");
|
maybeMoveTxToSpent(connectedTx, "spent tx");
|
||||||
}
|
}
|
||||||
|
// Refresh the timestamp.
|
||||||
|
tx.updatedAt = new Date();
|
||||||
// Add to the pending pool. It'll be moved out once we receive this transaction on the best chain.
|
// Add to the pending pool. It'll be moved out once we receive this transaction on the best chain.
|
||||||
pending.put(tx.getHash(), tx);
|
pending.put(tx.getHash(), tx);
|
||||||
}
|
}
|
||||||
|
@@ -296,14 +296,25 @@ public class WalletTest {
|
|||||||
assertEquals(1, transactions.size());
|
assertEquals(1, transactions.size());
|
||||||
assertEquals(tx2, transactions.get(0));
|
assertEquals(tx2, transactions.get(0));
|
||||||
|
|
||||||
|
// Create a spend.
|
||||||
|
Transaction tx3 = wallet.createSend(new ECKey().toAddress(params), Utils.toNanoCoins(0, 5));
|
||||||
|
// Does not appear in list yet.
|
||||||
|
assertEquals(2, wallet.getTransactionsByTime().size());
|
||||||
|
wallet.confirmSend(tx3);
|
||||||
|
// Now it does.
|
||||||
|
transactions = wallet.getTransactionsByTime();
|
||||||
|
assertEquals(3, transactions.size());
|
||||||
|
assertEquals(tx3, transactions.get(0));
|
||||||
|
|
||||||
// Verify we can handle the case of older wallets in which the timestamp is null (guessed from the
|
// Verify we can handle the case of older wallets in which the timestamp is null (guessed from the
|
||||||
// block appearances list).
|
// block appearances list).
|
||||||
tx1.updatedAt = null;
|
tx1.updatedAt = null;
|
||||||
tx2.updatedAt = null;
|
tx2.updatedAt = null;
|
||||||
// Check we got them back in order.
|
// Check we got them back in order.
|
||||||
transactions = wallet.getTransactionsByTime();
|
transactions = wallet.getTransactionsByTime();
|
||||||
assertEquals(tx2, transactions.get(0));
|
assertEquals(tx3, transactions.get(0));
|
||||||
assertEquals(tx1, transactions.get(1));
|
assertEquals(tx2, transactions.get(1));
|
||||||
assertEquals(2, transactions.size());
|
assertEquals(tx1, transactions.get(2));
|
||||||
|
assertEquals(3, transactions.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user