Commit Graph

9499 Commits

Author SHA1 Message Date
niftynei ff069ff924 rbf: consolidate failure paths, use "warnings"
We move over to the new "warning" paradigm, instead of using
an "rbf_fail" message.

Every failure is either a warning or an error; on warnings we
hang up and reconnect later, effectively resetting the state.
2021-03-06 15:03:56 +10:30
niftynei 4fb95a9350 df-rbf: separate first-time channel save from update (RBF)
We can't "first save" a channel twice; instead we split in two and just
update the underlying channel on subsequent passes (RBFs)
2021-03-06 15:03:56 +10:30
niftynei f22fed3fd5 df-rbf: only permit the channel initiator to init RBF
We're *mostly* set up for both sides doing RBF, except that it reverses
the callback flow (using the plugin vs RPC calls) and we're not
currently smart enough to flip between them gracefully
2021-03-06 15:03:56 +10:30
niftynei a0cb7bd9b4 df: update reserve calculation
We can use the funding amount to derive the reserve requirement.
2021-03-06 15:03:56 +10:30
niftynei 2719ff8c3b df-rbf: handle rbf failures in lightningd 2021-03-06 15:03:56 +10:30
niftynei d47358848f df-rbf: init an rbf for real, using openchannel_bumpfee
Reorg a bit of the RBF code so we use the same codepaths for we-init vs
they-init starts.
2021-03-06 15:03:56 +10:30
Rusty Russell 4dcd4ca155 listpeers: add latest feerate and actual last fee amount.
Users have no idea what they would pay for unilateral closes.
At least this gives them a clue!

Reported-by: @az0re on IRC.

Changelog-Added: JSON-RPC: `listpeers` now shows latest feerate and unilaral close fee.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-05 13:12:41 +10:30
Rusty Russell 4deb9311ce Makefile: fix parallel build error on clean tree.
Caused by missing common/iso4217.c from common/Makefile:

