Skip to content

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Oct 26, 2019

Continuation of wallet boxes project.

Actually makes ScriptPubKeyMan an interface which LegacyScriptPubkeyMan. Moves around functions and things from CWallet into LegacyScriptPubKeyMan so that they are actually separate things without circular dependencies.


Introducing the ScriptPubKeyMan (short for ScriptPubKeyManager) for managing scriptPubKeys and their associated scripts and keys. This functionality is moved over from CWallet. Instead, CWallet will have a pointer to a ScriptPubKeyMan for every possible address type, internal and external. It will fetch the correct ScriptPubKeyMan as necessary. When fetching new addresses, it chooses the ScriptPubKeyMan based on address type and whether it is change. For signing, it takes the script and asks each ScriptPubKeyMan for whether that ScriptPubKeyMan considers that script IsMine, whether it has that script, or whether it is able to produce a signature for it. If so, the ScriptPubKeyMan will provide a SigningProvider to the caller which will use that in order to sign.

There is currently one ScriptPubKeyMan - the LegacyScriptPubKeyMan. Each CWallet will have only one LegacyScriptPubKeyMan with the pointers for all of the address types and change pointing to this LegacyScriptPubKeyMan. It is created when the wallet is loaded and all keys and metadata are loaded into it instead of CWallet. The LegacyScriptPubKeyMan is primarily made up of all of the key and script management that used to be in CWallet. For convenience, CWallet has a GetLegacyScriptPubKeyMan which will return the LegacyScriptPubKeyMan or a nullptr if it does not have one (not yet implemented, but callers will check for the nullptr). For purposes of signing, LegacyScriptPubKeyMan's GetSigningProvider will return itself rather than a separate SigningProvider. This will be different for future ScriptPubKeyMans.

The LegacyScriptPubKeyMan will also handle the importing and exporting of keys and scripts instead of CWallet. As such, a number of RPCs have been limited to work only if a LegacyScriptPubKeyMan can be retrieved from the wallet. These RPCs are sethdseed, addmultisigaddress, importaddress, importprivkey, importpubkey, importmulti, dumpprivkey, and dumpwallet. Other RPCs which relied on the wallet for scripts and keys have been modified in order to take the SigningProvider retrieved from the ScriptPubKeyMan for a given script.

Overall, these changes should not effect how everything actually works and the user should experience no difference between having this change and not having it. As such, no functional tests were changed, and the only unit tests changed were those that were directly accessing CWallet functions that have been removed.

This PR is the last step in the Wallet Structure Changes.

@achow101
Copy link
Member Author

The final diff is very similar to #16341 just with some things dropped as they were deemed unnecessary.

@Sjors
Copy link
Member

Sjors commented Oct 26, 2019

For comparison, my last ACK on the original was for c37be15. That code was identical to @ryanofsky's branch at 299296e, just using a different set of commits to get there. This PR rebases that on master @25d7e2e78137d07eb612c44d19b0d496050c947a, with the last two commits (952ba99 & 299296e) dropped. The result is f47ffe0 here (minus two linter changes).

@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 26, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #17954 (wallet: Remove calls to Chain::Lock methods by ryanofsky)
  • #17878 (wip: zmq: Support -zmqpubwallettx by promag)
  • #17786 (refactor: Nuke policy/fees->mempool circular dependencies by hebasto)
  • #17681 (wallet: Keep inactive seeds after sethdseed and derive keys from them as needed by achow101)
  • #17484 (wallet: add cached m_is_ibd to remove Chain::isInitialBlockDownload by ariard)
  • #17443 (Drop checkFinalTx and use Median Time Past to check finality of wallet transactions by ariard)
  • #17211 (Allow fundrawtransaction and walletcreatefundedpsbt to take external inputs by achow101)
  • #16946 (wallet: include a checksum of encrypted private keys by achow101)
  • #16910 (wallet: reduce loading time by using unordered maps by achow101)
  • #16698 (Mempool: rework rebroadcast logic to improve privacy by amitiuttarwar)
  • #16528 ([WIP] Native Descriptor Wallets (take 2) by achow101)
  • #16440 (BIP-322: Generic signed message format by kallewoof)
  • #16224 (gui: Bilingual GUI error messages by hebasto)
  • #15761 (Replace -upgradewallet startup option with upgradewallet RPC by achow101)
  • #15719 (Drop Chain::requestMempoolTransactions method by ryanofsky)
  • #10443 (Add fee_est tool for debugging fee estimation code by ryanofsky)

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.

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Oct 29, 2019
Suggested by MarcoFalke <falke.marco@gmail.com>
bitcoin#17260 (comment)

