wallet: PSBT channel funding #4079
Conversation
Completed an initial pass. Upon first glance, it feel like the new internal flow to resume/suspend a funding flow to wait for PBST information could be made a bit more streamlined. There's a lot of mutation where instead perhaps we can apply our changes directly to a state machine using pre-defined methods. It also isn't clear to me why the user needs to register their shim before hand, compared to just passing it in with |
3f67a91
to
7ae75b9
eeef1e5
to
fc7e062
The control flow in this version is much easier to follow IMO! FWIW, it now more closely resembles the napkin sketch I made for a flow like this when I was first designing the |
26eeb98
to
9835b11
I further cleaned up the logic of the PR, thanks for the suggestions, @Roasbeef. |
a8fc623
to
befb099
About the logs: Yes, that is too much. There was still an error in there that if the remote peer canceled the reservation, we also tried to cancel it back, which resulted in additional errors. |
fc956c7
to
c79e221
Just a few more nits, but this is pretty much good to land by me! |
LGTM |
We add a new funding assembler and intent type that handle channel funding through the use of a PSBT. The PsbtIntent is in itself a simple state machine that can be stepped through the process of assembling the required information for the funding output, verifying a user supplied PSBT for correctness, accepting a fully signed PSBT and then assembling the funding wire message.
In case the funding manager detects that a funding flow is requested to be executed with the help of a PsbtIntent, the normal channel negotiation with the remote peer is interrupted, as soon as the accept_channel message was received. With the remote peer's funding multisig key and our local key, we can derive the funding output script and its address. This is enough to start the PSBT funding and signing process which the user will do externally to the daemon.
A PSBT funding flow consists of multiple steps. We add new RPC messages that can trigger the underlying state machine to transition to a new state. We also add new response messages that tell the API user what the current state is.
This is a pure code move!
We add a new flag --psbt to the openchannel command which triggers an interactive conversation between the command line and the user.
Nits fixed, commit dates adjusted and rebased. |
Fixes #3085 and #3936.
This PR introduces channel funding through PSBTs! With this, it is possible to open one or more channels from
lnd
without it needing to have a wallet balance.