Improve transaction display for BTC withrawals from BSQ wallet

This commit is contained in:
Christoph Atteneder 2019-04-05 16:28:08 +02:00
parent 32264070b7
commit 3275dfed10
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
4 changed files with 27 additions and 0 deletions

View File

@ -780,6 +780,7 @@ funds.tx.unknown=Unknown reason: {0}
funds.tx.noFundsFromDispute=No refund from dispute
funds.tx.receivedFunds=Received funds
funds.tx.withdrawnFromWallet=Withdrawn from wallet
funds.tx.withdrawnFromBSQWallet=BTC withdrawn from BSQ wallet
funds.tx.noTxAvailable=No transactions available
funds.tx.revert=Revert
funds.tx.txSent=Transaction successfully sent to a new address in the local Bisq wallet.
@ -1830,6 +1831,7 @@ dao.tx.type.enum.PROOF_OF_BURN=Proof of burn
# suppress inspection "UnusedProperty"
dao.tx.type.enum.IRREGULAR=Irregular
dao.tx.withdrawnFromWallet=BTC withdrawn from wallet
dao.tx.issuanceFromCompReq=Compensation request/issuance
dao.tx.issuanceFromCompReq.tooltip=Compensation request which led to an issuance of new BSQ.\n\
Issuance date: {0}

View File

@ -47,6 +47,7 @@ class BsqTxListItem extends TxConfidenceListItem {
private final BsqFormatter bsqFormatter;
private final Date date;
private final boolean isBurnedBsqTx;
private final boolean withdrawalToBTCWallet;
private final String address;
private final String direction;
@ -73,6 +74,11 @@ class BsqTxListItem extends TxConfidenceListItem {
Coin valueSentToMe = bsqWalletService.getValueSentToMeForTransaction(transaction);
Coin valueSentFromMe = bsqWalletService.getValueSentFromMeForTransaction(transaction);
Coin valueSentToMyBTCWallet = btcWalletService.getValueSentToMeForTransaction(transaction);
Coin valueSentFromMyBTCWallet = btcWalletService.getValueSentFromMeForTransaction(transaction);
withdrawalToBTCWallet = valueSentToMyBTCWallet.getValue() > valueSentFromMyBTCWallet.getValue();
amount = valueSentToMe.subtract(valueSentFromMe);
if (amount.isPositive()) {
if (txId.equals(daoFacade.getGenesisTxId()))
@ -124,5 +130,9 @@ class BsqTxListItem extends TxConfidenceListItem {
.flatMap(tx -> daoFacade.getOptionalTxType(tx.getId()))
.orElse(confirmations == 0 ? TxType.UNVERIFIED : TxType.UNDEFINED_TX_TYPE);
}
public boolean isWithdrawalToBTCWallet() {
return withdrawalToBTCWallet;
}
}

View File

@ -463,6 +463,10 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
setGraphic(field);
}
} else {
if (item.isWithdrawalToBTCWallet())
labelString = Res.get("dao.tx.withdrawnFromWallet");
label = new AutoTooltipLabel(labelString);
setGraphic(label);
}

View File

@ -93,6 +93,7 @@ class TransactionsListItem {
// TODO check and refactor
boolean txFeeForBsqPayment = false;
boolean withdrawalFromBSQWallet = false;
if (valueSentToMe.isZero()) {
amountAsCoin = valueSentFromMe.multiply(-1);
for (TransactionOutput output : transaction.getOutputs()) {
@ -145,6 +146,14 @@ class TransactionsListItem {
}
break;
}
} else {
addressString = WalletService.getAddressStringFromOutput(output);
outgoing = (valueSentToMe.getValue() < valueSentFromMe.getValue());
if (!outgoing) {
direction = Res.get("funds.tx.direction.receivedWith");
received = true;
withdrawalFromBSQWallet = true;
}
}
}
@ -216,6 +225,8 @@ class TransactionsListItem {
} else {
if (amountAsCoin.isZero())
details = Res.get("funds.tx.noFundsFromDispute");
else if (withdrawalFromBSQWallet)
details = Res.get("funds.tx.withdrawnFromBSQWallet");
else if (!txFeeForBsqPayment)
details = received ? Res.get("funds.tx.receivedFunds") : Res.get("funds.tx.withdrawnFromWallet");
else if (details.isEmpty())