lightning-txprepare

lightning-txprepare -- Command to prepare to withdraw funds from the internal wallet

SYNOPSIS

txprepare outputs [feerate] [minconf] [utxos]

DESCRIPTION

The txprepare RPC command creates an unsigned transaction which spends funds from Core Lightning's internal wallet to the outputs specified in outputs.

txprepare is similar to the first part of a withdraw command, but supports multiple outputs and uses outputs as parameter. The second part is provided by txsend.

  • outputs (array of outputdescs): Format is like: [{destination1: amount1}, {destination2: amount2}] or [{destination: all}]. It supports any number of confirmed outputs.:
    • (outputdesc, optional)
  • feerate (feerate, optional): Used for the transaction as initial feerate. The default is normal.
  • minconf (u32, optional): The minimum number of confirmations that used outputs should have. The default is 1.
  • utxos (array of outpoints, optional): To be used to fund the transaction, as an array of txid:vout. These must be drawn from the node's available UTXO set.:
    • (outpoint, optional)

RETURN VALUE

On success, an object is returned, containing:

  • psbt (string): The PSBT representing the unsigned transaction.
  • unsigned_tx (hex): The unsigned transaction.
  • txid (txid): The transaction id of unsigned_tx; you hand this to lightning-txsend(7) or lightning-txdiscard(7), as the inputs of this transaction are reserved.

ERRORS

On failure, an error is reported and the transaction is not created.

  • -1: Catchall nonspecific error.
  • 301: There are not enough funds in the internal wallet (including fees) to create the transaction.
  • 302: The dust limit is not met.

AUTHOR

Rusty Russell <[email protected]> is mainly responsible.

SEE ALSO

lightning-withdraw(7), lightning-txsend(7), lightning-txdiscard(7), lightning-feerates(7)

RESOURCES

Main web site: https://github.com/ElementsProject/lightning

EXAMPLES

Example 1:

Request:

lightning-cli txprepare "[{'bcrt1p0002020202020202020202020202020202020202020202020202020202': 16777216}]"
{
  "id": "example:txprepare#1",
  "method": "txprepare",
  "params": [
    [
      {
        "bcrt1p0002020202020202020202020202020202020202020202020202020202": 16777216
      }
    ]
  ]
}

Response:

{
  "unsigned_tx": "0200000000000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006000600060006",
  "txid": "txidtxprep000100001000010000100001000010000100001000010000100001",
  "psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000101000"
}

Example 2:

Request:

lightning-cli txprepare -k "outputs"='[{"bcrt1p0003030303030303030303030303030303030303030303030303030303": 16777216}]'
{
  "id": "example:txprepare#2",
  "method": "txprepare",
  "params": {
    "outputs": [
      {
        "bcrt1p0003030303030303030303030303030303030303030303030303030303": 16777216
      }
    ]
  }
}

Response:

{
  "unsigned_tx": "0200000000000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002000200020002",
  "txid": "txidtxprep000200002000020000200002000020000200002000020000200002",
  "psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000201000"
}

Core Lightning (previously c-lightning) is a lightweight, highly customizable and standard compliant implementation of the Lightning Network protocol.

© 2023 Core Lightning
All rights reserved.

Discussion Forum

The official Core Lightning forum is hosted at discuss.corelightning.org

BuildonL2 Community

The official BuildOnL2 community lives at community.corelightning.org. Join us and build the future of bitcoin on lightning.

Mailing List

For general discussions about CLN implementation, use [email protected]. For the Lightning Network, use [email protected]

Telegram

Community-driven telegram group where most of the node operators hang out. Go to https://t.me/lightningd to join.

Discord

Community-driven discord server where the devs flock together. Go to https://discord.gg/w27fMFESMN to join.

Internet Relay Chat

Don't hesitate to reach out to us on IRC at #lightning-dev @ libera.chat, #c-lightning @ libera.chat.