MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / fee

Method fee

code-ch13/tx.py:201–212  ·  view source on GitHub ↗

Returns the fee of this transaction in satoshi

(self)

Source from the content-addressed store, hash-verified

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

Callers 2

verifyMethod · 0.95
test_feeMethod · 0.45

Calls 1

valueMethod · 0.45

Tested by 1

test_feeMethod · 0.36