Commit Graph

7100 Commits

Author SHA1 Message Date
Joost Jager
c23bb5b3f1
htlcswitch: extract settle invoice into method 2019-03-15 10:09:03 +01:00
Joost Jager
22b68e5dc7
lncli: add hold invoice 2019-03-15 10:09:00 +01:00
Joost Jager
fcdc8f0e83
lnrpc/invoices: add hold invoice rpc 2019-03-15 10:08:58 +01:00
Joost Jager
19f79613df
channeldb: store hold invoice 2019-03-15 10:08:55 +01:00
Joost Jager
8392f6d28f
lnrpc/invoicesrpc: remove lnrpc type from add invoice 2019-03-15 10:08:52 +01:00
Joost Jager
b9cc165341
lnrpc: move add invoice logic to subserver 2019-03-15 10:08:49 +01:00
Joost Jager
4141773e90
htlcswitch: resolve invoice cancelation race condition
Previously it could happen that an invoice was open at the time of the
LookupInvoice call, the htlc was settled because of that, but when the
SettleInvoice call was made eventually, it would fail because the
invoice was canceled in the mean time. The htlc would then be settled,
but the invoice not marked as such.
2019-03-15 10:08:46 +01:00
Joost Jager
eb598ec7a4
htlcswitch: extract exit hop processing to method 2019-03-15 10:08:43 +01:00
Joost Jager
9643b45dbc
htlcswitch/test: move preimage cache to server level
In this commit the preimage cache is instantiated on the mock server
level where it belongs. Previously it was a cache shared across all mock
servers.
2019-03-15 10:08:40 +01:00
Joost Jager
c4263e7061
lntypes: return a value from constructors
Returning pointers proved inconvenient in almost all cases. This commmit
converts the constructors to returning values.
2019-03-15 10:08:38 +01:00
Joost Jager
449c3d533e
contractcourt: add access to full invoice registry from resolvers
Previously a function pointer was passed to chain arbitrator to avoid a
circular dependency. Now that the routetypes package exists, we can pass
the full invoice registry to chain arbitrator.

This is a preparation to be able to use other invoice registry methods
in contract resolvers.
2019-03-15 10:08:35 +01:00
Joost Jager
2be1051fb6
zpay32: move HopHint and DefaultFinalCLTVDelta 2019-03-15 10:08:32 +01:00
Joost Jager
652ebb1652
lnwire: add constructor for FinalExpiryTooSoon failure message 2019-03-15 10:08:29 +01:00
Joost Jager
10a655b6b1
lntypes: add preimage Matches method 2019-03-15 10:08:26 +01:00
Olaoluwa Osuntokun
36cc1da8ea
Merge pull request #2633 from halseth/autpilot-chansize-allocation
[autopilot] distribute available funds among channels
2019-03-14 12:51:02 -07:00
Johan T. Halseth
fb5b6ff425
autopilot/agent_test: add TestAgentChannelSizeAllocation
TestAgentChannelSizeAllocation tests that the autopilot agent opens
channel of size that stays within the channel budget and size
restrictions.
2019-03-14 08:49:28 +01:00
Johan T. Halseth
b71f4632a6
autopilot/agent_test: define testCtx, setup, other helpers
This commit defines a set of helper methods that are used by many of the existing tests.
2019-03-14 08:49:28 +01:00
Johan T. Halseth
4a1e06b204
autopilot/agent: distribute available funds among channels
This commit fixes a regression in how we allocate funds to attempted
channels. We would earlier stay within the channel size limits, but we
wouldn't account for funds consumed by other channels being opened in
parallel.

We fix this by introducing a loop which greadily tries to distribute the
funds among the channels to open, and reduces the number of channels to
open in case not enough funds are available to satisfy the channel size
limits.
2019-03-14 08:49:28 +01:00
Olaoluwa Osuntokun
c1228ae15f
Merge pull request #2671 from wpaulino/tx-broadcast-err-handling
lnwallet/btcwallet: remove invalid transactions from the wallet when broadcast fails
2019-03-13 21:03:04 -07:00
Conner Fromknecht
d81ce61033
config: add sanity check to prevent non-negative worker counts 2019-03-13 20:32:52 -07:00
Conner Fromknecht
76116f0d1a
config: use CLI worker configuration instead of NumCPU() 2019-03-13 20:32:39 -07:00
Conner Fromknecht
3f181b3c06
lncfg/workers: configurable read, write, and sig pool workers 2019-03-13 20:32:25 -07:00
Wilmer Paulino
7946d0a256
multi: remove ErrDoubleSpend check for PublishTransaction
In this commit, we address a lingering issue within some subsystems that
are responsible for broadcasting transactions. Previously,
ErrDoubleSpend indicated that a transaction was already included in the
mempool/chain. This error was then modified to actually be returned for
conflicting transactions, but its callers were not modified accordingly.
This would lead to conflicting transactions to be interpreted as valid,
when they shouldn't be.
2019-03-13 17:57:19 -07:00
Wilmer Paulino
5c5c542f94
lnwallet/btcwallet: remove unnecessary tx in mempool/chain checks
The checks to determine whether the transaction broadcast failed due to
it already existing in the mempool/chain are no longer needed since the
underlying btcwallet PublishTransaction call will not return an error
when running into these cases.
2019-03-13 17:57:19 -07:00
Olaoluwa Osuntokun
6983a9e146
contractcourt: fix off-by-one error in closeObserver case
In this commit, we fix an off-by-one error when handling force closes
from the remote party. Before this commit, if the remote party
broadcasts state 2, and we were on state 1, then we wouldn't act at all.
This is due to an extraneous +1 in the comparison, causing us to only
detect this DLP case if the remote party's state is two beyond what we
know atm. Before this commit, the test added in the prior commit failed.
2019-03-13 17:31:23 -07:00
Olaoluwa Osuntokun
795c9f1550
contractcourt: add new TestChainWatcherDataLossProtect test case
In this commit, we add a new test case to exercise the way we handle the
DLP detection and dispatch within the chain watcher. Briefly, we use
the `testing/quick` package to ensure that the following invariant is
always held: "if we do N state updates, then state M is broadcast, iff M
> N, we'll execute the DLP protocol". We limit the number of iterations
to 10 for now, as the tests can take a bit of time to execute, since it
actually does proper state transitions.
2019-03-13 17:31:21 -07:00
Olaoluwa Osuntokun
48532dc9f6
contractcourt: abstract call to GetStateNumHint within the closeObserver
In this commit, we abstract the call to `GetStateNumHint` within the
`closeObserver` method to a function closure in the primary config. This
allows us to feed in an arbitrary broadcast state number within unit
tests.
2019-03-13 17:31:20 -07:00
Olaoluwa Osuntokun
4645fc0c95 lnwallet: export ForceStateTransition for tests outside package
In this commit, we export the `ForceStateTransition` for tests outside
the package that need to interact with actual channel state machines.
2019-03-13 17:31:10 -07:00
Olaoluwa Osuntokun
10910318a2
lnd: extract neutrino initialization to new function 2019-03-13 17:20:38 -07:00
Wilmer Paulino
1fe6599fd8 lnd+chainregistry: initialize neutrino light client before wallet setup
In this commit, we slightly refactor the startup of lnd when running
with a Neutrino light client backend. We'll now begin syncing our
backend as soon as lnd starts and passes all configuration checks. Since
this is all done before lnd's wallet setup, the light client will be
syncing in the background while the user notes/inputs their wallet seed.
This is done in order to provide a better UX from the point of the user,
such that most of the chain will already be synced by the time they get
to deposit funds into the wallet.
2019-03-13 16:46:50 -07:00
Olaoluwa Osuntokun
d0757221b4
Merge pull request #2768 from Roasbeef/neutrino-rescan-btcwallet-broadcast-update
multi: update build to latest version of neutrino+btcwallet
2019-03-13 16:39:23 -07:00
Olaoluwa Osuntokun
d86fe393cd
multi: update build to latest version of neutrino+btcwallet
In this commit, we update the build to point to the latest version of
neutrino and btcwallet. The latest version of neutrino includes a number
of bug fixes, and new features like reliably transaction broadcast. The
latest version of btcwallet contains a number of bug fixes related to
properly remove invalid transactions from its database.
2019-03-13 15:03:39 -07:00
Olaoluwa Osuntokun
a24eeb9135
lnrpc/routerrpc: style fix ups 2019-03-12 21:20:21 -07:00
Olaoluwa Osuntokun
ad8849056b
Merge pull request #2497 from joostjager/querysingleroute
lnrpc: deprecate QueryRoutes with more than one route
2019-03-12 21:15:18 -07:00
Conner Fromknecht
714e42fce2
netann/chan_status_manager: remove unknown edges from passive disable
Modifies the netann.ChanStatusManager to remove outpoints
from the set of tracked channels when it encounters a
channeldb.ErrEdgeNotFound when passively disabling. It is
possible for this to occur if a channel is closed w/o first
being disabled, which may happen if the remote party force
closes.
2019-03-12 17:35:12 -07:00
Conner Fromknecht
f525d313b2
test_utils: start chan status manager 2019-03-12 17:34:57 -07:00
Conner Fromknecht
8baa6d6601
lnd_test: test disable is sent during close 2019-03-12 17:34:42 -07:00
Conner Fromknecht
325d77c431
chancloser+cnct: disable channel before closing 2019-03-12 17:34:28 -07:00
Wilmer Paulino
3371c5fab0
Merge pull request #2680 from grunch/passwd-length-validation-on-create-wallet
Add password length validation condition on create wallet cli
2019-03-12 12:12:54 -07:00
Olaoluwa Osuntokun
c302f1ea3a
lnd: lower default CLTV delta from 144 to 40
In this commit, we lower the default CLTV delta from 144 (1 day) to 40
blocks (~7 hours). We do this as the initial value was purposefully very
high, and was only in place as place holder in earlier versions of the
software. Such a high value can also discourage path finding algorithms
from taking lnd paths due to the negative impact of CLTV value in widely
deployed heuristics.
2019-03-11 18:43:37 -07:00
chokoboko
69d3c47d22 multi: inspect missed errors in scoped if statements 2019-03-11 13:23:21 -07:00
Joost Jager
293971cd03
routerrpc: move query routes into sub server
This commit moves the query routes backend logic from the main
rpc server into the sub server. It is another step towards splitting up
the main rpc server code.

In addition to this, a unit test is added to verify rpc parameter
parsing.
2019-03-11 09:56:16 +01:00
Olaoluwa Osuntokun
cfb5e249b9
Merge pull request #2749 from Roasbeef/bork-force-close
lnwallet: within ForceClose, mark the channel as borked, prevent mutations for borked channels
2019-03-10 15:21:09 -07:00
Matt Drollette
261558aad6 config: allow adding multiple tls ips and domains 2019-03-10 13:53:37 -05:00
Olaoluwa Osuntokun
33ad645f8c
lnwallet: update TestChanSyncFailure to pass with new borked update restriction
In this commit, we update the `TestChanSyncFailure` method to pass given
the new behavior around updating borked channel states. In order to do
this, we add a new method to allow the test to clear an existing channel
state. This method may be of independent use in other areas in the
codebase in the future as well.
2019-03-08 19:15:10 -08:00
Olaoluwa Osuntokun
bc72691806
contractcourt: mark channel as borked before removing the link
In this commit, we ensure that we mark the channel as borked before we
remove the link during the force close process. This ensures that if the
peer reconnects right after we remove the link, then it won't be loaded
into memory in `loadActiveChannels`. We'll now:

  * mark the channel as borked
  * remove the link
  * read the channel state from disk
  * force close

This ensures that the link (if it's active) is able to commit any
pending changes to disk before we read out the channel to force close.
2019-03-08 19:15:08 -08:00
Olaoluwa Osuntokun
dac35c46f3
lnwallet: properly examine and check error from AppendRemoteCommitChain 2019-03-08 19:15:07 -08:00
Olaoluwa Osuntokun
49c38ed56d
lnwallet: update line wrapping to project style where needed 2019-03-08 19:15:06 -08:00
Olaoluwa Osuntokun
032eacb796
channeldb: prevent mutating on-disk commitment state if channel is borked 2019-03-08 19:15:04 -08:00
Olaoluwa Osuntokun
b409e5dfc4 lnwallet: add new TestForceCloseBorkedState test
In this commit, we add a new test: `TestForceCloseBorkedState`. This
ensures that it isn't possible to update the channel state once a
channel has been marked as borked. This assumes that all calls to
`ForceClose` will also mark the channel as borked. This isn't the case
yet, so this test fails as is.
2019-03-08 18:56:42 -08:00