What this code is supposed to do:-
From the decoded raw transaction(s) found in the vin section of a decoded raw transaction I just received, I scrape every vout address and put them in a list.
I then remove addresses if identical to my company address or any address in my wallet.
vins = decoderawtransaction(getrawtransaction(input_transaction_hash, verbose=False))['vin']
vin_lst = []
c = 0
while c < len(vins):
vin_lst.append(vins[c]['txid'])
c += 1
vout_lst = []
for i in vin_lst:
vouts = decoderawtransaction(getrawtransaction(i, verbose=False))['vout']
c = 0
while c < len(vouts):
v = vouts[c]['scriptPubKey']['addresses'][0]
if v != input_address and v not in getaddressesbyaccount('customer'):
vout_lst.append(v)
c += 1
return_address = vout_lst[0]
Sometimes though the return address derived sends the funds to my wallet for some reason I don't understand.
It may be worth mentioning that i have been sending the funds between only two wallets during testing and wonder if this could be a possible reason?
I am using two instances of bitcoind each in a virtual machine.