mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-01 21:17:13 +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() {
|
public Coin getFee() {
|
||||||
Coin fee = Coin.ZERO;
|
Coin fee = Coin.ZERO;
|
||||||
|
if (inputs.isEmpty() || outputs.isEmpty()) // Incomplete transaction
|
||||||
|
return null;
|
||||||
for (TransactionInput input : inputs) {
|
for (TransactionInput input : inputs) {
|
||||||
if (input.getValue() == null)
|
if (input.getValue() == null)
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -2922,8 +2922,8 @@ public class WalletTest extends TestWithWallet {
|
|||||||
wallet.receiveFromBlock(tx, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
|
wallet.receiveFromBlock(tx, block, AbstractBlockChain.NewBlockType.BEST_CHAIN, 0);
|
||||||
try {
|
try {
|
||||||
request = SendRequest.emptyWallet(OTHER_ADDRESS);
|
request = SendRequest.emptyWallet(OTHER_ADDRESS);
|
||||||
assertEquals(ZERO, request.tx.getFee());
|
|
||||||
wallet.completeTx(request);
|
wallet.completeTx(request);
|
||||||
|
assertEquals(ZERO, request.tx.getFee());
|
||||||
fail();
|
fail();
|
||||||
} catch (Wallet.CouldNotAdjustDownwards e) {}
|
} catch (Wallet.CouldNotAdjustDownwards e) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user