Commit Graph

145 Commits

Author SHA1 Message Date
Daniel McNally
8543497dcc multi: fixing it's/its typos in comments 2018-02-06 19:13:07 -08:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
MeshCollider
4b1cc98808 multi: apply roasbeef diff to support incoming socks.ProxiedAddr 2018-02-05 17:37:46 -08:00
nsa
698df2ac16 torsvc: added new type that multiplexes torsvc and net packages
This commit adds the `lnnet` package which contains an
implementation of the newly created LightningNet interface which
multiplexes the Dial and DNS-related functions to use net
by default and torsvc if a flag is specified. This modularization
makes for cleaner code.
2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun
cfacc18f72
Merge pull request #711 from Roasbeef/funding-fail-first
funding: during funding error fail before sending Error to peer
2018-02-05 15:09:21 -08:00
Olaoluwa Osuntokun
30dbbd69a0
funding+htlcswitch: dynamically update short chan id of existing link
In this commit, we fix an existing bug that would result in some
payments getting “stuck”. This would happen if one side restarted
before the channel was fully locked in. In this case, since upon
re-connection, the link will get added to the switch with a *short
channel ID of zero*. If A then tries to make a multi-hop payment
through B, B will fail to forward the payment, as it’ll mistakenly
think that the payment originated from a local-subsystem as the channel
ID is zero. A short channel ID of zero is used to map local payments
back to their caller.

With fix this by allowing the funding manager to dynamically update the
short channel ID of a link after it discovers the short channel ID.

In this commit, we fix a second instance of reported “stuck” payments
by users.
2018-02-03 18:14:15 -08:00
Olaoluwa Osuntokun
71a837630a
funding: on startup only re-create funding barriers if channel is pending
In this commit, we fix an existing bug within the funding manager. A
channel barrier only needs to be create if upon startup the channel is
still pending. Otherwise, we’ll re-create the funding barrier
unnecessarily. This can lead to bugs when initiating payments between a
channels’ lock in and when it’s announced to the together network. If
during this period, a user attempts a payment, then the response won’t
be archived, as the grouting will be blocked waiting on the channel
barrier to close.

To fix this, we only re-create the barrier if the channel hasn’t been
confirmed.

This eliminates one source of reported “stuck payments”.
2018-02-03 18:02:21 -08:00
Olaoluwa Osuntokun
bba2ff1871
funding: display error if unable to watch for channel 2018-02-02 17:59:38 -08:00
Olaoluwa Osuntokun
c823aeafab
funding: during funding error fail before sending Error to peer
In this commit, we modify the logic executed when we decide that we
need to fail a funding flow. Before this commit, if the remote party
disconnected while we were attempting to fail the funding flow with an
error. Then we'd never actually cancel the reservation. This meant that
any inputs selected for that transaction would be locked until a
restart.

We fix this issue by always cancelling the reservation first, and
ensuring that failure to cancel the reservation doesn't prevent us from
sending the error.

