Skip to content

Commit c307d1e

Browse files
committed
docs: document fundtemplate sub command, add release notes
1 parent 6dea39c commit c307d1e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

docs/psbt.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,44 @@ $ bitcoin-cli decodepsbt cHNidP8BAJoCAAAAAkiMdlxF3M20VpdnCMK0NOkEoETG6Aa4HpC8V
258258
}
259259
```
260260

261+
In newer versions of `lnd` (`v0.18.0-beta` and later), there is also the new
262+
`lncli wallet psbt fundtemplate` command that offers a few advantages over the
263+
previous `lncli wallet psbt fund` command:
264+
1. The `fundtemplate` sub command allows users to specify only some inputs, even
265+
if they aren't enough to pay for all the outputs. `lnd` will then select more
266+
inputs and calculate the change amount and fee correctly (whereas the `fund`
267+
command would return an error, complaining about not enough inputs being
268+
specified).
269+
2. The `fundtemplate` sub command allows users to specify that an existing
270+
output should be used for any left-over change after selecting coins.
271+
272+
Here's the above example with the new sub command, where we only specify one
273+
input:
274+
275+
```shell
276+
$ LOCK_ID=$(cat /dev/urandom | head -c32 | xxd -p -c999)
277+
$ lncli wallet leaseoutput --outpoint 3597b451ff56bc901eb806e8c644a004e934b4c208679756b4cddc455c768c48:1 \
278+
--lockid $LOCK_ID --expiry 600
279+
$ lncli wallet psbt fundtemplate --outputs='["bcrt1qjrdns4f5zwkv29ln86plqzs092yd5fg6nsz8re:50000000"]' \
280+
--inputs='["3597b451ff56bc901eb806e8c644a004e934b4c208679756b4cddc455c768c48:1"]'
281+
{
282+
"psbt": "cHNidP8BAJoCAAAAAkiMdlxF3M20VpdnCMK0NOkEoETG6Aa4HpC8Vv9RtJc1AQAAAAAAAAAA4lBjZUtG260qBBgVRqMQqmMV+XRTKubrHbc66YOl7/gBAAAAAAAAAAACgPD6AgAAAAAWABSQ2zhVNBOsxRfzPoPwCg8qiNolGtIkCAcAAAAAFgAUuvRP5r7qAvj0egDxyX9/FH+vukgAAAAAAAEA3gIAAAAAAQEr9IZcho/gV/6fH8C8P+yhNRZP+l3YuxsyatdYcS0S6AEAAAAA/v///wLI/8+yAAAAABYAFDXoRFwgXNO5VVtVq2WpaENh6blAAOH1BQAAAAAWABTcAR0NeNdDHb96kMnH5EVUcr1YwwJHMEQCIDqugtYLp4ebJAZvOdieshLi1lLuPl2tHQG4jM4ybwEGAiBeMpCkbHBmzYvljxb1JBQyVAMuoco0xIfi+5OQdHuXaAEhAnH96NhTW09X0npE983YBsHUoMPI4U4xBtHenpZVTEqpVwAAAAEBHwDh9QUAAAAAFgAU3AEdDXjXQx2/epDJx+RFVHK9WMMBAwQBAAAAAAEA6wIAAAAAAQFvGpeAR/0OXNyqo0zrXSzmkvVfbnytrr4onbZ61vscBwEAAAAAAAAAAAIAJPQAAAAAACIAILtTVbSIkaFDqjsJ7EOHmTfpXq/fbnrGkD3/GYHYHJtMVl0NBAAAAAAWABQqnZOHOGzDIzZAeXK+YwHq1AHtXQJIMEUCIQDgx3xEhlioV1Q+yAPKiaXMwkv1snoejbckZOKFe0R6WAIgB41dEvK3zxI665YVWfcih0IThTkPoOiMgd6xGaKQXbwBIQMdgXMwQDF+Z+r3x5JKdm1TBvXDuYC0cbrnLyqJEU2ciQAAAAABAR9WXQ0EAAAAABYAFCqdk4c4bMMjNkB5cr5jAerUAe1dAQMEAQAAAAAAAA==",
283+
"change_output_index": 1,
284+
"locks": [
285+
{
286+
"id": "ede19a92ed321a4705f8a1cccc1d4f6182545d4bb4fae08bd5937831b7e38f98",
287+
"outpoint": "f8efa583e93ab71debe62a5374f91563aa10a3461518042aaddb464b656350e2:1",
288+
"expiration": 1601560626
289+
}
290+
]
291+
}
292+
```
293+
294+
Note that the format of the `--outputs` parameter is slightly different from the
295+
one in `lncli wallet psbt fund`. The order of the outputs is important in the
296+
template, so the new command uses an array notation, where the old command used
297+
a map (which doesn't guarantee preservation of the order of the elements).
298+
261299
## Signing and finalizing a PSBT
262300

263301
Assuming we now want to sign the transaction that we created in the previous

docs/release-notes/release-notes-0.18.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
broadcast. This means when a transaction has failed the `testmempoolaccept`
139139
check by bitcoind or btcd, the broadcast won't be attempted.
140140

141+
* The `coin-selection-strategy` config option [now also applies to channel
142+
funding operations and the new `PsbtCoinSelect` option of the `FundPsbt`
143+
RPC](https://github.com/lightningnetwork/lnd/pull/8378).
144+
141145
## RPC Additions
142146

143147
* [Deprecated](https://github.com/lightningnetwork/lnd/pull/7175)
@@ -167,6 +171,15 @@
167171
is not considered for session negotiation. TerminateSession can be used to
168172
mark a specific session as terminal so that that specific is never used again.
169173

174+
* [The `FundPsbt` RPC method now has a third option for specifying a
175+
template](https://github.com/lightningnetwork/lnd/pull/8378) to fund. This
176+
new option will instruct the wallet to perform coin selection even if some
177+
inputs are already specified in the template (which wasn't the case with
178+
the previous options). Also, users have the option to specify whether a new
179+
change output should be added or an existing output should be used for the
180+
change. And the fee estimation is correct even if no change output is
181+
required.
182+
170183
## lncli Additions
171184

172185
* Deprecate `bumpclosefee` for `bumpforceclosefee` to accommodate for the fact

0 commit comments

Comments
 (0)