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}]
[{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}]] }
  • I don’t have first-hand knowledge on the syntax of this call, but my suspicion would be that it doesn’t know what to do with the "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}]
    – Murch
    Commented Oct 25, 2023 at 17:51
  • 1
    That gives me the same result. The documentation also says: 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.
    – Zephyrus
    Commented Oct 25, 2023 at 17:55

1 Answer 1


I finally got this to work. Apparently, the entire outputs array has to be passed as a string with quotes escaped. So the request on the command line would look like this:

lightning-cli --conf=./cln.conf txprepare "[{\"bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\":\"50000sat\"}]"

However, for anyone else interested in sending on-chain funds from CLN, there is a single command you can use that is a lot easier. It is called withdraw and it is called like this:

lightning-cli --conf=./cln.conf withdraw bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50000

That command will send 50000 sats from the on-chain wallet to the address bcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. There are also a few optional parameters described in the withdraw documentation.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.