Search in sources :

Example 26 with Transaction

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();
}
Also used : Coin(org.bitcoinj.core.Coin) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) Transaction(org.bitcoinj.core.Transaction)

Example 27 with Transaction

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());
}
Also used : Coin(org.bitcoinj.core.Coin) BalanceListener(io.bitsquare.btc.listeners.BalanceListener) Transaction(org.bitcoinj.core.Transaction) PaymentAccount(io.bitsquare.payment.PaymentAccount)

Example 28 with Transaction

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");
    }
}
Also used : Trade(io.bitsquare.trade.Trade) BuyerTrade(io.bitsquare.trade.BuyerTrade) SellerTrade(io.bitsquare.trade.SellerTrade) Transaction(org.bitcoinj.core.Transaction) Popup(io.bitsquare.gui.main.overlays.popups.Popup) Dispute(io.bitsquare.arbitration.Dispute) Arbitrator(io.bitsquare.arbitration.Arbitrator)

Example 29 with Transaction

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();
    });
}
Also used : Insets(javafx.geometry.Insets) Transaction(org.bitcoinj.core.Transaction) FormBuilder.addLabelComboBox(io.bitsquare.gui.util.FormBuilder.addLabelComboBox) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) FormBuilder.addMultilineLabel(io.bitsquare.gui.util.FormBuilder.addMultilineLabel)

Example 30 with Transaction

use of org.bitcoinj.core.Transaction in project bitcoin-wallet by bitcoin-wallet.

the class MaintenanceDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final View view = LayoutInflater.from(activity).inflate(R.layout.maintenance_dialog, null);
    Coin value = Coin.ZERO;
    Coin fee = Coin.ZERO;
    for (final Transaction tx : determineMaintenanceTransactions()) {
        value = value.add(tx.getValueSentFromMe(wallet));
        fee = fee.add(tx.getFee());
    }
    final TextView messageView = (TextView) view.findViewById(R.id.maintenance_dialog_message);
    final MonetaryFormat format = application.getConfiguration().getFormat();
    messageView.setText(getString(R.string.maintenance_dialog_message, format.format(value), format.format(fee)));
    passwordGroup = view.findViewById(R.id.maintenance_dialog_password_group);
    passwordView = (EditText) view.findViewById(R.id.maintenance_dialog_password);
    passwordView.setText(null);
    badPasswordView = view.findViewById(R.id.maintenance_dialog_bad_password);
    final DialogBuilder builder = new DialogBuilder(activity);
    builder.setTitle(R.string.maintenance_dialog_title);
    builder.setView(view);
    // dummies, just to make buttons show
    builder.setPositiveButton(R.string.maintenance_dialog_button_move, null);
    builder.setNegativeButton(R.string.button_dismiss, null);
    builder.setCancelable(false);
    final AlertDialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(final DialogInterface d) {
            positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
            negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
            positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
            positiveButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    log.info("user decided to do maintenance");
                    handleGo();
                }
            });
            negativeButton.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    log.info("user decided to dismiss");
                    dismissAllowingStateLoss();
                }
            });
            passwordView.addTextChangedListener(textWatcher);
            MaintenanceDialogFragment.this.dialog = dialog;
            updateView();
        }
    });
    log.info("showing maintenance dialog");
    return dialog;
}
Also used : AlertDialog(android.app.AlertDialog) Coin(org.bitcoinj.core.Coin) MonetaryFormat(org.bitcoinj.utils.MonetaryFormat) Transaction(org.bitcoinj.core.Transaction) DialogInterface(android.content.DialogInterface) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) View(android.view.View) TextView(android.widget.TextView) OnShowListener(android.content.DialogInterface.OnShowListener)

Aggregations

Transaction (org.bitcoinj.core.Transaction)39 Coin (org.bitcoinj.core.Coin)14 AddressEntry (io.bitsquare.btc.AddressEntry)8 WalletService (io.bitsquare.btc.WalletService)8 Address (org.bitcoinj.core.Address)8 BalanceListener (io.bitsquare.btc.listeners.BalanceListener)7 VerificationException (org.bitcoinj.core.VerificationException)7 PaymentIntent (de.schildbach.wallet.data.PaymentIntent)6 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)6 Popup (io.bitsquare.gui.main.overlays.popups.Popup)5 Trade (io.bitsquare.trade.Trade)4 VersionedChecksummedBytes (org.bitcoinj.core.VersionedChecksummedBytes)4 DialogInterface (android.content.DialogInterface)3 View (android.view.View)3 TextView (android.widget.TextView)3 DialogBuilder (de.schildbach.wallet.ui.DialogBuilder)3 Arbitrator (io.bitsquare.arbitration.Arbitrator)3 Nullable (javax.annotation.Nullable)3 RecyclerView (android.support.v7.widget.RecyclerView)2 Inject (com.google.inject.Inject)2