Commit Graph

236 Commits

Author SHA1 Message Date
Conner Fromknecht 3ae7772ecb
htlcswitch/mailbox_test: adds checks for reset and replay of pkts 2018-03-09 21:08:43 -08:00
Conner Fromknecht 9b00f83656
htlcswitch/mailbox: makes pkts replayable via Reset 2018-03-09 21:08:43 -08:00
Conner Fromknecht 3a186a02a9
htlcswitch/link_test: generate random preimages 2018-03-09 21:08:43 -08:00
Conner Fromknecht 101ad09e9f
htlcswitch/link: batches processing of locked in htlcs 2018-03-09 21:08:43 -08:00
Conner Fromknecht 2c3d35bb40
htlcswitch/interfaces: have HandleSwitchPacket return an error 2018-03-09 21:08:43 -08:00
Conner Fromknecht 403028da78
htlcswitch/circuit_test: use half adds in circuit map test 2018-03-09 21:08:42 -08:00
Conner Fromknecht 0b71f74199
htlcswitch/circuit_map: moves circuit map impl to own file 2018-03-09 21:08:42 -08:00
Conner Fromknecht 067b261602
htlcswitch/circuit: add half adds to circuit map 2018-03-09 21:08:42 -08:00
Conner Fromknecht 02c65db0d1
htlcswitch/link_test: integrate new channel update APIs 2018-03-09 17:35:54 -08:00
Conner Fromknecht 1fe7c6d431
htlcswitch/link: integrate persistence changes to lnwallet APIs 2018-03-09 17:35:53 -08:00
Conner Fromknecht 6a88ff940a
htlcswitch_/test_utils: init OpenChannels w/ Packager 2018-03-09 14:45:31 -08:00
Olaoluwa Osuntokun 51a3cab39c
htlcswitch: fix race in forwarding log test by grabbing log mtx 2018-03-08 20:11:49 -08:00
Olaoluwa Osuntokun 649be5ee0b
Merge pull request #775 from cfromknecht/sphinx-replay
Switch Persistence [1/4]: Infra for Sphinx Batched Decoding and Replay Protection
2018-03-08 23:03:01 -05:00
Conner Fromknecht c2ec3a6ef5
htlcswitch/test_utils: use new ErrorEncrypter and HopIterator ifaces 2018-03-08 21:12:05 -05:00
Conner Fromknecht 5cbdb29bcc
htlcswitch/link_test: mock extracting of error encrypter from onion pkt 2018-03-08 21:12:04 -05:00
Conner Fromknecht 06fb524a3b
htlcswitch/mock: update mock obfuscator and iterators w/ new sphinx API 2018-03-08 21:12:04 -05:00
Conner Fromknecht 27df8d8ad1
htlcswitch/link: extract error encrypter from hop iterator 2018-03-08 21:12:04 -05:00
Conner Fromknecht f075905d6c
htlcswitch/iterator: use batch API for sphinx router 2018-03-08 21:12:04 -05:00
Conner Fromknecht fcf08382f7
htlcswitch/failure: add Encode/Decode to ErrorEncrypter 2018-03-08 21:12:03 -05:00
Olaoluwa Osuntokun 7031b5d217
htlcswitch: modify forwarding fee assertion to compare emperical fees
In this commit, we fix a bug that was uncovered by the recent change to
lnwire.MilliSatoshi. Rather than manually compute the diff in fees,
we’ll directly compare the fee that is given against the fee that we
expect.
2018-03-08 12:50:49 -05:00
Olaoluwa Osuntokun 4b20e805fe
multi: update packages due to recent SignDescriptor and WalletController changes 2018-03-06 16:04:03 -05:00
Olaoluwa Osuntokun 473dfd115b
htlcswitch: add set of tests for the forwarding log 2018-03-06 13:56:11 -05:00
Olaoluwa Osuntokun ad522a72c1
htlcswitch: add new ticker in switch to batch log forwarding events
In this commit, we extend the switch as is, to record details
concerning settled payment circuits. To do this, we introduce a new
interface to the package: the ForwardingLog. This is a tiny interface
that simply lets us abstract away the details of the storage backing of
the forwarding log.

