3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-16 04:05:50 +00:00

Hex dump pending transactions that double spend each other.

This commit is contained in:
Mike Hearn 2014-03-10 14:08:38 +01:00
parent 85d8145924
commit 5226cdc6fc

View File

@ -40,6 +40,7 @@ import org.bitcoinj.wallet.Protos.Wallet.EncryptionType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.spongycastle.crypto.params.KeyParameter; import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.util.encoders.Hex;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -1077,10 +1078,13 @@ public class Wallet implements Serializable, BlockChainListener, PeerFilterProvi
log.warn("updateForSpends: saw double spend from chain, handling later."); log.warn("updateForSpends: saw double spend from chain, handling later.");
} else { } else {
// We saw two pending transactions that double spend each other. We don't know which will win. // We saw two pending transactions that double spend each other. We don't know which will win.
// This should not happen. // This can happen in the case of bad network nodes that mutate transactions. Do a hex dump
log.warn("Saw two pending transactions double spend each other: {} vs {}", // so the exact nature of the mutation can be examined.
tx.getHash(), input.getConnectedOutput().getSpentBy().getParentTransaction().getHash()); log.warn("Saw two pending transactions double spend each other");
log.warn(" offending input is input {}", tx.getInputs().indexOf(input)); log.warn(" offending input is input {}", tx.getInputs().indexOf(input));
log.warn("{}: {}", tx.getHash(), new String(Hex.encode(tx.unsafeBitcoinSerialize())));
Transaction other = input.getConnectedOutput().getSpentBy().getParentTransaction();
log.warn("{}: {}", other.getHash(), new String(Hex.encode(tx.unsafeBitcoinSerialize())));
} }
} else if (result == TransactionInput.ConnectionResult.SUCCESS) { } else if (result == TransactionInput.ConnectionResult.SUCCESS) {
// Otherwise we saw a transaction spend our coins, but we didn't try and spend them ourselves yet. // Otherwise we saw a transaction spend our coins, but we didn't try and spend them ourselves yet.