Commit graph

90 commits

Author SHA1 Message Date
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
ffranr
2679396615
account: transaction labels code cleanup 2022-11-07 12:53:11 +00:00
Robyn
d76f0f1111
account: improve account on-chain transaction labels
This commit reformulates transaction labels as JSON strings. The JSON contains the following fields:

* An `action` field which takes one of the following values: create, deposit, withdraw, renew, or close.

* `key` which is the account key.

* `expiry_height` which is an integer block height at which the account expires. This value is important to ease the process of account recovery.

* `output_index` which is an integer denoting the account balance transaction output.

* `expiry_spend` which is a boolean denoting whether the transaction spends via the expiry output path.

* `tx_fee` which is the onchain transaction fee for executing the account action.

* `balance_diff` which is a signed integer denoting the difference (+/-) in the account balance as a result of the transaction.

The poold specific transaction label prefix tag is also modified such that its prefixes spaces are removed.
2022-11-03 21:17:45 +00:00
positiveblue
037671287e
account/manager: fix np2wkh deposits
The `.UnsignedTx` of a psbt does not include the related
SignatureScripts. Because SignatureScripts are not part of the signed
data, the partial signature for a psbt that does not include them is a
valid signature. However, the `TxHash` will change between a tx that has
SignatureScripts set and one that does not.

This behaviour led the auctioneer and the client to record the wrong
outpoint when using np2wkh.
2022-09-12 17:20:12 +02:00
Oliver Gugger
312e206dac
multi: implement taproot accounts 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
b6013e34e6
account: use spend witness type everywhere 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
fd3676f056
account: assert min lnd version for np2wkh 2022-06-30 16:18:32 +02:00
Oliver Gugger
232578a7ac
account+poolscript: assert minimum relay fee 2022-06-30 16:18:32 +02:00
Oliver Gugger
685a13daf1
account: refactor expiry witness path 2022-06-30 15:39:48 +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
Oliver Gugger
56eb099eb2
multi: bump to latest lnd and lndclient versions 2022-06-17 14:50:58 +02:00
Oliver Gugger
3508d7b9a4
multi: bump to latest lndclient and lnd versions 2022-06-01 16:16:57 +02:00
positiveblue
573f86dc83
mod: update lndclient to use new SignOutputRaw 2022-04-04 11:35:20 +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
7b53791997
account/watcher: delete expiryReq 2021-12-07 12:22:37 -08:00
positiveblue
abd603d765
account/watcher: add ExpiryWatcher and EventHandler interfaces
Split watcher logic in three pices:
    - Controller: API + message dispatching
    - ExpiryWatcher: handle account expirations
    - EventHandler: implementation for each handler
2021-12-07 12:22:27 -08:00
positiveblue
a34790e494
account/watcher: add Controller interface
Use the new watcher interface in the account manager instead of of a specific
struct type.
2021-12-07 11:58:40 -08:00
positiveblue
2e724ad4d6
account: disable renewAccount for StatePendingBatch status
If the account is currently participating in a batch
(`StatePendingBatch`) we disable the renewAccount command. After
enabling account autorenew it could be problematic to renew your
account before the batch is confirmed and you account expiry height
gets updated.
2021-12-02 22:54:12 -08:00
positiveblue
dae849c332
account: support expiry update for deposits/withdraws 2021-11-09 17:58:43 -08:00
Olaoluwa Osuntokun
d5f944e3fa
build: update to pin against current lnd v0.14.0 2021-10-20 19:25:48 -07: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
carla
234f4d80fb
gomod: bump to lndclient 13-7
This commit bumps pool to lndclient 13-7 so that code that depends
on lnd 0.13 can import pool. As is, pool is running with lndclient 0.12,
but pins minimum version to 0.11, so we are already in a state where
some of the apis available at compile time are not enforced by minimum
run version.

This commit bumps this minimum version up to 0.12 to minimize the
difference between the compile and runtime lnd version.
2021-08-20 16:49:41 +02:00
Oliver Gugger
f56eb50981
auctioneer+account: rename SubscribeAccountUpdates
The name SubscribeAccountUpdates could indicate that this is a
long-running operation. The method returns after successful
authentication of the stream though. That's why we rename it to
StartAccountSubscription and update the comment to make it more clear
that this should return after a few seconds at the most.
2021-04-02 14:18:11 +02:00
Oliver Gugger
52131d8690
manager: distinguish between lnwallet and btcwallet/wallet err
Unfortunately there are two error messages that are very similar (the
only difference is "doesn't" vs. "does not") and can both be returned,
depending on the code path taken.
2021-01-11 13:19:11 +01:00
Wilmer Paulino
79c7bb029b
account: add support for account renewals 2021-01-08 14:02:24 +01:00
Wilmer Paulino
1fd51e4c55
account: handle StateCanceledAfterRecovery in resumeAccount 2021-01-08 14:02:23 +01:00
Wilmer Paulino
8961e9a09e
account: introduce StateExpiredPendingUpdate state
This is an intermediate state where an account has met its expiration
while having a pending update waiting for confirmation. The introduction
of this state was necessary as the existing StateExpired state was not
sufficient to handle all edge cases regarding account renewals. Now
that this state exists, we can be sure renewals cannot happen until the
account is both confirmed, unspent, and expired.
2021-01-08 14:02:22 +01:00
Wilmer Paulino
f4229a9797
account: always watch account expiry on StateOpen transition
We no longer need to track if the account expiry needs to be watched or
not as the watcher now supports updating existing unfulfilled expiry
requests.
2021-01-08 14:02:21 +01:00
Wilmer Paulino
d3dc8f9ffc
watcher: overwrite request on successive calls to WatchAccountExpiration 2021-01-08 14:02:20 +01:00
Oliver Gugger
262793a493
account: use latest TX from DB instead of querying lnd
To make the account manager less dependent on the wallet state of lnd,
we use the latest TX state that we now store for the account instead of
the lnd ListTransactions RPC where possible.
This fixes account recovery for lnd nodes that were restored from the
seed and don't remember/detect all Pool transactions automatically.
2021-01-04 15:34:19 +01:00
Wilmer Paulino
ae50ee788b
account: fix account key in logs 2020-11-24 10:58:46 -08:00
Johan T. Halseth
28bf7cdce0
Merge pull request #150 from wpaulino/withdraw-output-dust-check
rpc: check dust outputs on account withdrawals and closures
2020-11-12 08:59:23 +01:00
Wilmer Paulino
c0d13d3fa9
account: check dust outputs on account spending transactions 2020-11-11 14:09:36 -08:00
Wilmer Paulino
c6ddfa1593
account: request signature before updating account due to modification
This ensures that a trader cannot progress their account state without
the server acknowledging their request.
2020-11-10 12:16:43 -08:00
Wilmer Paulino
84b841a9cf
account: ensure only one outstanding account reservation exists
The auctioneer only expects one outstanding account reservation to exist
per trader LSAT, so we should enforce this on the trader's side as well.
2020-11-06 15:04:13 -08:00
Wilmer Paulino
385794bde6
account: avoid broadcast of unsigned transactions
In some cases, like when an account is closed due to participating in a
batch, the latest transaction stored for the account is unsigned, which
can be rebroadcast upon a restart. This broadcast attempt will always
fail, so instead we opt to not rebroadcast it at all.
2020-10-19 12:39:31 -07:00
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