2

Is this possible to do?

I am trying to create a transaction with 1 input that will have 3 outputs.

I tried:

bitcoin-cli createrawtransaction "[{\"txid\":\"b0d6607323d5dadcd67dd1b5b6d6e5f08b70c45d187c8cf17ebfa00f9c0fb65e\",\"vout\":1}]" "[{\"2Mxmxo19LaqUePqkshcYQDzwW8SY6CpxzjN\":0.00989748, \"2N1ozs19uHsk2maPA5PiK8TEZQP8HfTd4Zn\":0.23247816, \"2NDgJmx7PykJRMK4QKTqUrfC6ewmccaq6fq\":0.0001}]"

But get an error:

error code: -8
error message:
Invalid parameter, key-value pair must contain exactly one key

I don't understand what I'm doing wrong since the inputs and outputs both take in an array of values.

Any ideas?

This is version 0.17.0.

Here's the pretty print json

I'm pretty confident that there is no syntax issue.

"[
    {
        \"txid\":   \"b0d6607323d5dadcd67dd1b5b6d6e5f08b70c45d187c8cf17ebfa00f9c0fb65e\",
        \"vout\":   1
    }
]" 
"[
    {
        \"2Mxmxo19LaqUePqkshcYQDzwW8SY6CpxzjN\":    0.00989748, 
        \"2N1ozs19uHsk2maPA5PiK8TEZQP8HfTd4Zn\":    0.23247816, 
        \"2NDgJmx7PykJRMK4QKTqUrfC6ewmccaq6fq\":    0.0001
    }
]"
mocode10
  • 135
  • 4

1 Answers1

2

You need to use (simplified notation) [{addr:amount},{addr:amount}] for the outputs, not [{addr:amount,addr:amount}]. This is to permit multiple outputs with the same address (which wouldn't be valid JSON in your assumed syntax).

A simpler alternative also exists, namely {addr:amount,addr:amount}.

Pieter Wuille
  • 98,249
  • 9
  • 183
  • 287