<p>The issue is that your hardened paths use the single quote notation which breaks the single quoting that surrounds the entire import command. You will need to escape those properly, and <code>\'</code> is not the way to do that. Instead, for every single quote within your import command, you need to do <code>'"'"'</code> - an explanation for why can be found <a href="https://stackoverflow.com/a/1250279">here</a>.</p>

<p>Alternatively, you can change those single quotes to <code>h</code>, but once you do so, you will need to recompute the descriptor checksum. But iff you give such a descriptor to <code>getdescriptorinfo</code> it will give you back the descriptor with single quotes (there is a <a href="https://github.com/bitcoin/bitcoin/pull/15986" rel="nofollow noreferrer">pull request</a> open to fix this) so you will need to use an external checksum tool to do this. I have a <a href="https://github.com/achow101/output-descriptors/blob/master/checksum.py" rel="nofollow noreferrer">python script</a> which can do this.</p>

<p>Running your descriptor with <code>h</code> instead of <code>'</code> through that script, I get:</p>

<pre><code>wpkh([18734cbe/84h/0h/0h]xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#rxk7wl9c
</code></pre>

CC BY-SA 4.0
2019-06-22T01:52:46.693Z
amazing, thank you yet again. Editing OP to show working code for anyone else who is trying
Fontaine
CC BY-SA 4.0
2019-06-21T13:58:48.750Z
2019-06-21T13:58:48.750Z
Ava Chow
<p>I have been trying to test importmulti with BIP84 derivation like so:</p>

<pre><code>bitcoin-cli -rpcwallet=BIP84Test importmulti '[{ "desc": "wpkh([18734cbe/84'/0'/0']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#shfp59jm", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'
</code></pre>

<p>But I always get an error:</p>

<pre><code>-bash: syntax error near unexpected token `)'
</code></pre>

<p>I have tried replacing <code>[18734cbe/84'/0'/0']</code> with <code>[18734cbe/84h/0h/0h]</code></p>

<p>and <code>[18734cbe/84\'/0\'/0\']</code></p>

<p>But it all returns errors. Is there anything obvious I am doing wrong? </p>

<p>I get the descriptor from <code>getdescriptorinfo</code></p>

<p>EDIT:</p>

<p>Here is the fix which is working:</p>

<p>First get the descriptor using <code>getdescriptorinfo</code> then:</p>

<pre><code>var descriptor = "\"\(result["descriptor"] as! String)\""

                descriptor = descriptor.replacingOccurrences(of: "4'", with: "4'\"'\"'")
                descriptor = descriptor.replacingOccurrences(of: "0'", with: "0'\"'\"'")

</code></pre>

<pre><code>bitcoin-cli -rpcwallet=NewTest importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/0'"'"'/0'"'"']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#jun2ynxt", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
        {
        success = 1;
    }
)
</code></pre>

<p>Very hacky but it works :)</p>

<bitcoin-core><json-rpc><bitcoin-cli>
importmulti with BIP84 derivation always fails
Fontaine
# importmulti with BIP84 derivation always fails

(Asked by: username_0 on 2019-06-21)

I have been trying to test importmulti with BIP84 derivation like so:
bitcoin-cli -rpcwallet=BIP84Test importmulti '[{ "desc": "wpkh([18734cbe/84'/0'/0']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#shfp59jm", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'

But I always get an error:
-bash: syntax error near unexpected token `)'

I have tried replacing [18734cbe/84'/0'/0'] with [18734cbe/84h/0h/0h]
and [18734cbe/84\'/0\'/0\']
But it all returns errors. Is there anything obvious I am doing wrong? 
I get the descriptor from getdescriptorinfo
EDIT:
Here is the fix which is working:
First get the descriptor using getdescriptorinfo then:
var descriptor = "\"\(result["descriptor"] as! String)\""

                descriptor = descriptor.replacingOccurrences(of: "4'", with: "4'\"'\"'")
                descriptor = descriptor.replacingOccurrences(of: "0'", with: "0'\"'\"'")


bitcoin-cli -rpcwallet=NewTest importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/0'"'"'/0'"'"']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#jun2ynxt", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
        {
        success = 1;
    }
)

Very hacky but it works :)

**Tags:** bitcoin-core, json-rpc, bitcoin-cli


---

## 1 answers

### Answer by username_1 on 2019-06-21. Score: 3 | Accepted answer

The issue is that your hardened paths use the single quote notation which breaks the single quoting that surrounds the entire import command. You will need to escape those properly, and \' is not the way to do that. Instead, for every single quote within your import command, you need to do '"'"' - an explanation for why can be found here.
Alternatively, you can change those single quotes to h, but once you do so, you will need to recompute the descriptor checksum. But iff you give such a descriptor to getdescriptorinfo it will give you back the descriptor with single quotes (there is a pull request open to fix this) so you will need to use an external checksum tool to do this. I have a python script which can do this.
Running your descriptor with h instead of ' through that script, I get:
wpkh([18734cbe/84h/0h/0h]xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#rxk7wl9c

> **Comments:**
> **username_0**: amazing, thank you yet again. Editing OP to show working code for anyone else who is trying  

---

