public Coin getFee ( ) { Coin fee = Coin . ZERO ; if ( inputs . isEmpty ( ) || outputs . isEmpty ( ) ) // Incomplete transaction return null ; for ( TransactionInput input : inputs ) { if ( input . getValue ( ) == null ) return null ; fee = fee . add ( input . getValue ( ) ) ; } for ( TransactionOutput output : outputs ) { fee = fee . subtract ( output . getValue ( ) ) ; } return fee ; }
The transaction fee is the difference of the value of all inputs and the value of all outputs . Currently the fee can only be determined for transactions created by us .