Do not use 0 btc outputs (#3725)

* Do not add an output if value is 0 BTC

Fixes https://github.com/bisq-network/bisq/issues/3721 and
https://github.com/bisq-network/bisq/issues/3722

There are still more issues as such a payout tx will cause that the
trade ends up in failed trades. This commit only fixes the invalid
tx issue.

* Refactoring: Replace isGreaterThan(Coin.ZERO) with isPositive()

* Do not display confirmation icon for 0 BTC tx

If we do not get any BTC from a mediated payout tx we do not know about
the confirmation state so it would stay always in the unconfirmed state.
To avoid that confusion we prefer to hide the icon. This is a known
issue from BitcoinJ but we have not found a solution for that yet.
This commit is contained in:
Christoph Atteneder 2019-12-02 11:09:38 +01:00 committed by GitHub
commit 77b2360698
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -926,10 +926,10 @@ public class TradeWalletService {
TransactionOutput p2SHMultiSigOutput = depositTx.getOutput(0);
Transaction payoutTx = new Transaction(params);
payoutTx.addInput(p2SHMultiSigOutput);
if (buyerPayoutAmount.isGreaterThan(Coin.ZERO)) {
if (buyerPayoutAmount.isPositive()) {
payoutTx.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
}
if (sellerPayoutAmount.isGreaterThan(Coin.ZERO)) {
if (sellerPayoutAmount.isPositive()) {
payoutTx.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
}
@ -989,10 +989,10 @@ public class TradeWalletService {
Sha256Hash spendTxHash = Sha256Hash.wrap(depositTxHex);
payoutTx.addInput(new TransactionInput(params, depositTx, p2SHMultiSigOutputScript.getProgram(), new TransactionOutPoint(params, 0, spendTxHash), msOutput));
if (buyerPayoutAmount.isGreaterThan(Coin.ZERO)) {
if (buyerPayoutAmount.isPositive()) {
payoutTx.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
}
if (sellerPayoutAmount.isGreaterThan(Coin.ZERO)) {
if (sellerPayoutAmount.isPositive()) {
payoutTx.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
}
@ -1135,8 +1135,13 @@ public class TradeWalletService {
TransactionOutput p2SHMultiSigOutput = depositTx.getOutput(0);
Transaction transaction = new Transaction(params);
transaction.addInput(p2SHMultiSigOutput);
transaction.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
transaction.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
if (buyerPayoutAmount.isPositive()) {
transaction.addOutput(buyerPayoutAmount, Address.fromBase58(params, buyerAddressString));
}
if (sellerPayoutAmount.isPositive()) {
transaction.addOutput(sellerPayoutAmount, Address.fromBase58(params, sellerAddressString));
}
checkArgument(transaction.getOutputs().size() >= 1, "We need at least one output.");
return transaction;
}

View file

@ -223,6 +223,10 @@ class TransactionsListItem {
} else if (trade.getPayoutTx() != null &&
trade.getPayoutTx().getHashAsString().equals(txId)) {
details = Res.get("funds.tx.multiSigPayout", tradeId);
if (amountAsCoin.isZero()) {
txConfidenceIndicator.setVisible(false);
}
} else {
Trade.DisputeState disputeState = trade.getDisputeState();
if (disputeState == Trade.DisputeState.DISPUTE_CLOSED) {