Commit Graph

425 Commits

Author SHA1 Message Date
nsa
4ee4a1a24e peer.go: remove height argument to addLink function
Best height is not needed to create a link.
2020-07-06 19:16:07 -04:00
nsa
328094d8fb peer.go: replace switch statements with if statements 2020-07-06 19:16:06 -04:00
nsa
0dda9e06ce multi: exporting PendingUpdate, ChannelCloseUpdate, ErrorBufferSize 2020-07-06 19:16:06 -04:00
nsa
d23b30d889 peer.go: comment clarifications, improved formatting 2020-07-06 19:16:06 -04:00
Joost Jager
8f2a2fc5da
Merge pull request #4018 from breez/intercept-forward-htlc
Intercept forward htlc
2020-06-22 10:18:14 +02:00
Roei Erez
0f50d8b2ed htlcswitch: introducing interceptable switch.
In this commit we implement a wrapper arround the switch, called
InterceptableSwitch. This kind of wrapper behaves like a proxy which
intercepts forwarded packets and allows an external interceptor to
signal if it is interested to hold this forward and resolve it
manually later or let the switch execute its default behavior.
This infrastructure allows the RPC layer to expose interceptor
registration API to the user and by that enable the implementation
of custom routing behavior.
2020-06-18 15:12:50 +03:00
nsa
2d68a64a5b chancloser: new package for cooperative channel closure
Introduces a new chancloser package which exposes a ChanCloser
struct that handles the cooperative channel closure negotiation
and is meant to replace chancloser.go in the lnd package. Updates
all references to chancloser.go to instead use chancloser package.
2020-06-16 20:34:44 -04:00
nsa
ec2d999371 chancloser+peer: export negotiationHeight, channel, and error 2020-06-11 15:49:23 -04:00
Oliver Gugger
42ac187932
peer: fix struct alignment
Integers used atomically MUST be aligned properly, otherwise the
sync library will crash on purpose. Therefore non-aligned struct
members must come later.
2020-05-21 11:28:49 +02:00
Oliver Gugger
7f1b865b53
multi: rename server's identityPriv to identityECDH 2020-05-20 09:05:14 +02:00
Oliver Gugger
7c1304b31c
peer: don't use global cfg 2020-05-14 16:18:02 +02:00
Andras Banki-Horvath
556e3525ea misc: fix error formatting in multiple files 2020-04-24 19:15:08 +02:00
Conner Fromknecht
ec1b8d874d
htlcswitch/link: add pending commit ticker for stall detection
This commit adds a PendingCommitTicker to the link config, which allows
us to control how quickly we fail the link if the commitment dance
stalls. Now that the mailbox has the ability to cancel packets, when the
link fails it will reset the mailbox packets on exit, forcing a
reevaluation of the HTLCs against their mailbox expiries.
2020-04-14 10:51:30 -07:00
Conner Fromknecht
d6fa2f9092
peer: filter channels loaded into switch via whitelist
This is less brittle than blacklisting states since it may not be clear
that new states needs to be added. Now that HasChanStatus is fixed for
ChanStatusDefault, we can safely implement this.
2020-04-13 15:19:59 -07:00
Wilmer Paulino
d04bc200e7
Merge pull request #4144 from cfromknecht/frozen-chan-fixups
multi: frozen chan fixups
2020-04-03 11:21:22 -07:00
Conner Fromknecht
ec784db511
multi: remove returned error from WipeChannel
The linter complains about not checking the return value from
WipeChannel in certain places. Instead of checking we simply remove the
returned error because the in-memory modifications cannot fail.
2020-04-02 17:39:29 -07:00
Wilmer Paulino
40f97e6c47
peer: send local node announcement upon establishing peer connections
We'll only do so when we have at least one confirmed advertised channel
with the remote peer. This ensures that our node announcement can
propagate throughout the network even for nodes that were offline when
we initially broadcast it.
2020-04-02 10:04:45 -07:00
nsa
f00159f64c peer: no pending channels in switch, buffer msgs until link active 2020-03-27 08:49:46 -04:00
nsa
966cd2112c multi: link notifies subscribers of ActiveLinkEvent, rpc ignores 2020-03-27 08:49:46 -04:00
carla
54089febd6
peer+server: store errors for peers with open channels
Add an error buffer to the peer struct which will store errors for
peers that we have active channels with. We do not store these errors
with peers that we do not have channels open with to prevent peers from
connecting and costlessly spamming us with error messages. When the peer
disconnects, the error buffer is offloaded to the server so that we can
track errors across connections. When peers reconnect, they are created
with their historic error buffer.
2020-03-17 08:22:35 +02:00
Johan T. Halseth
7b8eae38e5
peer: avoid chansync resend loop
If a peer receives a channel reestablish message shortly after the
channel has been closed, it will resend its own channel reestablish
message. In the meantime the other peer could also have seen the channel
being closed and will also resend its own message. This leads to a
resend loop that never terminates.

