From 566aa2e95315291dd7c2092dfc1378bf2fa0d484 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Sun, 22 Mar 2020 10:21:32 +0200 Subject: [PATCH] Tx inputs and outputs can find their index --- .../java/com/craigraw/drongo/protocol/TransactionInput.java | 5 +++++ .../java/com/craigraw/drongo/protocol/TransactionOutput.java | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/main/java/com/craigraw/drongo/protocol/TransactionInput.java b/src/main/java/com/craigraw/drongo/protocol/TransactionInput.java index 26515f5..9ecd4de 100644 --- a/src/main/java/com/craigraw/drongo/protocol/TransactionInput.java +++ b/src/main/java/com/craigraw/drongo/protocol/TransactionInput.java @@ -82,6 +82,11 @@ public class TransactionInput extends TransactionPart { this.sequence = sequence; } + public int getIndex() { + Transaction transaction = (Transaction)parent; + return transaction.getInputs().indexOf(this); + } + /** * Coinbase transactions have special inputs with hashes of zero. If this is such an input, returns true. */ diff --git a/src/main/java/com/craigraw/drongo/protocol/TransactionOutput.java b/src/main/java/com/craigraw/drongo/protocol/TransactionOutput.java index 7bfd0b9..6093ee4 100644 --- a/src/main/java/com/craigraw/drongo/protocol/TransactionOutput.java +++ b/src/main/java/com/craigraw/drongo/protocol/TransactionOutput.java @@ -77,4 +77,9 @@ public class TransactionOutput extends TransactionPart { public void setAddresses(Address[] addresses) { this.addresses = addresses; } + + public int getIndex() { + Transaction transaction = (Transaction)parent; + return transaction.getOutputs().indexOf(this); + } }