<p>I figured it out, just need a comma after the descriptor param.</p>

<p><code>let descriptor = "\"wpkh(xpub6Dy2ikUu5mXbDdhw2vAP1C4eiQM8rTz1NiWQt2BzGi83iHC2gEgTSD54JveyuHF9VLAqNkCGnee1jdBL7nA3JNorbqjSSS8DEV6Hn3PuNBt/*)#mn5jvyc3\""</code></p>

<pre><code>    let command = "curl --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"deriveaddresses\", \"params\":[\(descriptor), 99] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8332/"

    var error: NSError?

    let queue = DispatchQueue(label: "com.FullyNoded.getInitialNodeConnection")
    queue.async {

        if let responseString = self.ssh.session?.channel.execute(command, error: &amp;error) {

            guard let responseData = responseString.data(using: .utf8) else { return }

            do {

                let json = try JSONSerialization.jsonObject(with: responseData, options: [.allowFragments]) as Any

                print("json = \(json)")

            } catch {


            }

        }

    }`
</code></pre>

CC BY-SA 4.0
2019-05-08T17:36:09.360Z
2019-05-08T17:36:09.360Z
Fontaine
<p>I am trying to use curl via SSH to utilize the deriveaddresses bitcoin-cli rpc command.</p>

<p><code>let descriptor = "wpkh(xpub6Dy2ikUu5mXbDdhw2vAP1C4eiQM8rTz1NiWQt2BzGi83iHC2gEgTSD54JveyuHF9VLAqNkCGnee1jdBL7nA3JNorbqjSSS8DEV6Hn3PuNBt/*)#mn5jvyc3"</code></p>

<pre><code>    let command = "curl --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"deriveaddresses\", \"params\": [\"\(descriptor)\" 99] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8332/"

    var error: NSError?

    let queue = DispatchQueue(label: "com.app.getInitialNodeConnection")
    queue.async {

        if let responseString = self.ssh.session?.channel.execute(command, error: &amp;error) {

            guard let responseData = responseString.data(using: .utf8) else { return }

            do {

                let json = try JSONSerialization.jsonObject(with: responseData, options: [.allowFragments]) as Any

                print("json = \(json)")

            } catch {


            }

        }

    }`
</code></pre>

<p>I get the following error:</p>

<p><code>json = {
    error =     {
        code = "-32700";
        message = "Parse error";
    };
    id = "&lt;null&gt;";
    result = "&lt;null&gt;";
}</code></p>

<p>Is it not working because I need to escape special characters in the descriptor?</p>

<json-rpc><bitcoin-cli><command-line-options>
How to use deriveaddresses via a curl command
Fontaine
# How to use deriveaddresses via a curl command

(Asked by: username_0 on 2019-05-08)

I am trying to use curl via SSH to utilize the deriveaddresses bitcoin-cli rpc command.

`let descriptor = "wpkh(xpub6Dy2ikUu5mXbDdhw2vAP1C4eiQM8rTz1NiWQt2BzGi83iHC2gEgTSD54JveyuHF9VLAqNkCGnee1jdBL7nA3JNorbqjSSS8DEV6Hn3PuNBt/*)#mn5jvyc3"`

```
    let command = "curl --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"deriveaddresses\", \"params\": [\"\(descriptor)\" 99] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8332/"

    var error: NSError?

    let queue = DispatchQueue(label: "com.app.getInitialNodeConnection")
    queue.async {

        if let responseString = self.ssh.session?.channel.execute(command, error: &error) {

            guard let responseData = responseString.data(using: .utf8) else { return }

            do {

                let json = try JSONSerialization.jsonObject(with: responseData, options: [.allowFragments]) as Any

                print("json = \(json)")

            } catch {

            }

        }

    }`

```

I get the following error:

`json = {
error = {
code = "-32700";
message = "Parse error";
};
id = "<null>";
result = "<null>";
}`

Is it not working because I need to escape special characters in the descriptor?

**Tags:** json-rpc, bitcoin-cli, command-line-options


---

## 1 answers

### Answer by username_0 on 2019-05-08. Score: 1

I figured it out, just need a comma after the descriptor param.

`let descriptor = "\"wpkh(xpub6Dy2ikUu5mXbDdhw2vAP1C4eiQM8rTz1NiWQt2BzGi83iHC2gEgTSD54JveyuHF9VLAqNkCGnee1jdBL7nA3JNorbqjSSS8DEV6Hn3PuNBt/*)#mn5jvyc3\""`

```
    let command = "curl --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"deriveaddresses\", \"params\":[\(descriptor), 99] }' -H 'content-type: text/plain;' http://user:password@127.0.0.1:8332/"

    var error: NSError?

    let queue = DispatchQueue(label: "com.FullyNoded.getInitialNodeConnection")
    queue.async {

        if let responseString = self.ssh.session?.channel.execute(command, error: &error) {

            guard let responseData = responseString.data(using: .utf8) else { return }

            do {

                let json = try JSONSerialization.jsonObject(with: responseData, options: [.allowFragments]) as Any

                print("json = \(json)")

            } catch {

            }

        }

    }`

```


---

