sendmany with alternating asset input produces invalid tx #801
Description
Current behavior
with sendmany
you can create multiple transfers in a single tx. In a very specific scenario a tx is created that is not accepted by the network. I've done the following tests
# of tx | description
2 | gas to 2 different addresses success
2 | neo to 2 different addresses success
2 | neo & gas to same address success
4 | neo to 4 diferent addresses success
4 | gas to 4 different addresses success
4 | neo to address_a, neo to address_b, gas to address_a, gas to address_b success
4 | 1x neo + gas to address_a, 1 x neo_gas + address b fail
4 | neo/gas/neo/gas to 4 different addresses fail
3 | neo to address_a, gas to address_a, neo to address_b fail
3 | gas to address_a, neo to _address_a, gas to address_b fail
From these tests I was able to conclude that whenever we switch between neo/gas/neo or gas/neo/gas we end up calculating the wrong return value for the output that holds the "change funds". To eleborate; in a neo->gas->neo scenario, the first neo vout
is not taken into account when calculating the change. So only neo vout
2 is deduced from the vin
. This leads to the tx asking to return more funds as change than actually available.
Expected behavior
the correct return value should be calculated resulting in a valid tx.
How to reproduce
see the table above.
Your environment
Let us know in what environment you're running into the issue:
- OS: osx mojave
- neo-python version: 0.8.3-dev
- Python version: 3.6