lightninglabs / lightninglabs/pool

[bug] Account is left in `Pending Update` state after `spendAccount` fails to broadcast the new tx

Open
#438 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
259
Forks
51
PR merge metrics
No merged PRs in 30d

Description

**Description**

A user deposits new funds in his account calling the [DepositAccount](https://github.com/lightninglabs/pool/blob/master/rpcserver.go#L710) rpc method. A new AccountDiff is created and stored (client and server side).

The tx was never broadcasted to the network. The lnd node does not see it in pending txs and the lnd inputs are released. The account diff is not applied to the account because is waiting for confirmations.

**Expected behavior**

In the [spendAccount](https://github.com/lightninglabs/pool/blob/master/account/manager.go#L1304) we should rollback the [account update](https://github.com/lightninglabs/pool/blob/210bbd47435995cba4dd0e9d207de0360f0a3156/account/manager.go#L1683) if the [broadcast fails](https://github.com/lightninglabs/pool/blob/210bbd47435995cba4dd0e9d207de0360f0a3156/account/manager.go#L1696) which releases the funds in LND.

**Actual behavior**

The account becomes unusable because of its Pending Updating state.

**Workaround**

Delete the account diff from the server and make the user go through the recovery account process so it gets in sync with the server with the last state of this account before it became unusable.

Bug [spotted in the wild](https://github.com/lightninglabs/lightning-terminal/issues/488)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in account/manager.go at spendAccount and inspect the account update around the linked update and broadcast-failure locations. Trace how a failed broadcast leaves the AccountDiff and releases LND inputs. Done means the failed update is rolled back and the account no longer remains in Pending Update state.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.