mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-03 05:57:21 +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();
|
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.
|
* 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.
|
* Calculates the sum of the outputs that are sending coins to a key in the wallet.
|
||||||
*/
|
*/
|
||||||
public Coin getValueSentToMe(TransactionBag transactionBag) {
|
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
|
// 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
|
// against our pending transactions. Note that a tx may double spend our pending transactions and also send
|
||||||
// us money/spend our money.
|
// us money/spend our money.
|
||||||
boolean hasOutputsToMe = tx.getValueSentToMe(this, true).signum() > 0;
|
boolean hasOutputsToMe = tx.getValueSentToMe(this).signum() > 0;
|
||||||
if (hasOutputsToMe) {
|
if (hasOutputsToMe) {
|
||||||
// Needs to go into either unspent or spent (if the outputs were already spent by a pending tx).
|
// Needs to go into either unspent or spent (if the outputs were already spent by a pending tx).
|
||||||
if (tx.isEveryOwnedOutputSpent(this)) {
|
if (tx.isEveryOwnedOutputSpent(this)) {
|
||||||
|
|||||||
@@ -627,7 +627,7 @@ public class WalletTest extends TestWithWallet {
|
|||||||
public void balances() throws Exception {
|
public void balances() throws Exception {
|
||||||
Coin nanos = COIN;
|
Coin nanos = COIN;
|
||||||
Transaction tx1 = sendMoneyToWallet(nanos, AbstractBlockChain.NewBlockType.BEST_CHAIN);
|
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);
|
assertTrue(tx1.getWalletOutputs(wallet).size() >= 1);
|
||||||
// Send 0.10 to somebody else.
|
// Send 0.10 to somebody else.
|
||||||
Transaction send1 = wallet.createSend(new ECKey().toAddress(params), valueOf(0, 10));
|
Transaction send1 = wallet.createSend(new ECKey().toAddress(params), valueOf(0, 10));
|
||||||
|
|||||||
Reference in New Issue
Block a user