The same check was also added in the followup commit "Refactor: Move
SetupGeneration code out of CWallet" 9727a4d
from bitcoin#17261, but it's safer to start checking now without waiting for that
followup.
@ryanofsky
Copy link
Contributor

ryanofsky commented Oct 29, 2019

Suggestion: there's a cluster of fairly trivial refactoring commits in this PR that I think could be pulled out into a separate PR and merged pretty quickly. Doing this would reduce the number of commits here by almost half:

  • b318219 MOVEONLY: Reorder LegacyScriptPubKeyMan methods (4/36)
  • 8c7eac4 Refactor: Declare LegacyScriptPubKeyMan methods as virtual (5/36)
  • f0339ba Refactor: Add new ScriptPubKeyMan virtual methods (6/36)
  • 5321cf7 Refactor: Move SetAddressBook call out of LegacyScriptPubKeyMan::GetNewDestination (7/36)
  • 44f524e Refactor: Move SetWalletFlag out of LegacyScriptPubKeyMan::UpgradeKeyMetadata (8/36)
  • 2b92e87 Refactor: Remove UnsetWalletFlag call from LegacyScriptPubKeyMan::SetHDSeed (9/36)
  • 802dfb9 Refactor: Move SetAddressBookWithDB call out of LegacyScriptPubKeyMan::ImportScriptPubKeys (10/36)
  • d8d2d31 Refactor: Move LoadKey LegacyScriptPubKeyMan method definition (11/36)
  • 9f20667 Refactor: Move GetMetadata code out of getaddressinfo (12/36)
  • 309ee44 Refactor: Move MarkUnusedAddresses code out of CWallet::AddToWalletIfInvolvingMe (13/36)
  • 1ffce09 Refactor: Move Upgrade code out of CWallet::CreateWalletFromFile (14/36)
  • f09be4f Refactor: Move HavePrivateKeys code out of CWallet::CreateWalletFromFile (15/36)
  • 25d904c Refactor: Move SetupGeneration code out of CWallet (16/36)
  • a207dbc Refactor: Move RewriteDB code out of CWallet (17/36)
  • 1cca908 Refactor: Move GetKeypoolSize code out of CWallet (18/36)
  • 23008f4 Refactor: Move nTimeFirstKey accesses out of CWallet (19/36)

@achow101, would you want to pull out the commits above into a separate PR? I'd also be happy to make the PR if it would be more convenient.

@achow101
Copy link
Member Author

@ryanofsky Done as #17304

@maflcko
Copy link
Member

maflcko commented Oct 29, 2019

fanquake added this to Blockers in High-priority for review 5 hours ago

Why? I thought that high-prio could only be used once per week per contributor.

@fanquake
Copy link
Member

fanquake commented Oct 29, 2019 via email

@maflcko
Copy link
Member

maflcko commented Oct 30, 2019

#17260 (comment) was in for this week, but fair enough

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Feb 4, 2020
Make LegacyScriptPubKeyMan::CanProvide method able to recognize p2sh scripts
when the redeem script is present in the mapScripts map without the p2sh script
also having to be added to the mapScripts map. This restores behavior prior to
bitcoin#17261, which I think broke backwards
compatibility with old wallet files by no longer treating addresses created by
`addmultisigaddress` calls before bitcoin#17261 as solvable.

The reason why tests didn't fail with the CanProvide implementation in bitcoin#17261
is because of a workaround added in 4a7e43e
"Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem
for new `addmultisigaddress` RPC calls without fixing it for multisig addresses
already created in old wallet files.

