use of com.sparrowwallet.drongo.protocol.TransactionOutput in project sparrow by sparrowwallet.
the class SorobanController method calculateFee.
private long calculateFee(WalletTransaction walletTransaction, List<Map<BlockTransactionHashIndex, WalletNode>> selectedUtxoSets, Transaction transaction) {
Map<BlockTransactionHashIndex, WalletNode> selectedUtxos = new LinkedHashMap<>();
selectedUtxoSets.forEach(selectedUtxos::putAll);
long feeAmt = 0L;
for (BlockTransactionHashIndex utxo : selectedUtxos.keySet()) {
if (utxo.getValue() == 0) {
return walletTransaction == null ? -1 : walletTransaction.getFee();
}
feeAmt += utxo.getValue();
}
for (TransactionOutput txOutput : transaction.getOutputs()) {
feeAmt -= txOutput.getValue();
}
return feeAmt;
}
use of com.sparrowwallet.drongo.protocol.TransactionOutput 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);
}
Aggregations