Package org.bitcoinj.core

Examples of org.bitcoinj.core.Coin


        // Copy data from model.
        addressEdit.setText(model.address.get());
        titleEdit.setText(model.title.get());
        descriptionEdit.setText(model.memo.get());
        Coin goalCoin = Coin.valueOf(model.goalAmount.get());
        if (goalCoin.value != 1) {  // 1 satoshi is sentinel value meaning new project.
            goalAmountEdit.setText(goalCoin.toPlainString());
        }
        minPledgeEdit.setPromptText(model.getMinPledgeAmount().toPlainString());
        if (model.image.get() == null) {
            setupDefaultCoverImage();
        } else {
            InputStream stream = model.image.get().newInput();
            coverImageView.setImage(new Image(stream));
            uncheck(stream::close);
        }

        // Bind UI back to model.
        this.model.title.bind(titleEdit.textProperty());
        this.model.memo.bind(descriptionEdit.textProperty());
        this.model.address.bind(addressEdit.textProperty());

        coverPhotoSiteLink.setText(COVERPHOTO_SITE);

        ValidationLink goalValid = new ValidationLink(goalAmountEdit, str -> !LHUtils.didThrow(() -> valueOrThrow(str)));
        goalAmountEdit.textProperty().addListener((obj, prev, cur) -> {
            if (goalValid.isValid.get())
                this.model.goalAmount.set(valueOrThrow(cur).value);
        });
        // Figure out the smallest pledge that is allowed based on the goal divided by number of inputs we can have.
        model.minPledgeAmountProperty().addListener(o -> {
            minPledgeEdit.setPromptText(model.getMinPledgeAmount().toPlainString());
        });
        ValidationLink minPledgeValue = new ValidationLink(minPledgeEdit, str -> {
            if (str.isEmpty())
                return true// default is used
            Coin coin = valueOrNull(str);
            if (coin == null) return false;
            Coin amount = model.getMinPledgeAmount();
            // If min pledge == suggested amount it's ok, or if it's between min amount and goal.
            return coin.equals(amount) || (coin.isGreaterThan(amount) && coin.isLessThan(Coin.valueOf(this.model.goalAmount.get())));
        });

        ValidationLink.autoDisableButton(nextButton,
View Full Code Here


    public void initialize() {
        ValidationLink amountLink = new ValidationLink(amountEdit, str -> {
            // Can't pledge more than our balance or more than the project is trying to actually raise
            // as excess would go to miners fees.
            Coin coin = valueOrNull(str);
            boolean valid = coin != null && coin.compareTo(max) <= 0 && coin.compareTo(min) >= 0;
            minersFeeLabel.setVisible(valid && !coin.equals(Main.wallet.getBalance()));
            return valid;
        });
        ValidationLink emailLink = new ValidationLink(emailEdit, str -> str.contains("@"));
        ValidationLink.autoDisableButton(confirmButton, amountLink, emailLink);
View Full Code Here

TOP

Related Classes of org.bitcoinj.core.Coin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.