Commit graph

62 commits

Author SHA1 Message Date
Johan T. Halseth
b9f53f2c46
account: revert back to manager pointer 2020-10-06 09:46:35 +02:00
Olaoluwa Osuntokun
aed85f5bd4 multi: label all account modification txns with optional prefix
In this commit, in order to make accounting for account
modification/creation transactions a bit easier, we'll now always add a
label describing the transaction within the account manager. The user is
also able to set their own prefix to the label as well to allow
insertion of custom meta data.
2020-10-05 17:54:10 -07:00
Oliver Gugger
e98c465f7b
account: query auctioneer only if necessary
In case the auctioneer is offline or restarting during the initial boot
up of the trader server, we get a hard failure directly if we try to
query the terms when the server connection isn't ready yet. This isn't
really nice as we'd never come into the auto-retry of the account
subscription that way.
To optimize this, we only query the terms when we actually need them.
This makes it possible for confirmed, open accounts to go into the
subscription connection re-try logic. We'd only hard fail on startup if
there are any pending accounts and the auctioneer is offline exactly
during the trader boot up.
2020-10-05 14:31:39 +02:00
Wilmer Paulino
7e987fbeba
account: subscribe account updates on startup for StatePendingBatch
Not doing so would prevent accounts from participating in consecutive
batches if the corresponding trader performed a restart of their daemon.
2020-09-23 11:24:49 -07:00
Olaoluwa Osuntokun
1e0035d3d4
multi: fix import order 2020-09-09 19:55:16 -07:00
Olaoluwa Osuntokun
ffc9c60b13
multi: rename project from llm to pool 2020-09-09 19:55:10 -07:00
Wilmer Paulino
d60a44c73d
account: implement fee bump for transactions of accounts in pending states 2020-09-02 12:30:06 -07:00
Wilmer Paulino
f71adf7b67
multi: re-purpose account close tx field to latest tx 2020-09-02 12:10:23 -07:00
Wilmer Paulino
aa3465027c
account: set account value to 0 upon closure 2020-08-24 13:33:18 -07:00
Wilmer Paulino
a532b04246
account: introduce fee expressions for account closure
We introduce two distinct ways traders can express their closing
transaction fees: a single address/output script along with a fee rate,
or a list of outputs (script and value) which implicitly expresses the
transaction fees. This provides traders with greater coin control
flexibility, allowing them to directly send their account funds to their
desired destinations efficiently without needing multiple transactions.
2020-08-24 13:33:16 -07:00
Oliver Gugger
36f50534dd
account: query auctioneer for max acct size 2020-08-18 13:38:34 +02: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
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
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
a9b4255fe3
account: use custom funding conf target for account init 2020-08-03 11:08:54 +02:00
Oliver Gugger
6692073e89
clientdb+account: add code for migration-less new database fields
In the future we might want to have the possibility to add additional
fields to a database object (like orders or accounts) without the need
for a migration. We add the code for that already, even if it's not
being used currently.
2020-08-03 11:08:48 +02:00
Oliver Gugger
3d5a3e64fd
clmrpc+rpcserver+account: add QuoteAccount RPC 2020-07-31 14:37:22 +02:00
Oliver Gugger
c7dd0ebb57
clmrpc+rpcserver+account: add conf target, check wallet balance
To make sure we don't run into an error when actually sending the
desired amount to an account output, we invoke lnd's fee estimation RPC
to make sure we can construct a transaction that also respects the new
fee parameter.
2020-07-31 14:37:06 +02:00
Wilmer Paulino
fb219d5879
account: update account height hints for non-batch operations 2020-07-01 17:00:58 -07:00
Oliver Gugger
cc22edb9f1
account+auctioneer: remove need to find key again 2020-06-25 09:28:46 +02:00
Oliver Gugger
136c8d91d5
account: don't fund recovered accounts again
If we encounter an account in the state initiated when performing the
account recovery, we certainly don't want to send funds to it again. If
lnd finds the transaction that funded the account, great. We can try to
recover it. If the transaction isn't found, it is very likely that it
was never broadcast. We update the account's state to
StateRecoveryFailed in that case.
2020-06-25 09:26:36 +02:00
Oliver Gugger
9e55d476ff
clmrpc+account+rpcserver: add state recovery failed
Add a new client side state that denotes that account recovery for a
certain account failed.
2020-06-25 09:26:36 +02:00
Oliver Gugger
beaa9f49c3
account+auctioneer: send expiry and trader key in reservation 2020-06-25 09:17:37 +02:00
Olaoluwa Osuntokun
57fa63c237
multi: rename, fix modules 2020-06-21 19:37:00 -07:00
Wilmer Paulino
7c0a5070ea account: add support for lnd-backed account deposits 2020-06-17 18:34:53 -07:00
Wilmer Paulino
a92022392f account: allow inputs in transaction creation
This serves as prepatory work to introduce account deposits, as they
rely on a set of additional inputs being provided.
2020-06-17 18:34:52 -07:00
Wilmer Paulino
b7e48b5432 account: add basic coin selection heuristic
Most of the code is heavily borrowed from the chanfunding package in
lnd, except for some minor changes to account for the difference in
weights. Ideally, that package is refactored and abstracted such that it
doesn't only apply for channel funding.
2020-06-17 18:34:51 -07:00
Wilmer Paulino
573e3ea987 account: refactor withdrawal logic out from createNewAccountOutput
Some of the refactored methods will become useful with the introduction
of account deposits.
2020-06-17 18:34:50 -07:00
Oliver Gugger
679efaa7b7 client: perform account recovery 2020-06-05 16:24:33 +02:00
Oliver Gugger
6cc5240fda server+itest: validate maximum account value 2020-05-27 14:57:56 +02:00
Oliver Gugger
909a5bbc3e client: send account value on account reservation 2020-05-27 14:57:55 +02:00
Olaoluwa Osuntokun
c6dba8c7c1 client/account: raise max acct value to 1 BTC 2020-05-18 16:06:19 -07:00
Oliver Gugger
f110e8b948 client: use key descriptor to subscribe to account
The account subscription doesn't need access to the full account,
only its key descriptor. This is a preparation for the account
recovery where we want to subscribe to the auctioneer but don't have
the full account anymore.
2020-05-14 15:56:06 +02:00
Wilmer Paulino
ec0ecfa065 account: add support for withdrawals
This commit introduces support for trader account withdrawals to
arbitrary outputs. Traders are able to withdraw their accounts through
either spending paths, multi-sig or expiry, with the latter requiring a
new expiration (to be done as a follow-up). When spending through the
multi-sig path, traders submit their outputs to the auctioneer,
excluding the new account output as that can be reconstructed by the
auctioneer. The auctioneer then creates a transaction adhering to the
trader's constraints and provides a signature back.
2020-05-08 14:25:42 -07:00
Wilmer Paulino
e6727852d0 clmrpc: extend account modification parameters provided to auctioneer 2020-05-08 14:25:41 -07:00
Wilmer Paulino
6e07921286 account: add deep Copy method 2020-05-08 13:33:43 -07:00
Wilmer Paulino
1f0f0ca1fd account: refactor account spend flow within CloseAccount into method
This new method will serve as the unified path for all trader account
modifications.
2020-05-08 13:33:38 -07:00
Wilmer Paulino
35e8630247 account: request auctioneer sig after committing account modifications
This is essential as otherwise if the trader has an unexpected shutdown
between receiving the auctioneer's signature and committing the
modifications to disk, then there would be no context of said
modifications from the PoV of the trader after a restart.
2020-05-08 12:29:07 -07:00
Wilmer Paulino
cd287dcdd1 account: allow option to re-create account output
While the method is yet to be used, this lays down the groundwork for
allowing account modifications in which we're required to recreate the
account output.
2020-05-08 12:29:06 -07:00
Wilmer Paulino
043a9f7d98 account: properly handle spend on pending batch not finalized
This commit aims to address a current gap within the system where trader
account states can become desynchronized if they participated in a batch
and they never received a Finalize message from the auctioneer.

From now on, if an account spend arrives while a trader has a pending
batch, then we assume they weren't able to receive its Finalize message,
and use the spend as an indication that the batch has been finalized.
This works because if a trader signs for a batch and disconnects, the
batch should have already been persisted, and if the batch was actually
finalized (i.e., broadcast without any changes), then the account should
have been spent.
2020-05-05 13:53:32 -07:00
Wilmer Paulino
8a38d2ad2e account+order: use proper account batch key when storing batch 2020-04-20 11:45:16 -07:00
Wilmer Paulino
a9b2f7569b account: resume flow for accounts that have had updates applied 2020-04-20 11:45:13 -07:00
Wilmer Paulino
10239c5c4b multi: add StatePendingUpdate 2020-04-20 11:45:12 -07:00
Wilmer Paulino
60553c8447 account: assert account is subscribed for updates throughout open flow 2020-04-20 11:45:10 -07:00
Wilmer Paulino
687b1985ed account: remove fallthrough in transition StatePendingUpdate->StateOpen 2020-04-20 11:45:09 -07:00
Wilmer Paulino
dc8ad76c60 account: extract resumeAccount operations on StateOpen into method 2020-04-20 11:45:08 -07:00
Wilmer Paulino
f8811b9acf account: sort spending transaction according to BIP-69 2020-04-09 09:39:46 -07:00
Wilmer Paulino
2e21bd4971 account: sanity check input and output amounts in spending transaction 2020-04-09 09:39:45 -07:00
Wilmer Paulino
4514df1476 account: refactor toWalletOutput creation outside of createSpendTx 2020-04-09 09:39:44 -07:00