Search in sources :

Example 1 with ViewTransactionEvent

use of com.sparrowwallet.sparrow.event.ViewTransactionEvent in project sparrow by sparrowwallet.

the class OutputController method updateSpent.

private void updateSpent(List<BlockTransaction> outputTransactions) {
    int outputIndex = outputForm.getIndex();
    if (outputIndex < outputForm.getMaxOutputFetched()) {
        spent.setText("Unspent");
    } else {
        spent.setText("Unknown");
    }
    if (outputIndex >= 0 && outputIndex < outputTransactions.size()) {
        BlockTransaction outputBlockTransaction = outputTransactions.get(outputIndex);
        if (outputBlockTransaction != null) {
            spent.setText("Spent");
            if (outputBlockTransaction == ElectrumServer.UNFETCHABLE_BLOCK_TRANSACTION) {
                spent.setText("Spent (Spending transaction history too large to fetch)");
                return;
            }
            for (int i = 0; i < outputBlockTransaction.getTransaction().getInputs().size(); i++) {
                TransactionInput input = outputBlockTransaction.getTransaction().getInputs().get(i);
                if (input.getOutpoint().getHash().equals(outputForm.getTransaction().getTxId()) && input.getOutpoint().getIndex() == outputIndex) {
                    spentField.setVisible(false);
                    spentByField.setVisible(true);
                    final Integer inputIndex = i;
                    spentBy.setText(outputBlockTransaction.getHash().toString() + ":" + inputIndex);
                    spentBy.setOnAction(event -> {
                        EventManager.get().post(new ViewTransactionEvent(spentBy.getScene().getWindow(), outputBlockTransaction, TransactionView.INPUT, inputIndex));
                    });
                    spentBy.setContextMenu(new TransactionReferenceContextMenu(spentBy.getText()));
                }
            }
        }
    }
}
Also used : ViewTransactionEvent(com.sparrowwallet.sparrow.event.ViewTransactionEvent) BlockTransaction(com.sparrowwallet.drongo.wallet.BlockTransaction) TransactionInput(com.sparrowwallet.drongo.protocol.TransactionInput)

Aggregations

TransactionInput (com.sparrowwallet.drongo.protocol.TransactionInput)1 BlockTransaction (com.sparrowwallet.drongo.wallet.BlockTransaction)1 ViewTransactionEvent (com.sparrowwallet.sparrow.event.ViewTransactionEvent)1