This change adds a lot of comments and allows reverting commit
4a7e43e "Store p2sh scripts in
AddAndGetDestinationForScript", so the AddAndGetDestinationForScript() function,
CanProvide() method, and mapScripts map should all be more comprehensible
Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-merge code review ACK 3f37365. I did post two questions in review comments below that I think would be good to resolve.

Changes since last review (72df6f1):

  • Dropped commit daf6d54 "Set state to WATCH_ONLY if we can get the pubkey"
  • Added EnsureLegacyScriptPubKeyMan create argument to make RPCs like sethdseed work on empty wallets
  • coinselector_tests setup fix
  • OUTPUT_TYPES definition move
  • AddAndGetDestinationForScript formatting tweaks
  • Split commit 01b4511 "Make UpgradeKeyMetadata work only on LegacyScriptPubKeyMan" out of commit 264917f "Add multiple keyman maps and loops"
  • LegacyScriptPubKeyMan::Upgrade hd split version check no longer added
  • Replacement hd seed generation skipped in CWallet::EncryptWallet for nonlegacy wallets
  • CWallet::GetAllScriptPubKeyMans method added and used by CreateWalletFromFile to not skip inactive keyman instances when figuring out first key time
  • CWallet::GetScriptPubKeyMan internal true/false code deduped
  • CWallet::SetupLegacyScriptPubKeyMan asserts removed
  • LegacySigningProvider m_spk_man member rename and comment tweak