To avoid two peers getting into this situation, we now allow only one
such resent message per conection.
2020-03-11 12:13:25 +01:00
Conner Fromknecht
e4090c3c67
peer: remove unused failedChannels channels map 2020-03-06 15:45:34 -08:00
carla
d3cb6ad869
channeldb: store close initiator status
This commit adds two new channel statuses which indicate the party that
initatited closing the channel. These statuses are set in conjunction
with the existing commit broadcast status so that we do not need to
migrate existing logic to handle multiple types of closes. This status
is set for locally initiated force closes in this commit because they
follow a similar pattern to cooparative closes, marking the commitment
broadcast then proceeding with tx broadcast. Remote force closes are
added in the following commit, as they are handled differently.
2020-02-21 13:33:49 +02:00
carla
abf780bf03
multi: add htlcNotifier interface to switch and link
In this commit, a htlcNotifier interface is added to allow for easy
unit testing. Instances of the HtlcNotifier are added to the server,
switch and link.
2020-02-19 17:50:28 +02:00
Conner Fromknecht
0f9023256e
peer: use feature.ValidateRequired, cleanup error msgs 2020-01-08 12:25:41 -08:00
Wilmer Paulino
9a7f66f2f7
peer: modify ReplyChannelRange log message
The message now shows the block range the reply spans, which is a lot
more useful.
2020-01-06 14:03:19 -08:00
Conner Fromknecht
34fd27280a
peer: validate remote peer's feature deps 2019-12-16 13:06:59 -08:00
Joost Jager
ddb98fcc41
multi: distinguish between htlc in and out constraints 2019-12-11 00:16:57 +01:00
carla
94d3eb60a4
multi: Use user provided close address for cooperative closes
This commit is adapted from @Bluetegu's original
pull request #1462.

