mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 23:18:17 +01:00
commit
c777600dfa
5 changed files with 102 additions and 24 deletions
|
@ -149,7 +149,7 @@ public class ProposalListItem implements BsqNode.BsqBlockChainListener {
|
|||
break;
|
||||
case BREAK1:
|
||||
break;
|
||||
case OPEN_FOR_VOTING:
|
||||
case BLIND_VOTE:
|
||||
if (!isTxInPastCycle) {
|
||||
actionNode = actionButtonIconView;
|
||||
actionButton.setVisible(false);
|
||||
|
@ -176,6 +176,10 @@ public class ProposalListItem implements BsqNode.BsqBlockChainListener {
|
|||
break;
|
||||
case BREAK3:
|
||||
break;
|
||||
case ISSUANCE:
|
||||
break;
|
||||
case BREAK4:
|
||||
break;
|
||||
}
|
||||
actionButton.setManaged(actionButton.isVisible());
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ import bisq.common.crypto.CryptoException;
|
|||
import bisq.common.util.Tuple2;
|
||||
import bisq.common.util.Tuple3;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
|
||||
import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
|
@ -68,6 +70,8 @@ import java.util.ArrayList;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup;
|
||||
|
@ -136,7 +140,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
public void onFailure(@NotNull Throwable t) {
|
||||
//TODO
|
||||
}
|
||||
});
|
||||
|
@ -153,6 +157,8 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
e1.printStackTrace();
|
||||
} catch (ChangeBelowDustException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (InvalidProtocolBufferException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -249,7 +255,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
protected void onPhaseChanged(DaoPeriodService.Phase phase) {
|
||||
super.onPhaseChanged(phase);
|
||||
|
||||
changeVoteViewItemsVisibility(phase == DaoPeriodService.Phase.OPEN_FOR_VOTING);
|
||||
changeVoteViewItemsVisibility(phase == DaoPeriodService.Phase.BLIND_VOTE);
|
||||
|
||||
if (removeButton != null) {
|
||||
removeButton.setManaged(false);
|
||||
|
@ -274,7 +280,7 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
break;
|
||||
case BREAK1:
|
||||
break;
|
||||
case OPEN_FOR_VOTING:
|
||||
case BLIND_VOTE:
|
||||
if (acceptButton == null) {
|
||||
Tuple3<Button, Button, Button> tuple = add3ButtonsAfterGroup(detailsGridPane, proposalDisplay
|
||||
.incrementAndGetGridRow(),
|
||||
|
@ -303,6 +309,10 @@ public class ActiveProposalsView extends BaseProposalView implements BsqBalanceL
|
|||
break;
|
||||
case BREAK3:
|
||||
break;
|
||||
case ISSUANCE:
|
||||
break;
|
||||
case BREAK4:
|
||||
break;
|
||||
case UNDEFINED:
|
||||
default:
|
||||
log.warn("Undefined phase: " + phase);
|
||||
|
|
|
@ -99,10 +99,12 @@ public class ProposalDashboardView extends ActivatableView<GridPane, Void> {
|
|||
phaseBarsItems = Arrays.asList(
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.PROPOSAL, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK1, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.OPEN_FOR_VOTING, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BLIND_VOTE, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK2, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.VOTE_REVEAL, true),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK3, false));
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK3, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.ISSUANCE, false),
|
||||
new SeparatedPhaseBars.SeparatedPhaseBarsItem(DaoPeriodService.Phase.BREAK4, false));
|
||||
return new SeparatedPhaseBars(phaseBarsItems);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import bisq.core.btc.listeners.TxConfidenceListener;
|
|||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.btc.wallet.WalletService;
|
||||
import bisq.core.dao.blockchain.BsqBlockChain;
|
||||
import bisq.core.dao.blockchain.vo.TxType;
|
||||
import bisq.core.locale.Res;
|
||||
|
||||
|
@ -66,7 +65,7 @@ class BsqTxListItem {
|
|||
@Getter
|
||||
private final String direction;
|
||||
@Getter
|
||||
private final Coin amount;
|
||||
private Coin amount;
|
||||
@Getter
|
||||
private boolean received;
|
||||
@Getter
|
||||
|
@ -84,17 +83,17 @@ class BsqTxListItem {
|
|||
BtcWalletService btcWalletService,
|
||||
Optional<TxType> txTypeOptional,
|
||||
boolean isBurnedBsqTx,
|
||||
BsqBlockChain bsqBlockChain,
|
||||
Date date,
|
||||
BsqFormatter bsqFormatter) {
|
||||
this.transaction = transaction;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.txTypeOptional = txTypeOptional;
|
||||
this.isBurnedBsqTx = isBurnedBsqTx;
|
||||
this.date = date;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
|
||||
txId = transaction.getHashAsString();
|
||||
date = transaction.getUpdateTime();
|
||||
|
||||
setupConfidence(bsqWalletService);
|
||||
|
||||
|
@ -180,5 +179,9 @@ class BsqTxListItem {
|
|||
else
|
||||
return confirmations == 0 ? TxType.UNVERIFIED : TxType.UNDEFINED_TX_TYPE;
|
||||
}
|
||||
|
||||
public void setAmount(Coin amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,11 @@ import bisq.core.app.BisqEnvironment;
|
|||
import bisq.core.btc.wallet.BsqBalanceListener;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
import bisq.core.btc.wallet.BtcWalletService;
|
||||
import bisq.core.dao.blockchain.BsqBlockChain;
|
||||
import bisq.core.dao.DaoPeriodService;
|
||||
import bisq.core.dao.blockchain.ReadableBsqBlockChain;
|
||||
import bisq.core.dao.blockchain.vo.Tx;
|
||||
import bisq.core.dao.blockchain.vo.TxOutput;
|
||||
import bisq.core.dao.blockchain.vo.TxOutputType;
|
||||
import bisq.core.dao.blockchain.vo.TxType;
|
||||
import bisq.core.dao.node.BsqNode;
|
||||
import bisq.core.dao.node.BsqNodeProvider;
|
||||
|
@ -73,8 +77,9 @@ import javafx.collections.transformation.SortedList;
|
|||
import javafx.util.Callback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@FxmlView
|
||||
|
@ -85,7 +90,8 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqBlockChain bsqBlockChain;
|
||||
private final ReadableBsqBlockChain readableBsqBlockChain;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final BsqBalanceUtil bsqBalanceUtil;
|
||||
private final BsqNode bsqNode;
|
||||
|
@ -108,16 +114,20 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private BsqTxView(BsqFormatter bsqFormatter, BsqWalletService bsqWalletService,
|
||||
private BsqTxView(BsqFormatter bsqFormatter,
|
||||
BsqWalletService bsqWalletService,
|
||||
BsqNodeProvider bsqNodeProvider,
|
||||
Preferences preferences,
|
||||
BsqBlockChain bsqBlockChain,
|
||||
BtcWalletService btcWalletService, BsqBalanceUtil bsqBalanceUtil) {
|
||||
ReadableBsqBlockChain readableBsqBlockChain,
|
||||
DaoPeriodService daoPeriodService,
|
||||
BtcWalletService btcWalletService,
|
||||
BsqBalanceUtil bsqBalanceUtil) {
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.bsqNode = bsqNodeProvider.getBsqNode();
|
||||
this.preferences = preferences;
|
||||
this.bsqBlockChain = bsqBlockChain;
|
||||
this.readableBsqBlockChain = readableBsqBlockChain;
|
||||
this.daoPeriodService = daoPeriodService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.bsqBalanceUtil = bsqBalanceUtil;
|
||||
}
|
||||
|
@ -213,7 +223,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
|
||||
private void onChainHeightChanged() {
|
||||
final int bsqWalletChainHeight = bsqWalletService.getChainHeightProperty().get();
|
||||
final int bsqBlockChainHeight = bsqBlockChain.getChainHeadHeight();
|
||||
final int bsqBlockChainHeight = readableBsqBlockChain.getChainHeadHeight();
|
||||
if (bsqWalletChainHeight > 0) {
|
||||
final boolean synced = bsqWalletChainHeight == bsqBlockChainHeight;
|
||||
chainSyncIndicator.setVisible(!synced);
|
||||
|
@ -242,16 +252,65 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
|
||||
// copy list to avoid ConcurrentModificationException
|
||||
final List<Transaction> walletTransactions = new ArrayList<>(bsqWalletService.getWalletTransactions());
|
||||
Set<BsqTxListItem> items = walletTransactions.stream()
|
||||
List<BsqTxListItem> items = walletTransactions.stream()
|
||||
.map(transaction -> new BsqTxListItem(transaction,
|
||||
bsqWalletService,
|
||||
btcWalletService,
|
||||
bsqBlockChain.getTxType(transaction.getHashAsString()),
|
||||
bsqBlockChain.hasTxBurntFee(transaction.getHashAsString()),
|
||||
bsqBlockChain,
|
||||
readableBsqBlockChain.getTxType(transaction.getHashAsString()),
|
||||
readableBsqBlockChain.hasTxBurntFee(transaction.getHashAsString()),
|
||||
transaction.getUpdateTime(),
|
||||
bsqFormatter)
|
||||
)
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<BsqTxListItem> issuanceTxList = new ArrayList<>();
|
||||
items.stream()
|
||||
.filter(item -> item.getTxType() == TxType.COMPENSATION_REQUEST)
|
||||
.peek(item -> {
|
||||
final Tx tx = readableBsqBlockChain.getTx(item.getTxId()).get();
|
||||
long changeValue = tx.getOutputs().get(0).getValue();
|
||||
long inputValue = tx.getInputs().stream()
|
||||
.filter(input -> input.getConnectedTxOutput() != null)
|
||||
.mapToLong(input -> input.getConnectedTxOutput().getValue())
|
||||
.sum();
|
||||
long fee = inputValue - changeValue;
|
||||
item.setAmount(Coin.valueOf(fee));
|
||||
})
|
||||
.filter(item -> {
|
||||
final Optional<Tx> optionalTx = readableBsqBlockChain.getTx(item.getTxId());
|
||||
if (optionalTx.isPresent()) {
|
||||
final List<TxOutput> outputs = optionalTx.get().getOutputs();
|
||||
if (!outputs.isEmpty()) {
|
||||
return outputs.get(0).getTxOutputType() == TxOutputType.BSQ_OUTPUT;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
})
|
||||
.forEach(item -> {
|
||||
final Tx tx = readableBsqBlockChain.getTx(item.getTxId()).get();
|
||||
final int blockHeight = tx.getBlockHeight();
|
||||
final int issuanceBlockHeight = daoPeriodService.getAbsoluteStartBlockOfPhase(blockHeight, DaoPeriodService.Phase.ISSUANCE);
|
||||
log.error("blockHeight {}, issuanceBlockHeight={}", blockHeight, issuanceBlockHeight);
|
||||
final long blockTimeInSec = readableBsqBlockChain.getBlockTime(issuanceBlockHeight);
|
||||
|
||||
long inputValue = tx.getInputs().stream()
|
||||
.filter(input -> input.getConnectedTxOutput() != null)
|
||||
.mapToLong(input -> input.getConnectedTxOutput().getValue())
|
||||
.sum();
|
||||
long issuanceValue = tx.getOutputs().get(1).getValue();
|
||||
|
||||
final BsqTxListItem issuanceItem = new BsqTxListItem(item.getTransaction(),
|
||||
bsqWalletService,
|
||||
btcWalletService,
|
||||
Optional.of(TxType.ISSUANCE),
|
||||
item.isBurnedBsqTx(),
|
||||
new Date(blockTimeInSec * 1000),
|
||||
bsqFormatter);
|
||||
issuanceItem.setAmount(Coin.valueOf(issuanceValue));
|
||||
issuanceTxList.add(issuanceItem);
|
||||
|
||||
});
|
||||
items.addAll(issuanceTxList);
|
||||
observableList.setAll(items);
|
||||
}
|
||||
|
||||
|
@ -533,7 +592,7 @@ public class BsqTxView extends ActivatableView<GridPane, Void> implements BsqBal
|
|||
style = "dao-tx-type-vote-reveal-icon";
|
||||
break;
|
||||
case ISSUANCE:
|
||||
awesomeIcon = AwesomeIcon.UMBRELLA;
|
||||
awesomeIcon = AwesomeIcon.MONEY;
|
||||
style = "dao-tx-type-issuance-icon";
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue