#NEWLINE# def get_input_value( tx_hex ) : #NEWLINE# #INDENT# unspents = wallet . list_unspent ( ) #NEWLINE# ctx = bitcoinlib . core . CTransaction . deserialize ( binascii . unhexlify ( tx_hex ) ) #NEWLINE# inputs_value = 0 #NEWLINE# for vin in ctx . vin : #NEWLINE# #INDENT# vin_tx_hash = ib2h ( vin . prevout . hash ) #NEWLINE# vout_n = vin . prevout . n #NEWLINE# found = False #NEWLINE# for output in unspents : #NEWLINE# #INDENT# if ( ( output [ 'txid' ] == vin_tx_hash ) and ( output [ 'vout' ] == vout_n ) ) : #NEWLINE# #INDENT# inputs_value += int ( ( output [ 'amount' ] * config . UNIT ) ) #NEWLINE# found = True #NEWLINE# #UNINDENT# #UNINDENT# if ( not found ) : #NEWLINE# #INDENT# raise exceptions . TransactionError ( 'input not found in wallet list unspents' ) #NEWLINE# #UNINDENT# #UNINDENT# return inputs_value