diff --git a/src/com/google/bitcoin/core/Wallet.java b/src/com/google/bitcoin/core/Wallet.java index fcdeece54..9bb4c9db6 100644 --- a/src/com/google/bitcoin/core/Wallet.java +++ b/src/com/google/bitcoin/core/Wallet.java @@ -338,7 +338,10 @@ public class Wallet implements Serializable { // A -> spent by B [pending] // \-> spent by C [chain] Transaction doubleSpent = input.outpoint.fromTx; // == A - Transaction connected = doubleSpent.outputs.get((int)input.outpoint.index).getSpentBy().parentTransaction; + int index = (int) input.outpoint.index; + TransactionOutput output = doubleSpent.outputs.get(index); + TransactionInput spentBy = output.getSpentBy(); + Transaction connected = spentBy.parentTransaction; if (pending.containsKey(connected.getHash())) { log.info("Saw double spend from chain override pending tx {}", connected.getHashAsString()); log.info(" <-pending ->dead"); @@ -382,6 +385,14 @@ public class Wallet implements Serializable { eventListeners.add(listener); } + /** + * Removes the given event listener object. Returns true if the listener was removed, + * false if that listener was never added. + */ + public synchronized boolean removeEventListener(WalletEventListener listener) { + return eventListeners.remove(listener); + } + /** * Call this when we have successfully transmitted the send tx to the network, to update the wallet. */