3307 | @@ -3310,7 +3308,7 @@ static const CRPCCommand commands[] =
3308 | { "wallet", "addmultisigaddress", &addmultisigaddress, {"nrequired","keys","account"} },
3309 | { "wallet", "addwitnessaddress", &addwitnessaddress, {"address","p2sh"} },
3310 | { "wallet", "backupwallet", &backupwallet, {"destination"} },
3311 | - { "wallet", "bumpfee", &bumpfee, {"txid", "options"} },
3312 | + { "wallet", "bumpfee", &bumpfee, {"txid", "options"}, true },
There's no need to have this new "named_args" bool field. Univalue's array access operator explicitly works on object values as well as array values:
https://github.com/bitcoin/bitcoin/blob/99bc0b428b03b571afbc311b7f18fd3a707ac5af/src/univalue/lib/univalue.cpp#L211-L219
So instead of introducing different flavors of RPC functions where some receive array params and others receive object params, every RPC function could just receive the same params, and choose to access arguments by name or position, whichever is more convenient. Implementing this would also simplify transformNamedArguments which could get rid of the "hole-filling" logic no longer needed after #11050.
Hmm, interesting thought. It feels a bit too much like relying on undefined behaviour to me. It's also probably complicated to implement properly - so before I put a bunch of effort into that: What do others think?
Considering the bool is only temporary anyway (I can complete the conversion in a single PR?), is this worth it?
Considering the bool is only temporary anyway (I can complete the conversion in a single PR?), is this worth it?
Oh, I would say definitely not worth it if you are planning on getting rid of positional accesses entirely (and deleting transformNamedArguments).
It feels a bit too much like relying on undefined behaviour to me.
I can see how this "feels" like relying on undefined behavior, but of course it is not really. It is just relying on univalue behavior that's outside the realm on the json spec. In some cases where we do this (e.g. interpretation of numeric values, not distinguishing between undefined and null values) this isn't great because it can lead to incompatibility with client json libraries. But in this case we're just talking about passing params from our internal rpc framework to our internal rpc method implementations, so using univalue to pass on position metadata should not be a big deal. Again, though not worth it if you are planning on getting rid of positional accesses.