forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
backport: merge bitcoin#21207, #22008, #22686, #22742, #19101, #22183, #22009, #22938, #23288, #24592 (wallet backports: part 2) #6529
Draft
kwvg
wants to merge
16
commits into
dashpay:develop
Choose a base branch
from
kwvg:wbps_p2
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,630
−2,999
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We aren't adding the `assert` check as it's superceded by a "Fee needed > fee paid" error that was already backported from c1a84f1 (bitcoin#26643).
This is done to avoid conflicts in an upcoming backport which assume the tests are ordered as they are upstream. Validate with `git log -p -n1` ` --color-moved=dimmed_zebra`.
This is done to avoid conflicts arising from backports.
The PR is logically split in two for ease of review, this commit deals with folding ArgsManager, interfaces::Chain and interfaces::CoinJoin ::Loader into WalletContext.
This is required because we're going to get deglobalize wallet variables in an upcoming commit, which requires us to hold `WalletContext` in order to iterate through all wallets. So, we rely on the interface to help us do that. Also, let's fold in the `WalletInit::InitCoinJoinSettings` calls into `interfaces::CoinJoin::Loader` for simplicity's sake.
In an upcoming commit, wallet variables will be deglobalized. This means that RPCs that use wallet logic need to get ahold of WalletContext, which only happens if they're registered as a wallet RPC (i.e. registered through WalletLoader). The downside of being registered as a wallet RPC is that you lose access to NodeContext. For now, we will work around this by giving WalletContext access to NodeContext and modify EnsureAnyNodeContext to pull it from WalletContext.
This is the second half of the backport, which deals with deglobalizing wallet-specific variables like vpwallets, cs_wallets and friends.
…d on waste metric
…wallet tests Dash-specific tests have not been migrated to use descriptor wallets and the old AddKey() logic has been retained as AddLegacyKey(). final_hex needed to be recalculated in psbt_updater_test as one of the input scripts were an invalid-to-Dash address and its replacement with a descriptor that doesn't correspond to the same script requires recalculating the unsigned PSBT. excludes: - 9951628 (we don't support bech32 addresses)
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Additional Information
Dependent on backport: merge bitcoin#15596, #25497, #17331, #22155 (wallet backports: part 1) #6517
bitcoin#19101 has been split into two due to it performing two refactors in one commit, the first half deals with utilizing interfaces and managers as defined in
WalletContext
(as opposed to either passing them in separately as arguments or accessing them through globals) and the second half deals with deglobalizing wallet variables like::vpwallets
andcs_wallets
.WalletContext
still needs to be initialized with a constructor as it stores a const-refstd::unique_ptr
ofinterfaces::CoinJoin::Loader
. This requirement hasn't been done away with. Tests that don't have access tocoinjoin_loader
will still need to passnullptr
.Bitcoin registers wallet RPCs through
WalletClient::registerRpcs()
(source), which a part of theChainClient
interface (source). They are enumerated (source) differently from non-wallet RPCs (source).Wallet RPCs aren't supposed to have knowledge of
NodeContext
and likewise non-wallet RPCs aren't supposed to have knowledge ofWalletContext
. So far, Bitcoin has reworked their RPCs to maintain this separation and upstream RPCs are a part of thelibbitcoin_wallet
library.This isn't the case for some Dash RPCs, many of which reside in
libbitcoin_server
, some of which fit into two categories.Requires knowledge of both
NodeContext
andWalletContext
WalletContext
wasn't mandatory before deglobalization as wallet information could be accessed through the global context courtesy of::vpwallets
and friends but now that it is, many RPCs need to be able to accessWalletContext
when otherwise they wouldn't need to.WalletContext
cannot accessNodeContext
as their RPC registration logic doesn't give them access toNodeContext
(source,m_context
here isWalletContext
) but in order to give those RPCsWalletContext
, we need to register them as wallet RPCs, which prevent us from accessingNodeContext
.NodeContext
inWalletContext
(source) and modifyingEnsureAnyNodeContext()
to fetch fromWalletContext
if regular behavior doesn't yield aNodeContext
(source).Are RPCs that possess both wallet and non-wallet functionality (i.e. have "reduced" capabilities if wallet support isn't compiled in as opposed to being absent altogether).
Bitcoin doesn't use
#ifndef ENABLE_WALLET
for checking if support is absent, we're expected to use!g_wallet_init_interface.HasWalletSupport()
(which will always evaluatefalse
if support isn't compiled in, source, as the stub wallet would be utilized to initialize the global in those cases, source). This has been done in the PR.A notable change in this PR is that a lot of behavior that would be enabled if support was compiled in but disabled at runtime would now be disabled if support was disabled at runtime as
wallet_loader
won't be initialized if runtime disablement occurs (source), which in turns means that anything that relies onwallet_loader
wouldn't work either, such ascoinjoin_loader
.This means that we also need to register the RPC as a non-wallet RPC if support is compiled in but disabled at runtime (source).
To register RPCs as wallet RPCs, generally they're done through
WalletClient::registerRpcs()
, which iterates throughGetWalletRPCCommands()
. This is perfectly fine as both reside inlibbitcoin_wallet
. Unfortunately, our Dash RPCs reside inlibbitcoin_server
andregisterRpcs()
cannot be extended to enumerate through RPCs not included in its library.We cannot simply move the Dash RPCs either (at least in its current state) as they rely on non-wallet logic, so moving the source files for those RPCs into
libbitcoin_wallet
would pull more or less, all oflibbitcoin_server
along with it.WalletLoader::registerOtherRpcs()
, which will accept any set of RPCs for registration (source) and we use it in RPC init logic (source).Some usage of
CoreContext
had to be removed (source) as without those removals, the test suite would crash.Crash:
The assertion introduced in bitcoin#22686 (source) has not been backported as this assertion is downgraded to an error in bitcoin#26611 and then further modified in bitcoin#26643 (source), portions of which are already included in dash#6517 (source).
bitcoin#23288 finished what e3687f7 (dash#6078) started and
coinselection_tests
has now been realigned with upstream.Dash-specific tests in
wallet_tests
(as introduced in dash#3367) have not been moved over to descriptor wallets and are still based on legacy wallets (to this effect, the oldAddKey
logic has been retained asAddLegacyKey
, source).Notable Changes
CoinJoinWalletManager::{Add,Remove}()
will no longer callWalletInit::InitCoinJoinSettings()
if not called through the interface (i.e.interfaces::CoinJoin::Loader::{Add,Remove}()
). If not using the interface, those calls will need to be made manually.It is recommended to use the interface where possible.
NodeContext::coinjoin_loader
will not be initialized at all if wallet support is disabled at runtime. (Earlier behavior allowed for initialization so long as wallet support was included at compile-time, now it must be enabled at runtime as well).WalletInit::AutoLockMasternodeCollaterals()
(also moved out ofThreadImport()
) during init but since if wallet support is disabled at runtime, there would be no collaterals to lock, this change isn't of concern.Breaking Changes
coinjoin
,coinjoinsalt
,getpoolinfo
,gobject list-prepared
,gobject prepare
,gobject vote-alias
,gobject vote-many
,masternode outputs
,protx update*
,protx register*
andprotx revoke
will no longer be available if wallet support is disabled at runtime. This is not a change in functionality as they were already inoperative with disabled wallets but is a change in reporting as they would not be available at all.Checklist