This commit reads an optional address to pay funds out to
from a user iniitiated close channel address. If the channel
already has a shutdown script set, the request will fail if
an address is provided. Otherwise, the cooperative close will
pay out to the address provided.
2019-12-10 09:13:01 +02:00
Olaoluwa Osuntokun
b3b34d9de2
Revert "peer: clamp a link's max HTLC forwarding policy to current max HTLC pay size"
This reverts commit c943d850193a476be1bc37ed922d1954cf040948.
2019-12-06 15:11:56 -08:00
Conner Fromknecht
f3398c0c0e
Merge pull request #3789 from cfromknecht/coop-close-rpc-status
republish force and coop closes on startup
2019-12-05 10:35:53 -08:00
Olaoluwa Osuntokun
183797f102
Merge pull request #3655 from carlaKC/fundingmgr-optionupfrontshutdown
Add Option Upfront Shutdown
2019-12-04 21:05:24 -08:00
Olaoluwa Osuntokun
c943d85019
peer: clamp a link's max HTLC forwarding policy to current max HTLC pay size
In this commit, we start to clamp the max HTLC forwarding policy to the
current register max HTLC payment size. By doing this, we ensure that
any links that have a advertised max HTLC transit size above the max
payment size will reject any incoming or outgoing attempts for such
large payments.
2019-12-04 15:10:47 -08:00
Conner Fromknecht
d9cf0396b3
peer+chancloser: mark coop broadcasted 2019-12-04 14:25:28 -08:00
carla
f86d63144c
multi: Set and check upfront shutdown address on close
This commit sets our close addresss to the address
specified by option upfront shutdown, if specified,
and disconnects from peers that fail to provide
their upfront shutdown address for coopertaive closes
of channels that were opened with the option set.
2019-12-03 11:38:29 +02:00
Conner Fromknecht
16318c5a41
multi: merge local+global features from remote peer 2019-11-08 05:31:47 -08:00
Conner Fromknecht
6c86075354
peer+server: use feature manager to generate feature vectors 2019-11-08 05:29:29 -08:00
Wilmer Paulino
cf5dc90d04
peer+server: wait until peer is active to begin channel opening process
Without waiting, we would proceed to retrieve the remote peer's
supported features, which may have not been set due to not yet receiving
their Init message.
2019-10-01 17:42:43 -04:00
Olaoluwa Osuntokun
3f8526a0ca
peer+lnpeer: add new methods to expose local+global features for lnpeer interface 2019-09-25 18:26:01 -07:00
Olaoluwa Osuntokun
0c076bf82a
Merge pull request #3016 from halseth/republish-close-tx-on-startup
[contractcourt] Republish close tx on startup
2019-09-25 16:45:48 -07:00
Conner Fromknecht
a280a4987c
peer: resend channel reestablishes without starting chan streams
This prevents the DLP protocol from breaking as a result of the
refactor, since the closing or closed channels won't be included in the
peer's active map.
2019-09-25 12:18:21 -07:00
Conner Fromknecht
ced113452d
peer: only mark active channels as failed
Also adds similar sanity check for LinkUpdater msgs, so that we don't
process messages for inactive channels.
2019-09-25 12:01:23 -07:00
Conner Fromknecht
f33a1a61e6
peer: extract error handling logic 2019-09-25 12:01:11 -07:00
Conner Fromknecht
2df5a36048
peer+lnwire: add LinkUpdater iface and impl on relevant msgs
Removes longstanding TODO to simplify parsing of target chanid.
2019-09-25 12:00:59 -07:00
Johan T. Halseth
2a6ad6e634
channeldb+lnwallet: don't pass isRestoredChan to ChanSyncMsg
Since we have access to the internal state of the channel, we can
instead get it directly instead of passing it in as a parameter.
2019-09-25 14:04:44 +02:00
Johan T. Halseth
1974bfa4cf
peer: send channel reestablish message for borked channels
When loading active channels for a connected peer, we gather channel
sync messages for all borked channels, and send them to the peer. This
should help a peer realize that the state is irreconcible, as we have
already realized.
2019-09-25 14:04:42 +02:00
Johan T. Halseth
33fe09482b
lnwire+multi: define Error() for lnwire.Error
To make lnwire.Error actually satisfy the error interface, define the
Error method directly.
2019-09-20 10:55:21 +02:00
Conner Fromknecht
6dca07577d
multi: move active/inactive ntfns from switch to link
Since we will now wait to deliver the event after channel reestablish,
notifying when the link is added to the switch will no longer be
sufficient. Later, we will add receiving reestablish as an additional
requirement for EligibleToForward returning true.

The inactive ntfn is also moved, to ensure that we don't fire inactive
notifications if no corresponding active notification was sent.
2019-09-19 12:46:44 -07:00
Joost Jager
3d7de2ad39
multi: remove dead code 2019-09-10 17:21:59 +02:00
Wilmer Paulino
d8dd6b3245
htlcswitch: cap fee updates to max fee allocation
In this commit, we begin to enforce a maximum channel commitment fee for
channel initiators when attempting to update their commitment fee. Now,
if the new commitment fee happens to exceed their maximum, then a fee
update of the maximum fee allocation will be proposed instead if needed.

A default of up to 50% of the channel initiator's balance is enforced
for the maximum channel commitment fee. It can be modified through the
`--max-channel-fee-allocation` CLI flag.
2019-09-03 16:49:59 -07:00