public int getIndex ( ) { List < TransactionOutput > outputs = getParentTransaction ( ) . getOutputs ( ) ; for ( int i = 0 ; i < outputs . size ( ) ; i ++ ) { if ( outputs . get ( i ) == this ) return i ; } throw new IllegalStateException ( "Output linked to wrong parent transaction?" ) ; }
Gets the index of this output in the parent transaction or throws if this output is free standing . Iterates over the parents list to discover this .