This is a bugfix follow-up to D14472.
tx.inputs() now builds the coin dicts on demand, and changing the returned coin dicts no longer affects the transaction in any way. The code needs to operate on tx.txinputs() which returns a list of references to the actual coin stored in the transaction.