3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-12 18:25:51 +00:00

Add a Transaction.getValue(Wallet) method.

This commit is contained in:
Mike Hearn 2012-03-01 18:55:46 +01:00
parent ddb6da155b
commit 40bd728703
2 changed files with 8 additions and 0 deletions

View File

@ -288,6 +288,13 @@ public class Transaction extends ChildMessage implements Serializable {
return v;
}
/**
* Returns the difference of {@link Transaction#getValueSentFromMe(Wallet)} and {@link Transaction#getValueSentToMe(Wallet)}.
*/
public BigInteger getValue(Wallet wallet) throws ScriptException {
return getValueSentToMe(wallet).subtract(getValueSentFromMe(wallet));
}
boolean disconnectInputs() {
boolean disconnected = false;
maybeParse();

View File

@ -251,6 +251,7 @@ public class WalletTest {
// Reserialize.
Transaction send2 = new Transaction(params, send1.bitcoinSerialize());
assertEquals(nanos, send2.getValueSentFromMe(wallet));
assertEquals(BigInteger.ZERO.subtract(toNanoCoins(0, 10)), send2.getValue(wallet));
}
@Test