Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
0$ bitcoin-cli importdescriptors '[{"desc":"addr(bcrt1pm2kch7zv4tuc203tfv97yhfck3z456656u3852m03zfl8x2hnnpqw0jzka)#0ygsck2x","timestamp":"now","internal":false,"label":"l"}]'
1[
2 {
3 "success": false,
4 "error": {
5 "code": -8,
6 "message": "Internal addresses should not have a label"
7 }
8 }
9]
Expected behaviour
Setting internal:false should not be interpreted as internal.
The problem is that internal
is a std:optional but it is treated like a bool.
This fixes it:
0diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
1index ac23b092d4..2c2f90002e 100644
2--- a/src/wallet/rpc/backup.cpp
3+++ b/src/wallet/rpc/backup.cpp
4@@ -1522,7 +1522,7 @@ static UniValue ProcessDescriptorImport(CWallet& wallet, const UniValue& data, c
5 }
6
7 // Internal addresses should not have a label either
8- if (internal && data.exists("label")) {
9+ if (internal.has_value() && internal.value() && data.exists("label")) {
10 throw JSONRPCError(RPC_INVALID_PARAMETER, "Internal addresses should not have a label");
11 }
Steps to reproduce
As above
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
V29.0.0
Operating system and version
Any
Machine specifications
No response