Commit Graph

2383 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
5b226a9d37
discovery: add TCP fallback for DNSSeedBootstrapper
In this commit, we add a TCP fallback option for the
DNSSeedBootstrapper. We’ve received many reports of users unable to
bootstrap properly to the network due to the size of the SRV records we
currently return. It has been observed that many revolvers will simply
truncate and ignore the response due to the (current size).

To resolve (no pun intended) we now attempt to detect this failure mode
and will fallback to a manual TCP resolution in the case that our SRV
query over UDP fails. We do this by querying the special record at the
"soa." sub-domain of supporting DNS servers. The retuned IP address
will be the IP address of the authoritative DNS server. Once we have
this IP address, we'll connect manually over TCP to request the SRV
record. This is necessary as the records we return are currently too
large for a class of resolvers, causing them to be filtered out.
2017-10-30 19:00:27 -07:00
Olaoluwa Osuntokun
9bcb139bcc
autopilot: shuffle set of candidates using Fisher–Yates before selecting
In this commit we modify the ConstrainedPrefAttachment.Select method to
first shuffle the set of potential candidates before selecting them.
This serves to remove the existing grouping between candidates which
may have influenced the selection.
2017-10-30 18:55:55 -07:00
Olaoluwa Osuntokun
5ced45af01
docker/lnd: start container w/o prompting user for wallet passphrase
In this commit we restore the prior workflow of the docker-compose set
up with have to allow developers to quickly erect an lnd+btcd instance.
In a recent change, we now prompt the user for a passphrase that will
be used to encrypt the wallet database. This affected the prior
workflow, as it assumed set up was non-interactive.

In this commit we restore the prior behavior as we now start the lnd
nodes with --noencryptwallet.
2017-10-30 18:40:51 -07:00
Olaoluwa Osuntokun
a559319543
docker: update maintainer for lnd+ltcd docker files 2017-10-30 18:38:37 -07: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
Conner Fromknecht
3b2e4caa93 discovery/gossiper: isolate sync with node from query
This commit refactors the SynchronizeNode logic such that
  it can be called without interacting with the gossiper's
  main execution loop. This method does not require access
  to any of the gossiper's internal state, making the change
  fairly straightforward. The primary motivation behind
  this change is to minimize the possibility of introducing
  deadlock scenarios between the gossiper and server.
2017-10-27 15:48:37 -07:00
rajeshnair2k
0e07699550 lncli: add a convenience command for paying an invoice
Fixes #324.
2017-10-27 15:39:54 -07:00
Jim Posen
a13ad0a339 multi: Fix various typos. 2017-10-25 13:20:54 -07:00
Johan T. Halseth
4b883b9899 funding: poll or database state instead of using timeouts in tests
This commit make the fundingmanager tests poll for database state
for a time, instead of using an explicit sleep before accessing the
DB. This should address some of the flakes encountered on Travis,
where db writes might take longer than usual.
2017-10-25 13:17:22 -07:00
Jim Posen
2b58a39d30 lnwallet: Simplify updateLog struct by removing redundant pointers.
The updateLog struct contains pointers that refer to the state of the
commitment chains. Instead, query the commitments directly.
2017-10-25 13:11:46 -07:00
Olaoluwa Osuntokun
885753cae4
test: extend testMultiHopPayments to test a 4 node, 3 hop payment
In this commit, we extend the testMultiHopPayments test case to add an
additional node to the multi-hop payment route: Dave.

Related to #391 as it uses the provided code fragment to reproduce the
bug. With this test in place, we’ll now be able to notice any
regressions in this area.
2017-10-24 18:34:04 -07:00
Olaoluwa Osuntokun
21446c2872
htlcswitch: finish remainder of TestUpdateForwardingPolicy test case
In this commit, we address a lingering TODO within the
TestUpdateForwardingPolicy test case to ensure that Bob will reject the
payment the second time around due to an update in his fee policy.
2017-10-24 18:31:46 -07:00
Olaoluwa Osuntokun
57b9b78ce3
routing: modify path finding tests to accommodate for flip in fee calc
Before this commit, we would expect that structurally we don’t pay any
fee for the first hop, but do for the final hop. After the latest
commit, this is now flipped as when we say fee, we mean the fee that we
need to pay to transit a link. For the final hop, there’s no additional
distance to be traveled, so the fee is nothing.
2017-10-24 18:29:23 -07:00
Olaoluwa Osuntokun
a7fe7ae941
routing: correct miscalculation multi-hop onion payload fees
In this commit we fix an existing miscalculation in the fees that we
prescribe within the onion payloads for multi-hop routes. Before this
commit, if a route had more than 3 hops, then we would erroneously give
the second to last hop zero fees.

In this commit we correct this behavior, and also re-write the fee
calculation code fragment within newRoute for readability and clarity.
There are now only two cases: this is the last hop, and this is any
other hop. In the case of the last hop, simply send the exact amount
with no additional fee. In the case of an intermediate hop, we use the
_prior_ (closer to the destination) hop to calculate the amount of fees
we need, which allows us to compute the incoming flow. Using that
incoming flow, we then can compute the amount that the hop should
forward out.

