mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
Transaction.getFee(): Do not determine fee on incomplete transactions.
This commit is contained in:
@@ -414,6 +414,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;
|
||||
|
@@ -2922,8 +2922,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) {}
|
||||
}
|
||||
|
Reference in New Issue
Block a user