Currently we loop over transaction inputs within a loop over transaction inputs - ouch. Cache the `use_segwit_serialization` outside the iteration loop. Fix: #2357