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.
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.
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.
Split watcher logic in three pices:
- Controller: API + message dispatching
- ExpiryWatcher: handle account expirations
- EventHandler: implementation for each handler
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.