LIGHTNING-FUNDPSBT(7)
π LIGHTNING-FUNDPSBT(7) β fundpsbt π
manual name: LIGHTNING-FUNDPSBT(7) Β· command: fundpsbt Β· group-chat mode: on π
π NAME π
fundpsbt β Command to populate PSBT inputs from the wallet
β¨ SYNOPSIS β¨
fundpsbt satoshi feerate startweight [minconf] [reserve] [locktime]
[min_witness_weight] [excess_as_change] [nonwrapped]
[opening_anchor_channel]
π«Ά DESCRIPTION π«Ά
okay so fundpsbt is a low-level RPC command that creates a PSBT using unreserved inputs in the wallet, and it can optionally reserve them too. literally the wallet-to-PSBT pipeline, bestie π«Ά
satoshi(sat_or_all) β the minimum satoshi value of the output(s) needed, or the stringallmeaning use all unreserved inputs. If itβs a value, it can be a whole number, a whole number ending insat, a whole number ending in000msat, or a number with 1 to 8 decimal places ending inbtc.feerate(feerate) β used for the transaction as initial feerate. The default isnormal.startweight(u32) β the weight of the transaction beforefundpsbthas added any inputs.minconf(u32, optional) β the minimum number of confirmations that used outputs should have. The default is1.reserve(u32, optional) β if not zero, thenreserveinputsis called (successfully, withexclusivetrue) on the returned PSBT for this number of blocks. The default is72blocks.locktime(u32, optional) β the locktime of the transaction. if not set, it is set to a recent block height.min_witness_weight(u32, optional) β minimum weight to use for a UTXO's witness. If the actual witness weight is greater than the provided minimum, the actual witness weight will be used.excess_as_change(boolean, optional) β flag to add a change output for the excess sats.nonwrapped(boolean, optional) β to signal to filter out anyp2sh-wrappedinputs from funding this PSBT. (added v23.02)opening_anchor_channel(boolean, optional) β to signal that it needs emergency reserve for anchors so that we can lowball our commitment tx fees, andmin-emergency-msatfor reserving some sats for closing anchor channels. (added v23.08)
πΈ RETURN VALUE πΈ
slay, on success an object is returned containing:
psbt(string) β unsigned PSBT which fulfills the parameters given.feerate_per_kw(u32) β the feerate used to create the PSBT, in satoshis-per-kiloweight.estimated_final_weight(u32) β the estimated weight of the transaction once fully signed.excess_msat(msat) β the amount abovesatoshiwhich is available. This could be zero, or dust; it will be zero ifchange_outnumis also returned.change_outnum(u32, optional) β the 0-based output number where change was placed (only if parameterexcess_as_changewas true and there was sufficient funds).reservations(array of objects, optional) β ifreservewas true or a non-zero number, just as perlightning-reserveinputs(7).:txid(txid) β the txid of the transaction.vout(u32) β the 0-based output number.was_reserved(boolean) (alwaysfalse) β whether this output was previously reserved.reserved(boolean) (alwaystrue) β whether this output is now reserved.reserved_to_block(u32) β the blockheight the reservation will expire.
If excess_as_change is true and the excess is enough to cover an additional output above the dust_limit, then an output is added to the PSBT for the excess amount. The excess_msat will be zero. A change_outnum will be returned with the index of the change output.
π ERRORS π
ngl, on error the returned object will contain code and message properties, with code being one of the following:
-32602: If the given parameters are wrong.-1: Catchall nonspecific error.301: Insufficient UTXOs to meetsatoshivalue.
π AUTHOR π
Rusty Russell rusty@rustcorp.com.au is mainly responsible. main character energy π
π SEE ALSO π
lightning-utxopsbt(7), lightning-reserveinputs(7), lightning-unreserveinputs(7)
π RESOURCES π
Main web site: https://github.com/ElementsProject/lightning
π§ USAGE π§
Let's assume the caller is trying to produce a 100,000 satoshi output. okay so, hereβs the vibe:
First, the caller estimates the weight of the core (typically 42) and known outputs of the transaction (typically (9 + scriptlen) * 4). For a simple P2WPKH it's a 22 byte scriptpubkey, so that's 124 weight.
It calls fundpsbt 100000sat slow 166, which succeeds, and returns the psbt and feerate_per_kw it used, the estimated_final_weight and any excess_msat.
If excess_msat is greater than the cost of adding a change output, the caller adds a change output randomly to position 0 or 1 in the PSBT. Say feerate_per_kw is 253, and the change output is a P2WPKH (weight 124), the cost is around 31 sats. With the dust limit disallowing payments below 546 satoshis, we would only create a change output if excess_msat was greater or equal to 31 + 546.
π EXAMPLES π
π Example 1:
Request:
$ lightning-cli fundpsbt -k "satoshi"=1000000 "feerate"="253perkw" "startweight"=250 "reserve"=0
{
"id": "example:fundpsbt#1",
"method": "fundpsbt",
"params": {
"satoshi": 1000000,
"feerate": "253perkw",
"startweight": 250,
"reserve": 0
}
}
Response:
{
"psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000310000",
"feerate_per_kw": 253,
"estimated_final_weight": 652,
"excess_msat": 196962518000,
"change_outnum": 0
}
π Example 2:
Request:
$ lightning-cli fundpsbt -k "satoshi"=500000 "feerate"="urgent" "startweight"=166 "reserve"=0 "excess_as_change"=True "min_witness_weight"=110
{
"id": "example:fundpsbt#2",
"method": "fundpsbt",
"params": {
"satoshi": 500000,
"feerate": "urgent",
"startweight": 166,
"reserve": 0,
"excess_as_change": true,
"min_witness_weight": 110
}
}
Response:
{
"psbt": "cHNidP8BAgQCAAAAAQMEbwAAAAEEAQpsbt410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000410000",
"feerate_per_kw": 11000,
"estimated_final_weight": 613,
"excess_msat": 0,
"change_outnum": 0
}
xoxo, Core Lightning v26.06.9 Β· LIGHTNING-FUNDPSBT(7) β source/version is right there, and the original footer didnβt list a date, so no invented date here, bestie π
π¦ where this page comes from
- nixpkgs unstable: clightning 26.06.9
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms