CLN 23.02.2
I'm trying to send an on-chain transaction from a CLN node. It requires two calls from the command line client, one to txprepare
and the other to txsend
. But I can't get txprepare to work.
The documentation for txprepare says:
txprepare outputs [feerate] [minconf] [utxos]
The outputs is the array of output that include destination
and amount({destination: amount}). Its format is like:
[{address1: amount1}, {address2: amount2}]
or
[{address: all}].
How do I format the outputs parameter?
I tried a JSON object, like this:
lightning-cli --conf=./cln.conf txprepare {"outputs":[{"bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx":"50000sat"}]}
I also tried just the array, like this:
lightning-cli --conf=./cln.conf txprepare [{"bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx":"50000sat"}]
I tried a few other formats too. In all cases, I get a response telling me my parameters are malformed.
lightning-cli: Some parameters are malformed, cannot create a valid JSON-RPC request: { "jsonrpc" : "2.0", "method" : "txprepare", "id" : "cli:txprepare#404389", "params" :[ [{bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx:50000sat}]] }
"50000sat"
. Presumably, an amount would just be a plain number. Have you tried dropping the "sat" (and possibly the quotation marks on the number)?lightning-cli txprepare [{"bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx":"50000sat"}]
↦lightning-cli txprepare [{"bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx":50000}]
The amount of output is the amount to be sent from the internal wallet (expressed, as name suggests, in amount). The string all can be used to specify all available funds. Otherwise, it is in amount precision; it can be a whole number, a whole number ending in sat, a whole number ending in 000msat, or a number with 1 to 8 decimal places ending in btc.