Commit Graph

2421 Commits

Author SHA1 Message Date
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
Olaoluwa Osuntokun
126c73af59
test: increase timeout for testNodeAnnouncement 2017-10-19 21:18:27 -07:00
Dustin Dettmer
5661748df0 test: fix typo 2017-10-19 20:20:27 -07:00
nsa
aa6395874d wallet: channel test fee fix for added HTLC
This commit fixes the TestChannelBalanceDustLimit unit test in
channel_test.go. The unit test does not account for the fees
required by adding an HTLC. As a result, Alice's balance according
to her local and remote commitment chains drops below 0 at certain
points. By using the correct fee, this is avoided.
2017-10-19 20:04:04 -07:00
mlerner
cc221b1548 Fix spelling in docker docs 2017-10-19 20:03:00 -07:00
Jim Posen
e9c16845dc chainntnfs: Remove some unnecessary channels in interface_test. 2017-10-19 20:00:16 -07:00
Jim Posen
be7cb08f41 chainntnfs: Rename file with typo in filename. 2017-10-19 20:00:16 -07:00
Olaoluwa Osuntokun
8358349b2d
lnd: revert back to prior default wallet public passphrase
In this commit we ensure the behavior of lnd with the —noencryptwallet
command line option heaves as it did before user initiated wallet
encryption was implemented. We do this by modifying the
waitForWalletPassword method to instead return two pass phrases: one
public and one private. The default wallet public passphrase is then
restarted back to the value which was used stoically in the codebase
before the latest merged PR.
2017-10-19 19:53:28 -07:00
Olaoluwa Osuntokun
08940b43d5
walletunlocker: don't utilize the macaroon authentication service
In this commit we remove all instances of the macaroon authentication
service from the UnlockerService struct. We do this, as in the future,
the macaroons themselves will be encrypted using the user’s passphrase,
therefore we wouldn’t be able to _verify_ the macaroon unless the
wallet itself was encrypted.
2017-10-19 19:46:48 -07:00
Olaoluwa Osuntokun
8de0a4cb24
peer: when logging message summaries use the correct preposition 2017-10-19 19:45:34 -07:00
Olaoluwa Osuntokun
4cf4fd377f
peer: in chanMsgStream release lock for condition var after msg q pop
In this commit we fix an existing bug within the msgConsumer grouting
of the chanMsgStream that could result in a partial deadlock, as the
readHandler would no longer be able to add messages to the message
queue. The primary cause of this issue would be if we got an update for
a channel that “we don’t know of”. The main loop would continue,
leaving the mutex unlocked. We would then try to re-lock at the top of
the loop, leading to a deadlock.

We avoid this situation by properly unlocking the condition variable as
soon as we’re done modifying the condition itself.
2017-10-19 19:45:08 -07:00
Johan T. Halseth
00ee3afab8 lncli: add commands "create" and "unlock"
lncli create:
This command is used to set up a wallet encryption password for
use with lnd at first time use. It will ask fot the user to
confirm the chosen password, then do a call to the lnd RPC method
CreateWallet with the chosen password.

lncli unlock:
This command is used to unlock the wallet of a running lnd instance.
It calls the RPC method UnlockWallet with the provided password.

Both methods makes use of the terminal.ReadPassword method, to
securely read a password from user input without making it
replayable in the terminal.
2017-10-19 19:17:35 -07:00
Johan T. Halseth
2c2d18ee10 networktest: --noencryptwallet for test nodes
This commit adds the --noencryptwallet flag to integration test
nodes,  causing them to be operational during the tests without
having to provide a password over rpc.
2017-10-19 19:17:35 -07:00