Partially addresses #710.
2018-01-31 13:52:21 -08:00
Olaoluwa Osuntokun
1b15c30f7a
Merge pull request #592 from wilmerpaulino/rest-close-channel
lnrpc: make ChannelPoint.funding_txid a protobuf oneof and change CloseChannel endpoint
2018-01-31 12:38:03 -08:00
Olaoluwa Osuntokun
bde3828208
funding: fix format directive in logging statement 2018-01-28 14:48:56 -08:00
Wilmer Paulino
f674e10a2b
lnd+cmd/lncli: handle ChannelPoint funding txid proto update
Since a ChannelPoint's funding txid can now be get/set as raw bytes or
a string, we first need to check what type it's currently set to before
accessing it.
2018-01-27 22:00:01 -05:00
Olaoluwa Osuntokun
d4e650c85d
peer: the chancloser no longer needs to notify the breach arb of settled transactions 2018-01-22 19:19:59 -08:00
Olaoluwa Osuntokun
69e6ec9954
peer+funding: remove unneeded channel handoff code with the breach arbiter
We no longer need to hand off new channels that come online as the
chainWatcher will be persistent, and always have an active signal for
the entire lifetime of the channel.
2018-01-22 19:19:50 -08:00
Olaoluwa Osuntokun
8807d1d752
fundingmgr: add new function closure to send new channels to the ChainArbitrator 2018-01-22 19:19:38 -08:00
Johan T. Halseth
3edc1a7456
fundingmanager: define min and maxRemoteDelay
This commit defines minRemoteDelay and maxRemoteDelay,
which is the extremes of the CSV delay we will require
the remote to use for its commitment transaction. The
actual delay we will require will be somewhere between
these values, depending on channel size.
2018-01-12 22:57:01 +01:00
Johan T. Halseth
79a6efe33f
fundingmanager: use minHtlc from initFundingMsg
This commit makes the fundingmanager read the minHtlc
field of the initFundingMsg, and add it to the reservation
as this node's htlc_minimum_msat for the open_channel
message. If the field is not specified in the initFundingMsg,
the default value found in the DefaultRoutingPolicy will
be used.
2018-01-12 22:56:39 +01:00
Johan T. Halseth
9af7cc9b99 funding: cleanup of 6 conf and 'private' channel logic
This commits slightly rewrites the newly introduced
logic for private channels. Instead of keeping the
channel announce preference in a database within
fundingManager, it is stored as part of the
OpenChannel struct.

In addition, the ChanOpenStatus_Open update is now
sent after the channel is added to the router, instead
of waiting until the 6 blocks confirmation has passed.
2017-12-17 18:35:34 -08:00
nsa
c954ca1f21 funding: adding to graph, private chans, chanAnn after 6 confs
This commit introduces some new interdependent functionality. As
soon as the fundingLocked message is sent, the channel is
immediately added to the ChannelRouter's internal topology.

