Skip to content

Introduce Role-based interfaces for wallet#1083

Open
yyforyongyu wants to merge 309 commits into
masterfrom
interface-wallet
Open

Introduce Role-based interfaces for wallet#1083
yyforyongyu wants to merge 309 commits into
masterfrom
interface-wallet

Conversation

@yyforyongyu

Copy link
Copy Markdown
Collaborator

Open this PR to track rebase conflicts.

TODO: add descriptions and link PRs and issues.

@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 4 times, most recently from 23ebf86 to afdbbd9 Compare October 2, 2025 07:18
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 2 times, most recently from b1c1a55 to 12b10a8 Compare October 14, 2025 17:53
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 2 times, most recently from 2b3d4cd to 3c66ae5 Compare November 4, 2025 06:29
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 8 times, most recently from 071e0fd to 7fb0543 Compare November 24, 2025 02:45
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 4 times, most recently from 30cd22f to 3f9e5c8 Compare December 8, 2025 10:28
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 3 times, most recently from ff3a0ae to 6382f26 Compare December 18, 2025 04:21
@yyforyongyu yyforyongyu force-pushed the interface-wallet branch 2 times, most recently from 31a6cff to a92782d Compare December 24, 2025 07:40
@yyforyongyu

Copy link
Copy Markdown
Collaborator Author

#1153 introduced a new tab width, which cause the lastest push to fail the linter CI - this is fine as they are fixed in a later PR.

We now use `Locked` field from `Credit` and `CreditRecord`.
We now remove the usage of the deprecated methods `AccountNumber` and
`requireChainClient`.
This commit fixes a race condition where concurrent address generation
requests could result in duplicate addresses. The issue was caused by
relying on the in-memory account index cache, which could be stale
during a pending database commit.

We now resolve this by:
    1. Always fetching the 'next index' directly from the database's
       consistent transaction view in 'nextAddresses' and 'extendAddresses'.
    2. Implementing a monotonic check in the 'OnCommit' cache update hook,
       ensuring the in-memory cache only moves forward and never regresses
       if concurrent transactions commit out of order.
    3. Adding a 'getNextIndex' helper to encapsulate the authoritative
       index retrieval logic.

With this fix at the manager level, the broad 'newAddrMtx' lock in the
wallet package is no longer necessary.
This commit refactors several functions to reduce their cyclomatic
complexity, making the code easier to read and maintain.
We now complete the implementation of `ImportAccount` by removing the
usage of the deprecated methods. We also identified a few methods that
should not be deprecated.
We now remove the usage of the old `testWallet`.
This specifies different ways the wallet can be created.
This manager replaces the old wallet loader to handle the creation and
loading the wallets.
After rebasing the interface-wallet branch onto the btcd-v2 module
upgrade, the feature-only files still carried v1 btcd import paths and
the v1 `btcutil.Address` API. This commit completes the migration:

- Rewrite remaining v1 btcd import paths to their v2 equivalents
  (btcutil->btcutil/v2, chaincfg->chaincfg/v2, chaincfg/chainhash->
  chainhash/v2, txscript->txscript/v2, wire->wire/v2, btcutil/psbt->
  psbt/v2, btcutil/gcs[/builder]->btcutil/v2/gcs[/builder]).
- Move the address types and constructors off btcutil onto the new
  github.com/btcsuite/btcd/address/v2 package.
- Restore the local replace directives for the feature-modified
  wtxmgr and wallet/txsizes submodules and run `go mod tidy`.
- Add the SubmitPackage method to the wallet mockChain so it satisfies
  the SubmitPackage addition to chain.Interface.
- Drop a duplicated hasMinConfs/calcConf pair left over from the
  deprecated-method file split.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants