use of org.bitcoinj.core.Transaction in project bitsquare by bitsquare.
the class DepositView method initialize.
@Override
public void initialize() {
// trigger creation of at least 1 savings address
walletService.getOrCreateAddressEntry(AddressEntry.Context.AVAILABLE);
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
tableView.setPlaceholder(new Label("No deposit addresses have been generated yet"));
tableViewSelectionListener = (observableValue, oldValue, newValue) -> {
if (newValue != null)
fillForm(newValue.getAddressString());
};
setSelectColumnCellFactory();
setAddressColumnCellFactory();
setBalanceColumnCellFactory();
setUsageColumnCellFactory();
setConfidenceColumnCellFactory();
addressColumn.setComparator((o1, o2) -> o1.getAddressString().compareTo(o2.getAddressString()));
balanceColumn.setComparator((o1, o2) -> o1.getBalanceAsCoin().compareTo(o2.getBalanceAsCoin()));
confidenceColumn.setComparator((o1, o2) -> Double.valueOf(o1.getTxConfidenceIndicator().getProgress()).compareTo(o2.getTxConfidenceIndicator().getProgress()));
usageColumn.setComparator((a, b) -> (a.getNumTxOutputs() < b.getNumTxOutputs()) ? -1 : ((a.getNumTxOutputs() == b.getNumTxOutputs()) ? 0 : 1));
tableView.getSortOrder().add(usageColumn);
tableView.setItems(sortedList);
titledGroupBg = addTitledGroupBg(gridPane, gridRow, 3, "Fund your wallet");
qrCodeLabel = addLabel(gridPane, gridRow, "", 0);
//GridPane.setMargin(qrCodeLabel, new Insets(Layout.FIRST_ROW_DISTANCE - 9, 0, 0, 5));
qrCodeImageView = new ImageView();
qrCodeImageView.setStyle("-fx-cursor: hand;");
Tooltip.install(qrCodeImageView, new Tooltip("Open large QR-Code window"));
qrCodeImageView.setOnMouseClicked(e -> GUIUtil.showFeeInfoBeforeExecute(() -> UserThread.runAfter(() -> new QRCodeWindow(getBitcoinURI()).show(), 200, TimeUnit.MILLISECONDS)));
GridPane.setRowIndex(qrCodeImageView, gridRow);
GridPane.setColumnIndex(qrCodeImageView, 1);
GridPane.setMargin(qrCodeImageView, new Insets(Layout.FIRST_ROW_DISTANCE, 0, 0, 0));
gridPane.getChildren().add(qrCodeImageView);
Tuple2<Label, AddressTextField> addressTuple = addLabelAddressTextField(gridPane, ++gridRow, "Address:");
addressLabel = addressTuple.first;
//GridPane.setValignment(addressLabel, VPos.TOP);
//GridPane.setMargin(addressLabel, new Insets(3, 0, 0, 0));
addressTextField = addressTuple.second;
addressTextField.setPaymentLabel(paymentLabelString);
Tuple2<Label, InputTextField> amountTuple = addLabelInputTextField(gridPane, ++gridRow, "Amount in BTC (optional):");
amountLabel = amountTuple.first;
amountTextField = amountTuple.second;
if (DevFlags.DEV_MODE)
amountTextField.setText("10");
titledGroupBg.setVisible(false);
titledGroupBg.setManaged(false);
qrCodeLabel.setVisible(false);
qrCodeLabel.setManaged(false);
qrCodeImageView.setVisible(false);
qrCodeImageView.setManaged(false);
addressLabel.setVisible(false);
addressLabel.setManaged(false);
addressTextField.setVisible(false);
addressTextField.setManaged(false);
amountLabel.setVisible(false);
amountTextField.setManaged(false);
generateNewAddressButton = addButton(gridPane, ++gridRow, "Generate new address", -20);
GridPane.setColumnIndex(generateNewAddressButton, 0);
GridPane.setHalignment(generateNewAddressButton, HPos.LEFT);
generateNewAddressButton.setOnAction(event -> {
boolean hasUnUsedAddress = observableList.stream().filter(e -> e.getNumTxOutputs() == 0).findAny().isPresent();
if (hasUnUsedAddress) {
new Popup().warning("Please select an unused address from the table above rather than generating a new one.").show();
} else {
AddressEntry newSavingsAddressEntry = walletService.getOrCreateUnusedAddressEntry(AddressEntry.Context.AVAILABLE);
updateList();
observableList.stream().filter(depositListItem -> depositListItem.getAddressString().equals(newSavingsAddressEntry.getAddressString())).findAny().ifPresent(depositListItem -> tableView.getSelectionModel().select(depositListItem));
}
});
balanceListener = new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateList();
}
};
}
use of org.bitcoinj.core.Transaction in project bitsquare by bitsquare.
the class ReservedView method initialize.
@Override
public void initialize() {
tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
tableView.setPlaceholder(new Label("No funds are reserved in open offers"));
setDateColumnCellFactory();
setDetailsColumnCellFactory();
setAddressColumnCellFactory();
setBalanceColumnCellFactory();
addressColumn.setComparator((o1, o2) -> o1.getAddressString().compareTo(o2.getAddressString()));
detailsColumn.setComparator((o1, o2) -> o1.getOpenOffer().getId().compareTo(o2.getOpenOffer().getId()));
balanceColumn.setComparator((o1, o2) -> o1.getBalance().compareTo(o2.getBalance()));
dateColumn.setComparator((o1, o2) -> {
if (getTradable(o1).isPresent() && getTradable(o2).isPresent())
return getTradable(o2).get().getDate().compareTo(getTradable(o1).get().getDate());
else
return 0;
});
tableView.getSortOrder().add(dateColumn);
dateColumn.setSortType(TableColumn.SortType.DESCENDING);
balanceListener = new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateList();
}
};
openOfferListChangeListener = c -> updateList();
tradeListChangeListener = c -> updateList();
}
use of org.bitcoinj.core.Transaction in project bitsquare by bitsquare.
the class TakeOfferDataModel method initWithData.
///////////////////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////////////////
// called before activate
void initWithData(Offer offer) {
this.offer = offer;
tradePrice = offer.getPrice();
addressEntry = walletService.getOrCreateAddressEntry(offer.getId(), AddressEntry.Context.OFFER_FUNDING);
checkNotNull(addressEntry, "addressEntry must not be null");
ObservableList<PaymentAccount> possiblePaymentAccounts = getPossiblePaymentAccounts();
checkArgument(!possiblePaymentAccounts.isEmpty(), "possiblePaymentAccounts.isEmpty()");
paymentAccount = possiblePaymentAccounts.get(0);
amountAsCoin.set(offer.getAmount());
if (DevFlags.DEV_MODE)
amountAsCoin.set(offer.getAmount());
calculateVolume();
calculateTotalToPay();
balanceListener = new BalanceListener(addressEntry.getAddress()) {
@Override
public void onBalanceChanged(Coin balance, Transaction tx) {
updateBalance();
/*if (isMainNet.get()) {
SettableFuture<Coin> future = blockchainService.requestFee(tx.getHashAsString());
Futures.addCallback(future, new FutureCallback<Coin>() {
public void onSuccess(Coin fee) {
UserThread.execute(() -> setFeeFromFundingTx(fee));
}
public void onFailure(@NotNull Throwable throwable) {
UserThread.execute(() -> new Popup()
.warning("We did not get a response for the request of the mining fee used " +
"in the funding transaction.\n\n" +
"Are you sure you used a sufficiently high fee of at least " +
formatter.formatCoinWithCode(FeePolicy.getMinRequiredFeeForFundingTx()) + "?")
.actionButtonText("Yes, I used a sufficiently high fee.")
.onAction(() -> setFeeFromFundingTx(FeePolicy.getMinRequiredFeeForFundingTx()))
.closeButtonText("No. Let's cancel that payment.")
.onClose(() -> setFeeFromFundingTx(Coin.NEGATIVE_SATOSHI))
.show());
}
});
} else {
setFeeFromFundingTx(FeePolicy.getMinRequiredFeeForFundingTx());
isFeeFromFundingTxSufficient.set(feeFromFundingTx.compareTo(FeePolicy.getMinRequiredFeeForFundingTx()) >= 0);
}*/
}
};
offer.resetState();
if (!preferences.getUseStickyMarketPrice())
priceFeedService.setCurrencyCode(offer.getCurrencyCode());
}
use of org.bitcoinj.core.Transaction in project bitsquare by bitsquare.
the class PendingTradesDataModel method doOpenDispute.
private void doOpenDispute(boolean isSupportTicket, Transaction depositTx) {
Log.traceCall("depositTx=" + depositTx);
byte[] depositTxSerialized = null;
byte[] payoutTxSerialized = null;
String depositTxHashAsString = null;
String payoutTxHashAsString = null;
if (depositTx != null) {
depositTxSerialized = depositTx.bitcoinSerialize();
depositTxHashAsString = depositTx.getHashAsString();
} else {
log.warn("depositTx is null");
}
Trade trade = getTrade();
if (trade != null) {
Transaction payoutTx = trade.getPayoutTx();
if (payoutTx != null) {
payoutTxSerialized = payoutTx.bitcoinSerialize();
payoutTxHashAsString = payoutTx.getHashAsString();
} else {
log.debug("payoutTx is null at doOpenDispute");
}
final Arbitrator acceptedArbitratorByAddress = user.getAcceptedArbitratorByAddress(trade.getArbitratorNodeAddress());
checkNotNull(acceptedArbitratorByAddress, "acceptedArbitratorByAddress must no tbe null");
Dispute dispute = new Dispute(disputeManager.getDisputeStorage(), trade.getId(), // traderId
keyRing.getPubKeyRing().hashCode(), trade.getOffer().getDirection() == Offer.Direction.BUY ? isOfferer : !isOfferer, isOfferer, keyRing.getPubKeyRing(), trade.getDate(), trade.getContract(), trade.getContractHash(), depositTxSerialized, payoutTxSerialized, depositTxHashAsString, payoutTxHashAsString, trade.getContractAsJson(), trade.getOffererContractSignature(), trade.getTakerContractSignature(), acceptedArbitratorByAddress.getPubKeyRing(), isSupportTicket);
trade.setDisputeState(Trade.DisputeState.DISPUTE_REQUESTED);
if (p2PService.isBootstrapped()) {
sendOpenNewDisputeMessage(dispute, false);
} else {
new Popup().information("You need to wait until you are fully connected to the network.\n" + "That might take up to about 2 minutes at startup.").show();
}
} else {
log.warn("trade is null at doOpenDispute");
}
}
use of org.bitcoinj.core.Transaction in project bitsquare by bitsquare.
the class SelectDepositTxWindow method addContent.
///////////////////////////////////////////////////////////////////////////////////////////
// Protected
///////////////////////////////////////////////////////////////////////////////////////////
private void addContent() {
Label label = addMultilineLabel(gridPane, ++rowIndex, "The deposit transaction was not stored in the trade.\n" + "Please select one of the existing MultiSig transactions from your wallet which was the " + "deposit transaction used in the failed trade.\n\n" + "You can find the correct transaction by opening the trade details window (click on the trade ID in the list)" + " and following the offer fee payment transaction output to the next transaction where you see " + "the Multisig deposit transaction (the address starts with 3). That transaction ID should be " + "visible in the list presented here. Once you found the correct transaction select that transaction here and continue.\n\n" + "Sorry for the inconvenience but that error case should be happen very rare and in future we will try " + "to find better ways to resolve it.", 10);
GridPane.setMargin(label, new Insets(0, 0, 10, 0));
Tuple2<Label, ComboBox> tuple = addLabelComboBox(gridPane, ++rowIndex, "Select deposit transaction");
transactionsComboBox = tuple.second;
transactionsComboBox.setPromptText("Select");
transactionsComboBox.setConverter(new StringConverter<Transaction>() {
@Override
public String toString(Transaction transaction) {
return transaction.getHashAsString();
}
@Override
public Transaction fromString(String string) {
return null;
}
});
transactionsComboBox.setItems(FXCollections.observableArrayList(transactions));
transactionsComboBox.setOnAction(event -> {
selectHandlerOptional.get().accept(transactionsComboBox.getSelectionModel().getSelectedItem());
hide();
});
}
Aggregations