{"success" : false}
in addpeeraddress
for an empty or invalid IP. This changes it to throw RPC_CLIENT_INVALID_IP_OR_SUBNET
with the error message Invalid IP address
. Tests updated to match.
{"success" : false}
in addpeeraddress
for an empty or invalid IP. This changes it to throw RPC_CLIENT_INVALID_IP_OR_SUBNET
with the error message Invalid IP address
. Tests updated to match.
Throw RPC_CLIENT_INVALID_IP_OR_SUBNET when LookupHost(addr, false) fails
in addpeeraddress. This aligns with setban/addconnection and avoids the
opaque {"success": false} result for input errors. The JSON {success,
error?} object remains for addrman outcomes only. Update test to match.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33430.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | vasild, sipa, pablomartin4btc, achow101 |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
ACK 316a0c513278d53cb25f42ea502d20691962aad6
As an alternative, we could use the error
field in the response instead of throwing an exception. The error
field is currently not set in master
if an invalid IP address is provided.
tACK 316a0c513278d53cb25f42ea502d20691962aad6
master:
0./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc addpeeraddress "" 8883
1{
2 "success": false
3}
This branch:
0./build/bin/bitcoin-cli -regtest -datadir=/tmp/btc addpeeraddress "" 8883
1error code: -30
2error message:
3Invalid IP address
I agree with @vasild with the suggested alternative, not strong opinion.
Would it be useful for the user to differentiate from an empty address vs a provided invalid IP (which obviously includes an empty value) in the error message?
Thanks, all! @vasild
As an alternative, we could use the
error
field in the response instead of throwing an exception.
I tried to use the same pattern as setban
does, which I think has a clean boundary between an invalid input and a problem that occurred despite valid input. To me, that category separation makes sense.
@pablomartin4btc
Would it be useful for the user to differentiate from an empty address vs a provided invalid IP (which obviously includes an empty value) in the error message?
My gut says it’s probably overkill, but I’m certainly happy to change it if others disagree.