MCPcopy
hub / github.com/jimmysong/programmingbitcoin / fee

Method fee

code-ch08/tx.py:149–160  ·  view source on GitHub ↗

Returns the fee of this transaction in satoshi

(self)

Source from the content-addressed store, hash-verified

147 return result
148
149 def fee(self):
150 '''Returns the fee of this transaction in satoshi'''
151 # initialize input sum and output sum
152 input_sum, output_sum = 0, 0
153 # use TxIn.value() to sum up the input amounts
154 for tx_in in self.tx_ins:
155 input_sum += tx_in.value(self.testnet)
156 # use TxOut.amount to sum up the output amounts
157 for tx_out in self.tx_outs:
158 output_sum += tx_out.amount
159 # fee is input sum - output sum
160 return input_sum - output_sum
161
162 def sig_hash(self, input_index, redeem_script=None):
163 '''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