Each time we receive a successful HTLC settle, we’ll log the full
details (chans, fees, time) as a pending forwarding log entry. Every 15
seconds, we’ll then batch flush out these entries to disk. When we’re
exiting, we’ll try to flush out all entries to ensure everything gets
recorded to disk.
2018-03-06 13:56:11 -05:00
Olaoluwa Osuntokun 6f11fee1a4
htlcswitch: when forwarding htlcs, set the incomingHtlcAmt 2018-03-06 13:56:10 -05:00
Olaoluwa Osuntokun d377ffafdd
htlcswitch: populate the incoming+outgoing in the payment circuit 2018-03-06 13:56:10 -05:00
Olaoluwa Osuntokun 157e052958
htlcswitch: add the incoming payment amount to the htlcPacket
We’ll need this value within the link+switch in order to fully populate
the forwarding event that will be generated if this HTLC circuit is
successfully completed.
2018-03-06 13:56:10 -05:00
Olaoluwa Osuntokun 2b8cad2f08
htlcswitch: add incoming+outgoing amounts to the PaymentCircuit
In this commit, we add the incoming+outgoing amounts if the HTLC’s that
the payment circuit consists of. With these new fields, we’ll be able
to populate the forwarding event log once the payment circuit has been
successfully completed.
2018-03-06 13:56:09 -05:00
Johan T. Halseth 4d2a36dce8
htlcswitch tests: update tests to new FeeEstimator and fee rate types 2018-02-26 22:42:25 +01:00
Johan T. Halseth 80277c0517
htlcswitch: use fee rate types instead of btcutil.Amount for fee rates 2018-02-26 22:42:25 +01:00
practicalswift b8e1351cf3 multi: fix some recently introduced typos 2018-02-18 15:27:29 -08:00
Johan T. Halseth 509adce2ad
htlcswitch test: add TestChannelLinkBandwidthChanReserve 2018-02-08 18:35:24 -05:00
Johan T. Halseth e6f7a46d90
htlcswitch: don't return negative value from Bandwidth()
This commits prevents the Bandwith() method from returning
a negative value if the channel reserve is larger than
the actual available balance.
2018-02-08 18:35:24 -05:00
nsa 7e84892c21
htlcswitch: account for channel reserve in Bandwidth 2018-02-08 18:35:23 -05:00
Conner Fromknecht 1dc12549d2
htlcswitch/switch: select on quit channels for switch commands
This commit fixes a deadlock scenario caused when some
switch methods are waiting for a response on the
command's done/err chan. However, no such response will
be delivered if the main event loop has already exited.
This is resolved by selecting on the command's done/err chan
and the server's quit chan simultaneously.
2018-02-07 20:43:53 -08:00
Olaoluwa Osuntokun 850abbbeb5
htlcswitch: update tests to respect recent API changes 2018-02-06 20:14:31 -08:00
Olaoluwa Osuntokun 1afadf4822
htlcswitch: properly rename struct in tests 2018-02-06 19:28:36 -08:00
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
Olaoluwa Osuntokun 18741831dd
Merge pull request #485 from halseth/fix-negative-balance
Use remoteACKed index when calculating availableBalance.
2018-02-05 16:23:17 -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
Johan T. Halseth 12d3327833
htlcswitch/link_test: update Bandwidth tests
This commit updates the tests for checking a links Bandwidth()
calculation, after the change that made us use the remoteACKedIndex
instead of the logIndex when calculating it. The main result of this
change is that we never consider incoming updates before they are
acked, when calculating the bandwidth. This is because this was
inconsistent with the state we actually end up signing later on.
2018-02-02 21:16:37 -05:00
Johan T. Halseth ab75cd3a4d
htlcswitch/test_utils: set BatchTicker mock and BatchSize
This commit adds the mockTicker and BatchSize to the link
config. It also exits the goroutines draining the HtlcUpdates
gracefully.
2018-02-02 21:16:37 -05:00
Johan T. Halseth cc050f183f
htlcswitch tests: add mockTicker struct 2018-02-02 21:16:37 -05:00
Johan T. Halseth 9b7b3fa3b6
channellink: make BatchTicker and BatchSize configurable
This commit introduces a new Ticker interface, that can be used
to control when the batch timer should tick. This is done to be
able to more easily control the ticker during tests. The batch
timer is wrapped in the new BatchTicker struct, and made part
of the config together with BatchSize.
2018-02-02 21:16:36 -05:00
Wilmer Paulino f0d6d31ca4
htlcswitch: allow sending htlcs when paying invoices with a zero amount 2018-01-27 19:05:23 -05:00
Olaoluwa Osuntokun f8adab1f1c
test: add comprehensive integration tests for on-chain HTLC handling
In this commit, we add 6 new integration tests to test the various
actions that may need to be performed when either side goes on-chain to
fully resolve HTLC’s. Many of the tests are mirrors of each other as
they test sweeping/resolving HTLC’s from both commitment transactions.
2018-01-22 19:20:02 -08:00
Olaoluwa Osuntokun 96fbc7da84
htlcswitch: fix deadlock during chainWatcher notifications 2018-01-22 19:19:59 -08:00
Olaoluwa Osuntokun ca613a625f
htlcswitch: handleLocalDispatch can now handle locally sourced resolutions
In this commit, we update the failure case within handleLocalDispatch
to handle locally sourced resolutions. This is the case that we send a
payment out, but before it can even get past the first hop, we need to
go to chain (may have been a cascading failure). Once the HTLC is fully
resolved, we’ll send back a resolution message, however, that message
doesn’t have a failure reason populated. To properly handle this, we’ll
send back a permanent channel failure to the router.
2018-01-22 19:19:56 -08:00
Olaoluwa Osuntokun 239416f242
htlcswitch: update to use new event stream from the chainWatcher 2018-01-22 19:19:51 -08:00
Olaoluwa Osuntokun 703057c821
htlcswitch: with debughtlc+hodlhtlc mode, skip all HTLC level checks 2018-01-22 19:19:41 -08:00