Finally, channels are now only broadcasted to the greater
network after six confirmations on the funding transaction
has been reached.
2017-12-17 18:35:34 -08:00
Olaoluwa Osuntokun
bdfbda63bd
funding: register our desired minHTLC value during the funding flow
In this commit, we ensure that we actually advertise our desired value
for the smallest HTLC we’ll accept as incoming. Before this commit, the
value advertised was always zero.
2017-12-13 17:16:48 -08:00
Johan T. Halseth
6f263610ae fundingmanager: add more logging after funding confirmation (#454)
This commit adds additional logging around the sending
of fundingLocked and channel announcements.
2017-12-08 14:50:26 -08:00
Olaoluwa Osuntokun
0ba80f5b40
funding: return an error if unable to sendFundingLocked 2017-12-07 19:03:51 -08:00
Olaoluwa Osuntokun
4444ec39ea
funding: properly display our 1-byte error code messages 2017-12-06 18:43:58 -08:00
Olaoluwa Osuntokun
9314aa2e7d
funding: route back full lnwire.Error to caller upon funding flow failure 2017-11-30 22:53:48 -08:00
Olaoluwa Osuntokun
c081b386d2
funding: when crafting our ChannelUpdate use the remote party's minHTLC
In this commit, we implement a recent spec change that require nodes to
advertise the minHTLC of the remote node within their ChannelUpdate. We
do this as it will be the remote node which carries the HTLC towards
us, therefore we should advertise *their* minHTLC value.
2017-11-30 22:52:39 -08:00
Olaoluwa Osuntokun
55bdf25235
funding: attempt to send error back to caller within CancelPeerReservations 2017-11-30 22:42:26 -08:00
Olaoluwa Osuntokun
c986e52da7
funding+server: ensure we cancel all reservations when a peer disconnects
In this commit, we fix an existing issue that could at times cause an
inconsistent view between the set of total coins, and the set of segwit
coins in the wallet of the node. This could be caused by initiating a
funding flow, but then the funding negotiation breaking down somewhere
along the lines. In this case, us or the other peer will disconnect.
When we initiate funding flows, we lock coins exclusively, to ensure
that concurrent funding flows don’t end up double spending the same
coin. Before this commit, we wouldn’t ever unlock those coins. As a
result, our view of available coins would be skewed.

The walletbalance call would show all the coins, but when adding the
—witness_only flag, some coins would be missing, or gone all together.
This is because the former call actually scans the txstore and manually
tallies the amount of available coins, while the latter looks at the
sent of available outputs, which is filtered based on which coins are
locked.

To remedy this, we now ensure that when a peer disconnects, we wipe all
existing reservations which will return any locked outputs to the set
of available outputs for funding flows.
2017-11-26 14:08:53 -06:00
Olaoluwa Osuntokun
530c49f12e
funding: sent channel to breachArbiter as soon as it's open 2017-11-23 23:10:14 -06:00
Olaoluwa Osuntokun
6e3d231619
funding: properly pass in channel state as argument of closure in Start 2017-11-23 23:10:13 -06:00
Olaoluwa Osuntokun
a3cd248404
funding+utxonursery+breacharbiter: use new FeeEstimator API 2017-11-23 23:10:13 -06:00
Olaoluwa Osuntokun
88d418c0ec
funding: add additional debug logging to during final funding flow stages 2017-11-16 20:00:06 -08:00
Olaoluwa Osuntokun
4700c1be04
funding: populate the HtlcPoint during the funding workflow 2017-11-16 20:00:02 -08:00
Jim Posen
78f8ddef72 lnd: Remove some sleeps in integration tests.
There is a sleep after channels are opened to ensure the channel is
removed from the set of pending reservations. We can avoid this sleep
and get better guarantees of the channel being opened by deleting the
reservation just before updating channel state to active instead of
after.
2017-11-13 20:52:07 -08:00
Olaoluwa Osuntokun
2862b6e6f1
funding: update to adhere to new channels API's 2017-11-10 19:51:08 -08:00
Olaoluwa Osuntokun
3764e5c65e
funding: by default, signal to announce initiated channel to network 2017-11-09 12:00:18 -08:00
nsa
9c0c889131 funding: decouple funding wait from fundingLocked and chanAnn
This commit decouples the wait for funding transaction confirmations
in the waitForFundingConfirmation function from the announcement of
the channel in the sendFundingLockedAndAnnounceChannel function.
Additionally, the sendFundingLockedAndAnnounceChannel function is
now decoupled into the sendFundingLocked and sendChannelAnnouncement
functions. There is also now a helper function that houses creation
of a lnwire.LightningChannel object, calls to both sendFundingLocked
and sendChannelAnnouncement.
2017-10-27 16:43:07 -07:00
Jim Posen
9fd77a6e40 multi: Update lnd to use new feature vector API. 2017-10-17 22:47:20 -07:00
Johan T. Halseth
ff2adf96a9
fundingManager: conditional select on arbiterChan and peer.newChannels
This commit adds a select statement for sending on the fundingManager's
arbiterChan and the peer's newChannels channel. This makes sure we won't
be blocked sending on these channels in case of a shutdown.
2017-10-02 13:29:56 +02:00
Johan T. Halseth
b8cadf881c
fundingManager: use NotifyWhenOnline when sending fundingLocked.
The fundingManager will register with the server to get notified
when the targetted peer comes online, in case of a failed send
of the fundingLocked message. This is necessary because if the
peer is not connected yet (or was disconnected while we were
waiting for the funding tx to confirm), we cannot continue the
the opening process before the peer successfully has received
the fundingLocked.
2017-10-02 13:29:52 +02:00
Johan T. Halseth
8244b7a78c
fundingManager: handle duplicate fundingLocked
This commit adds a channel barrier on fundingManager startup for
channels where the opening process is not finished. This fixes
a bug where we after restarting the fundingManager would receive
the fundingLocked message, and crash when trying to close the
non-existing barrier.

In case we received a fundingLocked message after our own opening
process was finished, we would crash with the same error. We
therefore check if the channel barrier exists before we try to
close it.

It also adds functionality to fundingManager that makes it
ignore a fundingLocked message it receives for a channel where
this is already received. This is necessary when we in case of
a reconnection resend the fundingLocked since we cannot be sure
the remote has received it.

The fundingmanager tests are also updated to check that the
fundingLocked messages are sent and handled correcly, and also
exercise the scanarios described above.
2017-10-02 13:29:49 +02:00
Olaoluwa Osuntokun
c06b82c3a2
funding: add a conditional send on quit for all process* methods
This commit adds a conditional send on quit to all methods used by
outside sub-systems to the funding manager. This ensures, that in the
case the funding manager is exiting, the caller won’t block
indefinitely.
2017-09-27 20:07:08 -07:00
Olaoluwa Osuntokun
31d53c6070
funding: properly display pending chan ID within logs
This commit corrects a minor formatting error when logging the pending
channel ID within the logs. Previously, the logging directives and
parameter could cause the pending chan ID to display in a double-hex
encoded format. We fix this by ensuring that we properly slice the chan
ID before printing it, and also ensure that we use the %x formatting
(which will hex encode the bytes) everywhere.

Fixes #331.
2017-09-18 19:33:43 +02:00
Olaoluwa Osuntokun
737eeedd49
funding: don't send a funding error in the case of a funding timeout 2017-09-13 01:04:09 +02:00
Olaoluwa Osuntokun
3b2ed69638
funding: in failFundingFlow properly embed passed error 2017-09-12 22:38:44 +02:00
Olaoluwa Osuntokun
769abb87ea
funding: properly verify and apply channel constraints during funding flow
This commit implements some missing functionality as we’ll now properly
validate and generate the various channel flow control constraints
during initial channel funding.

With this commit, we take an additional step towards full spec
compliance as we’ll now properly send over the required channel
reservation, max HTLC’s, and other parameters during the funding flow.

When processing the desired parameters by the remote party, if we think
they’re unreasonable, then we’ll send an Error message and end the
funding flow.
2017-09-12 18:07:50 +02:00
Olaoluwa Osuntokun
25766fc9ca
funding: use new failFundingFlow method when error encountered during funding 2017-09-12 17:31:29 +02:00
Olaoluwa Osuntokun
3701757cdc
funding: add new failFundingFlow method to fail flow and send funding error 2017-09-12 17:30:06 +02:00
Olaoluwa Osuntokun
1ce6c4668e
funding: unconditionally forward all received errors to client
Previously, our old lnwire.Error message used a special code to
indicate different types of errors. With the recent push for spec
compatibility, we removed this field and instead stuffed the error into
the first byte of the error data. This works between lnd nodes, but
with other implementations they may send different errors which use a
different error scheme.

To fix this, we’ll now unconditionally return the error to the end
caller (if one exists).
2017-08-30 20:31:40 -07:00
Olaoluwa Osuntokun
7be039adec
multi: ensure that BlockEpoch clients are cancelled
This commit fixes a prior goroutine leak that could result in a node
having thousands of goroutines, particularly due to many concurrent
channel fundings. We now ensure that for each BlockEpoch client
created, we ensure that the client is cancelled once the creating
grouting exits.
2017-08-30 20:26:17 -07:00
Olaoluwa Osuntokun
39ab177567
funding: populate ChainHash in announcement messages, update signing
This commit updates the tail end of the funding workflow to properly
include the ChainHash field when crafting ChannelAnnouncements and the
initial ChannelUpdate messages. Additionally, we now properly generate
the proper signatures to match the changes to BOLT0007.
2017-08-22 00:53:01 -07:00