If the concern is that the addition with other fees is not done within the function, as documented the caller can set the in/out argument to zero before calling. I could also always return only the value for the single transaction without accumulating anything (although I don’t see the gain, it’s just more code), at that point the argument would be out only, not in/out.
From there, to return the output argument as a tuple or pair I think it’s just making things uglier and unnecessarily complicated.
instead of:
0CAmount tx_fee = 0; // You will initialize the variable even if the function starts setting it to zero
1if (!CheckTxInputs(..., tx_fee))
2 return false;
3accumulated_fee += tx_fee;
You would have something like:
0struct CheckTxInputsReturn
1{
2 bool fValid;
3 CAmount tx_fee;
4}
5
6CheckTxInputsReturn ret = CheckTxInputs(...);
7if (!ret.fValid)
8 return false;
9accumulated_fee += ret.tx_fee;
I think that’s incredibly ugly. Specially since I don’t see the problem with how it is currently used when you don’t want to accumulate any fees:
0CAmount tx_fee = 0;
1if (!CheckTxInputs(..., tx_fee))
2 return false;
Please, I invite you to write your suggestions on top of this and see for yourselves that they are not an improvement but actually the contrary.
If people agree that those IMO much uglier solutions are better, I will squash your suggestions, no problem.