Tx inputs and outputs can find their index

This commit is contained in:
Craig Raw 2020-03-22 10:21:32 +02:00
parent 0340f06de4
commit 566aa2e953
2 changed files with 10 additions and 0 deletions

View file

@ -82,6 +82,11 @@ public class TransactionInput extends TransactionPart {
this.sequence = sequence; 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. * Coinbase transactions have special inputs with hashes of zero. If this is such an input, returns true.
*/ */

View file

@ -77,4 +77,9 @@ public class TransactionOutput extends TransactionPart {
public void setAddresses(Address[] addresses) { public void setAddresses(Address[] addresses) {
this.addresses = addresses; this.addresses = addresses;
} }
public int getIndex() {
Transaction transaction = (Transaction)parent;
return transaction.getOutputs().indexOf(this);
}
} }