mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-01 21:17:13 +00:00
Transaction: Get rid of getValueSentToMe() variant that was not used any more.
This commit is contained in:
@@ -250,21 +250,6 @@ public class Transaction extends ChildMessage {
|
||||
return getHash().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the sum of the outputs that are sending coins to a key in the wallet. The flag controls whether to
|
||||
* include spent outputs or not.
|
||||
*/
|
||||
Coin getValueSentToMe(TransactionBag transactionBag, boolean includeSpent) {
|
||||
// This is tested in WalletTest.
|
||||
Coin v = Coin.ZERO;
|
||||
for (TransactionOutput o : outputs) {
|
||||
if (!o.isMineOrWatched(transactionBag)) continue;
|
||||
if (!includeSpent && !o.isAvailableForSpending()) continue;
|
||||
v = v.add(o.getValue());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sum of the inputs, regardless of who owns them.
|
||||
*/
|
||||
@@ -308,7 +293,13 @@ public class Transaction extends ChildMessage {
|
||||
* Calculates the sum of the outputs that are sending coins to a key in the wallet.
|
||||
*/
|
||||
public Coin getValueSentToMe(TransactionBag transactionBag) {
|
||||
return getValueSentToMe(transactionBag, true);
|
||||
// This is tested in WalletTest.
|
||||
Coin v = Coin.ZERO;
|
||||
for (TransactionOutput o : outputs) {
|
||||
if (!o.isMineOrWatched(transactionBag)) continue;
|
||||
v = v.add(o.getValue());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2101,7 +2101,7 @@ public class Wallet extends BaseTaggableObject
|
||||
// Now make sure it ends up in the right pool. Also, handle the case where this TX is double-spending
|
||||
// against our pending transactions. Note that a tx may double spend our pending transactions and also send
|
||||
// us money/spend our money.
|
||||
boolean hasOutputsToMe = tx.getValueSentToMe(this, true).signum() > 0;
|
||||
boolean hasOutputsToMe = tx.getValueSentToMe(this).signum() > 0;
|
||||
if (hasOutputsToMe) {
|
||||
// Needs to go into either unspent or spent (if the outputs were already spent by a pending tx).
|
||||
if (tx.isEveryOwnedOutputSpent(this)) {
|
||||
|
||||
@@ -627,7 +627,7 @@ public class WalletTest extends TestWithWallet {
|
||||
public void balances() throws Exception {
|
||||
Coin nanos = COIN;
|
||||
Transaction tx1 = sendMoneyToWallet(nanos, AbstractBlockChain.NewBlockType.BEST_CHAIN);
|
||||
assertEquals(nanos, tx1.getValueSentToMe(wallet, true));
|
||||
assertEquals(nanos, tx1.getValueSentToMe(wallet));
|
||||
assertTrue(tx1.getWalletOutputs(wallet).size() >= 1);
|
||||
// Send 0.10 to somebody else.
|
||||
Transaction send1 = wallet.createSend(new ECKey().toAddress(params), valueOf(0, 10));
|
||||
|
||||
Reference in New Issue
Block a user