Transaction: Add getTxId() and getWTxId(); deprecate getHash() and getHashAsString().

This commit is contained in:
Andreas Schildbach
2019-02-05 16:44:39 +01:00
parent 2d943838dd
commit 53a63c43bb
23 changed files with 145 additions and 113 deletions

View File

@@ -53,7 +53,7 @@ public class FetchTransactions {
System.out.println("Waiting for node to send us the dependencies ...");
List<Transaction> deps = peer.downloadDependencies(tx).get();
for (Transaction dep : deps) {
System.out.println("Got dependency " + dep.getHashAsString());
System.out.println("Got dependency " + dep.getTxId());
}
System.out.println("Done.");

View File

@@ -145,7 +145,7 @@ public class ForwardingService {
@Override
public void run() {
// The wallet has changed now, it'll get auto saved shortly or when the app shuts down.
System.out.println("Sent coins onwards! Transaction hash is " + sendResult.tx.getHashAsString());
System.out.println("Sent coins onwards! Transaction hash is " + sendResult.tx.getTxId());
}
}, MoreExecutors.directExecutor());
} catch (KeyCrypterException | InsufficientMoneyException e) {

View File

@@ -108,7 +108,7 @@ public class GenerateLowSTests {
// First output a conventional low-S transaction with the LOW_S flag, for the tx_valid.json set
System.out.println("[\"A transaction with a low-S signature.\"],");
System.out.println("[[[\""
+ inputTransaction.getHashAsString() + "\", "
+ inputTransaction.getTxId() + "\", "
+ output.getIndex() + ", \""
+ scriptToString(output.getScriptPubKey()) + "\"]],\n"
+ "\"" + Utils.HEX.encode(proposedTransaction.partialTx.unsafeBitcoinSerialize()) + "\", \""
@@ -123,7 +123,7 @@ public class GenerateLowSTests {
// A high-S transaction without the LOW_S flag, for the tx_valid.json set
System.out.println("[\"A transaction with a high-S signature.\"],");
System.out.println("[[[\""
+ inputTransaction.getHashAsString() + "\", "
+ inputTransaction.getTxId() + "\", "
+ output.getIndex() + ", \""
+ scriptToString(output.getScriptPubKey()) + "\"]],\n"
+ "\"" + Utils.HEX.encode(proposedTransaction.partialTx.unsafeBitcoinSerialize()) + "\", \""
@@ -132,7 +132,7 @@ public class GenerateLowSTests {
// Lastly a conventional high-S transaction with the LOW_S flag, for the tx_invalid.json set
System.out.println("[\"A transaction with a high-S signature.\"],");
System.out.println("[[[\""
+ inputTransaction.getHashAsString() + "\", "
+ inputTransaction.getTxId() + "\", "
+ output.getIndex() + ", \""
+ scriptToString(output.getScriptPubKey()) + "\"]],\n"
+ "\"" + Utils.HEX.encode(proposedTransaction.partialTx.unsafeBitcoinSerialize()) + "\", \""

View File

@@ -68,7 +68,7 @@ public class Kit {
kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("-----> coins resceived: " + tx.getHashAsString());
System.out.println("-----> coins resceived: " + tx.getTxId());
System.out.println("received: " + tx.getValue(wallet));
}
});
@@ -97,7 +97,7 @@ public class Kit {
kit.wallet().addTransactionConfidenceEventListener(new TransactionConfidenceEventListener() {
@Override
public void onTransactionConfidenceChanged(Wallet wallet, Transaction tx) {
System.out.println("-----> confidence changed: " + tx.getHashAsString());
System.out.println("-----> confidence changed: " + tx.getTxId());
TransactionConfidence confidence = tx.getConfidence();
System.out.println("new block depth: " + confidence.getDepthInBlocks());
}

View File

@@ -47,7 +47,7 @@ public class RefreshWallet {
wallet.addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
@Override
public synchronized void onCoinsReceived(Wallet w, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("\nReceived tx " + tx.getHashAsString());
System.out.println("\nReceived tx " + tx.getTxId());
System.out.println(tx.toString());
}
});

View File

@@ -59,7 +59,7 @@ public class SendRequest {
// In this example we catch the InsufficientMoneyException and register a BalanceFuture callback that runs once the wallet has enough balance.
try {
Wallet.SendResult result = kit.wallet().sendCoins(kit.peerGroup(), to, value);
System.out.println("coins sent. transaction hash: " + result.tx.getHashAsString());
System.out.println("coins sent. transaction hash: " + result.tx.getTxId());
// you can use a block explorer like https://www.biteasy.com/ to inspect the transaction with the printed transaction hash.
} catch (InsufficientMoneyException e) {
System.out.println("Not enough coins in your wallet. Missing " + e.missing.getValue() + " satoshis are missing (including fees)");