Migrate usage of deprecated Transaction.getHash() to getTxId().

This commit is contained in:
Andreas Schildbach
2019-02-17 17:27:14 +01:00
parent 23e6862e9c
commit f94f8cd692
37 changed files with 228 additions and 227 deletions

View File

@@ -876,7 +876,7 @@ public abstract class AbstractBlockChain {
Set<Sha256Hash> falsePositives) throws VerificationException {
for (Transaction tx : transactions) {
try {
falsePositives.remove(tx.getHash());
falsePositives.remove(tx.getTxId());
if (clone)
tx = tx.params.getDefaultSerializer().makeTransaction(tx.bitcoinSerialize());
listener.receiveFromBlock(tx, block, blockType, relativityOffset++);

View File

@@ -620,7 +620,7 @@ public class Block extends Message {
ArrayList<byte[]> tree = new ArrayList<>();
// Start by adding all the hashes of the transactions as leaves of the tree.
for (Transaction t : transactions) {
tree.add(t.getHash().getBytes());
tree.add(t.getTxId().getBytes());
}
int levelOffset = 0; // Offset in the list where the currently processed level starts.
// Step through each level, stopping when we reach the root (levelSize == 1).

View File

@@ -318,7 +318,7 @@ public class BloomFilter extends Message {
byte[] bits = new byte[(int) Math.ceil(txns.size() / 8.0)];
for (int i = 0; i < txns.size(); i++) {
Transaction tx = txns.get(i);
txHashes.add(tx.getHash());
txHashes.add(tx.getTxId());
if (applyAndUpdate(tx)) {
Utils.setBitLE(bits, i);
matched.add(tx);
@@ -332,7 +332,7 @@ public class BloomFilter extends Message {
}
public synchronized boolean applyAndUpdate(Transaction tx) {
if (contains(tx.getHash().getBytes()))
if (contains(tx.getTxId().getBytes()))
return true;
boolean found = false;
BloomUpdate flag = getUpdateFlag();

View File

@@ -102,7 +102,7 @@ public class FilteredBlock extends Message {
* @return false if the tx is not relevant to this FilteredBlock
*/
public boolean provideTransaction(Transaction tx) throws VerificationException {
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
if (getTransactionHashes().contains(hash)) {
associatedTransactions.put(hash, tx);
return true;

View File

@@ -235,7 +235,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
// BIP30 document for more details on this: https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki
for (Transaction tx : block.transactions) {
final Set<VerifyFlag> verifyFlags = params.getTransactionVerificationFlags(block, tx, getVersionTally(), height);
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
// If we already have unspent outputs for this hash, we saw the tx already. Either the block is
// being added twice (bug) or the block is a BIP30 violator.
if (blockStore.hasUnspentOutputs(hash, tx.getOutputs().size()))
@@ -283,7 +283,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
txOutsSpent.add(prevOut);
}
}
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
for (TransactionOutput out : tx.getOutputs()) {
valueOut = valueOut.add(out.getValue());
// For each output, add it to the set of unspent outputs so it can be consumed in future.
@@ -370,7 +370,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
if (!params.isCheckpoint(newBlock.getHeight())) {
for (Transaction tx : transactions) {
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
if (blockStore.hasUnspentOutputs(hash, tx.getOutputs().size()))
throw new VerificationException("Block failed BIP30 test!");
}
@@ -414,7 +414,7 @@ public class FullPrunedBlockChain extends AbstractBlockChain {
txOutsSpent.add(prevOut);
}
}
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
for (TransactionOutput out : tx.getOutputs()) {
valueOut = valueOut.add(out.getValue());
Script script = getScript(out.getScriptBytes());

View File

@@ -58,7 +58,7 @@ public class InventoryMessage extends ListMessage {
}
public void addTransaction(Transaction tx) {
addItem(new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getHash()));
addItem(new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getTxId()));
}
/** Creates a new inv message for the given transactions. */

View File

@@ -836,7 +836,7 @@ public class Peer extends PeerSocketHandler {
log.info("{}: Dependency download complete!", getAddress());
wallet.receivePending(tx, dependencies);
} catch (VerificationException e) {
log.error("{}: Wallet failed to process pending transaction {}", getAddress(), tx.getHash());
log.error("{}: Wallet failed to process pending transaction {}", getAddress(), tx.getTxId());
log.error("Error was: ", e);
// Not much more we can do at this point.
}
@@ -917,7 +917,7 @@ public class Peer extends PeerSocketHandler {
final Transaction tx, final Object marker, final List<Transaction> results) {
final SettableFuture<Object> resultFuture = SettableFuture.create();
final Sha256Hash rootTxHash = tx.getHash();
final Sha256Hash rootTxHash = tx.getTxId();
// We want to recursively grab its dependencies. This is so listeners can learn important information like
// whether a transaction is dependent on a timelocked transaction or has an unexpectedly deep dependency tree
// or depends on a no-fee transaction.
@@ -984,7 +984,7 @@ public class Peer extends PeerSocketHandler {
// Start the operation.
sendMessage(getdata);
} catch (Exception e) {
log.error("{}: Couldn't send getdata in downloadDependencies({})", this, tx.getHash(), e);
log.error("{}: Couldn't send getdata in downloadDependencies({})", this, tx.getTxId(), e);
resultFuture.setException(e);
return resultFuture;
} finally {

View File

@@ -76,7 +76,7 @@ public class Transaction extends ChildMessage {
final long time2 = tx2.getUpdateTime().getTime();
final int updateTimeComparison = -(Longs.compare(time1, time2));
//If time1==time2, compare by tx hash to make comparator consistent with equals
return updateTimeComparison != 0 ? updateTimeComparison : tx1.getHash().compareTo(tx2.getHash());
return updateTimeComparison != 0 ? updateTimeComparison : tx1.getTxId().compareTo(tx2.getTxId());
}
};
/** A comparator that can be used to sort transactions by their chain height. */
@@ -91,7 +91,7 @@ public class Transaction extends ChildMessage {
? confidence2.getAppearedAtChainHeight() : Block.BLOCK_HEIGHT_UNKNOWN;
final int heightComparison = -(Ints.compare(height1, height2));
//If height1==height2, compare by tx hash to make comparator consistent with equals
return heightComparison != 0 ? heightComparison : tx1.getHash().compareTo(tx2.getHash());
return heightComparison != 0 ? heightComparison : tx1.getTxId().compareTo(tx2.getTxId());
}
};
private static final Logger log = LoggerFactory.getLogger(Transaction.class);
@@ -1524,7 +1524,7 @@ public class Transaction extends ChildMessage {
*/
public TransactionConfidence getConfidence(TxConfidenceTable table) {
if (confidence == null)
confidence = table.getOrCreate(getHash()) ;
confidence = table.getOrCreate(getTxId()) ;
return confidence;
}
@@ -1537,12 +1537,12 @@ public class Transaction extends ChildMessage {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
return getHash().equals(((Transaction)o).getHash());
return getTxId().equals(((Transaction)o).getTxId());
}
@Override
public int hashCode() {
return getHash().hashCode();
return getTxId().hashCode();
}
/**

View File

@@ -93,7 +93,7 @@ public class TransactionBroadcast {
public Message onPreMessageReceived(Peer peer, Message m) {
if (m instanceof RejectMessage) {
RejectMessage rejectMessage = (RejectMessage)m;
if (tx.getHash().equals(rejectMessage.getRejectedObjectHash())) {
if (tx.getTxId().equals(rejectMessage.getRejectedObjectHash())) {
rejects.put(peer, rejectMessage);
int size = rejects.size();
long threshold = Math.round(numWaitingFor / 2.0);
@@ -203,7 +203,7 @@ public class TransactionBroadcast {
//
// We're done! It's important that the PeerGroup lock is not held (by this thread) at this
// point to avoid triggering inversions when the Future completes.
log.info("broadcastTransaction: {} complete", tx.getHash());
log.info("broadcastTransaction: {} complete", tx.getTxId());
peerGroup.removePreMessageReceivedEventListener(rejectionListener);
conf.removeEventListener(this);
future.set(tx); // RE-ENTRANCY POINT

View File

@@ -366,7 +366,7 @@ public class TransactionInput extends ChildMessage {
* @return NO_SUCH_TX if transaction is not the prevtx, ALREADY_SPENT if there was a conflict, SUCCESS if not.
*/
public ConnectionResult connect(Transaction transaction, ConnectMode mode) {
if (!transaction.getHash().equals(outpoint.getHash()))
if (!transaction.getTxId().equals(outpoint.getHash()))
return ConnectionResult.NO_SUCH_TX;
checkElementIndex((int) outpoint.getIndex(), transaction.getOutputs().size(), "Corrupt transaction");
TransactionOutput out = transaction.getOutput((int) outpoint.getIndex());
@@ -468,7 +468,7 @@ public class TransactionInput extends ChildMessage {
*/
public void verify(TransactionOutput output) throws VerificationException {
if (output.parent != null) {
if (!getOutpoint().getHash().equals(output.getParentTransaction().getHash()))
if (!getOutpoint().getHash().equals(output.getParentTransaction().getTxId()))
throw new VerificationException("This input does not refer to the tx containing the output.");
if (getOutpoint().getIndex() != output.getIndex())
throw new VerificationException("This input refers to a different output on the given tx.");

View File

@@ -50,7 +50,7 @@ public class TransactionOutPoint extends ChildMessage {
super(params);
this.index = index;
if (fromTx != null) {
this.hash = fromTx.getHash();
this.hash = fromTx.getTxId();
this.fromTx = fromTx;
} else {
// This happens when constructing the genesis block.

View File

@@ -315,7 +315,8 @@ public class TransactionOutput extends ChildMessage {
return false;
} catch (ScriptException e) {
// Just means we didn't understand the output of this transaction: ignore it.
log.debug("Could not parse tx {} output script: {}", parent != null ? parent.getHash() : "(no parent)", e.toString());
log.debug("Could not parse tx {} output script: {}",
parent != null ? ((Transaction) parent).getTxId() : "(no parent)", e.toString());
return false;
}
}
@@ -366,7 +367,7 @@ public class TransactionOutput extends ChildMessage {
*/
@Nullable
public Sha256Hash getParentTransactionHash() {
return parent == null ? null : parent.getHash();
return parent == null ? null : ((Transaction) parent).getTxId();
}
/**

View File

@@ -511,7 +511,7 @@ public class PaymentChannelClient implements IPaymentChannelClient {
checkState(lock.isHeldByCurrentThread());
if (msg.hasSettlement()) {
Transaction settleTx = wallet.getParams().getDefaultSerializer().makeTransaction(msg.getSettlement().getTx().toByteArray());
log.info("CLOSE message received with settlement tx {}", settleTx.getHash());
log.info("CLOSE message received with settlement tx {}", settleTx.getTxId());
// TODO: set source
if (state != null && state().isSettlementTransaction(settleTx)) {
// The wallet has a listener on it that the state object will use to do the right thing at this
@@ -602,8 +602,8 @@ public class PaymentChannelClient implements IPaymentChannelClient {
.setTimeWindowSecs(timeWindow);
if (storedChannel != null) {
versionNegotiationBuilder.setPreviousChannelContractHash(ByteString.copyFrom(storedChannel.contract.getHash().getBytes()));
log.info("Begun version handshake, attempting to reopen channel with contract hash {}", storedChannel.contract.getHash());
versionNegotiationBuilder.setPreviousChannelContractHash(ByteString.copyFrom(storedChannel.contract.getTxId().getBytes()));
log.info("Begun version handshake, attempting to reopen channel with contract hash {}", storedChannel.contract.getTxId());
} else
log.info("Begun version handshake creating new channel");

View File

@@ -160,7 +160,7 @@ public abstract class PaymentChannelClientState {
synchronized (PaymentChannelClientState.this) {
if (getContractInternal() == null) return;
if (isSettlementTransaction(tx)) {
log.info("Close: transaction {} closed contract {}", tx.getHash(), getContractInternal().getHash());
log.info("Close: transaction {} closed contract {}", tx.getTxId(), getContractInternal().getTxId());
// Record the fact that it was closed along with the transaction that closed it.
stateMachine.transition(State.CLOSED);
if (storedChannel == null) return;

View File

@@ -419,7 +419,7 @@ public class PaymentChannelServer {
.addListener(new Runnable() {
@Override
public void run() {
multisigContractPropogated(providedContract, contract.getHash());
multisigContractPropogated(providedContract, contract.getTxId());
}
}, Threading.SAME_THREAD);
}
@@ -611,7 +611,7 @@ public class PaymentChannelServer {
StoredPaymentChannelServerStates channels = (StoredPaymentChannelServerStates)
wallet.getExtensions().get(StoredPaymentChannelServerStates.EXTENSION_ID);
if (channels != null) {
StoredServerChannel storedServerChannel = channels.getChannel(state.getContract().getHash());
StoredServerChannel storedServerChannel = channels.getChannel(state.getContract().getTxId());
if (storedServerChannel != null) {
storedServerChannel.clearConnectedHandler();
}

View File

@@ -261,8 +261,8 @@ public abstract class PaymentChannelServerState {
// Get the wallet's copy of the contract (ie with confidence information), if this is null, the wallet
// was not connected to the peergroup when the contract was broadcast (which may cause issues down the road, and
// disables our double-spend check next)
Transaction walletContract = wallet.getTransaction(contract.getHash());
checkNotNull(walletContract, "Wallet did not contain multisig contract {} after state was marked READY", contract.getHash());
Transaction walletContract = wallet.getTransaction(contract.getTxId());
checkNotNull(walletContract, "Wallet did not contain multisig contract {} after state was marked READY", contract.getTxId());
// Note that we check for DEAD state here, but this test is essentially useless in production because we will
// miss most double-spends due to bloom filtering right now anyway. This will eventually fixed by network-wide
@@ -368,7 +368,7 @@ public abstract class PaymentChannelServerState {
if (storedServerChannel != null)
return;
log.info("Storing state with contract hash {}.", getContract().getHash());
log.info("Storing state with contract hash {}.", getContract().getTxId());
StoredPaymentChannelServerStates channels = (StoredPaymentChannelServerStates)
wallet.addOrGetExistingExtension(new StoredPaymentChannelServerStates(wallet, broadcaster));
storedServerChannel = new StoredServerChannel(this, getMajorVersion(), getContract(), getClientOutput(), getExpiryTime(), serverKey, getClientKey(), bestValueToMe, bestValueSignature);

View File

@@ -267,7 +267,7 @@ public class PaymentChannelV1ClientState extends PaymentChannelClientState {
StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates)
wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
checkNotNull(channels, "You have not added the StoredPaymentChannelClientStates extension to the wallet.");
checkState(channels.getChannel(id, multisigContract.getHash()) == null);
checkState(channels.getChannel(id, multisigContract.getTxId()) == null);
storedChannel = new StoredClientChannel(getMajorVersion(), id, multisigContract, refundTx, myKey, serverKey, valueToMe, refundFees, 0, true);
channels.putChannel(storedChannel);
}

View File

@@ -252,7 +252,7 @@ public class PaymentChannelV1ServerState extends PaymentChannelServerState {
ListenableFuture<Transaction> future = broadcaster.broadcastTransaction(tx).future();
Futures.addCallback(future, new FutureCallback<Transaction>() {
@Override public void onSuccess(Transaction transaction) {
log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
log.info("TX {} propagated, channel successfully closed.", transaction.getTxId());
stateMachine.transition(State.CLOSED);
closedFuture.set(transaction);
}

View File

@@ -199,7 +199,7 @@ public class PaymentChannelV2ClientState extends PaymentChannelClientState {
StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates)
wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
checkNotNull(channels, "You have not added the StoredPaymentChannelClientStates extension to the wallet.");
checkState(channels.getChannel(id, contract.getHash()) == null);
checkState(channels.getChannel(id, contract.getTxId()) == null);
storedChannel = new StoredClientChannel(getMajorVersion(), id, contract, refundTx, myKey, serverKey, valueToMe, refundFees, expiryTime, true);
channels.putChannel(storedChannel);
}

View File

@@ -206,7 +206,7 @@ public class PaymentChannelV2ServerState extends PaymentChannelServerState {
ListenableFuture<Transaction> future = broadcaster.broadcastTransaction(tx).future();
Futures.addCallback(future, new FutureCallback<Transaction>() {
@Override public void onSuccess(Transaction transaction) {
log.info("TX {} propagated, channel successfully closed.", transaction.getHash());
log.info("TX {} propagated, channel successfully closed.", transaction.getTxId());
stateMachine.transition(State.CLOSED);
closedFuture.set(transaction);
}

View File

@@ -144,7 +144,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
for (StoredClientChannel channel : setChannels) {
synchronized (channel) {
// Check if the channel is usable (has money, inactive) and if so, activate it.
log.info("Considering channel {} contract {}", channel.hashCode(), channel.contract.getHash());
log.info("Considering channel {} contract {}", channel.hashCode(), channel.contract.getTxId());
if (channel.close != null || channel.valueToMe.equals(Coin.ZERO)) {
log.info(" ... but is closed or empty");
continue;
@@ -172,7 +172,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
try {
Set<StoredClientChannel> setChannels = mapChannels.get(id);
for (StoredClientChannel channel : setChannels) {
if (channel.contract.getHash().equals(contractHash))
if (channel.contract.getTxId().equals(contractHash))
return channel;
}
return null;
@@ -314,7 +314,7 @@ public class StoredPaymentChannelClientStates implements WalletExtension {
.setValueToMe(channel.valueToMe.value)
.setExpiryTime(channel.expiryTime);
if (channel.close != null)
value.setCloseTransactionHash(ByteString.copyFrom(channel.close.getHash().getBytes()));
value.setCloseTransactionHash(ByteString.copyFrom(channel.close.getTxId().getBytes()));
builder.addChannels(value);
}
return builder.build().toByteArray();

View File

@@ -109,7 +109,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
public void closeChannel(StoredServerChannel channel) {
lock.lock();
try {
if (mapChannels.remove(channel.contract.getHash()) == null)
if (mapChannels.remove(channel.contract.getTxId()) == null)
return;
} finally {
lock.unlock();
@@ -190,7 +190,7 @@ public class StoredPaymentChannelServerStates implements WalletExtension {
public void putChannel(final StoredServerChannel channel) {
lock.lock();
try {
checkArgument(mapChannels.put(channel.contract.getHash(), checkNotNull(channel)) == null);
checkArgument(mapChannels.put(channel.contract.getTxId(), checkNotNull(channel)) == null);
// Add the difference between real time and Utils.now() so that test-cases can use a mock clock.
Date autocloseTime = new Date((channel.refundTransactionUnlockTimeSecs + CHANNEL_EXPIRE_OFFSET) * 1000L
+ (System.currentTimeMillis() - Utils.currentTimeMillis()));

View File

@@ -1739,7 +1739,7 @@ public class Wallet extends BaseTaggableObject
Set<Sha256Hash> hashes = new HashSet<>();
for (Transaction tx : transactions) {
hashes.add(tx.getHash());
hashes.add(tx.getTxId());
}
int size1 = transactions.size();
@@ -1836,7 +1836,7 @@ public class Wallet extends BaseTaggableObject
tx = riskDropped.get(txHash);
if (tx != null) {
// If this happens our risk analysis is probably wrong and should be improved.
log.info("Risk analysis dropped tx {} but was included in block anyway", tx.getHash());
log.info("Risk analysis dropped tx {} but was included in block anyway", tx.getTxId());
} else {
// False positive that was broadcast to us and ignored by us because it was irrelevant to our keys.
return false;
@@ -1882,7 +1882,7 @@ public class Wallet extends BaseTaggableObject
return;
if (isTransactionRisky(tx, dependencies) && !acceptRiskyTransactions) {
// isTransactionRisky already logged the reason.
riskDropped.put(tx.getHash(), tx);
riskDropped.put(tx.getTxId(), tx);
log.warn("There are now {} risk dropped transactions being kept in memory", riskDropped.size());
return;
}
@@ -2033,16 +2033,16 @@ public class Wallet extends BaseTaggableObject
void addTransactionsDependingOn(Set<Transaction> txSet, Set<Transaction> txPool) {
Map<Sha256Hash, Transaction> txQueue = new LinkedHashMap<>();
for (Transaction tx : txSet) {
txQueue.put(tx.getHash(), tx);
txQueue.put(tx.getTxId(), tx);
}
while(!txQueue.isEmpty()) {
Transaction tx = txQueue.remove(txQueue.keySet().iterator().next());
for (Transaction anotherTx : txPool) {
if (anotherTx.equals(tx)) continue;
for (TransactionInput input : anotherTx.getInputs()) {
if (input.getOutpoint().getHash().equals(tx.getHash())) {
if (txQueue.get(anotherTx.getHash()) == null) {
txQueue.put(anotherTx.getHash(), anotherTx);
if (input.getOutpoint().getHash().equals(tx.getTxId())) {
if (txQueue.get(anotherTx.getTxId()) == null) {
txQueue.put(anotherTx.getTxId(), anotherTx);
txSet.add(anotherTx);
}
}
@@ -2092,7 +2092,7 @@ public class Wallet extends BaseTaggableObject
checkState(lock.isHeldByCurrentThread());
Coin prevBalance = getBalance();
Sha256Hash txHash = tx.getHash();
Sha256Hash txHash = tx.getTxId();
boolean bestChain = blockType == BlockChain.NewBlockType.BEST_CHAIN;
boolean sideChain = blockType == BlockChain.NewBlockType.SIDE_CHAIN;
@@ -2113,7 +2113,7 @@ public class Wallet extends BaseTaggableObject
// If this transaction is already in the wallet we may need to move it into a different pool. At the very
// least we need to ensure we're manipulating the canonical object rather than a duplicate.
{
Transaction tmp = transactions.get(tx.getHash());
Transaction tmp = transactions.get(tx.getTxId());
if (tmp != null)
tx = tmp;
}
@@ -2150,7 +2150,7 @@ public class Wallet extends BaseTaggableObject
} else {
// Ignore the case where a tx appears on a side chain at the same time as the best chain (this is
// quite normal and expected).
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
if (!unspent.containsKey(hash) && !spent.containsKey(hash) && !dead.containsKey(hash)) {
// Otherwise put it (possibly back) into pending.
// Committing it updates the spent flags and inserts into the pool as well.
@@ -2267,7 +2267,7 @@ public class Wallet extends BaseTaggableObject
/** Finds whether txA spends txB */
boolean spends(Transaction txA, Transaction txB) {
for (TransactionInput txInput : txA.getInputs()) {
if (txInput.getOutpoint().getHash().equals(txB.getHash())) {
if (txInput.getOutpoint().getHash().equals(txB.getTxId())) {
return true;
}
}
@@ -2309,10 +2309,10 @@ public class Wallet extends BaseTaggableObject
// This is so that they can update their depth.
Set<Transaction> transactions = getTransactions(true);
for (Transaction tx : transactions) {
if (ignoreNextNewBlock.contains(tx.getHash())) {
if (ignoreNextNewBlock.contains(tx.getTxId())) {
// tx was already processed in receive() due to it appearing in this block, so we don't want to
// increment the tx confidence depth twice, it'd result in miscounting.
ignoreNextNewBlock.remove(tx.getHash());
ignoreNextNewBlock.remove(tx.getTxId());
} else {
TransactionConfidence confidence = tx.getConfidence();
if (confidence.getConfidenceType() == ConfidenceType.BUILDING) {
@@ -2351,12 +2351,12 @@ public class Wallet extends BaseTaggableObject
*/
private void processTxFromBestChain(Transaction tx, boolean forceAddToPool) throws VerificationException {
checkState(lock.isHeldByCurrentThread());
checkState(!pending.containsKey(tx.getHash()));
checkState(!pending.containsKey(tx.getTxId()));
// This TX may spend our existing outputs even though it was not pending. This can happen in unit
// tests, if keys are moved between wallets, if we're catching up to the chain given only a set of keys,
// or if a dead coinbase transaction has moved back onto the best chain.
boolean isDeadCoinbase = tx.isCoinBase() && dead.containsKey(tx.getHash());
boolean isDeadCoinbase = tx.isCoinBase() && dead.containsKey(tx.getTxId());
if (isDeadCoinbase) {
// There is a dead coinbase tx being received on the best chain. A coinbase tx is made dead when it moves
// to a side chain but it can be switched back on a reorg and resurrected back to spent or unspent.
@@ -2367,7 +2367,7 @@ public class Wallet extends BaseTaggableObject
// happen in practice, thus for simplicities sake we ignore it here.
log.info(" coinbase tx <-dead: confidence {}", tx.getTxId(),
tx.getConfidence().getConfidenceType().name());
dead.remove(tx.getHash());
dead.remove(tx.getTxId());
}
// Update tx and other unspent/pending transactions by connecting inputs/outputs.
@@ -2440,7 +2440,7 @@ public class Wallet extends BaseTaggableObject
private void updateForSpends(Transaction tx, boolean fromChain) throws VerificationException {
checkState(lock.isHeldByCurrentThread());
if (fromChain)
checkState(!pending.containsKey(tx.getHash()));
checkState(!pending.containsKey(tx.getTxId()));
for (TransactionInput input : tx.getInputs()) {
TransactionInput.ConnectionResult result = input.connect(unspent, TransactionInput.ConnectMode.ABORT_ON_CONFLICT);
if (result == TransactionInput.ConnectionResult.NO_SUCH_TX) {
@@ -2471,9 +2471,9 @@ public class Wallet extends BaseTaggableObject
// so the exact nature of the mutation can be examined.
log.warn("Saw two pending transactions double spend each other");
log.warn(" offending input is input {}", tx.getInputs().indexOf(input));
log.warn("{}: {}", tx.getHash(), Utils.HEX.encode(tx.unsafeBitcoinSerialize()));
log.warn("{}: {}", tx.getTxId(), Utils.HEX.encode(tx.unsafeBitcoinSerialize()));
Transaction other = output.getSpentBy().getParentTransaction();
log.warn("{}: {}", other.getHash(), Utils.HEX.encode(other.unsafeBitcoinSerialize()));
log.warn("{}: {}", other.getTxId(), Utils.HEX.encode(other.unsafeBitcoinSerialize()));
}
} else if (result == TransactionInput.ConnectionResult.SUCCESS) {
// Otherwise we saw a transaction spend our coins, but we didn't try and spend them ourselves yet.
@@ -2529,16 +2529,16 @@ public class Wallet extends BaseTaggableObject
overridingTx != null ? " by " + overridingTx.getTxId() : "");
log.warn("Disconnecting each input and moving connected transactions.");
// TX could be pending (finney attack), or in unspent/spent (coinbase killed by reorg).
pending.remove(tx.getHash());
unspent.remove(tx.getHash());
spent.remove(tx.getHash());
pending.remove(tx.getTxId());
unspent.remove(tx.getTxId());
spent.remove(tx.getTxId());
addWalletTransaction(Pool.DEAD, tx);
for (TransactionInput deadInput : tx.getInputs()) {
Transaction connected = deadInput.getConnectedTransaction();
if (connected == null) continue;
if (connected.getConfidence().getConfidenceType() != ConfidenceType.DEAD && deadInput.getConnectedOutput().getSpentBy() != null && deadInput.getConnectedOutput().getSpentBy().equals(deadInput)) {
checkState(myUnspents.add(deadInput.getConnectedOutput()));
log.info("Added to UNSPENTS: {} in {}", deadInput.getConnectedOutput(), deadInput.getConnectedOutput().getParentTransaction().getHash());
log.info("Added to UNSPENTS: {} in {}", deadInput.getConnectedOutput(), deadInput.getConnectedOutput().getParentTransaction().getTxId());
}
deadInput.disconnect();
maybeMovePool(connected, "kill");
@@ -2552,7 +2552,7 @@ public class Wallet extends BaseTaggableObject
TransactionInput connected = deadOutput.getSpentBy();
if (connected == null) continue;
final Transaction parentTransaction = connected.getParentTransaction();
log.info("This death invalidated dependent tx {}", parentTransaction.getHash());
log.info("This death invalidated dependent tx {}", parentTransaction.getTxId());
work.push(parentTransaction);
}
}
@@ -2584,18 +2584,18 @@ public class Wallet extends BaseTaggableObject
checkState(lock.isHeldByCurrentThread());
if (tx.isEveryOwnedOutputSpent(this)) {
// There's nothing left I can spend in this transaction.
if (unspent.remove(tx.getHash()) != null) {
if (unspent.remove(tx.getTxId()) != null) {
if (log.isInfoEnabled()) {
log.info(" {} {} <-unspent ->spent", tx.getTxId(), context);
}
spent.put(tx.getHash(), tx);
spent.put(tx.getTxId(), tx);
}
} else {
if (spent.remove(tx.getHash()) != null) {
if (spent.remove(tx.getTxId()) != null) {
if (log.isInfoEnabled()) {
log.info(" {} {} <-spent ->unspent", tx.getTxId(), context);
}
unspent.put(tx.getHash(), tx);
unspent.put(tx.getTxId(), tx);
}
}
}
@@ -2609,7 +2609,7 @@ public class Wallet extends BaseTaggableObject
tx.verify();
lock.lock();
try {
if (pending.containsKey(tx.getHash()))
if (pending.containsKey(tx.getTxId()))
return false;
log.info("commitTx of {}", tx.getTxId());
Coin balance = getBalance();
@@ -3033,19 +3033,19 @@ public class Wallet extends BaseTaggableObject
*/
private void addWalletTransaction(Pool pool, Transaction tx) {
checkState(lock.isHeldByCurrentThread());
transactions.put(tx.getHash(), tx);
transactions.put(tx.getTxId(), tx);
switch (pool) {
case UNSPENT:
checkState(unspent.put(tx.getHash(), tx) == null);
checkState(unspent.put(tx.getTxId(), tx) == null);
break;
case SPENT:
checkState(spent.put(tx.getHash(), tx) == null);
checkState(spent.put(tx.getTxId(), tx) == null);
break;
case PENDING:
checkState(pending.put(tx.getHash(), tx) == null);
checkState(pending.put(tx.getTxId(), tx) == null);
break;
case DEAD:
checkState(dead.put(tx.getHash(), tx) == null);
checkState(dead.put(tx.getTxId(), tx) == null);
break;
default:
throw new RuntimeException("Unknown wallet transaction type " + pool);
@@ -3234,7 +3234,7 @@ public class Wallet extends BaseTaggableObject
myUnspents.remove(output);
i.remove();
transactions.remove(tx.getHash());
transactions.remove(tx.getTxId());
dirty = true;
log.info("Removed transaction {} from pending pool during cleanup.", tx.getTxId());
} else {
@@ -3259,7 +3259,7 @@ public class Wallet extends BaseTaggableObject
lock.lock();
try {
EnumSet<Pool> result = EnumSet.noneOf(Pool.class);
Sha256Hash txHash = tx.getHash();
Sha256Hash txHash = tx.getTxId();
if (unspent.containsKey(txHash)) {
result.add(Pool.UNSPENT);
}
@@ -4604,7 +4604,7 @@ public class Wallet extends BaseTaggableObject
for (Sha256Hash blockHash : oldBlockHashes) {
for (TxOffsetPair pair : mapBlockTx.get(blockHash)) {
Transaction tx = pair.tx;
final Sha256Hash txHash = tx.getHash();
final Sha256Hash txHash = tx.getTxId();
if (tx.isCoinBase()) {
// All the transactions that we have in our wallet which spent this coinbase are now invalid
// and will never confirm. Hopefully this should never happen - that's the point of the maturity
@@ -4639,7 +4639,7 @@ public class Wallet extends BaseTaggableObject
// Coinbase transactions on the old part of the chain are dead for good and won't come back unless
// there's another re-org.
if (tx.isCoinBase()) continue;
log.info(" ->pending {}", tx.getHash());
log.info(" ->pending {}", tx.getTxId());
tx.getConfidence().setConfidenceType(ConfidenceType.PENDING); // Wipe height/depth/work data.
confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.TYPE);
@@ -4672,7 +4672,7 @@ public class Wallet extends BaseTaggableObject
for (StoredBlock block : newBlocks) {
log.info("Replaying block {}", block.getHeader().getHashAsString());
for (TxOffsetPair pair : mapBlockTx.get(block.getHeader().getHash())) {
log.info(" tx {}", pair.tx.getHash());
log.info(" tx {}", pair.tx.getTxId());
try {
receive(pair.tx, block, BlockChain.NewBlockType.BEST_CHAIN, pair.offset);
} catch (ScriptException e) {
@@ -5180,7 +5180,7 @@ public class Wallet extends BaseTaggableObject
// 1) Old wallets may have transactions marked as broadcast by 1 peer when in reality the network
// never saw it, due to bugs.
// 2) It can't really hurt.
log.info("New broadcaster so uploading waiting tx {}", tx.getHash());
log.info("New broadcaster so uploading waiting tx {}", tx.getTxId());
broadcaster.broadcastTransaction(tx);
}
}

View File

@@ -255,7 +255,7 @@ public class WalletProtobufSerializer {
Protos.Transaction.Builder txBuilder = Protos.Transaction.newBuilder();
txBuilder.setPool(getProtoPool(wtx))
.setHash(hashToByteString(tx.getHash()))
.setHash(hashToByteString(tx.getTxId()))
.setVersion((int) tx.getVersion());
if (tx.getUpdateTime() != null) {
@@ -294,7 +294,7 @@ public class WalletProtobufSerializer {
.setValue(output.getValue().value);
final TransactionInput spentBy = output.getSpentBy();
if (spentBy != null) {
Sha256Hash spendingHash = spentBy.getParentTransaction().getHash();
Sha256Hash spendingHash = spentBy.getParentTransaction().getTxId();
outputBuilder.setSpentByTransactionHash(hashToByteString(spendingHash))
.setSpentByTransactionIndex(spentBy.getIndex());
}
@@ -368,7 +368,7 @@ public class WalletProtobufSerializer {
// Copy in the overriding transaction, if available.
// (A dead coinbase transaction has no overriding transaction).
if (confidence.getOverridingTransaction() != null) {
Sha256Hash overridingHash = confidence.getOverridingTransaction().getHash();
Sha256Hash overridingHash = confidence.getOverridingTransaction().getTxId();
confidenceBuilder.setOverridingTransaction(hashToByteString(overridingHash));
}
}
@@ -699,8 +699,8 @@ public class WalletProtobufSerializer {
// Transaction should now be complete.
Sha256Hash protoHash = byteStringToHash(txProto.getHash());
if (!tx.getHash().equals(protoHash))
throw new UnreadableWalletException(String.format(Locale.US, "Transaction did not deserialize completely: %s vs %s", tx.getHash(), protoHash));
if (!tx.getTxId().equals(protoHash))
throw new UnreadableWalletException(String.format(Locale.US, "Transaction did not deserialize completely: %s vs %s", tx.getTxId(), protoHash));
if (txMap.containsKey(txProto.getHash()))
throw new UnreadableWalletException("Wallet contained duplicate transaction " + byteStringToHash(txProto.getHash()));
txMap.put(txProto.getHash(), tx);

View File

@@ -176,7 +176,7 @@ public abstract class AbstractFullPrunedBlockChainTest {
// Build some blocks on genesis block to create a spendable output
Block rollingBlock = PARAMS.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);
chain.add(rollingBlock);
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, rollingBlock.getTransactions().get(0).getHash());
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, rollingBlock.getTransactions().get(0).getTxId());
byte[] spendableOutputScriptPubKey = rollingBlock.getTransactions().get(0).getOutputs().get(0).getScriptBytes();
for (int i = 1; i < PARAMS.getSpendableCoinbaseDepth(); i++) {
rollingBlock = rollingBlock.createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);
@@ -250,7 +250,7 @@ public abstract class AbstractFullPrunedBlockChainTest {
Block rollingBlock = PARAMS.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);
chain.add(rollingBlock);
Transaction transaction = rollingBlock.getTransactions().get(0);
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, transaction.getHash());
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, transaction.getTxId());
byte[] spendableOutputScriptPubKey = transaction.getOutputs().get(0).getScriptBytes();
for (int i = 1; i < PARAMS.getSpendableCoinbaseDepth(); i++) {
rollingBlock = rollingBlock.createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);
@@ -301,7 +301,7 @@ public abstract class AbstractFullPrunedBlockChainTest {
Block rollingBlock = PARAMS.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);
chain.add(rollingBlock);
Transaction transaction = rollingBlock.getTransactions().get(0);
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, transaction.getHash());
TransactionOutPoint spendableOutput = new TransactionOutPoint(PARAMS, 0, transaction.getTxId());
byte[] spendableOutputScriptPubKey = transaction.getOutputs().get(0).getScriptBytes();
for (int i = 1; i < PARAMS.getSpendableCoinbaseDepth(); i++) {
rollingBlock = rollingBlock.createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, outKey.getPubKey(), height++);

View File

@@ -125,7 +125,7 @@ public class ChainSplitTest {
assertTrue(chain.add(b7));
Block b8 = b1.createNextBlock(coinsTo);
final Transaction t = b7.getTransactions().get(1);
final Sha256Hash tHash = t.getHash();
final Sha256Hash tHash = t.getTxId();
b8.addTransaction(t);
b8.solve();
assertTrue(chain.add(roundtrip(b8)));
@@ -235,7 +235,7 @@ public class ChainSplitTest {
chain.add(roundtrip(b3));
// The external spend is now pending.
assertEquals(ZERO, wallet.getBalance());
Transaction tx = wallet.getTransaction(spend.getHash());
Transaction tx = wallet.getTransaction(spend.getTxId());
assertEquals(ConfidenceType.PENDING, tx.getConfidence().getConfidenceType());
Block b4 = b3.createNextBlock(someOtherGuy);
chain.add(b4);
@@ -262,7 +262,7 @@ public class ChainSplitTest {
chain.add(roundtrip(b2));
assertEquals(FIFTY_COINS, wallet.getBalance());
assertTrue(wallet.isConsistent());
assertEquals(2, wallet.getTransaction(t.getHash()).getAppearsInHashes().size());
assertEquals(2, wallet.getTransaction(t.getTxId()).getAppearsInHashes().size());
// -> b2 -> b3
Block b3 = b2.createNextBlock(someOtherGuy);
chain.add(b3);
@@ -390,8 +390,8 @@ public class ChainSplitTest {
assertEquals(ZERO, wallet.getBalance());
// t2 is pending - resurrected double spends take precedence over our dead transactions (which are in nobodies
// mempool by this point).
t1 = checkNotNull(wallet.getTransaction(t1.getHash()));
t2 = checkNotNull(wallet.getTransaction(t2.getHash()));
t1 = checkNotNull(wallet.getTransaction(t1.getTxId()));
t2 = checkNotNull(wallet.getTransaction(t2.getTxId()));
assertEquals(ConfidenceType.DEAD, t1.getConfidence().getConfidenceType());
assertEquals(ConfidenceType.PENDING, t2.getConfidence().getConfidenceType());
}
@@ -588,10 +588,10 @@ public class ChainSplitTest {
// Check the coinbase transaction is building and in the unspent pool only.
final Transaction coinbase = txns.get(0);
assertEquals(ConfidenceType.BUILDING, coinbase.getConfidence().getConfidenceType());
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getTxId()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getTxId()));
// Add blocks to b3 until we can spend the coinbase.
Block firstTip = b3;
@@ -636,10 +636,10 @@ public class ChainSplitTest {
// Transaction 1 (in block b2) is now on a side chain and should have confidence type of dead and be in
// the dead pool only.
assertEquals(TransactionConfidence.ConfidenceType.DEAD, coinbase.getConfidence().getConfidenceType());
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getTxId()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getTxId()));
assertTrue(fodderIsDead.get());
// ... and back to the first chain.
@@ -658,10 +658,10 @@ public class ChainSplitTest {
// The coinbase transaction should now have confidence type of building once more and in the unspent pool only.
assertEquals(TransactionConfidence.ConfidenceType.BUILDING, coinbase.getConfidence().getConfidenceType());
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getTxId()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getTxId()));
// However, fodder is still dead. Bitcoin Core doesn't keep killed transactions around in case they become
// valid again later. They are just deleted from the mempool for good.
@@ -681,9 +681,9 @@ public class ChainSplitTest {
// The coinbase transaction should now have the confidence type of dead and be in the dead pool only.
assertEquals(TransactionConfidence.ConfidenceType.DEAD, coinbase.getConfidence().getConfidenceType());
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getHash()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, coinbase.getTxId()));
assertTrue(!wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, coinbase.getTxId()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, coinbase.getTxId()));
}
}

View File

@@ -103,8 +103,8 @@ public class FilteredBlockAndPartialMerkleTreeTests extends TestWithPeerGroup {
assertEquals(4, filteredBlock.getTransactionCount());
// This call triggers verification of the just created data.
List<Sha256Hash> txns = filteredBlock.getTransactionHashes();
assertTrue(txns.contains(tx1.getHash()));
assertTrue(txns.contains(tx2.getHash()));
assertTrue(txns.contains(tx1.getTxId()));
assertTrue(txns.contains(tx2.getTxId()));
}
private Sha256Hash numAsHash(int num) {
@@ -142,21 +142,21 @@ public class FilteredBlockAndPartialMerkleTreeTests extends TestWithPeerGroup {
assertTrue(txHashList.size() == 4);
// Four transactions (0, 1, 2, 6) from block 100001
Transaction tx0 = UNITTEST.getDefaultSerializer().makeTransaction(HEX.decode("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff07044c86041b010dffffffff0100f2052a01000000434104b27f7e9475ccf5d9a431cb86d665b8302c140144ec2397fce792f4a4e7765fecf8128534eaa71df04f93c74676ae8279195128a1506ebf7379d23dab8fca0f63ac00000000"));
assertTrue(tx0.getHash().equals(Sha256Hash.wrap("bb28a1a5b3a02e7657a81c38355d56c6f05e80b9219432e3352ddcfc3cb6304c")));
assertEquals(tx0.getHash(), txHashList.get(0));
assertTrue(tx0.getTxId().equals(Sha256Hash.wrap("bb28a1a5b3a02e7657a81c38355d56c6f05e80b9219432e3352ddcfc3cb6304c")));
assertEquals(tx0.getTxId(), txHashList.get(0));
Transaction tx1 = UNITTEST.getDefaultSerializer().makeTransaction(HEX.decode("0100000001d992e5a888a86d4c7a6a69167a4728ee69497509740fc5f456a24528c340219a000000008b483045022100f0519bdc9282ff476da1323b8ef7ffe33f495c1a8d52cc522b437022d83f6a230220159b61d197fbae01b4a66622a23bc3f1def65d5fa24efd5c26fa872f3a246b8e014104839f9023296a1fabb133140128ca2709f6818c7d099491690bd8ac0fd55279def6a2ceb6ab7b5e4a71889b6e739f09509565eec789e86886f6f936fa42097adeffffffff02000fe208010000001976a914948c765a6914d43f2a7ac177da2c2f6b52de3d7c88ac00e32321000000001976a9140c34f4e29ab5a615d5ea28d4817f12b137d62ed588ac00000000"));
assertTrue(tx1.getHash().equals(Sha256Hash.wrap("fbde5d03b027d2b9ba4cf5d4fecab9a99864df2637b25ea4cbcb1796ff6550ca")));
assertEquals(tx1.getHash(), txHashList.get(1));
assertTrue(tx1.getTxId().equals(Sha256Hash.wrap("fbde5d03b027d2b9ba4cf5d4fecab9a99864df2637b25ea4cbcb1796ff6550ca")));
assertEquals(tx1.getTxId(), txHashList.get(1));
Transaction tx2 = UNITTEST.getDefaultSerializer().makeTransaction(HEX.decode("01000000059daf0abe7a92618546a9dbcfd65869b6178c66ec21ccfda878c1175979cfd9ef000000004a493046022100c2f7f25be5de6ce88ac3c1a519514379e91f39b31ddff279a3db0b1a229b708b022100b29efbdbd9837cc6a6c7318aa4900ed7e4d65662c34d1622a2035a3a5534a99a01ffffffffd516330ebdf075948da56db13d22632a4fb941122df2884397dda45d451acefb0000000048473044022051243debe6d4f2b433bee0cee78c5c4073ead0e3bde54296dbed6176e128659c022044417bfe16f44eb7b6eb0cdf077b9ce972a332e15395c09ca5e4f602958d266101ffffffffe1f5aa33961227b3c344e57179417ce01b7ccd421117fe2336289b70489883f900000000484730440220593252bb992ce3c85baf28d6e3aa32065816271d2c822398fe7ee28a856bc943022066d429dd5025d3c86fd8fd8a58e183a844bd94aa312cefe00388f57c85b0ca3201ffffffffe207e83718129505e6a7484831442f668164ae659fddb82e9e5421a081fb90d50000000049483045022067cf27eb733e5bcae412a586b25a74417c237161a084167c2a0b439abfebdcb2022100efcc6baa6824b4c5205aa967e0b76d31abf89e738d4b6b014e788c9a8cccaf0c01ffffffffe23b8d9d80a9e9d977fab3c94dbe37befee63822443c3ec5ae5a713ede66c3940000000049483045022020f2eb35036666b1debe0d1d2e77a36d5d9c4e96c1dba23f5100f193dbf524790221008ce79bc1321fb4357c6daee818038d41544749127751726e46b2b320c8b565a201ffffffff0200ba1dd2050000001976a914366a27645806e817a6cd40bc869bdad92fe5509188ac40420f00000000001976a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac00000000"));
assertTrue(tx2.getHash().equals(Sha256Hash.wrap("8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb")));
assertEquals(tx2.getHash(), txHashList.get(2));
assertTrue(tx2.getTxId().equals(Sha256Hash.wrap("8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb")));
assertEquals(tx2.getTxId(), txHashList.get(2));
Transaction tx3 = UNITTEST.getDefaultSerializer().makeTransaction(HEX.decode("01000000011b56cf3aab3286d582c055a42af3a911ee08423f276da702bb67f1222ac1a5b6000000008c4930460221009e9fba682e162c9627b96b7df272006a727988680b956c61baff869f0907b8fb022100a9c19adc7c36144bafe526630783845e5cb9554d30d3edfb56f0740274d507f30141046e0efbfac7b1615ad553a6f097615bc63b7cdb3b8e1cb3263b619ba63740012f51c7c5b09390e3577e377b7537e61226e315f95f926444fc5e5f2978c112e448ffffffff02c0072b11010000001976a914b73e9e01933351ca076faf8e0d94dd58079d0b1f88ac80b63908000000001976a9141aca0bdf0d2cee63db19aa4a484f45a4e26a880c88ac00000000"));
assertTrue(tx3.getHash().equals(Sha256Hash.wrap("c5abc61566dbb1c4bce5e1fda7b66bed22eb2130cea4b721690bc1488465abc9")));
assertEquals(tx3.getHash(),txHashList.get(3));
assertTrue(tx3.getTxId().equals(Sha256Hash.wrap("c5abc61566dbb1c4bce5e1fda7b66bed22eb2130cea4b721690bc1488465abc9")));
assertEquals(tx3.getTxId(),txHashList.get(3));
BloomFilter filter = wallet.getBloomFilter(wallet.getKeyChainGroupSize()*2, 0.001, 0xDEADBEEF);
// Compare the serialized bloom filter to a known-good value

View File

@@ -91,7 +91,7 @@ class TransactionOutPointWithValue {
}
public TransactionOutPointWithValue(Transaction tx, int output) {
this(new TransactionOutPoint(tx.getParams(), output, tx.getHash()),
this(new TransactionOutPoint(tx.getParams(), output, tx.getTxId()),
tx.getOutput(output).getValue(), tx.getOutput(output).getScriptPubKey());
}
}
@@ -196,14 +196,14 @@ public class FullBlockTestGenerator {
Block chainHead = params.getGenesisBlock().createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, coinbaseOutKeyPubKey, chainHeadHeight);
blocks.add(new BlockAndValidity(chainHead, true, false, chainHead.getHash(), 1, "Initial Block"));
spendableOutputs.offer(new TransactionOutPointWithValue(
new TransactionOutPoint(params, 0, chainHead.getTransactions().get(0).getHash()),
new TransactionOutPoint(params, 0, chainHead.getTransactions().get(0).getTxId()),
FIFTY_COINS, chainHead.getTransactions().get(0).getOutputs().get(0).getScriptPubKey()));
for (int i = 1; i < params.getSpendableCoinbaseDepth(); i++) {
chainHead = chainHead.createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, coinbaseOutKeyPubKey, chainHeadHeight);
chainHeadHeight++;
blocks.add(new BlockAndValidity(chainHead, true, false, chainHead.getHash(), i+1, "Initial Block chain output generation"));
spendableOutputs.offer(new TransactionOutPointWithValue(
new TransactionOutPoint(params, 0, chainHead.getTransactions().get(0).getHash()),
new TransactionOutPoint(params, 0, chainHead.getTransactions().get(0).getTxId()),
FIFTY_COINS, chainHead.getTransactions().get(0).getOutputs().get(0).getScriptPubKey()));
}
@@ -236,7 +236,7 @@ public class FullBlockTestGenerator {
UTXORule utxo1;
{
Transaction coinbase = b2.block.getTransactions().get(0);
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getHash());
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getTxId());
long[] heights = {chainHeadHeight + 2};
UTXOsMessage result = new UTXOsMessage(params, ImmutableList.of(coinbase.getOutput(0)), heights, b2.getHash(), chainHeadHeight + 2);
utxo1 = new UTXORule("utxo1", outpoint, result);
@@ -255,7 +255,7 @@ public class FullBlockTestGenerator {
// Check that the old coinbase is no longer in the UTXO set and the new one is.
{
Transaction coinbase = b4.block.getTransactions().get(0);
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getHash());
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, coinbase.getTxId());
List<TransactionOutPoint> queries = ImmutableList.of(utxo1.query.get(0), outpoint);
List<TransactionOutput> results = Lists.asList(null, coinbase.getOutput(0), new TransactionOutput[]{});
long[] heights = {chainHeadHeight + 3};
@@ -717,7 +717,7 @@ public class FullBlockTestGenerator {
tx.addOutput(new TransactionOutput(params, tx, SATOSHI, scriptPubKey.toByteArray()));
tx.addOutput(new TransactionOutput(params, tx, lastOutputValue, new byte[]{OP_1}));
addOnlyInputToTransaction(tx, out11);
lastOutPoint = new TransactionOutPoint(params, 1, tx.getHash());
lastOutPoint = new TransactionOutPoint(params, 1, tx.getTxId());
b39.addTransaction(tx);
}
b39numP2SHOutputs++;
@@ -730,7 +730,7 @@ public class FullBlockTestGenerator {
tx.addOutput(new TransactionOutput(params, tx, SATOSHI, scriptPubKey.toByteArray()));
tx.addOutput(new TransactionOutput(params, tx, lastOutputValue, new byte[]{OP_1}));
tx.addInput(new TransactionInput(params, tx, new byte[]{OP_1}, lastOutPoint));
lastOutPoint = new TransactionOutPoint(params, 1, tx.getHash());
lastOutPoint = new TransactionOutPoint(params, 1, tx.getTxId());
if (b39.block.getMessageSize() + tx.getMessageSize() < Block.MAX_BLOCK_SIZE) {
b39.addTransaction(tx);
@@ -755,7 +755,7 @@ public class FullBlockTestGenerator {
int numTxes = (Block.MAX_BLOCK_SIGOPS - sigOps) / b39sigOpsPerOutput;
checkState(numTxes <= b39numP2SHOutputs);
TransactionOutPoint lastOutPoint = new TransactionOutPoint(params, 1, b40.block.getTransactions().get(1).getHash());
TransactionOutPoint lastOutPoint = new TransactionOutPoint(params, 1, b40.block.getTransactions().get(1).getTxId());
byte[] scriptSig = null;
for (int i = 1; i <= numTxes; i++) {
@@ -764,7 +764,7 @@ public class FullBlockTestGenerator {
tx.addInput(new TransactionInput(params, tx, new byte[]{OP_1}, lastOutPoint));
TransactionInput input = new TransactionInput(params, tx, new byte[]{},
new TransactionOutPoint(params, 0, b39.block.getTransactions().get(i).getHash()));
new TransactionOutPoint(params, 0, b39.block.getTransactions().get(i).getTxId()));
tx.addInput(input);
if (scriptSig == null) {
@@ -791,7 +791,7 @@ public class FullBlockTestGenerator {
input.setScriptBytes(scriptSig);
lastOutPoint = new TransactionOutPoint(params, 0, tx.getHash());
lastOutPoint = new TransactionOutPoint(params, 0, tx.getTxId());
b40.addTransaction(tx);
}
@@ -821,7 +821,7 @@ public class FullBlockTestGenerator {
checkState(numTxes <= b39numP2SHOutputs);
TransactionOutPoint lastOutPoint = new TransactionOutPoint(
params, 1, b41.block.getTransactions().get(1).getHash());
params, 1, b41.block.getTransactions().get(1).getTxId());
byte[] scriptSig = null;
for (int i = 1; i <= numTxes; i++) {
@@ -833,7 +833,7 @@ public class FullBlockTestGenerator {
TransactionInput input = new TransactionInput(params, tx,
new byte[] {}, new TransactionOutPoint(params, 0,
b39.block.getTransactions().get(i).getHash()));
b39.block.getTransactions().get(i).getTxId()));
tx.addInput(input);
if (scriptSig == null) {
@@ -867,7 +867,7 @@ public class FullBlockTestGenerator {
input.setScriptBytes(scriptSig);
lastOutPoint = new TransactionOutPoint(params, 0,
tx.getHash());
tx.getTxId());
b41.addTransaction(tx);
}
@@ -1093,21 +1093,21 @@ public class FullBlockTestGenerator {
Transaction tx2 = new Transaction(params);
tx2.addOutput(new TransactionOutput(params, tx2, SATOSHI, new byte[] {OP_TRUE}));
addOnlyInputToTransaction(tx2, new TransactionOutPointWithValue(
new TransactionOutPoint(params, 0, tx1.getHash()),
new TransactionOutPoint(params, 0, tx1.getTxId()),
SATOSHI, tx1.getOutputs().get(0).getScriptPubKey()));
b57p2.addTransaction(tx2);
b56p2txToDuplicate1 = new Transaction(params);
b56p2txToDuplicate1.addOutput(new TransactionOutput(params, b56p2txToDuplicate1, SATOSHI, new byte[]{OP_TRUE}));
addOnlyInputToTransaction(b56p2txToDuplicate1, new TransactionOutPointWithValue(
new TransactionOutPoint(params, 0, tx2.getHash()),
new TransactionOutPoint(params, 0, tx2.getTxId()),
SATOSHI, tx2.getOutputs().get(0).getScriptPubKey()));
b57p2.addTransaction(b56p2txToDuplicate1);
b56p2txToDuplicate2 = new Transaction(params);
b56p2txToDuplicate2.addOutput(new TransactionOutput(params, b56p2txToDuplicate2, SATOSHI, new byte[]{}));
addOnlyInputToTransaction(b56p2txToDuplicate2, new TransactionOutPointWithValue(
new TransactionOutPoint(params, 0, b56p2txToDuplicate1.getHash()),
new TransactionOutPoint(params, 0, b56p2txToDuplicate1.getTxId()),
SATOSHI, b56p2txToDuplicate1.getOutputs().get(0).getScriptPubKey()));
b57p2.addTransaction(b56p2txToDuplicate2);
}
@@ -1259,7 +1259,7 @@ public class FullBlockTestGenerator {
b65.addTransaction(tx1);
Transaction tx2 = new Transaction(params);
tx2.addOutput(ZERO, OP_TRUE_SCRIPT);
tx2.addInput(tx1.getHash(), 0, OP_TRUE_SCRIPT);
tx2.addInput(tx1.getTxId(), 0, OP_TRUE_SCRIPT);
b65.addTransaction(tx2);
}
b65.solve();
@@ -1279,7 +1279,7 @@ public class FullBlockTestGenerator {
addOnlyInputToTransaction(tx1, out20, 0);
Transaction tx2 = new Transaction(params);
tx2.addOutput(ZERO, OP_TRUE_SCRIPT);
tx2.addInput(tx1.getHash(), 0, OP_NOP_SCRIPT);
tx2.addInput(tx1.getTxId(), 0, OP_NOP_SCRIPT);
b66.addTransaction(tx2);
b66.addTransaction(tx1);
}
@@ -1298,11 +1298,11 @@ public class FullBlockTestGenerator {
b67.addTransaction(tx1);
Transaction tx2 = new Transaction(params);
tx2.addOutput(ZERO, OP_TRUE_SCRIPT);
tx2.addInput(tx1.getHash(), 0, OP_NOP_SCRIPT);
tx2.addInput(tx1.getTxId(), 0, OP_NOP_SCRIPT);
b67.addTransaction(tx2);
Transaction tx3 = new Transaction(params);
tx3.addOutput(out20.value, OP_TRUE_SCRIPT);
tx3.addInput(tx1.getHash(), 0, OP_NOP_SCRIPT);
tx3.addInput(tx1.getTxId(), 0, OP_NOP_SCRIPT);
b67.addTransaction(tx3);
}
b67.solve();
@@ -1490,7 +1490,7 @@ public class FullBlockTestGenerator {
{
b79tx.addOutput(ZERO, OP_TRUE_SCRIPT);
b79tx.addInput(b78tx.getHash(), 0, OP_NOP_SCRIPT);
b79tx.addInput(b78tx.getTxId(), 0, OP_NOP_SCRIPT);
b79.addTransaction(b79tx);
}
b79.solve();
@@ -1511,13 +1511,13 @@ public class FullBlockTestGenerator {
spendableOutputs.offer(b82.getCoinbaseOutput());
HashSet<InventoryItem> post82Mempool = new HashSet<>();
post82Mempool.add(new InventoryItem(InventoryItem.Type.TRANSACTION, b78tx.getHash()));
post82Mempool.add(new InventoryItem(InventoryItem.Type.TRANSACTION, b79tx.getHash()));
post82Mempool.add(new InventoryItem(InventoryItem.Type.TRANSACTION, b78tx.getTxId()));
post82Mempool.add(new InventoryItem(InventoryItem.Type.TRANSACTION, b79tx.getTxId()));
blocks.add(new MemoryPoolState(post82Mempool, "post-b82 tx resurrection"));
// Check the UTXO query takes mempool into account.
{
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, b79tx.getHash());
TransactionOutPoint outpoint = new TransactionOutPoint(params, 0, b79tx.getTxId());
long[] heights = { UTXOsMessage.MEMPOOL_HEIGHT };
UTXOsMessage result = new UTXOsMessage(params, ImmutableList.of(b79tx.getOutput(0)), heights, b82.getHash(), chainHeadHeight + 28);
UTXORule utxo3 = new UTXORule("utxo3", outpoint, result);
@@ -1541,7 +1541,7 @@ public class FullBlockTestGenerator {
Transaction tx2 = new Transaction(params);
tx2.addOutput(new TransactionOutput(params, tx2, ZERO, new byte[]{OP_TRUE}));
tx2.addInput(new TransactionInput(params, tx2, new byte[]{OP_FALSE},
new TransactionOutPoint(params, 0, tx1.getHash())));
new TransactionOutPoint(params, 0, tx1.getTxId())));
b83.addTransaction(tx2);
}
b83.solve();
@@ -1689,7 +1689,7 @@ public class FullBlockTestGenerator {
Preconditions.checkArgument(blockStorageFile != null);
NewBlock lastBlock = b1001;
TransactionOutPoint lastOutput = new TransactionOutPoint(params, 1, b1001.block.getTransactions().get(1).getHash());
TransactionOutPoint lastOutput = new TransactionOutPoint(params, 1, b1001.block.getTransactions().get(1).getTxId());
int blockCountAfter1001;
int nextHeight = heightAfter1001;
@@ -1702,8 +1702,8 @@ public class FullBlockTestGenerator {
tx.addInput(lastOutput.getHash(), lastOutput.getIndex(), OP_NOP_SCRIPT);
tx.addOutput(ZERO, OP_TRUE_SCRIPT);
tx.addOutput(ZERO, OP_TRUE_SCRIPT);
lastOutput = new TransactionOutPoint(params, 1, tx.getHash());
hashesToSpend.add(tx.getHash());
lastOutput = new TransactionOutPoint(params, 1, tx.getTxId());
hashesToSpend.add(tx.getTxId());
block.addTransaction(tx);
}
block.solve();

View File

@@ -406,7 +406,7 @@ public class PeerGroupTest extends TestWithPeerGroup {
inbound(p3, inv);
pingAndWait(p3);
Threading.waitForUserCode();
assertEquals(tx.getHash(), confEvent[0].getTransactionHash());
assertEquals(tx.getTxId(), confEvent[0].getTransactionHash());
assertEquals(3, tx.getConfidence().numBroadcastPeers());
assertTrue(tx.getConfidence().wasBroadcastBy(peerOf(p3).getAddress()));
}
@@ -622,7 +622,7 @@ public class PeerGroupTest extends TestWithPeerGroup {
tx2.addInput(tx.getOutput(0));
TransactionOutPoint outpoint = tx2.getInput(0).getOutpoint();
assertTrue(p1.lastReceivedFilter.contains(key.getPubKey()));
assertFalse(p1.lastReceivedFilter.contains(tx.getHash().getBytes()));
assertFalse(p1.lastReceivedFilter.contains(tx.getTxId().getBytes()));
inbound(p1, tx);
// p1 requests dep resolution, p2 is quiet.
assertTrue(outbound(p1) instanceof GetDataMessage);

View File

@@ -266,13 +266,13 @@ public class PeerTest extends TestWithNetworkConnections {
Coin value = COIN;
Transaction tx = createFakeTx(UNITTEST, value, address);
InventoryMessage inv = new InventoryMessage(UNITTEST);
InventoryItem item = new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getHash());
InventoryItem item = new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getTxId());
inv.addItem(item);
inbound(writeTarget, inv);
// Peer hasn't seen it before, so will ask for it.
GetDataMessage getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(1, getdata.getItems().size());
assertEquals(tx.getHash(), getdata.getItems().get(0).hash);
assertEquals(tx.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, tx);
// Ask for the dependency, it's not in the mempool (in chain).
getdata = (GetDataMessage) outbound(writeTarget);
@@ -299,7 +299,7 @@ public class PeerTest extends TestWithNetworkConnections {
Coin value = COIN;
Transaction tx = createFakeTx(UNITTEST, value, this.address);
InventoryMessage inv = new InventoryMessage(UNITTEST);
InventoryItem item = new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getHash());
InventoryItem item = new InventoryItem(InventoryItem.Type.TRANSACTION, tx.getTxId());
inv.addItem(item);
inbound(writeTarget, inv);
@@ -307,7 +307,7 @@ public class PeerTest extends TestWithNetworkConnections {
// We got a getdata message.
GetDataMessage message = (GetDataMessage)outbound(writeTarget);
assertEquals(1, message.getItems().size());
assertEquals(tx.getHash(), message.getItems().get(0).hash);
assertEquals(tx.getTxId(), message.getItems().get(0).hash);
assertNotEquals(0, tx.getConfidence().numBroadcastPeers());
// Advertising to peer2 results in no getdata message.
@@ -603,7 +603,7 @@ public class PeerTest extends TestWithNetworkConnections {
inbound(writeTarget, inv);
GetDataMessage getdata = (GetDataMessage) outbound(writeTarget);
Threading.waitForUserCode();
assertEquals(t1.getHash(), getdata.getItems().get(0).hash);
assertEquals(t1.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t1);
pingAndWait(writeTarget);
assertEquals(t1, onTx[0]);
@@ -613,8 +613,8 @@ public class PeerTest extends TestWithNetworkConnections {
// It will recursively ask for the dependencies of t1: t2, t3, t7, t8.
getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(4, getdata.getItems().size());
assertEquals(t2.getHash(), getdata.getItems().get(0).hash);
assertEquals(t3.getHash(), getdata.getItems().get(1).hash);
assertEquals(t2.getTxId(), getdata.getItems().get(0).hash);
assertEquals(t3.getTxId(), getdata.getItems().get(1).hash);
assertEquals(t7hash, getdata.getItems().get(2).hash);
assertEquals(t8hash, getdata.getItems().get(3).hash);
// Deliver the requested transactions.
@@ -635,7 +635,7 @@ public class PeerTest extends TestWithNetworkConnections {
assertFalse(futures.isDone());
// Request t4 ...
getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(t4.getHash(), getdata.getItems().get(0).hash);
assertEquals(t4.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t4);
// Continue to explore the t4 branch and ask for t6, which is in the chain.
getdata = (GetDataMessage) outbound(writeTarget);
@@ -681,7 +681,7 @@ public class PeerTest extends TestWithNetworkConnections {
inbound(writeTarget, inv);
GetDataMessage getdata = (GetDataMessage) outbound(writeTarget);
Threading.waitForUserCode();
assertEquals(t1.getHash(), getdata.getItems().get(0).hash);
assertEquals(t1.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t1);
pingAndWait(writeTarget);
// We want its dependencies so ask for them.
@@ -690,7 +690,7 @@ public class PeerTest extends TestWithNetworkConnections {
// level 1
getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(1, getdata.getItems().size());
assertEquals(t2.getHash(), getdata.getItems().get(0).hash);
assertEquals(t2.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t2);
// no level 2
getdata = (GetDataMessage) outbound(writeTarget);
@@ -788,13 +788,13 @@ public class PeerTest extends TestWithNetworkConnections {
inbound(writeTarget, inv);
// Send it.
GetDataMessage getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(t1.getHash(), getdata.getItems().get(0).hash);
assertEquals(t1.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t1);
// Nothing arrived at our event listener yet.
assertNull(vtx[0]);
// We request t2.
getdata = (GetDataMessage) outbound(writeTarget);
assertEquals(t2.getHash(), getdata.getItems().get(0).hash);
assertEquals(t2.getTxId(), getdata.getItems().get(0).hash);
inbound(writeTarget, t2);
// We request t3.
getdata = (GetDataMessage) outbound(writeTarget);

View File

@@ -134,7 +134,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
assertEquals(tx, outbound(channels[1]));
assertEquals(tx, outbound(channels[2]));
assertEquals(tx, outbound(channels[4]));
RejectMessage reject = new RejectMessage(UNITTEST, RejectMessage.RejectCode.DUST, tx.getHash(), "tx", "dust");
RejectMessage reject = new RejectMessage(UNITTEST, RejectMessage.RejectCode.DUST, tx.getTxId(), "tx", "dust");
inbound(channels[1], reject);
inbound(channels[4], reject);
try {
@@ -251,6 +251,6 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
// Add the wallet to the peer group (simulate initialization). Transactions should be announced.
peerGroup.addWallet(wallet);
// Transaction announced to the first peer. No extra Bloom filter because no change address was needed.
assertEquals(t3.getHash(), outbound(p1).getHash());
assertEquals(t3.getTxId(), outbound(p1).getHash());
}
}

View File

@@ -50,7 +50,7 @@ public class TxConfidenceTableTest {
tx1 = FakeTxBuilder.createFakeTxWithChangeAddress(UNITTEST, COIN, to, change);
tx2 = FakeTxBuilder.createFakeTxWithChangeAddress(UNITTEST, COIN, to, change);
assertEquals(tx1.getHash(), tx2.getHash());
assertEquals(tx1.getTxId(), tx2.getTxId());
address1 = new PeerAddress(UNITTEST, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }));
address2 = new PeerAddress(UNITTEST, InetAddress.getByAddress(new byte[] { 127, 0, 0, 2 }));
@@ -60,7 +60,7 @@ public class TxConfidenceTableTest {
@Test
public void pinHandlers() throws Exception {
Transaction tx = UNITTEST.getDefaultSerializer().makeTransaction(tx1.bitcoinSerialize());
Sha256Hash hash = tx.getHash();
Sha256Hash hash = tx.getTxId();
table.seen(hash, address1);
assertEquals(1, tx.getConfidence().numBroadcastPeers());
final int[] seen = new int[1];
@@ -85,10 +85,10 @@ public class TxConfidenceTableTest {
run[0] = reason;
}
});
table.seen(tx1.getHash(), address1);
table.seen(tx1.getTxId(), address1);
assertEquals(TransactionConfidence.Listener.ChangeReason.SEEN_PEERS, run[0]);
run[0] = null;
table.seen(tx1.getHash(), address1);
table.seen(tx1.getTxId(), address1);
assertNull(run[0]);
}
@@ -129,15 +129,15 @@ public class TxConfidenceTableTest {
@Test
public void invAndDownload() throws Exception {
// Base case: we see a transaction announced twice and then download it. The count is in the confidence object.
assertEquals(0, table.numBroadcastPeers(tx1.getHash()));
table.seen(tx1.getHash(), address1);
assertEquals(1, table.numBroadcastPeers(tx1.getHash()));
table.seen(tx1.getHash(), address2);
assertEquals(2, table.numBroadcastPeers(tx1.getHash()));
assertEquals(0, table.numBroadcastPeers(tx1.getTxId()));
table.seen(tx1.getTxId(), address1);
assertEquals(1, table.numBroadcastPeers(tx1.getTxId()));
table.seen(tx1.getTxId(), address2);
assertEquals(2, table.numBroadcastPeers(tx1.getTxId()));
assertEquals(2, tx2.getConfidence().numBroadcastPeers());
// And now we see another inv.
table.seen(tx1.getHash(), address3);
table.seen(tx1.getTxId(), address3);
assertEquals(3, tx2.getConfidence().numBroadcastPeers());
assertEquals(3, table.numBroadcastPeers(tx1.getHash()));
assertEquals(3, table.numBroadcastPeers(tx1.getTxId()));
}
}

View File

@@ -213,7 +213,7 @@ public class ChannelConnectionTest extends TestWithWallet {
Transaction broadcastMultiSig = broadcasts.take();
// Wait for the channel to finish opening.
client.getChannelOpenFuture().get();
assertEquals(broadcastMultiSig.getHash(), channelOpenFuture.get());
assertEquals(broadcastMultiSig.getTxId(), channelOpenFuture.get());
assertEquals(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE, client.state().getValueSpent());
// Set up an autosave listener to make sure the server is saving the wallet after each payment increase.
@@ -248,7 +248,7 @@ public class ChannelConnectionTest extends TestWithWallet {
latch.await();
StoredPaymentChannelServerStates channels = (StoredPaymentChannelServerStates)serverWallet.getExtensions().get(StoredPaymentChannelServerStates.EXTENSION_ID);
StoredServerChannel storedServerChannel = channels.getChannel(broadcastMultiSig.getHash());
StoredServerChannel storedServerChannel = channels.getChannel(broadcastMultiSig.getTxId());
PaymentChannelServerState serverState = storedServerChannel.getOrCreateState(serverWallet, mockBroadcaster);
// Check that you can call settle multiple times with no exceptions.
@@ -860,7 +860,7 @@ public class ChannelConnectionTest extends TestWithWallet {
final Transaction settlement2 = new Transaction(UNITTEST, closeMsg.getSettlement().getTx().toByteArray());
assertEquals(settlement1, settlement2);
client.receiveMessage(closeMsg);
assertNotNull(wallet.getTransaction(settlement2.getHash())); // Close TX entered the wallet.
assertNotNull(wallet.getTransaction(settlement2.getTxId())); // Close TX entered the wallet.
sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, settlement1);
client.connectionClosed();
server.connectionClosed();

View File

@@ -278,14 +278,14 @@ public class PaymentChannelStateTest extends TestWithWallet {
assertEquals(2, wallet.getTransactions(false).size());
Iterator<Transaction> walletTransactionIterator = wallet.getTransactions(false).iterator();
Transaction clientWalletMultisigContract = walletTransactionIterator.next();
assertFalse(clientWalletMultisigContract.getHash().equals(clientState.getRefundTransaction().getHash()));
if (!clientWalletMultisigContract.getHash().equals(multisigContract.getHash())) {
assertFalse(clientWalletMultisigContract.getTxId().equals(clientState.getRefundTransaction().getTxId()));
if (!clientWalletMultisigContract.getTxId().equals(multisigContract.getTxId())) {
clientWalletMultisigContract = walletTransactionIterator.next();
assertFalse(clientWalletMultisigContract.getHash().equals(clientState.getRefundTransaction().getHash()));
assertFalse(clientWalletMultisigContract.getTxId().equals(clientState.getRefundTransaction().getTxId()));
} else
assertFalse(walletTransactionIterator.next().getHash().equals(clientState.getRefundTransaction().getHash()));
assertEquals(multisigContract.getHash(), clientWalletMultisigContract.getHash());
assertFalse(clientWalletMultisigContract.getInput(0).getConnectedOutput().getSpentBy().getParentTransaction().getHash().equals(refund.getHash()));
assertFalse(walletTransactionIterator.next().getTxId().equals(clientState.getRefundTransaction().getTxId()));
assertEquals(multisigContract.getTxId(), clientWalletMultisigContract.getTxId());
assertFalse(clientWalletMultisigContract.getInput(0).getConnectedOutput().getSpentBy().getParentTransaction().getTxId().equals(refund.getTxId()));
// Both client and server are now in the ready state. Simulate a few micropayments of 0.005 bitcoins.
Coin size = HALF_COIN.divide(100);
@@ -327,11 +327,11 @@ public class PaymentChannelStateTest extends TestWithWallet {
walletTransactionIterator = wallet.getTransactions(false).iterator();
Transaction clientWalletCloseTransaction = walletTransactionIterator.next();
if (!clientWalletCloseTransaction.getHash().equals(closeTx.getHash()))
if (!clientWalletCloseTransaction.getTxId().equals(closeTx.getTxId()))
clientWalletCloseTransaction = walletTransactionIterator.next();
if (!clientWalletCloseTransaction.getHash().equals(closeTx.getHash()))
if (!clientWalletCloseTransaction.getTxId().equals(closeTx.getTxId()))
clientWalletCloseTransaction = walletTransactionIterator.next();
assertEquals(closeTx.getHash(), clientWalletCloseTransaction.getHash());
assertEquals(closeTx.getTxId(), clientWalletCloseTransaction.getTxId());
assertNotNull(clientWalletCloseTransaction.getInput(0).getConnectedOutput());
}
@@ -424,16 +424,16 @@ public class PaymentChannelStateTest extends TestWithWallet {
clientState.doStoreChannelInWallet(Sha256Hash.of(new byte[]{}));
TxFuturePair clientBroadcastedMultiSig = broadcasts.take();
TxFuturePair broadcastRefund = broadcasts.take();
assertEquals(clientBroadcastedMultiSig.tx.getHash(), multisigContract.getHash());
assertEquals(clientBroadcastedMultiSig.tx.getTxId(), multisigContract.getTxId());
for (TransactionInput input : clientBroadcastedMultiSig.tx.getInputs())
input.verify();
clientBroadcastedMultiSig.future.set(clientBroadcastedMultiSig.tx);
Transaction clientBroadcastedRefund = broadcastRefund.tx;
assertEquals(clientBroadcastedRefund.getHash(), clientState.getRefundTransaction().getHash());
assertEquals(clientBroadcastedRefund.getTxId(), clientState.getRefundTransaction().getTxId());
for (TransactionInput input : clientBroadcastedRefund.getInputs()) {
// If the multisig output is connected, the wallet will fail to deserialize
if (input.getOutpoint().getHash().equals(clientBroadcastedMultiSig.tx.getHash()))
if (input.getOutpoint().getHash().equals(clientBroadcastedMultiSig.tx.getTxId()))
assertNull(input.getConnectedOutput().getSpentBy());
input.verify(clientBroadcastedMultiSig.tx.getOutput(0));
}
@@ -481,7 +481,7 @@ public class PaymentChannelStateTest extends TestWithWallet {
}
refund = new Transaction(UNITTEST, refundTxBytes);
refund.addInput(new TransactionInput(UNITTEST, refund, new byte[]{}, new TransactionOutPoint(UNITTEST, 42, refund.getHash())));
refund.addInput(new TransactionInput(UNITTEST, refund, new byte[]{}, new TransactionOutPoint(UNITTEST, 42, refund.getTxId())));
try {
serverV1State().provideRefundTransaction(refund, myKey.getPubKey());
fail();
@@ -973,14 +973,14 @@ public class PaymentChannelStateTest extends TestWithWallet {
assertEquals(2, wallet.getTransactions(false).size());
Iterator<Transaction> walletTransactionIterator = wallet.getTransactions(false).iterator();
Transaction clientWalletMultisigContract = walletTransactionIterator.next();
assertFalse(clientWalletMultisigContract.getHash().equals(clientState.getRefundTransaction().getHash()));
if (!clientWalletMultisigContract.getHash().equals(multisigContract.getHash())) {
assertFalse(clientWalletMultisigContract.getTxId().equals(clientState.getRefundTransaction().getTxId()));
if (!clientWalletMultisigContract.getTxId().equals(multisigContract.getTxId())) {
clientWalletMultisigContract = walletTransactionIterator.next();
assertFalse(clientWalletMultisigContract.getHash().equals(clientState.getRefundTransaction().getHash()));
assertFalse(clientWalletMultisigContract.getTxId().equals(clientState.getRefundTransaction().getTxId()));
} else
assertFalse(walletTransactionIterator.next().getHash().equals(clientState.getRefundTransaction().getHash()));
assertEquals(multisigContract.getHash(), clientWalletMultisigContract.getHash());
assertFalse(clientWalletMultisigContract.getInput(0).getConnectedOutput().getSpentBy().getParentTransaction().getHash().equals(refund.getHash()));
assertFalse(walletTransactionIterator.next().getTxId().equals(clientState.getRefundTransaction().getTxId()));
assertEquals(multisigContract.getTxId(), clientWalletMultisigContract.getTxId());
assertFalse(clientWalletMultisigContract.getInput(0).getConnectedOutput().getSpentBy().getParentTransaction().getTxId().equals(refund.getTxId()));
// Both client and server are now in the ready state. Simulate a few micropayments of 0.005 bitcoins.
Coin size = HALF_COIN.divide(100);

View File

@@ -134,7 +134,7 @@ public class WalletProtobufSerializerTest {
Wallet wallet1 = roundTrip(myWallet);
assertEquals(1, wallet1.getTransactions(true).size());
assertEquals(v1, wallet1.getBalance(Wallet.BalanceType.ESTIMATED));
Transaction t1copy = wallet1.getTransaction(t1.getHash());
Transaction t1copy = wallet1.getTransaction(t1.getTxId());
assertArrayEquals(t1.unsafeBitcoinSerialize(), t1copy.unsafeBitcoinSerialize());
assertEquals(2, t1copy.getConfidence().numBroadcastPeers());
assertNotNull(t1copy.getConfidence().getLastBroadcastedAt());
@@ -148,7 +148,7 @@ public class WalletProtobufSerializerTest {
Protos.Transaction t1p = walletProto.getTransaction(0);
assertEquals(0, t1p.getBlockHashCount());
assertArrayEquals(t1.getHash().getBytes(), t1p.getHash().toByteArray());
assertArrayEquals(t1.getTxId().getBytes(), t1p.getHash().toByteArray());
assertEquals(Protos.Transaction.Pool.PENDING, t1p.getPool());
assertFalse(t1p.hasLockTime());
assertFalse(t1p.getTransactionInput(0).hasSequence());
@@ -166,7 +166,7 @@ public class WalletProtobufSerializerTest {
t1.setPurpose(Purpose.RAISE_FEE);
myWallet.receivePending(t1, null);
Wallet wallet1 = roundTrip(myWallet);
Transaction t1copy = wallet1.getTransaction(t1.getHash());
Transaction t1copy = wallet1.getTransaction(t1.getTxId());
assertEquals(Purpose.RAISE_FEE, t1copy.getPurpose());
}
@@ -180,7 +180,7 @@ public class WalletProtobufSerializerTest {
myWallet.receiveFromBlock(doubleSpends.t2, null, BlockChain.NewBlockType.BEST_CHAIN, 0);
Wallet wallet1 = roundTrip(myWallet);
assertEquals(1, wallet1.getTransactions(true).size());
Transaction t1 = wallet1.getTransaction(doubleSpends.t1.getHash());
Transaction t1 = wallet1.getTransaction(doubleSpends.t1.getTxId());
assertEquals(ConfidenceType.DEAD, t1.getConfidence().getConfidenceType());
assertEquals(Coin.ZERO, wallet1.getBalance());
@@ -241,9 +241,9 @@ public class WalletProtobufSerializerTest {
tx2.getInput(0).setSequenceNumber(TransactionInput.NO_SEQUENCE - 1);
wallet.receivePending(tx2, null);
Wallet walletCopy = roundTrip(wallet);
Transaction tx1copy = checkNotNull(walletCopy.getTransaction(tx1.getHash()));
Transaction tx1copy = checkNotNull(walletCopy.getTransaction(tx1.getTxId()));
assertEquals(TransactionInput.NO_SEQUENCE, tx1copy.getInput(0).getSequenceNumber());
Transaction tx2copy = checkNotNull(walletCopy.getTransaction(tx2.getHash()));
Transaction tx2copy = checkNotNull(walletCopy.getTransaction(tx2.getTxId()));
assertEquals(TransactionInput.NO_SEQUENCE - 1, tx2copy.getInput(0).getSequenceNumber());
}
@@ -384,7 +384,7 @@ public class WalletProtobufSerializerTest {
assertEquals(tx.getTxId().toString(), "0321b1413ed9048199815bd6bc2650cab1a9e8d543f109a42c769b1f18df4174");
myWallet.addWalletTransaction(new WalletTransaction(Pool.UNSPENT, tx));
Wallet wallet1 = roundTrip(myWallet);
Transaction tx2 = wallet1.getTransaction(tx.getHash());
Transaction tx2 = wallet1.getTransaction(tx.getTxId());
assertEquals(checkNotNull(tx2).getVersion(), 2);
}
@@ -398,10 +398,10 @@ public class WalletProtobufSerializerTest {
assertTrue(chain.add(b));
// Wallet now has a coinbase tx in it.
assertEquals(1, myWallet.getTransactions(true).size());
assertTrue(myWallet.getTransaction(coinbase.getHash()).isCoinBase());
assertTrue(myWallet.getTransaction(coinbase.getTxId()).isCoinBase());
Wallet wallet2 = roundTrip(myWallet);
assertEquals(1, wallet2.getTransactions(true).size());
assertTrue(wallet2.getTransaction(coinbase.getHash()).isCoinBase());
assertTrue(wallet2.getTransaction(coinbase.getTxId()).isCoinBase());
}
@Test
@@ -481,7 +481,7 @@ public class WalletProtobufSerializerTest {
assertEquals(tx.getTxId().toString(), "1c687396f4710f26206dbdd8bf07a28c76398be6750226ddfaf05a1a80d30034");
myWallet.addWalletTransaction(new WalletTransaction(Pool.UNSPENT, tx));
Wallet wallet1 = roundTrip(myWallet);
Transaction tx2 = wallet1.getTransaction(tx.getHash());
Transaction tx2 = wallet1.getTransaction(tx.getTxId());
assertEquals(tx.getInput(0).getWitness(), tx2.getInput(0).getWitness());
}
}

View File

@@ -87,7 +87,7 @@ public class TestWithWallet {
wallet.notifyNewBestBlock(bp.storedBlock);
}
if (transactions.length == 1)
return wallet.getTransaction(transactions[0].getHash()); // Can be null if tx is a double spend that's otherwise irrelevant.
return wallet.getTransaction(transactions[0].getTxId()); // Can be null if tx is a double spend that's otherwise irrelevant.
else
return null;
}

View File

@@ -626,7 +626,7 @@ public class WalletTest extends TestWithWallet {
Threading.waitForUserCode();
assertEquals(null, txn[1]); // onCoinsSent not called.
assertEquals(tx1, confTxns.getFirst()); // onTransactionConfidenceChanged called
assertEquals(txn[0].getHash(), tx1.getHash());
assertEquals(txn[0].getTxId(), tx1.getTxId());
assertEquals(ZERO, bigints[0]);
assertEquals(oneCoin, bigints[1]);
assertEquals(TransactionConfidence.ConfidenceType.BUILDING, tx1.getConfidence().getConfidenceType());
@@ -643,7 +643,7 @@ public class WalletTest extends TestWithWallet {
assertEquals(Coin.valueOf(0, 90), wallet.getBalance());
assertEquals(null, txn[0]);
assertEquals(2, confTxns.size());
assertEquals(txn[1].getHash(), send1.getHash());
assertEquals(txn[1].getTxId(), send1.getTxId());
assertEquals(Coin.COIN, bigints[2]);
assertEquals(Coin.valueOf(0, 90), bigints[3]);
// And we do it again after the catchup.
@@ -859,8 +859,8 @@ public class WalletTest extends TestWithWallet {
sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, send1);
// Back to having one coin.
assertEquals(value, wallet.getBalance());
assertEquals(send2.getHash(), dead.poll().getTransactionHash());
assertEquals(send3.getHash(), dead.poll().getTransactionHash());
assertEquals(send2.getTxId(), dead.poll().getTransactionHash());
assertEquals(send3.getTxId(), dead.poll().getTransactionHash());
}
@Test
@@ -1212,27 +1212,27 @@ public class WalletTest extends TestWithWallet {
private void assertInConflict(Transaction tx) {
assertEquals(ConfidenceType.IN_CONFLICT, tx.getConfidence().getConfidenceType());
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, tx.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, tx.getTxId()));
}
private void assertPending(Transaction tx) {
assertEquals(ConfidenceType.PENDING, tx.getConfidence().getConfidenceType());
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, tx.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.PENDING, tx.getTxId()));
}
private void assertSpent(Transaction tx) {
assertEquals(ConfidenceType.BUILDING, tx.getConfidence().getConfidenceType());
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, tx.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.SPENT, tx.getTxId()));
}
private void assertUnspent(Transaction tx) {
assertEquals(ConfidenceType.BUILDING, tx.getConfidence().getConfidenceType());
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, tx.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.UNSPENT, tx.getTxId()));
}
private void assertDead(Transaction tx) {
assertEquals(ConfidenceType.DEAD, tx.getConfidence().getConfidenceType());
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, tx.getHash()));
assertTrue(wallet.poolContainsTxHash(WalletTransaction.Pool.DEAD, tx.getTxId()));
}
@Test
@@ -2162,7 +2162,7 @@ public class WalletTest extends TestWithWallet {
for (int i = 0; i < ITERATIONS; i++) {
Transaction spend = wallet.createSend(OTHER_ADDRESS, COIN);
assertEquals(spend.getInputs().size(), 1);
assertEquals("Failed on iteration " + i, spend.getInput(0).getOutpoint().getHash(), txns[i].getHash());
assertEquals("Failed on iteration " + i, spend.getInput(0).getOutpoint().getHash(), txns[i].getTxId());
wallet.commitTx(spend);
}
}
@@ -2313,7 +2313,7 @@ public class WalletTest extends TestWithWallet {
// Generate a few outputs to us that are far too small to spend reasonably
Transaction tx1 = createFakeTx(UNITTEST, SATOSHI, myAddress);
Transaction tx2 = createFakeTx(UNITTEST, SATOSHI, myAddress);
assertNotEquals(tx1.getHash(), tx2.getHash());
assertNotEquals(tx1.getTxId(), tx2.getTxId());
Transaction tx3 = createFakeTx(UNITTEST, SATOSHI.multiply(10), myAddress);
sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, tx1, tx2, tx3);
@@ -2768,7 +2768,7 @@ public class WalletTest extends TestWithWallet {
Transaction tx1 = createFakeTx(UNITTEST, COIN, myAddress);
wallet.receiveFromBlock(tx1, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
Transaction tx2 = createFakeTx(UNITTEST, COIN, myAddress);
assertNotEquals(tx1.getHash(), tx2.getHash());
assertNotEquals(tx1.getTxId(), tx2.getTxId());
wallet.receiveFromBlock(tx2, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 1);
Transaction tx3 = createFakeTx(UNITTEST, CENT, myAddress);
wallet.receiveFromBlock(tx3, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 2);
@@ -2796,7 +2796,7 @@ public class WalletTest extends TestWithWallet {
// However, if there is no connected output, we will grab a COIN output anyway and add the CENT to fee
SendRequest request3 = SendRequest.to(OTHER_ADDRESS, CENT);
request3.tx.addInput(new TransactionInput(UNITTEST, request3.tx, new byte[]{}, new TransactionOutPoint(UNITTEST, 0, tx3.getHash())));
request3.tx.addInput(new TransactionInput(UNITTEST, request3.tx, new byte[]{}, new TransactionOutPoint(UNITTEST, 0, tx3.getTxId())));
// Now completeTx will result in two inputs, two outputs and a fee of a CENT
// Note that it is simply assumed that the inputs are correctly signed, though in fact the first is not
request3.shuffleOutputs = false;
@@ -2991,7 +2991,7 @@ public class WalletTest extends TestWithWallet {
// Now round-trip the wallet and check the protobufs are storing the data correctly.
wallet = roundTrip(wallet);
tx = wallet.getTransaction(tx.getHash());
tx = wallet.getTransaction(tx.getTxId());
checkNotNull(tx);
assertEquals(Transaction.Purpose.KEY_ROTATION, tx.getPurpose());
// Have to divide here to avoid mismatch due to second-level precision in serialisation.
@@ -3229,7 +3229,7 @@ public class WalletTest extends TestWithWallet {
@Override
public RiskAnalysis create(Wallet wallet, Transaction wtx, List<Transaction> dependencies) {
RiskAnalysis.Result result = RiskAnalysis.Result.OK;
if (wtx.getHash().equals(tx.getHash()))
if (wtx.getTxId().equals(tx.getTxId()))
result = RiskAnalysis.Result.NON_STANDARD;
final RiskAnalysis.Result finalResult = result;
return new RiskAnalysis() {
@@ -3258,13 +3258,13 @@ public class WalletTest extends TestWithWallet {
final Transaction tx = createFakeTx(UNITTEST, COIN, myAddress);
StoredBlock block = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS, tx).storedBlock;
wallet.receivePending(tx, null);
boolean notification = wallet.notifyTransactionIsInBlock(tx.getHash(), block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 1);
boolean notification = wallet.notifyTransactionIsInBlock(tx.getTxId(), block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 1);
assertTrue(notification);
final Transaction tx2 = createFakeTx(UNITTEST, COIN, OTHER_ADDRESS);
wallet.receivePending(tx2, null);
StoredBlock block2 = createFakeBlock(blockStore, Block.BLOCK_HEIGHT_GENESIS + 1, tx2).storedBlock;
boolean notification2 = wallet.notifyTransactionIsInBlock(tx2.getHash(), block2, AbstractBlockChain.NewBlockType.BEST_CHAIN, 1);
boolean notification2 = wallet.notifyTransactionIsInBlock(tx2.getTxId(), block2, AbstractBlockChain.NewBlockType.BEST_CHAIN, 1);
assertFalse(notification2);
}