@@ -384,7 +384,7 @@ bool LegacyScriptPubKeyMan::Upgrade(int prev_version, std::string& error)
hd_upgrade = true;
}
// Upgrade to HD chain split if necessary
if (m_storage.CanSupportFeature(FEATURE_HD_SPLIT)) {
if (m_storage.CanSupportFeature(FEATURE_HD_SPLIT) && CHDChain::VERSION_HD_CHAIN_SPLIT) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit "HD Split: Avoid redundant upgrades" (415afcc):

This seems buggy and the change looks like it has no effect. Is this supposed to say && hdChain.nVersion < CHDChain::VERSION_HD_CHAIN_SPLIT?

@@ -569,7 +574,7 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
Unlock(strWalletPassphrase);

// if we are using HD, replace the HD seed with a new one
if (auto spk_man = m_spk_man.get()) {
if (auto spk_man = GetLegacyScriptPubKeyMan()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re: #17261 (comment)

No, descriptor wallets have a different way of doing it.

In commit "Box the wallet: Add multiple keyman maps and loops" (c729afd):

It seems bad to do nothing at all and keep using unencrypted seeds for non-legacy wallets, and the comment here doesn't here doesn't explain any legacy/nonlegacy distinction. It would seem safer to trigger some kind of error for non-legacy wallets if planned behavior hasn't been implemented yet, than to just do nothing.

If there is supposed to be legacy / non-legacy distinction, it would seem better to move legacy code out of CWallet into LegacyScriptPubKeyMan in a PostEncrypt or similar ScriptPubKeyMan virtual method

ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Feb 12, 2020
Make LegacyScriptPubKeyMan::CanProvide method able to recognize p2sh scripts
when the redeem script is present in the mapScripts map without the p2sh script
also having to be added to the mapScripts map. This restores behavior prior to
bitcoin#17261, which I think broke backwards
compatibility with old wallet files by no longer treating addresses created by
`addmultisigaddress` calls before bitcoin#17261 as solvable.

The reason why tests didn't fail with the CanProvide implementation in bitcoin#17261
is because of a workaround added in 4a7e43e
"Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem
for new `addmultisigaddress` RPC calls without fixing it for multisig addresses
already created in old wallet files.

This change adds a lot of comments and allows reverting commit
4a7e43e "Store p2sh scripts in
AddAndGetDestinationForScript", so the AddAndGetDestinationForScript() function,
CanProvide() method, and mapScripts map should all be more comprehensible
ryanofsky added a commit to ryanofsky/bitcoin that referenced this pull request Feb 12, 2020
Make LegacyScriptPubKeyMan::CanProvide method able to recognize p2sh scripts
when the redeem script is present in the mapScripts map without the p2sh script
also having to be added to the mapScripts map. This restores behavior prior to
bitcoin#17261, which I think broke backwards
compatibility with old wallet files by no longer treating addresses created by
`addmultisigaddress` calls before bitcoin#17261 as solvable.

The reason why tests didn't fail with the CanProvide implementation in bitcoin#17261
is because of a workaround added in 4a7e43e
"Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem
for new `addmultisigaddress` RPC calls without fixing it for multisig addresses
already created in old wallet files.

This change adds a lot of comments and allows reverting commit
4a7e43e "Store p2sh scripts in
AddAndGetDestinationForScript", so the AddAndGetDestinationForScript() function,
CanProvide() method, and mapScripts map should all be more comprehensible
meshcollider added a commit that referenced this pull request Feb 19, 2020
…t recognition

a304a36 Revert "Store p2sh scripts in AddAndGetDestinationForScript" (Russell Yanofsky)
eb7d8a5 [test] check for addmultisigaddress regression (Sjors Provoost)
005f8a9 wallet: Improve LegacyScriptPubKeyMan::CanProvide script recognition (Russell Yanofsky)

Pull request description:

  Make `LegacyScriptPubKeyMan::CanProvide` method able to recognize p2sh scripts when the redeem script is present in the `mapScripts` map without the p2sh script also having to be added to the `mapScripts` map. This restores behavior prior to #17261, which I think broke backwards compatibility with old wallet files by no longer treating addresses created by `addmultisigaddress` calls before #17261 as solvable.

  The reason why tests didn't fail with the CanProvide implementation in #17261 is because of a workaround added in 4a7e43e "Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem for new `addmultisigaddress` RPC calls without fixing it for multisig addresses already created in old wallet files.

  This change adds a lot of comments and allows reverting commit 4a7e43e "Store p2sh scripts in AddAndGetDestinationForScript", so the `AddAndGetDestinationForScript()` function, `CanProvide()` method, and `mapScripts` map should all be more comprehensible

ACKs for top commit:
  Sjors:
    re-ACK a304a36 (rebase, slight text changes and my test)
  achow101:
    re-ACK a304a36
  meshcollider:
    utACK a304a36

Tree-SHA512: 03b625220c49684c376a8062d7646aeba0e5bfe043f977dc7dc357a6754627d594e070e4d458d12d2291888405d94c1dbe08c7787c318374cedd5755e724fb6e
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Feb 19, 2020
…e script recognition

a304a36 Revert "Store p2sh scripts in AddAndGetDestinationForScript" (Russell Yanofsky)
eb7d8a5 [test] check for addmultisigaddress regression (Sjors Provoost)
005f8a9 wallet: Improve LegacyScriptPubKeyMan::CanProvide script recognition (Russell Yanofsky)

Pull request description:

  Make `LegacyScriptPubKeyMan::CanProvide` method able to recognize p2sh scripts when the redeem script is present in the `mapScripts` map without the p2sh script also having to be added to the `mapScripts` map. This restores behavior prior to bitcoin#17261, which I think broke backwards compatibility with old wallet files by no longer treating addresses created by `addmultisigaddress` calls before bitcoin#17261 as solvable.

  The reason why tests didn't fail with the CanProvide implementation in bitcoin#17261 is because of a workaround added in 4a7e43e "Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem for new `addmultisigaddress` RPC calls without fixing it for multisig addresses already created in old wallet files.

  This change adds a lot of comments and allows reverting commit 4a7e43e "Store p2sh scripts in AddAndGetDestinationForScript", so the `AddAndGetDestinationForScript()` function, `CanProvide()` method, and `mapScripts` map should all be more comprehensible

ACKs for top commit:
  Sjors:
    re-ACK a304a36 (rebase, slight text changes and my test)
  achow101:
    re-ACK a304a36
  meshcollider:
    utACK a304a36

Tree-SHA512: 03b625220c49684c376a8062d7646aeba0e5bfe043f977dc7dc357a6754627d594e070e4d458d12d2291888405d94c1dbe08c7787c318374cedd5755e724fb6e
meshcollider added a commit that referenced this pull request Mar 9, 2020
…nstead of exporting the private keys

d2774c0 Clear any input_errors for an input after it is signed (Andrew Chow)
dc17488 Replace GetSigningProvider with GetSolvingProvider (Andrew Chow)
6a9c429 Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan (Andrew Chow)
82a30fa Move key and script filling and signing from CWallet::FillPSBT to ScriptPubKeyMan::FillPSBT (Andrew Chow)
3d70dd9 Move FillPSBT to be a member of CWallet (Andrew Chow)
a4af324 Use CWallet::SignTransaction in CreateTransaction and signrawtransactionwithwallet (Andrew Chow)
f37de92 Implement CWallet::SignTransaction using ScriptPubKeyMan::SignTransaction (Andrew Chow)
d999dd5 Add SignTransaction function to ScriptPubKeyMan and LegacyScriptPubKeyMan (Andrew Chow)
2c52b59 Refactor rawtransaction's SignTransaction into generic SignTransaction function (Andrew Chow)

Pull request description:

  Following #17261, the way to sign transactions, PSBTs, and messages was to use `GetSigningProvider()` and get a `SigningProvider` containing the private keys. However this may not be feasible for future `ScriptPubKeyMan`s, such as for hardware wallets. Instead of exporting a `SigningProvider` containing private keys, we need to pass these things into the `ScriptPubKeyMan` (via `CWallet`) so that they can do whatever is needed internally to sign them. This is largely a refactor as the logic of processing transactions, PSBTs, and messages for is moved into `LegacyScriptPubKeyMan` and `CWallet` instead of being handled by the caller (e.g. `signrawtransaction`).

  To help with this, I've refactored the 3(!) implementations of a `SignTransaction()` function into one generic one. This function will be called by `signrawtransactionwithkey` and `LegacyScriptPubKeyMan::SignTransaction()`. `CWallet::CreateTransaction()` is changed to call `CWallet::SignTransaction()` which in turn, calls `LegacyScriptPubKeyMan::SignTransaction()`. Other `ScriptPubKeyMan`s may implement `SignTransaction()` differently.

  `FillPSBT()` is moved to be a member function of `CWallet` and the `psbtwallet.cpp/h` files removed. It is further split so that `CWallet` handles filling the UTXOs while the `ScriptPubKeyMan` handles adding keys, derivation paths, scripts, and signatures. In the end `LegacyScriptPubKeyMan::FillPSBT` still calls `SignPSBTInput`, but the `SigningProvider` is internal to `LegacyScriptPubKeyMan`. Other `ScriptPubKeyMan`s may do something different.

  A new `SignMessage()` function is added to both `CWallet` and `ScriptPubKeyMan`. Instead of having the caller (i.e. `signmessage` or the sign message dialog) get the private key, hash the message, and sign, `ScriptPubKeyMan` will now handle that (`CWallet` passes through to the `ScriptPubKeyMan`s as it does for many functions). This signing code is thus consolidated into `LegacyScriptPubKeyMan::SignMessage()`, though other `ScriptPubKeyMan`s may implement it differently. Additionally, a `SigningError` enum is introduced for the different errors that we expect to see from `SignMessage()`.

  Lastly, `GetSigningProvider()` is renamed to `GetPublicSigningProvider()`. It will now only provide pubkeys, key origins, and scripts. `LegacySigningProvider` has it's `GetKey` and `HaveKey` functions changed to only return false. Future implementations should return `HidingSigningProvider`s where private keys are hidden.

  Other things like `dumpprivkey` and `dumpwallet` are not changed because they directly need and access the `LegacyScriptPubKeyMan` so are not relevant to future changes.

ACKs for top commit:
  instagibbs:
    reACK d2774c0
  Sjors:
    re-utACK d2774c0
  meshcollider:
    re-utACK d2774c0

Tree-SHA512: 89c83e7e7e9315e283fae145a2264648a9d7f7ace8f3281cb3f44f0b013c988d67ba4fa9726e50c643c0ed921bdd269adaec984840d11acf4a681f3e8a582cc1
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 10, 2020
…gning instead of exporting the private keys

d2774c0 Clear any input_errors for an input after it is signed (Andrew Chow)
dc17488 Replace GetSigningProvider with GetSolvingProvider (Andrew Chow)
6a9c429 Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan (Andrew Chow)
82a30fa Move key and script filling and signing from CWallet::FillPSBT to ScriptPubKeyMan::FillPSBT (Andrew Chow)
3d70dd9 Move FillPSBT to be a member of CWallet (Andrew Chow)
a4af324 Use CWallet::SignTransaction in CreateTransaction and signrawtransactionwithwallet (Andrew Chow)
f37de92 Implement CWallet::SignTransaction using ScriptPubKeyMan::SignTransaction (Andrew Chow)
d999dd5 Add SignTransaction function to ScriptPubKeyMan and LegacyScriptPubKeyMan (Andrew Chow)
2c52b59 Refactor rawtransaction's SignTransaction into generic SignTransaction function (Andrew Chow)

Pull request description:

  Following bitcoin#17261, the way to sign transactions, PSBTs, and messages was to use `GetSigningProvider()` and get a `SigningProvider` containing the private keys. However this may not be feasible for future `ScriptPubKeyMan`s, such as for hardware wallets. Instead of exporting a `SigningProvider` containing private keys, we need to pass these things into the `ScriptPubKeyMan` (via `CWallet`) so that they can do whatever is needed internally to sign them. This is largely a refactor as the logic of processing transactions, PSBTs, and messages for is moved into `LegacyScriptPubKeyMan` and `CWallet` instead of being handled by the caller (e.g. `signrawtransaction`).

  To help with this, I've refactored the 3(!) implementations of a `SignTransaction()` function into one generic one. This function will be called by `signrawtransactionwithkey` and `LegacyScriptPubKeyMan::SignTransaction()`. `CWallet::CreateTransaction()` is changed to call `CWallet::SignTransaction()` which in turn, calls `LegacyScriptPubKeyMan::SignTransaction()`. Other `ScriptPubKeyMan`s may implement `SignTransaction()` differently.

  `FillPSBT()` is moved to be a member function of `CWallet` and the `psbtwallet.cpp/h` files removed. It is further split so that `CWallet` handles filling the UTXOs while the `ScriptPubKeyMan` handles adding keys, derivation paths, scripts, and signatures. In the end `LegacyScriptPubKeyMan::FillPSBT` still calls `SignPSBTInput`, but the `SigningProvider` is internal to `LegacyScriptPubKeyMan`. Other `ScriptPubKeyMan`s may do something different.

  A new `SignMessage()` function is added to both `CWallet` and `ScriptPubKeyMan`. Instead of having the caller (i.e. `signmessage` or the sign message dialog) get the private key, hash the message, and sign, `ScriptPubKeyMan` will now handle that (`CWallet` passes through to the `ScriptPubKeyMan`s as it does for many functions). This signing code is thus consolidated into `LegacyScriptPubKeyMan::SignMessage()`, though other `ScriptPubKeyMan`s may implement it differently. Additionally, a `SigningError` enum is introduced for the different errors that we expect to see from `SignMessage()`.

  Lastly, `GetSigningProvider()` is renamed to `GetPublicSigningProvider()`. It will now only provide pubkeys, key origins, and scripts. `LegacySigningProvider` has it's `GetKey` and `HaveKey` functions changed to only return false. Future implementations should return `HidingSigningProvider`s where private keys are hidden.

  Other things like `dumpprivkey` and `dumpwallet` are not changed because they directly need and access the `LegacyScriptPubKeyMan` so are not relevant to future changes.

ACKs for top commit:
  instagibbs:
    reACK bitcoin@d2774c0
  Sjors:
    re-utACK d2774c0
  meshcollider:
    re-utACK d2774c0

Tree-SHA512: 89c83e7e7e9315e283fae145a2264648a9d7f7ace8f3281cb3f44f0b013c988d67ba4fa9726e50c643c0ed921bdd269adaec984840d11acf4a681f3e8a582cc1
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Apr 17, 2020
Make LegacyScriptPubKeyMan::CanProvide method able to recognize p2sh scripts
when the redeem script is present in the mapScripts map without the p2sh script
also having to be added to the mapScripts map. This restores behavior prior to
bitcoin#17261, which I think broke backwards
compatibility with old wallet files by no longer treating addresses created by
`addmultisigaddress` calls before bitcoin#17261 as solvable.

The reason why tests didn't fail with the CanProvide implementation in bitcoin#17261
is because of a workaround added in 4a7e43e
"Store p2sh scripts in AddAndGetDestinationForScript", which masked the problem
for new `addmultisigaddress` RPC calls without fixing it for multisig addresses
already created in old wallet files.

This change adds a lot of comments and allows reverting commit
4a7e43e "Store p2sh scripts in
AddAndGetDestinationForScript", so the AddAndGetDestinationForScript() function,
CanProvide() method, and mapScripts map should all be more comprehensible
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 2, 2020
Summary:
Revert D7674 and D7691 (since it built on top of the prior).

D7674 is failing all sanitizer builds and appears to be adding flakiness
to `ninja check` in some configurations. There's hints that backporting up
to [[bitcoin/bitcoin#17261 | PR17261]] may fix one or more of these problems. Until then, we should
revert as it's making diff tests unreliable and incredibly noisy, as
well as zero reliability on sanitizer builds.

I opted to revert them together as one patch in order to give us the
option of un-reverting them both as a single change (by reverting this
change).

This reverts commit 78322df and 28efd9a

Test Plan:
```
ninja all check check-functional
```

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D7729
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 9, 2020
…in legacy keyman

Summary:
This commit only affects locking behavior and doesn't have other changes.

bitcoin/bitcoin@fadc08a

---

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  cmake -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-Werror
  ninja all check check-functional

Reviewers: #bitcoin_abc, Fabien, deadalnix

Reviewed By: #bitcoin_abc, Fabien, deadalnix

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7838
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
Summary:
In CWallet::LoadWallet, use this to detect and empty wallet with no keys

This commit does not change behavior.

---

bitcoin/bitcoin@eb81fc3

Depends on D7838

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  export CC=clang CXX=clang++; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug
  ninja all check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7848
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…erated over

Summary:
bitcoin/bitcoin@81610ed

Depends on D7848

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7849
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
Summary:
bitcoin/bitcoin@501acb5

Depends on D7849

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

---

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7850
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…ript

Summary:
bitcoin/bitcoin@4a7e43e

Depends on D7850

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7851
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…ptPubKeyMan

Summary:
bitcoin/bitcoin@01b4511

Depends on D7851

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7854
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
Summary:
This avoids repeaded upgrades when support for more multiple keyman references
is added in the next commit:
bitcoin/bitcoin#16341 (comment)

bitcoin/bitcoin@415afcc

Depends on D7854

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7855
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
Summary:
Instead of having a uint256 representations of one scattered throughout
where it is used, define it globally in uint256.h

bitcoin/bitcoin@4977c30

Depends on D7855

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7858
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…oops

Summary:
Add wallet logic for dealing with multiple ScriptPubKeyMan instances. This
doesn't change current behavior because there is still only a single
LegacyScriptPubKeyMan. But in the future the new logic will be used to support
descriptor wallets.

---

bitcoin/bitcoin@c729afd

Note: Had to bring in [[bitcoin/bitcoin#18052 | PR18052]] to fix an instance of -Wmaybe-uninitialized

Depends on D7858

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]] and [[bitcoin/bitcoin#18052 | PR18052]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Subscribers: deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7859
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…ion to LegacyScriptPubKeyMan

Summary:
This commit does not change behavior.

---

bitcoin/bitcoin@e2f02aa

Depends on D7859

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7860
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…ethod

Summary:
This commit does not change behavior.

bitcoin/bitcoin@3afe53c

Depends on D7860

Partial backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7861
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 10, 2020
…h unique_ptrs

Summary:
Needed for future ScriptPubKeyMans which may need to create
SigningProviders dynamically and thus a normal pointer is not enough

This commit does not change behavior.

bitcoin/bitcoin@3f37365

Depends on D7861

Concludes backport of Core [[bitcoin/bitcoin#17261 | PR17261]]

Test Plan:
  ninja all check check-functional

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7863
@bitcoin bitcoin locked and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.