```
In file included from ./common/iso4217.h:4,
                 from common/iso4217.c:3:
./wire/wire.h:7:10: fatal error: secp256k1_recovery.h: No such file or directory
    7 | #include <secp256k1_recovery.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:265: common/iso4217.o] Error 1
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-03 16:36:22 -06:00
Rusty Russell 7c2ecd8241 wire/Makefile: make sure we regen exp files if patches change.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-03-03 16:36:22 -06:00
niftynei 063948d51a df-feerates: send back original + last known feerates
For calculating the next RBF attempt's feerate, we need some historical
information about the feerate used for this channel
2021-03-03 16:19:04 -06:00
niftynei fe688ab718 df: revert channel state in dualopend
Now that RBF's are possible, we revert the channel's state
after a failure to the previous channel info.
2021-03-03 16:19:04 -06:00
niftynei cf170c3909 df: allow for RBF_INIT in sigs states 2021-03-03 16:19:04 -06:00
niftynei 02d99acca1 dualopen: check that peer is connected for json calls
Before we start trying to talk to the peer, check that they're
connected.
2021-03-03 16:19:04 -06:00
niftynei d8221aae76 df: update channel_id when opening; closing; disconnecting
We were missing the channel_id for accepter opens; it's also a good idea
to reset it to 0xFF when we disconnect totally
2021-03-03 16:19:04 -06:00
niftynei 474233f1b7 memleak,df: patchup memleak code for v2 channels
Takes 'unsaved' channels into account for memleak cleanups, instead of
solely relying on `uncommitted_channels`
2021-03-03 16:19:04 -06:00
niftynei 6407ad334f df, channel: if a channel reconnects, but it's "unsaved" still
Go ahead and start dualopend, but as a fresh instance.
2021-03-03 16:19:04 -06:00
niftynei 779067d74c df: check inflights when deciding whether or not to allow command
We were missing the inflight state checks before allowing to proceed
with a command.
2021-03-03 16:19:04 -06:00
niftynei da81d4bced channel: skip unsaved channels
Now that "peer->channels" contains `unsaved` channels, skip overthem
where appropriate
2021-03-03 16:19:04 -06:00
niftynei b9f867b1dd connectd: check for re-connected unsaved channels 2021-03-03 16:19:04 -06:00
niftynei 4c9a4250bf subd: remove "swap" methods
only needed for moving the subd->channel from an uncommitted_channel to
a channel; we removed uncommitted_channel from dual_open so it's no
longer necessary
2021-03-03 16:19:04 -06:00
niftynei de3599e98a subd: remove ctype (channel_type)
We only needed the type check for dual_open, since it was the only
subdaemon path that used two 'types' in the subd->channel field.
2021-03-03 16:19:04 -06:00
niftynei 1e9a900918 df: start of RPC for bumping the fee!
Doesn't call into dualopend yet
2021-03-03 16:19:04 -06:00
niftynei d49db8ad41 df: do the right thing, now that we have a cancellation routine
removes a fixme
2021-03-03 16:19:04 -06:00
niftynei 3da2ae4d30 df: move to inflights for sigs/openchannel_signed parts of flow
We create an inflight once we get the commitment tx for a channel
instead of once we get the funding transaction signatures
2021-03-03 16:19:04 -06:00
niftynei 8b0e88dfb3 df: move initialization over to unsaved channel
uncommitted_channel -> channel (but unsaved)
2021-03-03 16:19:04 -06:00
niftynei 0951e2c941 df: get rid of unnecessary struct `commit_rcvd` 2021-03-03 16:19:04 -06:00
niftynei 95e81ce82c df: helper to find the last (most recent) inflight for a channel 2021-03-03 16:19:04 -06:00
niftynei 628f9df320 df: consolidate callbacks for opener/accepter, move to open_attempt 2021-03-03 16:19:04 -06:00
niftynei bfb862564e df: method for disconnecting an *unsaved* channel
Since we're moving over to "unsaved channels" instead of
"uncommitted_channel" struct, we need a new utility to disconnect this
channe
2021-03-03 16:19:04 -06:00
niftynei 538fd670ce df: add helper for creating an "unsaved" channel
Channel that's not saved to database yet
2021-03-03 16:19:04 -06:00
niftynei 1786fcbbdc df: migrate from "uncommitted_channel" to "open_attempt"
We're going to move over to "unsaved channels" instead of using a
separate "uncommitted_channel" struct. This means a peer might have a
channel that's not saved to the database yet in its channel list
2021-03-03 16:19:04 -06:00
niftynei 6474779e38 df-rbf: hook for rbf_init attempt, called "rbf_channel"
When we get an RBF request, we ask the/a plugin what they'd like to do
about it. This pipes the request through to the plugin
2021-03-03 16:19:04 -06:00
niftynei 50b8655cbe channel: remove 'uncommitted_channel' from channel lookup
We're going to be removing "uncommitted_channel" from v2 open stat
2021-03-03 12:28:22 +10:30
niftynei 4baa10ef68 channel: remove `psbt` and `remote_tx_sigs`
We just added this, but we've migrated them to the "inflight" struct
instead, as they actually pertain to an single inflight open attempt
2021-03-03 12:28:22 +10:30
niftynei e15de71375 channel: only delete saved channels from database
There will be 'unsaved' channels now, with a dbid of 0
2021-03-03 12:28:22 +10:30
niftynei 99123ddbe4 dual-funding, rbf: reject RBFs that will fail the total-fee rule
RBFs must have a total fee greater than the last successful RBF attempt
2021-03-03 12:28:22 +10:30
lisa neigut 0d8351155e df-rbf: validate that the candidate funding transaction is valid
We need to make sure that there's at least one input that's represented
in every single RBF-attempt for this channel, to prevent "parallel"
subsequent RBFs from succeeding/opening (the multi-channel backdoor?!)
2021-03-03 12:28:22 +10:30
niftynei b30489310b df-rbf: break out opener commitment codepath, use for rbf 2021-03-03 12:28:22 +10:30
niftynei 63b060066b df-rbf: opener setup for "interactive" protocol portion
If we're the opener, there's a bit of extra setup we need to do before
calling "run_tx_interactive", namely adding the funding_output to the
PSBT
2021-03-03 12:28:22 +10:30
niftynei e67d5d7559 df: move out logic for adding funding output to PSBT 2021-03-03 12:28:22 +10:30
niftynei 804b93c81f df-rbf: split out "commitment txs" portion of accepter
use it for received RBFs requests, when we're the "accepter"
2021-03-03 12:28:22 +10:30
niftynei 22078262f0 df-reinit: pass back channel_flags
We should also restore the channel_flags field on reinit; we use them if
we do an RBF after a reconnection
2021-03-03 12:28:22 +10:30
niftynei 940347b04e df: put channel_flags onto state
They need to exist through multiple open channel attempst (via RBF)
2021-03-03 12:28:22 +10:30
niftynei a489f92ee8 df-rbf: start of handling an incoming RBF attempt from peer
A peer init's an RBF, we start handling it
2021-03-03 12:28:22 +10:30
niftynei 067f1f2eb7 df-rbf: add method to fail an RBF
this is a bit different than straight up failing a channel. we want to
signal that the RBF attempt failed, only
2021-03-03 12:28:22 +10:30
niftynei 54d5cdb938 df-rbf: update wires with ack and fail rbf 2021-03-03 12:28:22 +10:30
niftynei cf2f0c32d1 df-rbf: refactor state for opening attempts
Since a channel can now have multiple successful funding transactions
constructed for it, we need space to express this in the states.
2021-03-03 12:28:22 +10:30
niftynei e18af6aaa3 rbf: check all inflights for matching transaction data
Even though, technically, we only need to check for v1 open data, go
ahead and extend this check to encompass the inflights
2021-03-03 12:28:22 +10:30
niftynei b8b910e4c4 df-rbf: update channel data on depth reached
When the funding tx reaches depth, update the channel's data to the
"correct" funding transaction info from inflights (if necessary).

This will be necessary if:
    - the transaction has been successfully RBF'd and
    - the lesser fee transaction is the one successfully mined, OR
    - the channel is in the process of being RBF'd
2021-03-03 12:28:22 +10:30
niftynei 36f3b13279 inflight: add a 'channel-inflight' concept, in-progress channel stuffs
"inflights" are all potential channel funding transactions that we
currently have commitment transactions for.
2021-03-03 12:28:22 +10:30