mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-10 17:26:28 +01:00
Transaction.getFee(): Do not determine fee on incomplete transactions.
This commit is contained in:
parent
e62275d41b
commit
6841fceabc
2 changed files with 3 additions and 1 deletions
|
@ -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;
|
||||
|
|
|
@ -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) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue