I have a technical question regarding the signrawtransaction function in Bitcoin core when signing a partially-signed transaction.
I have tested different scenarios and signrawtransaction will always sort the signatures in the correct way in the scriptSig, regardless of the order the transaction is signed one-by-one.
Is this achieved by analyzing the scriptSig of the partially-signed transaction when signing, and then verifying each signature in the partially-signed transactions scriptSig against all public keys in the redeemscript and finally ordering them correctly? Or is there a better way of doing this?
Unfortunately I don't understand how this is done by reading the C-code of bitcoin core.