Skip to content

Refactor wallet.Interface into Role-Based Interfaces #1038

@yyforyongyu

Description

@yyforyongyu

This doc serves as the master tracking issue.

Motivation

The btcwallet package currently exposes a large, monolithic wallet.Interface with approximately 50 methods. Its primary consumer, lnd, defines its own lnwallet.WalletController interface with around 40 methods, many of which are duplicates or slight variations of the wallet.Interface methods.

This duplication and the sheer size of these interfaces make the code difficult to maintain, test, and reason about. It violates the Interface Segregation Principle and the Single Responsibility Principle.

The goal of this refactoring is to decompose these monolithic interfaces into a new set of clean, logical, and role-based interfaces within the btcwallet package. This will provide a more secure, flexible, and intuitive API for all consumers.

For a full breakdown of the design, please see the wallet architecture documentation. For the analysis of the current code structure, check this analysis.

Guiding Principles

All implementation work must adhere to the following key principles:

  • Separation of Concerns: A primary goal of this refactoring is to create a clean separation between business logic (the "how") and data persistence (the "what"). The new interfaces should be implemented in a way that the database logic is fully encapsulated and abstracted, preparing for the upcoming transition to a SQL backend.
  • Actor Model: Concurrency should be managed using the Actor Model to ensure thread safety and avoid complex locking.
  • SOLID Principles: The implementation should follow the SOLID principles, particularly the Single Responsibility and Interface Segregation Principles.

Implementation Plan

The following is a checklist of the new interfaces to be implemented. Each item represents an ADR that can be picked up by a developer,

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions