Transaction.getFee(): Do not determine fee on incomplete transactions.

This commit is contained in:
Andreas Schildbach 2017-06-02 15:32:42 +02:00
parent e62275d41b
commit 6841fceabc
2 changed files with 3 additions and 1 deletions

View file

@ -415,6 +415,8 @@ public class Transaction extends ChildMessage {
*/
public Coin getFee() {
Coin fee = Coin.ZERO;
if (inputs.isEmpty() || outputs.isEmpty()) // Incomplete transaction
return null;
for (TransactionInput input : inputs) {
if (input.getValue() == null)
return null;

View file

@ -2865,8 +2865,8 @@ public class WalletTest extends TestWithWallet {
wallet.receiveFromBlock(tx, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
try {
request = SendRequest.emptyWallet(OTHER_ADDRESS);
assertEquals(ZERO, request.tx.getFee());
wallet.completeTx(request);
assertEquals(ZERO, request.tx.getFee());
fail();
} catch (Wallet.CouldNotAdjustDownwards e) {}
}