Cannot import descriptors with label and internal:false #32376

issue gmart7t2 openend this issue on April 29, 2025
  1. gmart7t2 commented at 12:38 pm on April 29, 2025: none

    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

  2. laanwj added the label Wallet on Apr 29, 2025
  3. furszy commented at 2:17 pm on April 29, 2025: member
    The fix looks correct (could also use value_or(false) to shorten it). Remember to add a test case when you push it.
  4. achow101 commented at 5:05 pm on April 29, 2025: member
  5. bitcoin deleted a comment on Apr 30, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-05 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me