0

Copied the body part from https://bitcoincore.org/en/doc/0.21.0/rpc/wallet/addmultisigaddress/ and replaced addresses with 2 new addresses (regtest):

POST / HTTP/1.1
Host: localhost:18333
Authorization: Basic YmFzZTY0dXNlcjpiYXNlNjRwYXNz
Content-Type: text/plain
Content-Length: 186

{"jsonrpc": "1.0", "id": "curltest", "method": "addmultisigaddress", "params": [2, "[\"bcrt1qvtp07jfnk5wcslr6xjmntnkxchzt7j2rzswnqn\",\"bcrt1qzwpuwrykaacx7057tnafyrd4nnfecc602gptca\"]"]}

Error:

{
    "result": null,
    "error": {
        "code": -1,
        "message": "JSON value is not an array as expected"
    },
    "id": "curltest"
}
5
  • 1
    You don't need the backslashes. Those are to prevent the shell from interpreting the " characters, but you're not entering this in a shell. Commented Jul 29, 2021 at 23:49
  • If I remove those I get a different error: "code": -32700, "message": "Parse error"
    – user103136
    Commented Jul 29, 2021 at 23:55
  • I suspect you're making yourself hard by trying to play shell yourself. JSON isn't very complicated: json.org/json-en.html Commented Jul 29, 2021 at 23:58
  • 1
    Oh, I see. You also have the remove the unquoted ". Commented Jul 30, 2021 at 0:01
  • That resolved the issue. Thanks :)
    – user103136
    Commented Jul 30, 2021 at 0:37

1 Answer 1

1

I was doing 2 things wrong:

  1. backslash \ is used in shell
  2. Extra quotes had to be removed

Thanks Pieter Wuille for the help.

Below request works fine:

POST / HTTP/1.1
Host: localhost:18333
Authorization: Basic YmFzZTY0dXNlcjpiYXNlNjRwYXNz
Content-Type: text/plain
Content-Length: 180

{"jsonrpc": "1.0", "id": "curltest", "method": "addmultisigaddress", "params": [2, ["bcrt1qvtp07jfnk5wcslr6xjmntnkxchzt7j2rzswnqn","bcrt1qzwpuwrykaacx7057tnafyrd4nnfecc602gptca"]]}

Response:

{
    "result": {
        "address": "bcrt1q5pza3z8vmt29xv2kyw9nvd30t0sgrfnzv55s6g9q22df4pkqp65qtuf0nn",
        "redeemScript": "5221024b72aac0b3a6dab576b344fa36384d39e95c0bc05f4e6ddf6567b581c50031712103e38d84ad58ddc696ee67e08ebec0df5931ce729fdd234acb50a2ed6785a9badc52ae",
        "descriptor": "wsh(multi(2,[7aabbdcc/0'/0'/16']024b72aac0b3a6dab576b344fa36384d39e95c0bc05f4e6ddf6567b581c5003171,[7aabbdcc/0'/0'/17']03e38d84ad58ddc696ee67e08ebec0df5931ce729fdd234acb50a2ed6785a9badc))#yg7pyr0r"
    },
    "error": null,
    "id": "curltest"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.