lnd
's wallet now features a full set of PSBT functionality, including creating, signing and funding channels with PSBTs.wallet psbt fund
command is very similar to bitcoind
's walletcreatefundedpsbt
command. One main difference is that you can specify a template PSBT in the lncli
variant that contains the output(s) and optional inputs. Another difference is that for the --outputs
flag, lncli
expects the amounts to be in satoshis instead of fractions of a bitcoin.bcrt1qjrdns4f5zwkv29ln86plqzs092yd5fg6nsz8re
:fund
command. We again want to send half a coin to bcrt1qjrdns4f5zwkv29ln86plqzs092yd5fg6nsz8re
but we want to select our inputs manually.listunspent
command:finalize
sub command of the wallet:lnd
by using a PSBT as the funding transaction.
We will use bitcoind
to create and sign the transaction just to keep the example simple. Of course any other PSBT compatible wallet could be used and the process would likely be spread out over multiple signing steps. The goal of this example is not to cover each and every possible edge case but to help users of lnd
understand what inputs the lncli
utility expects.03db1e56e5f76bc4018cf6f03d1bb98a7ae96e3f18535e929034f85e7f1ca2b8ac
by using a PSBT. That means, lnd
can have a wallet balance of 0
and is still able to open a channel. We'll jump into an example right away.lnd
node, we know it's after 10 minutes. So as long as the whole process takes less than 10 minutes, everything should work fine.Wasabi
for instance, where the "publish" button is very easy to hit by accident.--psbt
flag in lncli openchannel
--psbt
flag in the openchannel
command starts an interactive dialog between lncli
and the user. Below the command you see an example output from a regtest setup. Of course all values will be different.openchannel
running as is.bitcoind
to create a funding transactionbitcoind
. We'll go ahead and execute it now. The meaning of this command is something like "bitcoind, give me a PSBT that sends the given amount to the given address, choose any input you see fit":bitcoind
has given us a transaction that would pay 3060
satoshi in fees. Fee estimation/calculation can be changed with parameters of the walletcreatefundedpsbt
command. To see all options, use bitcoin-cli help walletcreatefundedpsbt
.decodepsbt
command:lnd
to create a funding transactionv0.12.0
, lnd
can also create PSBTs. This assumes a scenario where one instance of lnd
only has public keys (watch only mode) and a secondary, hardened and firewalled lnd
instance has the corresponding private keys. On the watching only mode, the following command can be used to create the funding PSBT:lncli
that is still waiting for our input.bitcoind
for this again, but in practice this would now happen on a hardware wallet and perhaps bitcoind
would only know the public keys and couldn't sign for the transaction itself. Again, this is only an example and can't reflect all real-world use cases.lnd
node model as described in 2b, you can achieve the same result with the following command:lncli
to continue:openchannel
and feed it into the --base_psbt
parameter of the next openchannel
command. This won't work with bitcoind
though, as it cannot take a PSBT as partial input for the walletcreatefundedpsbt
command.bitcoin-cli
examples from the command line can be combined into a single command. For example:openchannel --psbt
two times, combine the funding addresses as shown above, verify the PSBT, sign it and finally paste it into the terminal of the first command. lnd
then goes ahead and finishes the negotiations with peer 1. If successful, lnd
publishes the transaction. In the meantime we paste the same PSBT into the second terminal window. But by now, the peer 2 for channel 2 has timed out our funding flow and aborts the negotiation. Normally this would be fine, we would just not publish the funding transaction. But in the batch case, channel 1 has already published the transaction that contains both channel outputs. But because we never got a signature from peer 2 to spend the funds now locked in a 2-of-2 multisig, the fund are lost (unless peer 2 cooperates in a complicated, manual recovery process).--no_publish
flag for each channel but the very last. This prevents the full batch transaction to be published before each and every single channel has fully completed its funding negotiation.