Skip to content

Conversation

@luke-jr
Copy link
Member

@luke-jr luke-jr commented Sep 13, 2022

This is a minimal "step 1" to migrating wallet RPC methods to access via the abstract interfaces. Only trivial methods are ported at this stage.

Long term goal is to support different actual wallet classes (in particular, core-lighting wallets) which won't have remotely the same internals as Bitcoin Core wallets.

@w0xlt
Copy link
Contributor

w0xlt commented Sep 13, 2022

Approach ACK. This provides a better separation of concerns.

@S3RK
Copy link
Contributor

S3RK commented Sep 14, 2022

Can you elaborate on "support different actual wallet classes (in particular, core-lighting wallets)"? I always though of lighting wallets operating on another abstraction layer on-top of bitcoin wallets, i.e. bitcoin wallets abstract the use of the blockchain while lighting wallets make use of that. Thus it seems like lighting wallets should have different interface from bitcoin wallets.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 14, 2022

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
Approach ACK w0xlt

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #26365 (wallet: GetEffectiveBalance by willcl-ark)
  • #26347 (wallet: ensure the wallet is unlocked when needed for rescanning by ishaanam)
  • #26294 (build: move util/url to common/url by fanquake)
  • #24897 ([Draft / POC] Silent Payments by w0xlt)
  • #24313 (Improve display address handling for external signer by Sjors)
  • #24058 (BIP-322 basic support by kallewoof)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@luke-jr
Copy link
Member Author

luke-jr commented Sep 14, 2022

Can you elaborate on "support different actual wallet classes (in particular, core-lighting wallets)"? I always though of lighting wallets operating on another abstraction layer on-top of bitcoin wallets, i.e. bitcoin wallets abstract the use of the blockchain while lighting wallets make use of that. Thus it seems like lighting wallets should have different interface from bitcoin wallets.

Wallets in general are at the same abstraction layer. Most interfaces are common whether you're sending/receiving on-chain or Lightning.

@ryanofsky
Copy link
Contributor

I think this is a good change for a different reason than the one stated. Even if there won't be multiple wallet implementations, letting RPC methods interact with wallets through the interfaces::Wallet class instead of the CWallet class means new RPC methods can avoid accessing internal wallet state just like GUI code avoids it, and new RPC features should be easier to port to the GUI because they can be implemented behind the interface rather than on top of it.

One suggestion I would have is to drop commit "Wallet: Add missing const attribute to interfaces" (cc0a1d5) from this PR. The interface::Wallet class is an abstract class and the methods it declares are intentionally non-const, because making them const exposes internal implementation details of interface::Wallet subclasses that callers should not be aware of. In practice, it breaks multiprocess support (see #25337 (comment), commit e81daff from #10102). Dropping this would also make the PR more focused and smaller.

@S3RK
Copy link
Contributor

S3RK commented Sep 14, 2022

I think this is a good change for a different reason than the one stated. Even if there won't be multiple wallet implementations, letting RPC methods interact with wallets through the interfaces::Wallet class instead of the CWallet class means new RPC methods can avoid accessing internal wallet state just like GUI code avoids it, and new RPC features should be easier to port to the GUI because they can be implemented behind the interface rather than on top of it.

Agree that having RPC interacting through clear interface is great. Maybe we should discuss the long-term goal "to support different actual wallet classes (in particular, core-lighting wallets)" in some other place.

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Sep 24, 2022
a60d9eb Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  cs_desc_main is typically locked within scope of a cs_wallet lock, but:

  CWallet::IsLocked locks cs_wallet
  ...called from DescriptorScriptPubKeyMan::GetKeys
  ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

  Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first

  -------------

  Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by bitcoin#26082 (CI fails as a result)

ACKs for top commit:
  achow101:
    ACK a60d9eb
  w0xlt:
    ACK bitcoin@a60d9eb

Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 25, 2022
a60d9eb Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  cs_desc_main is typically locked within scope of a cs_wallet lock, but:

  CWallet::IsLocked locks cs_wallet
  ...called from DescriptorScriptPubKeyMan::GetKeys
  ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

  Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first

  -------------

  Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by bitcoin#26082 (CI fails as a result)

ACKs for top commit:
  achow101:
    ACK a60d9eb
  w0xlt:
    ACK bitcoin@a60d9eb

Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 1, 2022

🐙 This pull request conflicts with the target branch and needs rebase.

@bitcoin bitcoin deleted a comment from notkanekiii Dec 5, 2022
@fanquake fanquake marked this pull request as draft February 6, 2023 14:56
@fanquake
Copy link
Member

fanquake commented Feb 6, 2023

Moved to draft, as it looks like this needs further discussion, and has needed rebase for 3 months.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 7, 2023

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

1 similar comment
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 5, 2023

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko
Copy link
Member

maflcko commented Aug 8, 2023

cc @luke-jr

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 6, 2023

There hasn't been much activity lately and the patch still needs rebase. What is the status here?

  • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
  • Is it no longer relevant? ➡️ Please close.
  • Did the author lose interest or time to work on this? ➡️ Please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future.

@maflcko
Copy link
Member

maflcko commented Nov 6, 2023

Closing for now. Please leave a comment here, to have it re-opened by someone.

@maflcko maflcko closed this Nov 6, 2023
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Feb 29, 2024
a60d9eb Bugfix: Wallet: Lock cs_wallet for SignMessage (Luke Dashjr)

Pull request description:

  cs_desc_main is typically locked within scope of a cs_wallet lock, but:

  CWallet::IsLocked locks cs_wallet
  ...called from DescriptorScriptPubKeyMan::GetKeys
  ...called from DescriptorScriptPubKeyMan::GetSigningProvider which locks cs_desc_main first, but has no access to cs_wallet ...called from DescriptorScriptPubKeyMan::SignMessage ...called from CWallet::SignMessage which can access and lock cs_wallet

  Resolve the out of order locks by grabbing cs_wallet in CWallet::SignMessage first

  -------------

  Note this is currently only an issue for the GUI (which lacks sufficient testing apparently), but can be reproduced by bitcoin#26082 (CI fails as a result)

ACKs for top commit:
  achow101:
    ACK a60d9eb
  w0xlt:
    ACK bitcoin@a60d9eb

Tree-SHA512: 60f6959b0ceaf4d9339ba1a47154734034b637c41b1f9e26748a2dbbc3a2a95fc3696019103c55ae70c91d910ba8f3d7f4e27d263030eb60b689f290c4d82ea9
@bitcoin bitcoin locked and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants