Commit graph

274 commits

Author SHA1 Message Date
Oliver Gugger
e53190862d
rpcserver+fundingmgr: de-duplicate peer connections
To avoid a race error in lnd when we try to connect to the same node
twice in a short interval, we instead de-duplicate the connection
attempts by node pubkey and only try connecting once per remote peer.
2020-08-21 15:19:49 +02:00
Oliver Gugger
0d91342717
fundingmgr: let bidder connect to asker
To allow a bidder to be a mobile or Tor only node, we only require the
asker to be reachable through clearnet. This requirement wasn't
implemented correctly in the funding flow. This commit fixes that and
turns the logic around. The asker creates the channel but the
bidder does all the work for it (connecting out and registering the
funding shim).
2020-08-21 15:19:49 +02:00
Oliver Gugger
fbc60963a1
fundingmgr: rename receiver 2020-08-21 15:19:49 +02:00
Oliver Gugger
e457d08b01
rpcserver+fundingmgr: extract funding into fundingMgr struct
With this commit we decouple everything funding related from the RPC
server and move the logic into the fundingMgr struct.
2020-08-21 15:19:48 +02:00
Oliver Gugger
06797752c1
rpcserver: move funding related code to own file
This is a pure code move as a preparation for creating a funding manager
struct that handles all the funding related tasks.
2020-08-21 15:19:48 +02:00
Oliver Gugger
75bf4e020a
rpcserver+order: remove funding shim on subsequent prepare
Because we have to always expect an OrderMatchPrepare to be sent
multiple times, we need to make sure we clean up our funding shims from
the previous pending batch.
2020-08-21 15:19:44 +02:00
Oliver Gugger
e42497a4c6
cmd/llm: add force flag to ask order submission 2020-08-19 09:12:50 +02:00
Oliver Gugger
9cab2779e6
cmd/llmd: remove committed binary 2020-08-19 09:12:50 +02:00
Olaoluwa Osuntokun
fa6842b8eb
cmd/llm/account: add available_balance to json account output 2020-08-18 16:52:45 -07:00
Wilmer Paulino
95a403d677
Merge pull request #51 from guggero/scale-confirmations
Limits [1/2]: Scale confirmations by server account size, limit max duration blocks and enforce multiple of 144
2020-08-18 15:00:05 -07:00
Wilmer Paulino
ff240804ac
Merge pull request #52 from guggero/shutdown-hang
auctioneer: add quit chan to account subscription, fix shutdown hang
2020-08-18 10:05:37 -07:00
Oliver Gugger
21e19d8c5e
clmrpc+auctioneer: remove unused FeeQuote RPC 2020-08-18 13:38:35 +02:00
Oliver Gugger
7fb4ef9782
order+rpcserver: enforce order duration limit and multiple 2020-08-18 13:38:35 +02:00
Oliver Gugger
36f50534dd
account: query auctioneer for max acct size 2020-08-18 13:38:34 +02:00
Oliver Gugger
774ae42933
clmrpc+auctioneer: add Terms RPC 2020-08-18 13:15:36 +02:00
Oliver Gugger
3df4e2f005
multi: move FeeSchedule to terms package
As a preparation to avoid package import cycles when introducing more
generic terms, we move the FeeSchedule interface and its
LinearFeeSchedule implementation to the terms package.
2020-08-18 13:15:34 +02:00
Oliver Gugger
7b4394e148
auctioneer: add quit chan to account subscription
To fix an issue where the trader daemon wouldn't properly shutdown if an
authentication was still ongoing, we add a quit chan to the account
subscription.
2020-08-18 10:21:26 +02:00
Wilmer Paulino
61dec56810
Merge pull request #49 from guggero/consecutive-batches
Consecutive Batches [1/2]: handle consecutive batch confirmations
2020-08-17 11:19:09 -07:00
Oliver Gugger
fa05add3b7
account+rpcserver: handle consecutive batch confirmations
This commit allows the account manager to handle the situation where
an account participates in multiple consecutive batches that might still
be in the mempool. Once the first batch confirms, the database state of
the account might differ from the batch key used in that earlier batch.
We need to cancel old spend and conf watches and only watch the latest
batch for confirmation. While an account is in this pending batch state, no
user modification like deposits or withdrawals are allowed so it's safe
to just jump to the latest batch and wait for confirmations on that one.
2020-08-17 13:53:04 +02:00
Oliver Gugger
bd738d31c7
clmscript: add DecrementKey 2020-08-17 11:44:31 +02:00
Oliver Gugger
584d4e032e
rpcserver: allow orders to be submitted in StatePendingBatch 2020-08-17 11:44:30 +02:00
Oliver Gugger
09515098f2
order: use state pending batch when storing account diff 2020-08-17 11:44:30 +02:00
Oliver Gugger
a662b907d2
multi: add account state for pending batch update
To track whether or not an account was recently involved in one or more
batches, we need to add a new pending state. This pending state is
different from the normal pending update from a balance modification as
the auctioneer allows an account in this state to participate in a
batch. A scenario is possible where an account was involved in two or
more consecutive batches that both aren't confirmed on chain yet. To
handle that special case we need to also track the special account state
on the trader side.
2020-08-17 11:44:30 +02:00
Oliver Gugger
246ef8664f
Merge pull request #46 from guggero/wait-for-chain-sync
Dependency cleanup, wait for lnd to be synced to chain
2020-08-11 19:47:47 +02:00
Oliver Gugger
7d9e6bdce3
server: pin required lnd version, block until synced
With this commit we address two issues with the connection to lnd:
First, we didn't specify the required version of lnd even though we used
features of 0.11.0. This is fixed by pinning the version to 0.11.0
explicitly and specifying the subservers that are required to be active.
Second, we didn't wait for lnd to be synced to its chain backend. We use
the new functionality in the lndclient repo that does exactly this.
2020-08-11 19:41:02 +02:00
Oliver Gugger
978950600c
multi: update aperture, use lndclient, remove loop
To get rid of the loop dependency, we update aperture (which now houses
all the LSAT code) and use the standalone lndclient repository.
2020-08-11 19:41:01 +02:00
Oliver Gugger
668bc2c279
multi: copy lndclient mocks from loop repository
As a preparation to get rid of the loop dependency, we copy the mocks we
need from the test package of that dependency and use them in our tests.
2020-08-11 10:44:24 +02:00
Oliver Gugger
f6f72e9b0b
mod: bump lnd to version v0.11.0-beta.rc2 2020-08-11 10:14:49 +02:00
Oliver Gugger
3df466e68b
Merge pull request #45 from guggero/dockerfile
build: add Dockerfile
2020-08-11 10:10:26 +02:00
Oliver Gugger
93f347cd48
build: add Dockerfile 2020-08-10 10:24:38 +02:00
Oliver Gugger
8f65890328
Merge pull request #44 from Roasbeef/account-available-balance
multi: return available balance for an account over RPC, add acct isolation for validate order reserved balance
2020-08-10 09:35:08 +02:00
Olaoluwa Osuntokun
5c7c80b81c
clmrpc: add new available balance field for returned accounts
In this commit, we update the account response to return the total
"available balance". Which is computed as the total useable balance of
the account assuming all the outstanding orders are matched in a
worst-case manner.
2020-08-07 18:35:41 -07:00
Olaoluwa Osuntokun
9bb337f684
order: update validateOrder to only accumulate reserved vals for target acct
Without this commit, an account would at times be prevented on
submitting an order that it itself is able to handle.
2020-08-07 18:35:39 -07:00
Olaoluwa Osuntokun
fcdc26afa0
order: add new TestValidateOrderAccountIsolation test case
In this commit, we add a new test that fails with the current logic in
`validateOrder`. The function as isn't doesn't isolate the orders for
each account, so the orders from account A can prevent a user from
making an order to account B.
2020-08-07 18:35:38 -07:00
Olaoluwa Osuntokun
e1a9f636b8
Merge pull request #40 from halseth/reserved-value
Reserve value for execution and chainfees for orders
2020-08-07 16:51:47 -07:00
Johan T. Halseth
5caa1f9d7f
order: require an order's Min/MaxDuration to be at least 144 2020-08-07 16:34:07 +02:00
Johan T. Halseth
81b6dd2139
order: acccount for worst case chain fee in reserved value
Use the MaxBatchFeeRate value to reserve the maximum chain fee that can
be paid by the trader.
2020-08-07 16:34:07 +02:00
Johan T. Halseth
a2abc187f3
multi: rename FundingFeeRate to MaxBatchFeeRate
The funding feerate field was previoulsy unused, so we rename it to
"max batch fee rate" in order to use it to communicate to the server the
maximum fee rate we are willing to pay to be included in a batch.

We also increase the default value to 500 sat/vbyte.
2020-08-07 16:34:07 +02:00
Johan T. Halseth
204a442695
order/manager: check reserved value when submitting order
To check whether the account has enough balance for a new order, sum the
reserved value of all orders before submitting a new one.
2020-08-06 10:52:52 +02:00
Johan T. Halseth
c9e6e2a3a7
order: add ReservedValue to interface
The ReservedValue method returns the worst case value the must be
available in the account to ensure the trader can pay for the order
including its fees.
2020-08-06 10:52:52 +02:00
Johan T. Halseth
93c324c35c
order: add StateExpired to Archived() 2020-08-06 10:52:52 +02:00
Johan T. Halseth
bb89eaba74
order: extract maker and taker delta calculation
To be able to re-use the caluclation for a single order without keeping
a tally.
2020-08-06 10:52:51 +02:00
Olaoluwa Osuntokun
9f8d7d00d8
Merge pull request #41 from Roasbeef/order-cancel-fix
rpc: fix order cancellation, sync local order state on start up
2020-08-04 19:41:44 -07:00
Olaoluwa Osuntokun
fb3f2b6f76
server: on start up, sync local with remote order state
In this commit, we add some new logic to reconcile our local order state
with what the auctioneer has on start up. However, we'll only update our
local order if the auctioneer shows the order as being cancelled. For
all other cases, we should reconcile that difference if we have a
pending batch that was confirmed while we were offline, or confirmed
after we sent our signature. In this case, we'll log the order nonce
with a warning log-level so users can track down any possible issues.
2020-08-04 18:21:05 -07:00
Olaoluwa Osuntokun
a28fa78813
rpc: update state of cancelled order on disk
Fixes #38.
2020-08-04 18:21:02 -07:00
Olaoluwa Osuntokun
c9802b0cc1
rpc: when closing an account, compare order state with remote server 2020-08-04 18:21:01 -07:00
Olaoluwa Osuntokun
4d5d019c7b
rpc: print out which orders are still open when account closure fails 2020-08-04 18:21:00 -07:00
Oliver Gugger
7f84085e64
Merge pull request #36 from guggero/acct-creation
account: add funding target_conf and check balance before reserving account
2020-08-03 12:45:50 +02:00
Oliver Gugger
48243c310b
clmrpc: document trader RPCs 2020-08-03 11:08:55 +02:00
Oliver Gugger
68e0e68284
cmd/llm: add listauth command 2020-08-03 11:08:55 +02:00