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:[email protected]: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?