use of bisq.core.btc.listeners.AddressConfidenceListener in project bisq-core by bisq-network.
the class MakerSetupDepositTxListener method run.
@Override
protected void run() {
try {
runInterceptHook();
if (trade.getDepositTx() == null && processModel.getPreparedDepositTx() != null) {
BtcWalletService walletService = processModel.getBtcWalletService();
final NetworkParameters params = walletService.getParams();
Transaction preparedDepositTx = new Transaction(params, processModel.getPreparedDepositTx());
checkArgument(!preparedDepositTx.getOutputs().isEmpty(), "preparedDepositTx.getOutputs() must not be empty");
Address depositTxAddress = preparedDepositTx.getOutput(0).getAddressFromP2SH(params);
final TransactionConfidence confidence = walletService.getConfidenceForAddress(depositTxAddress);
if (isInNetwork(confidence)) {
applyConfidence(confidence);
} else {
confidenceListener = new AddressConfidenceListener(depositTxAddress) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
if (isInNetwork(confidence))
applyConfidence(confidence);
}
};
walletService.addAddressConfidenceListener(confidenceListener);
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newValue -> {
if (trade.isDepositPublished()) {
swapReservedForTradeEntry();
// hack to remove tradeStateSubscription at callback
UserThread.execute(this::unSubscribe);
}
});
}
}
// we complete immediately, our object stays alive because the balanceListener is stored in the WalletService
complete();
} catch (Throwable t) {
failed(t);
}
}
use of bisq.core.btc.listeners.AddressConfidenceListener in project bisq-desktop by bisq-network.
the class BalanceWithConfirmationTextField method setup.
public void setup(Address address, BSFormatter formatter) {
this.formatter = formatter;
confidenceListener = new AddressConfidenceListener(address) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
};
walletService.addAddressConfidenceListener(confidenceListener);
updateConfidence(walletService.getConfidenceForAddress(address));
balanceListener = new BalanceListener(address) {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateBalance(balance);
}
};
walletService.addBalanceListener(balanceListener);
updateBalance(walletService.getBalanceForAddress(address));
}
use of bisq.core.btc.listeners.AddressConfidenceListener in project bisq-core by bisq-network.
the class BuyerSetupPayoutTxListener method run.
@Override
protected void run() {
try {
runInterceptHook();
if (!trade.isPayoutPublished()) {
BtcWalletService walletService = processModel.getBtcWalletService();
final String id = processModel.getOffer().getId();
Address address = walletService.getOrCreateAddressEntry(id, AddressEntry.Context.TRADE_PAYOUT).getAddress();
final TransactionConfidence confidence = walletService.getConfidenceForAddress(address);
if (isInNetwork(confidence)) {
applyConfidence(confidence);
} else {
confidenceListener = new AddressConfidenceListener(address) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
if (isInNetwork(confidence))
applyConfidence(confidence);
}
};
walletService.addAddressConfidenceListener(confidenceListener);
tradeStateSubscription = EasyBind.subscribe(trade.stateProperty(), newValue -> {
if (trade.isPayoutPublished()) {
swapMultiSigEntry();
// hack to remove tradeStateSubscription at callback
UserThread.execute(this::unSubscribe);
}
});
}
}
// we complete immediately, our object stays alive because the balanceListener is stored in the WalletService
complete();
} catch (Throwable t) {
failed(t);
}
}
Aggregations