Partially fixes #391.
2017-10-24 18:27:35 -07:00
Olaoluwa Osuntokun
176fde4ec0
routing: modify applyChannelUpdate to not error out if update is stale
In this commit we fix a slight bug within the existing SendPayment loop
which would cause the wrong error to be returned to users. Prior to
this commit, if we received an update identical to what we were already
aware of, then that error would be returned rather than the
ForwardingError that encapsulated this update.

In this commit with remedy this by properly returning the exact error.

Partially fixes #391.
2017-10-24 18:23:04 -07:00
Olaoluwa Osuntokun
3e64ba0394
test: modify all testing involving HTLC routing to directly use payreqs
In this commit we modify all the test that involve sending payments to
use the payreq returned rather than manually populating the
payhash+dest fields in the SendRequest proto argument to SendPayment.
This is required as if we don’t use the payreq returned, then the
receiving node will reject the payment as it’ll use the global final
CLTV delta value, rather than the value (within the pay req) that the
receiver is expecting.
2017-10-22 18:37:02 -07:00
Olaoluwa Osuntokun
e02af3f877
htlcswitch: as exit node check for invoice and HTLC value match after existence 2017-10-22 18:37:00 -07:00
Olaoluwa Osuntokun
a29210f089
rpc: properly interpret and parse cltvDelta from payreqs (if exists) 2017-10-22 18:37:00 -07:00
Olaoluwa Osuntokun
25614f67f8
routing: restore in memory selfNode within the ChannelRouter
In this commit we restore the in memory ChannelRouter as we’ll no
dynamically set the ChannelRouter’s pointer within he spec path finding
test example.
2017-10-22 18:36:59 -07:00
Olaoluwa Osuntokun
76ec41103e
routing: extend missionControl.RequestRoute to take final CLTV delta 2017-10-22 18:36:58 -07:00
Olaoluwa Osuntokun
828057889e
routing/testdata: modify spec example to set bob as initial source node 2017-10-22 18:36:58 -07:00
Olaoluwa Osuntokun
74165ca8c1
htlcswitch: update l.clearedOnionBlobs in link to use new HtlcIndex 2017-10-22 18:36:57 -07:00
Olaoluwa Osuntokun
3b94e5df4d
lnwallet: introduce distinct HTLC counter+index on top of updateLog
In this commit, we fix an existing derivation from the commitment state
machine as defined within the specification. Before this commit, we
only kept a single counter which both HTLC adds and fails/settles would
share. This was valid in the prior pre-spec iteration of the state
machine. However in the current draft of the spec, only a distinct
counter for HTLCs are used throughout.

This would cause an incompatibility, as if we mixed adds and settles
during an exchange, then our counter values would differ with other
implementations. To remedy this, we now introduce a distinct HTLC
counter and index within the updateLog.

Each Add will increment both the log counter, and the HTLC counter.
Each Settle/Fail will only increment the log counter. Inbound
Settle/Fails will index into the HTLC index as to target the proper
HTLC. The PaymentDescriptor type has been extended with an additional
field (HltcIndex) which itself tracks the index of an incoming/outgoing
HTLC.
2017-10-22 18:36:57 -07:00
Olaoluwa Osuntokun
da9a771a58
htlcswitch: update timelock policy mismatch test due to time lock changes
In this commit, we update the TestLinkForwardTimelockPolicyMismatch to
instead _subtract_ time from the first HTLC extended to the initial
hop. We now subtract instead as giving intermediate hops more time
is.now permitted.
2017-10-22 18:36:56 -07:00
Olaoluwa Osuntokun
6a255fb588
htlcswitch: relax timelock verification in middle link to allow for shadow routes
In this commit, we relax the time lock verification when we realize
we’re an intermediate hop. We no longer directly assert that the time
lock we receive is _identical_, instead we allow slow slack and will
reject iff, the incoming timelock minus the outgoing time lock doesn’t
meet our delta requirements.
2017-10-22 18:36:56 -07:00
Olaoluwa Osuntokun
bdc4d09b25
rpc: display the cltv expiry in decoded pay req 2017-10-22 18:36:55 -07:00
Olaoluwa Osuntokun
22881ec05e
rpc: in createRPCInvoice properly populate CltvExpiry 2017-10-22 18:36:55 -07:00
Olaoluwa Osuntokun
5bc906dd18
rpc: properly parse our CltvExpiry in AddInvoice 2017-10-22 18:36:54 -07:00
Olaoluwa Osuntokun
c54e6fc803
zpay32: add new 'c' field to payreqs for specifying final cltv delta 2017-10-22 18:36:53 -07:00
Olaoluwa Osuntokun
de7e339281
lnrpc: add cltv_expiry to Invoice and PayReq protos 2017-10-22 18:36:53 -07:00
Olaoluwa Osuntokun
6e00abf3f1
routing: update tests in router_test.go to pass in new param to FindRoutes 2017-10-22 18:36:52 -07:00
Olaoluwa Osuntokun
69a3783d55
routing: add new test case from spec to assert proper route calc 2017-10-22 18:36:52 -07:00
Olaoluwa Osuntokun
acd160a419
routing: update path finding tests to account for change in fee calculation 2017-10-22 18:36:51 -07:00
Olaoluwa Osuntokun
aee1619488
routing: add new FinalCLTVDelta attribute to SendPayment
In this commit, we’ll now optionally allow the user to pass in the CLTV
delta value specified by the recipient a payment. If the value isn’t
specified, then we’ll use the current global default for the payment.
2017-10-22 18:36:51 -07:00
Olaoluwa Osuntokun
c8f45e3a04
routing: add new param to FindRoutes for CLTV expiry for final hop
In this commit, we modify the FindRoutes method to pass in the CLTV
expiry for the final hop. If the value isn’t passed in, then we’ll use
the current global default value in place.
2017-10-22 18:36:50 -07:00
Olaoluwa Osuntokun
4b82e2ec43
routing: correct fee calculation when converting from path to route
In this commit, we correct the fee calculation when converting from a
path to route. Previously we would apply the “no fee” case at the
_first_ hop, rather than the last hop. As a result, we needed to swap
the edges during path finding, otherwise, if the incoming and outgoing
edges had different fee rates, then we would create an invalid onion
payload.

