mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-02 03:46:01 +02:00
wallet: Use util::Error throughout AddWalletDescriptor
32023 changed AddWalletDescriptor to return util::Error, but did not change all of the failure cases to do so. This may result in some callers continuing when there was actually an error. Unify all of the failure cases to use util::Error so that all callers handle AddWalletDescriptor errors in the same way. The encapsulated return type is changed from ScriptPubKeyMan* to std::reference_wrapper<DescriptorScriptPubKeyMan>. This avoids having a value that can be interpreted as a bool, and also removes the need to constantly dynamic_cast the returned value. The only kind of ScriptPubKeyMan that can come out of AddWalletDescriptor is a DescriptorScriptPubKeyMan anyways.
This commit is contained in:
@@ -25,13 +25,13 @@ BOOST_AUTO_TEST_CASE(DescriptorScriptPubKeyManTests)
|
||||
// Verify that a SigningProvider for a pubkey is only returned if its corresponding private key is available
|
||||
auto key_internal = GenerateRandomKey();
|
||||
std::string desc_str = "tr(" + EncodeSecret(key_internal) + ",pk(" + HexStr(key_scriptpath.GetPubKey()) + "))";
|
||||
auto spk_man1 = dynamic_cast<DescriptorScriptPubKeyMan*>(CreateDescriptor(keystore, desc_str, true));
|
||||
auto spk_man1 = CreateDescriptor(keystore, desc_str, true);
|
||||
BOOST_CHECK(spk_man1 != nullptr);
|
||||
auto signprov_keypath_spendable = spk_man1->GetSigningProvider(key_internal.GetPubKey());
|
||||
BOOST_CHECK(signprov_keypath_spendable != nullptr);
|
||||
|
||||
desc_str = "tr(" + HexStr(XOnlyPubKey::NUMS_H) + ",pk(" + HexStr(key_scriptpath.GetPubKey()) + "))";
|
||||
auto spk_man2 = dynamic_cast<DescriptorScriptPubKeyMan*>(CreateDescriptor(keystore, desc_str, true));
|
||||
auto spk_man2 = CreateDescriptor(keystore, desc_str, true);
|
||||
BOOST_CHECK(spk_man2 != nullptr);
|
||||
auto signprov_keypath_nums_h = spk_man2->GetSigningProvider(XOnlyPubKey::NUMS_H.GetEvenCorrespondingCPubKey());
|
||||
BOOST_CHECK(signprov_keypath_nums_h == nullptr);
|
||||
|
||||
Reference in New Issue
Block a user