Commit Graph

3043 Commits

Author SHA1 Message Date
niftynei 8182e9cea4 df: update the openchannel2 parameter 'accepter' -> 'our'
The `rbf_channel` hook uses `our_funding_msat`, which is a nicer
and more easily understood than the `openchannel2`
`accepter_funding_msat`.

This updates the `openchannel2` hook to use the same nomenclature as
`rbf_channel`.
2021-03-12 14:00:19 +10:30
niftynei a60d652517 df: add missing check for already set scriptpubkey
Noticed while adding the documentation for the hook.
2021-03-12 14:00:19 +10:30
niftynei 52b5dbb01d df: add doc for `channel_open_failed` notification
When a channel fails, send out a notification.

We were missing this notification in one case, which has been added.
2021-03-12 14:00:19 +10:30
niftynei fc9e72b62b df-doc: add docs for openchannel_bump, more checks for valid psbt
Add docs for openchannel_bump, plus some checks that were missed for
verifying the amount is valid.
2021-03-12 14:00:19 +10:30
niftynei a648ec827a df-doc: update error codes, make sure they're correct 2021-03-12 14:00:19 +10:30
Christian Decker 0bc8a47226 plugin: Add details about which plugin caused a clash in RPC methods 2021-03-10 12:03:10 -06:00
Christian Decker e59940eb61 plugin: Abort early if we have a misconfiguration in the plugins
We were reporting the failure immediately but still continuing with
the startup. This could happen if an important plugin ends up in a
race with another plugin (important or not) for a contended
resource (CLI option or RPC method name). We would eventually notice
that we were supposed to abort, but at that point we already processed
a couple of blocks, loaded the entire state, etc.

This just aborts early with a sane error message.

Changelog-Added: plugin: If there is a misconfiguration with important plugins we now abort early with a more descriptive error message.

Reported-by: PsySc0rpi0n
Reported-by: Ján Sáreník <@jsarenik>
2021-03-10 12:03:10 -06:00
niftynei 26e4bae9ce df: fail channel if peer sends witnesses that aren't paid for
The receiving node: ...
      - MUST fail the channel if:
        - the `witness_stack` weight lowers the effective `feerate`
          below the agreed upon transaction `feerate`
2021-03-09 14:55:05 +10:30
niftynei 31e3bdb42d df-spec: consolidate dual-funding patches, update feerate protocol
We consolidate to the latest/singular RFC patch for dual-funding, so
there's just a single patchfile for the change. Plus we move back to the
opener setting the desired feerate, the accepter merely declines to
participate if they disagree with the set rate.
2021-03-09 14:55:05 +10:30
niftynei 71164799f9 dual-fund: remove all references to PODLEs
We're punting on PODLE's for v1 of dual-funded channels
2021-03-09 14:55:05 +10:30
Christian Decker 21355edc43 plugin: Do not send the internal framed message over the wire
Looks like #4394 treated a symptom but not the root cause. We were
actually sending the message framed with the WIRE_CUSTOMMSG_OUT and
the length prefix over the encrypted connection to the peer. It just
happened to be a valid custommsg...

This fixes the issue, and this time I made sure we actually send the
raw message over the wire. However for backward compatibility we
needed to imitate the faulty behavior which is 90% of this patch :-)

Changelog-Fixed: plugin: `dev-sendcustommsg` included the type and length prefix when sending a message.
2021-03-09 14:39:22 +10:30
niftynei 8cc2919884 connectd: clean up the channel stuffs when we get a reconnect
If they've disconnected/reconnected we need to terminate all the
inflight stuff, plus go ahead and call 'disconnect' plugin trigger etc.
2021-03-06 15:03:56 +10:30
niftynei 97e64915c5 df: add (over zealous?) note about the usage of `psbt_has_req_fields`
Requested-In-Part-By: Rusty Russell @rustyrussell
2021-03-06 15:03:56 +10:30
niftynei fc411a5925 df-memleak: expose memleak error and fix
We were getting a memleak error that the open_attempt isnt' being
cleaned up in test_rbf_reconnect_tx_construct. I had some trouble
reproducing it, so I removed the reliance on using `tmpctx` to clean it
up and was more surgical about cleaning it up inline.
2021-03-06 15:03:56 +10:30
niftynei e0a2d47903 df-rbf: reconnection tests (init_rbf + ack_rbf) 2021-03-06 15:03:56 +10:30
niftynei 07153bff6a df: cleanup error handling on lightningd side
Make existing methods understand how unsaved channels work, re-work
errors so that we handle everything appropriately
2021-03-06 15:03:56 +10:30
niftynei dfdf9259d7 listpeers: include feerate info for RBF-candidate channels
Changelog-Added: JSON-RPC: `listpeers` now includes 'last_feerate', 'next_feerate', 'initial_feerate' and 'next_fee_step' for channels in state DUALOPEND_AWAITING_LOCKIN

fixup! listpeers: include feerate info for RBF-candidate channels
2021-03-06 15:03:56 +10:30
niftynei 6c76dd338e channel: move inflight + feerate methods to channel.c
Need these more accessible for next patch, which moves the next_feerate
info into listpeers
2021-03-06 15:03:56 +10:30
niftynei a23277af57 listpeers: include info on channels that are in-process
Channels that we're in negotiation for, but don't have a commitment
transaction saved for yet.
2021-03-06 15:03:56 +10:30
niftynei 1acc1aa27e rbf: clean up channel on error
Make sure we clean up unsaved channels appropriately on failure.

We forget the peer/channel if it's unsaved!
2021-03-06 15:03:56 +10:30
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
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 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