In this commit we now properly switch fee calculation into three cases:
  * a single hop route, so there’s no fee
  * we’re at the first hop in a multi hop route, and we apply the fee
for the _next_ hop
  * we’re at an intermediate hop and the fee calculation proceeds as
normal
2017-10-22 18:36:50 -07:00
Olaoluwa Osuntokun
8df69a83a7
routing: revert the swapping of in/out edges during path finding
In this commit we revert a commit which was added in the past as way to
allow the path -> route conversion code to remain the same, while
properly respecting the necessary time locks and fees. In an upcoming
change, this swap is no longer necessary as we’ll always use: the time
lock of the outgoing node and the fee of the incoming node.
2017-10-22 18:36:49 -07:00
Olaoluwa Osuntokun
23b6d84493
routing: modify newPath to take the preferred final CLTV delta of last hop
In this commit, rather than reading the final CLTV delta from the
channel graph itself (which would require _both_ edges to be advertised
in order to route over), we now instead have moved to allowing the
receiving node to choose their own final CLTV delta.
2017-10-22 18:36:48 -07:00
Olaoluwa Osuntokun
65482faa79
routing: remove the selfNode attribute from memory
In this commit, we’ve removed the selfNode attribute from memory, as
the set of new tests we’ll write, will depend on us being able to
switch the source node dynamically from the database itself.
2017-10-22 18:36:48 -07:00
Olaoluwa Osuntokun
f5881ad3df
routing: only write a single edge as edges in test data are now directional 2017-10-22 18:36:47 -07:00
Olaoluwa Osuntokun
86283b0d06
routing: make setting source node optional when parsing testdata 2017-10-22 18:36:47 -07:00
Olaoluwa Osuntokun
e70031da7b
routing: properly assign flags and write both edges when parsing test data 2017-10-22 18:36:46 -07:00
Olaoluwa Osuntokun
4ff66efa2b
routing: convert testChan stuct to take an int64 for FeeRate 2017-10-22 18:36:46 -07:00
Olaoluwa Osuntokun
fae3dacc9b
routing: modify basic_graph.json to include both directional edges 2017-10-22 18:36:45 -07:00
Olaoluwa Osuntokun
3c01d5bab9
routing: convert basic_graph.json testdata to use fixed point fee rate 2017-10-22 18:36:44 -07:00
Olaoluwa Osuntokun
bb1fd98b67
peer: print hex encoded failure reason for lnwire.UpdateFailHTLC in msg summaries 2017-10-22 18:36:40 -07:00
Jim Posen
7c1ae8bda3 lnwallet: Split tx generation code out of fetchCommitmentView.
This moves the commitment transaction generation code out of
fetchCommitmentView into createCommitmentTx. Aside from being a pretty
clean logical split, this allows the transaction generation code to be
unit tested more effectively.
2017-10-19 22:23:14 -07:00
Jim Posen
bd497438af lnwallet: Pass around key ring instead of individual keys.
The signatures of some functions/methods in lnwallet are simplified by
passing in a commitmentKeyRing argument instead of multiple keys.
2017-10-19 22:23:14 -07:00
Jim Posen
3151a3a596 lnwallet: Refactor commitment key generation code.
Create struct holding all commitment keys to clean up code and avoid
deriving keys multiple times.
2017-10-19 22:23:14 -07:00
Alex
0994852396 lnwallet: add reorg test 2017-10-19 21:26:31 -07:00