mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 15:00:30 +01:00
Fix confirmations list view
This commit is contained in:
parent
547fb2f070
commit
bcc1b88bfc
4 changed files with 77 additions and 73 deletions
|
@ -32,19 +32,18 @@ import lombok.Data;
|
|||
|
||||
|
||||
@Data
|
||||
public class BaseBsqTxListItem {
|
||||
public class TxConfidenceListItem {
|
||||
protected final BsqWalletService bsqWalletService;
|
||||
protected final String txId;
|
||||
protected int confirmations = 0;
|
||||
protected TxConfidenceIndicator txConfidenceIndicator;
|
||||
protected TxConfidenceListener txConfidenceListener;
|
||||
|
||||
protected BaseBsqTxListItem(Transaction transaction,
|
||||
BsqWalletService bsqWalletService) {
|
||||
protected TxConfidenceListItem(Transaction transaction,
|
||||
BsqWalletService bsqWalletService) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
|
||||
txId = transaction.getHashAsString();
|
||||
|
||||
setupConfidence(bsqWalletService);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ package bisq.desktop.main.dao.bonding.unlock;
|
|||
|
||||
import bisq.desktop.components.AutoTooltipButton;
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.main.dao.BaseBsqTxListItem;
|
||||
import bisq.desktop.main.dao.TxConfidenceListItem;
|
||||
|
||||
import bisq.core.btc.listeners.TxConfidenceListener;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
|
@ -43,14 +43,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
class LockupTxListItem extends BaseBsqTxListItem {
|
||||
class LockupTxListItem extends TxConfidenceListItem {
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final DaoFacade daoFacade;
|
||||
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final Date date;
|
||||
|
||||
private int confirmations = 0;
|
||||
private Coin amount = Coin.ZERO;
|
||||
private int lockTime;
|
||||
private AutoTooltipButton button;
|
||||
|
|
|
@ -228,6 +228,74 @@ public class UnlockView extends ActivatableView<GridPane, Void> implements BsqBa
|
|||
// Private
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void onButtonClick() {
|
||||
if (GUIUtil.isReadyForTxBroadcast(p2PService, walletsSetup)) {
|
||||
Optional<TxOutput> lockupTxOutput = daoFacade.getLockupTxOutput(selectedItem.getTxId());
|
||||
if (!lockupTxOutput.isPresent()) {
|
||||
log.warn("Lockup output not found, txId = ", selectedItem.getTxId());
|
||||
return;
|
||||
}
|
||||
|
||||
Coin unlockAmount = Coin.valueOf(lockupTxOutput.get().getValue());
|
||||
Optional<Integer> opLockTime = daoFacade.getLockTime(selectedItem.getTxId());
|
||||
int lockTime = opLockTime.orElse(-1);
|
||||
|
||||
try {
|
||||
new Popup<>().headLine(Res.get("dao.bonding.unlock.sendTx.headline"))
|
||||
.confirmation(Res.get("dao.bonding.unlock.sendTx.details",
|
||||
bsqFormatter.formatCoinWithCode(unlockAmount),
|
||||
lockTime
|
||||
))
|
||||
.actionButtonText(Res.get("shared.yes"))
|
||||
.onAction(() -> {
|
||||
daoFacade.publishUnlockTx(selectedItem.getTxId(),
|
||||
() -> {
|
||||
new Popup<>().confirmation(Res.get("dao.tx.published.success")).show();
|
||||
},
|
||||
errorMessage -> new Popup<>().warning(errorMessage.toString()).show()
|
||||
);
|
||||
})
|
||||
.closeButtonText(Res.get("shared.cancel"))
|
||||
.show();
|
||||
} catch (Throwable t) {
|
||||
log.error(t.toString());
|
||||
t.printStackTrace();
|
||||
new Popup<>().warning(t.getMessage()).show();
|
||||
}
|
||||
} else {
|
||||
GUIUtil.showNotReadyForTxBroadcastPopups(p2PService, walletsSetup);
|
||||
}
|
||||
log.info("unlock tx: {}", selectedItem.getTxId());
|
||||
}
|
||||
|
||||
private void openTxInBlockExplorer(LockupTxListItem item) {
|
||||
if (item.getTxId() != null)
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId());
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
observableList.forEach(LockupTxListItem::cleanup);
|
||||
|
||||
// copy list to avoid ConcurrentModificationException
|
||||
final List<Transaction> walletTransactions = new ArrayList<>(bsqWalletService.getWalletTransactions());
|
||||
List<LockupTxListItem> items = walletTransactions.stream()
|
||||
.map(transaction -> {
|
||||
return new LockupTxListItem(transaction,
|
||||
bsqWalletService,
|
||||
btcWalletService,
|
||||
daoFacade,
|
||||
transaction.getUpdateTime(),
|
||||
bsqFormatter);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
observableList.setAll(items);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Table columns
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void addTxIdColumn() {
|
||||
TableColumn<LockupTxListItem, LockupTxListItem> column = new AutoTooltipTableColumn<>(Res.get("shared.txId"));
|
||||
|
||||
|
@ -373,67 +441,4 @@ public class UnlockView extends ActivatableView<GridPane, Void> implements BsqBa
|
|||
unlockColumn.setComparator(Comparator.comparing(LockupTxListItem::getConfirmations));
|
||||
tableView.getColumns().add(unlockColumn);
|
||||
}
|
||||
|
||||
private void onButtonClick() {
|
||||
if (GUIUtil.isReadyForTxBroadcast(p2PService, walletsSetup)) {
|
||||
Optional<TxOutput> lockupTxOutput = daoFacade.getLockupTxOutput(selectedItem.getTxId());
|
||||
if (!lockupTxOutput.isPresent()) {
|
||||
log.warn("Lockup output not found, txId = ", selectedItem.getTxId());
|
||||
return;
|
||||
}
|
||||
|
||||
Coin unlockAmount = Coin.valueOf(lockupTxOutput.get().getValue());
|
||||
Optional<Integer> opLockTime = daoFacade.getLockTime(selectedItem.getTxId());
|
||||
int lockTime = opLockTime.orElse(-1);
|
||||
|
||||
try {
|
||||
new Popup<>().headLine(Res.get("dao.bonding.unlock.sendTx.headline"))
|
||||
.confirmation(Res.get("dao.bonding.unlock.sendTx.details",
|
||||
bsqFormatter.formatCoinWithCode(unlockAmount),
|
||||
lockTime
|
||||
))
|
||||
.actionButtonText(Res.get("shared.yes"))
|
||||
.onAction(() -> {
|
||||
daoFacade.publishUnlockTx(selectedItem.getTxId(),
|
||||
() -> {
|
||||
new Popup<>().confirmation(Res.get("dao.tx.published.success")).show();
|
||||
},
|
||||
errorMessage -> new Popup<>().warning(errorMessage.toString()).show()
|
||||
);
|
||||
})
|
||||
.closeButtonText(Res.get("shared.cancel"))
|
||||
.show();
|
||||
} catch (Throwable t) {
|
||||
log.error(t.toString());
|
||||
t.printStackTrace();
|
||||
new Popup<>().warning(t.getMessage()).show();
|
||||
}
|
||||
} else {
|
||||
GUIUtil.showNotReadyForTxBroadcastPopups(p2PService, walletsSetup);
|
||||
}
|
||||
log.info("unlock tx: {}", selectedItem.getTxId());
|
||||
}
|
||||
|
||||
private void openTxInBlockExplorer(LockupTxListItem item) {
|
||||
if (item.getTxId() != null)
|
||||
GUIUtil.openWebPage(preferences.getBsqBlockChainExplorer().txUrl + item.getTxId());
|
||||
}
|
||||
|
||||
private void updateList() {
|
||||
observableList.forEach(LockupTxListItem::cleanup);
|
||||
|
||||
// copy list to avoid ConcurrentModificationException
|
||||
final List<Transaction> walletTransactions = new ArrayList<>(bsqWalletService.getWalletTransactions());
|
||||
List<LockupTxListItem> items = walletTransactions.stream()
|
||||
.map(transaction -> {
|
||||
return new LockupTxListItem(transaction,
|
||||
bsqWalletService,
|
||||
btcWalletService,
|
||||
daoFacade,
|
||||
transaction.getUpdateTime(),
|
||||
bsqFormatter);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
observableList.setAll(items);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package bisq.desktop.main.dao.wallet.tx;
|
||||
|
||||
import bisq.desktop.components.indicator.TxConfidenceIndicator;
|
||||
import bisq.desktop.main.dao.BaseBsqTxListItem;
|
||||
import bisq.desktop.main.dao.TxConfidenceListItem;
|
||||
|
||||
import bisq.core.btc.listeners.TxConfidenceListener;
|
||||
import bisq.core.btc.wallet.BsqWalletService;
|
||||
|
@ -37,19 +37,20 @@ import java.util.Date;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Slf4j
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
class BsqTxListItem extends BaseBsqTxListItem {
|
||||
class BsqTxListItem extends TxConfidenceListItem {
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final DaoFacade daoFacade;
|
||||
private final BsqFormatter bsqFormatter;
|
||||
private final Date date;
|
||||
private final boolean isBurnedBsqTx;
|
||||
|
||||
private int confirmations = 0;
|
||||
private final String address;
|
||||
private final String direction;
|
||||
private Coin amount;
|
||||
|
|
Loading…
Add table
Reference in a new issue