Returns the fee of this transaction in satoshi
(self)
| 199 | # end::source4[] |
| 200 | |
| 201 | def fee(self): |
| 202 | '''Returns the fee of this transaction in satoshi''' |
| 203 | # initialize input sum and output sum |
| 204 | input_sum, output_sum = 0, 0 |
| 205 | # use TxIn.value() to sum up the input amounts |
| 206 | for tx_in in self.tx_ins: |
| 207 | input_sum += tx_in.value(self.testnet) |
| 208 | # use TxOut.amount to sum up the output amounts |
| 209 | for tx_out in self.tx_outs: |
| 210 | output_sum += tx_out.amount |
| 211 | # fee is input sum - output sum |
| 212 | return input_sum - output_sum |
| 213 | |
| 214 | def sig_hash(self, input_index, redeem_script=None): |
| 215 | '''Returns the integer representation of the hash that needs to get |