The payjoin psbt construction code reintroduces original psbt inputs that the receiver may have lost. It does this by iterating through each proposed input and original input.
This fix only iterates to the next original_input once a proposed input that matches is found, otherwise inputs could be skipped and signing could fail. The outer loop already iterates through proposed inputs. Inputs in the proposal are in the same order as the original as per spec, and just insert receiver inputs so this iteration will always find matches.
The payjoin psbt construction code reintroduces original psbt inputs that the receiver may have lost. It does this by iterating through each proposed input and original input.
This fix only iterates to the next original_input once a proposed input that matches is found, otherwise inputs could be skipped and signing could fail. The outer loop already iterates through proposed inputs. Inputs in the proposal are in the same order as the original as per spec, and just insert receiver inputs so this iteration will always find matches.