From ca15e611cabe4a58017f0923c74a7ab87f6c15df Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 30 Jul 2013 17:53:46 +0200 Subject: [PATCH] Fix manually-added transactions that make it into blocks. --- core/src/main/java/com/google/bitcoin/core/Wallet.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/bitcoin/core/Wallet.java b/core/src/main/java/com/google/bitcoin/core/Wallet.java index f690bb78..f9f6c096 100644 --- a/core/src/main/java/com/google/bitcoin/core/Wallet.java +++ b/core/src/main/java/com/google/bitcoin/core/Wallet.java @@ -866,7 +866,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi if (spentBy != null) spentBy.disconnect(); } } - processTxFromBestChain(tx); + processTxFromBestChain(tx, wasPending); } else { checkState(sideChain); // Transactions that appear in a side chain will have that appearance recorded below - we assume that @@ -995,7 +995,7 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi * Handle when a transaction becomes newly active on the best chain, either due to receiving a new block or a * re-org. Places the tx into the right pool, handles coinbase transactions, handles double-spends and so on. */ - private void processTxFromBestChain(Transaction tx) throws VerificationException { + private void processTxFromBestChain(Transaction tx, boolean forceAddToPool) throws VerificationException { checkState(lock.isHeldByCurrentThread()); checkState(!pending.containsKey(tx.getHash())); @@ -1032,6 +1032,10 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi // Didn't send us any money, but did spend some. Keep it around for record keeping purposes. log.info(" tx {} ->spent", tx.getHashAsString()); addWalletTransaction(Pool.SPENT, tx); + } else if (forceAddToPool) { + // Was manually added to pending, so we should keep it to notify the user of confidence information + log.info(" tx {} ->spent (manually added)", tx.getHashAsString()); + addWalletTransaction(Pool.SPENT, tx); } checkForDoubleSpendAgainstPending(tx, true);