Skip to content

Unify RPC connection creation for chain backends #7951

@yyforyongyu

Description

@yyforyongyu

When using bitcoind as the chain backend, lnd creates three RPC connections,

  1. using chain.NewBitcoindConn in chainreg.
  2. using rpcclient.New in chainreg.
  3. using rpcclient.New in chainfee.

This could cause issues as lndmay make concurrent RPC requests to bitcoind which may cause failures. This also breaks the abstraction provided by chain.BitcoindConn as we are now accessing the connection directly. To fix it,

  • replace the rpcclient.New used in 2 and 3 with the chain.BitcoindConn created in 1, to make sure we only ever create one RPC connection to bitcoind.
  • replace other occurrences of rpcclient.New with chain.NewRPCClient for btcd backend.
  • rename chain.NewRPCClient to chain.NewBtcdClient in btcwallet for clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2should be fixed if one has timebitcoindBitcoin Core backendbtcdchain handlingintermediateIssues suitable for developers moderately familiar with the codebase and LN

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions