Commit graph

33 commits

Author SHA1 Message Date
Oliver Gugger
34af866ce9
multi: fix linter issues 2023-02-23 11:26:42 +01:00
Robyn
cd632058b0
account: expose historical account modification fees via RPC
This commit adds a new RPC endpoint which returns a per-account list of account modification fees.
2022-11-15 12:54:28 +00:00
Oliver Gugger
312e206dac
multi: implement taproot accounts 2022-09-12 17:20:11 +02:00
Oliver Gugger
355e0577f8
account: refactor account manager tests 2022-09-12 17:20:11 +02:00
Oliver Gugger
bec62efa71
account: refactor away spend package
With this commit we streamline the signing code somewhat to make it
easier to understand. With the new flow the spendPkg struct is no longer
needed as we directly pass back the (partially) signed TX.
2022-09-12 17:20:11 +02:00
Oliver Gugger
a63985d614
multi: add account version to RPCs and manager 2022-09-12 17:20:10 +02:00
Oliver Gugger
232578a7ac
account+poolscript: assert minimum relay fee 2022-06-30 16:18:32 +02:00
Oliver Gugger
74d2ae48b2
account: use PSBT for account signing 2022-06-30 15:39:44 +02:00
Oliver Gugger
7571464968
multi: add chain params and lnd version to account manager 2022-06-30 13:46:59 +02:00
positiveblue
6027ccd3d6
multi: bump btcec/v2 and btcutil to new versions 2022-03-28 15:22:41 +02:00
positiveblue
29135cf864
account: add the account Manager interface 2021-12-14 20:40:02 -08:00
positiveblue
dae849c332
account: support expiry update for deposits/withdraws 2021-11-09 17:58:43 -08:00
Jordi Montes
d493378fb5
account: check valid signer when resuming accounts
If `poold` is using a different `lndclient.SignerClient` than the one
used during an account creation it won't be able to generate valid
signatures. `poold` wasn't checking the signatures before sending them
to the backend and it was sending invalid
`ClientAuctionMessage_Subscribe` messages.

With this change `poold` will detect invalid signatures before sending
them, instead of waiting for the backend to send back an error.
2021-10-20 10:40:05 -07:00
positiveblue
68a38b34d7 account: use raw sat/byte when making an account
Generally the confirmation target is much less granular than a direct sat/byte
due to jumps in the confirmation confidence intervals. Changed the
account manager to take the `feeRate` instead of the `confTarget`. The
caller will be the one with the responsability of calculating the
`freeRate`. If the caller does not provide a value (`freeRate=0`) we
will calculate it from the default confTarget (6 blocks).
2021-09-29 21:14:08 -07:00
Wilmer Paulino
c0d13d3fa9
account: check dust outputs on account spending transactions 2020-11-11 14:09:36 -08: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
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
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
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
Wilmer Paulino
7c0a5070ea account: add support for lnd-backed account deposits 2020-06-17 18:34:53 -07: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
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
60553c8447 account: assert account is subscribed for updates throughout open flow 2020-04-20 11:45:10 -07:00
Wilmer Paulino
9bf50766f7 multi: allow account closure through expiration and multi-sig paths
Traders are now able to close their accounts, whether or not they have
already expired, to arbitrary outputs or to a wallet output by default.
If an account hasn't expired, then the auctioneer's signature of the
closing transaction is required to successfully close the account.
2020-02-05 12:09:47 -08:00
Wilmer Paulino
f9faebc842 account: mark accounts as expired once their expiry is reached
Accounts in this state remain in it until they're renewed or closed.
These functionalities will be added at a later time.
2020-02-05 12:09:11 -08:00
Wilmer Paulino
4021b2919c multi: tweak trader key with shared secret and per-batch key
In this commit, we overhaul the keys used in the multi-sig construction
of an account to prevent script reuse and provide plausible deniability
between account outputs to third parties. This is done by tweaking the
trader's key with two new components:

1. A per-batch key, which is obtained from the auctioneer during account
creation. Every time the account is modified or participates in a
cleared batch within the system, the per-batch key is incremented by the
curve's base point, resulting in a different key used in the account
script.

2. A shared secret derived using Diffie-Hellman between the trader's and
auctioneer's base keys. By using this secret, we provide plausible
deniability to third parties with knowledge of the base keys and
per-batch key.

The resulting tweaked key for the trader is then used as the tweak for
the auctioneer's base key.
2020-01-29 13:23:15 -08:00
Wilmer Paulino
004e1cf857 multi: use btcec.PublicKey instead of [33]byte
This allows us to use utility functions that require the use of a parsed
public key without needing to parse every time.
2020-01-24 13:45:48 -08:00
Wilmer Paulino
dca3f2717e account: implement account manager with support to create accounts
The account manager is a subsystem of the client that will be
responsible for management of all CLM accounts on-chain. This initial
version only supports opening accounts at the moment, but this will be
extended later on to also support closing and modifying them. Open
accounts are also watched for their confirmation and spend, though the
spend path remains unhandled.

The commit stands alone by itself, and is not yet integrated into the
server as we still need to satisfy its dependencies, which we'll do in
the following commits.
2020-01-10 16:57:56 -08:00