Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database: store whether coin is from self #1483

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jp1ac4
Copy link
Collaborator

@jp1ac4 jp1ac4 commented Nov 22, 2024

⚠️ This PR upgrades and migrates DB version so a wallet opened against this PR will no longer work on Liana v8.

This is a first step towards #1375.

Following the approach from #1391, it adds a new is_from_self column to the coins database table to track which coins are fully controlled by the user's wallet. This PR is limited to adding the column and keeping it updated in the poller.

This column could instead have been added to the transactions table, but for consistency with other transaction-related columns, I added it to the coins table. It's also important to note that being from self is wallet-dependent, so adding it to the transactions table would not work if multiple wallets were supported in the same DB (h/t @edouardparis).

Subsequent PRs will then return this field in the listcoins command, which the GUI can then use to determine which unconfirmed coins, if any, can be included in the confirmed balance. Another use of this field will be to determine which unconfirmed coins to include in coin selection (#1484).

The first commit in this PR refactors some existing DB migration tests so that they will not be affected by future changes to the coins table schema.

Some migration tests used structs and methods that are expected
to change and so will not be backward compatible.

This change replaces those with structs and methods specific to
the migration tests so that the tests will be unaffected by DB
schema changes. At the same time, these new structs and methods
simplify some of the setup by allowing to store new coins,
including their confirmation and spend status, in a single
DB operation.
This adds a new `is_from_self` column to the coins table that
indicates if the coin is an output of a transaction for which
all inputs are ours. In the case of unconfirmed coins, being
from self requires that all unconfirmed ancestors, if any, are
also from self.

The DB migration sets the value of this column for all existing
coins and the poller keeps the column up to date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

1 participant