Search in sources :

Example 1 with NonStandardScriptException

use of com.sparrowwallet.drongo.protocol.NonStandardScriptException in project sparrow by sparrowwallet.

the class TransactionFormController method addPieData.

protected void addPieData(PieChart pie, List<TransactionOutput> outputs) {
    ObservableList<PieChart.Data> outputsPieData = FXCollections.observableArrayList();
    long totalAmt = 0;
    for (int i = 0; i < outputs.size(); i++) {
        TransactionOutput output = outputs.get(i);
        String name = "#" + i;
        try {
            Address[] addresses = output.getScript().getToAddresses();
            if (addresses.length == 1) {
                name = name + " " + addresses[0].getAddress();
            } else {
                name = name + " [" + addresses[0].getAddress() + ",...]";
            }
        } catch (NonStandardScriptException e) {
        // ignore
        }
        totalAmt += output.getValue();
        outputsPieData.add(new PieChart.Data(name, output.getValue()));
    }
    addPieData(pie, outputsPieData);
}
Also used : NonStandardScriptException(com.sparrowwallet.drongo.protocol.NonStandardScriptException) TransactionOutput(com.sparrowwallet.drongo.protocol.TransactionOutput) Address(com.sparrowwallet.drongo.address.Address) PieChart(javafx.scene.chart.PieChart) TransactionTabData(com.sparrowwallet.sparrow.TransactionTabData)

Example 2 with NonStandardScriptException

use of com.sparrowwallet.drongo.protocol.NonStandardScriptException in project sparrow by sparrowwallet.

the class OutputController method initializeView.

public void initializeView() {
    TransactionOutput txOutput = outputForm.getTransactionOutput();
    outputForm.signingWalletProperty().addListener((observable, oldValue, signingWallet) -> {
        updateOutputLegendFromWallet(txOutput, signingWallet);
    });
    updateOutputLegendFromWallet(txOutput, outputForm.getSigningWallet());
    value.setValue(txOutput.getValue());
    to.setVisible(false);
    try {
        Address[] addresses = txOutput.getScript().getToAddresses();
        to.setVisible(true);
        if (addresses.length == 1) {
            address.setAddress(addresses[0]);
        } else {
            address.setText("multiple addresses");
        }
    } catch (NonStandardScriptException e) {
    // ignore
    }
    spentField.managedProperty().bind(spentField.visibleProperty());
    spentByField.managedProperty().bind(spentByField.visibleProperty());
    spentByField.setVisible(false);
    if (outputForm.getPsbt() != null) {
        spent.setText("Unspent");
    } else if (outputForm.getOutputTransactions() != null) {
        updateSpent(outputForm.getOutputTransactions());
    } else {
        spent.setText("Unknown");
    }
    initializeScriptField(scriptPubKeyArea);
    scriptPubKeyArea.clear();
    scriptPubKeyArea.appendScript(txOutput.getScript(), null, null);
}
Also used : NonStandardScriptException(com.sparrowwallet.drongo.protocol.NonStandardScriptException) TransactionOutput(com.sparrowwallet.drongo.protocol.TransactionOutput) Address(com.sparrowwallet.drongo.address.Address)

Aggregations

Address (com.sparrowwallet.drongo.address.Address)2 NonStandardScriptException (com.sparrowwallet.drongo.protocol.NonStandardScriptException)2 TransactionOutput (com.sparrowwallet.drongo.protocol.TransactionOutput)2 TransactionTabData (com.sparrowwallet.sparrow.TransactionTabData)1 PieChart (javafx.scene.chart.PieChart)1