16 #include <boost/test/unit_test.hpp>
28 std::unique_ptr<Descriptor> parsed_desc =
Parse(desc_str, keys,
error,
false);
30 if (!success)
return nullptr;
32 const int64_t range_start = 0, range_end = 1, next_index = 0, timestamp = 1;
34 WalletDescriptor w_desc(std::move(parsed_desc), timestamp, range_start, range_end, next_index);
36 LOCK(keystore.cs_wallet);
38 return Assert(keystore.AddWalletDescriptor(w_desc, keys,
"",
false));
45 for (
int i = 0; i < 2; i++) {
53 std::unique_ptr<interfaces::Chain>& chain =
m_node.
chain;
80 std::string desc_str =
"pk(" +
EncodeSecret(keys[0]) +
")";
85 result = spk_manager->IsMine(scriptPubKey);
111 std::string desc_str =
"pk(" +
EncodeSecret(uncompressedKey) +
")";
116 result = spk_manager->IsMine(scriptPubKey);
142 std::string desc_str =
"pkh(" +
EncodeSecret(keys[0]) +
")";
147 result = spk_manager->IsMine(scriptPubKey);
173 std::string desc_str =
"pkh(" +
EncodeSecret(uncompressedKey) +
")";
178 result = spk_manager->IsMine(scriptPubKey);
212 std::string desc_str =
"sh(pkh(" +
EncodeSecret(keys[0]) +
"))";
218 result = spk_manager->IsMine(scriptPubKey);
244 std::string desc_str =
"sh(sh(" +
EncodeSecret(keys[0]) +
"))";
272 std::string desc_str =
"wsh(sh(" +
EncodeSecret(keys[0]) +
"))";
298 std::string desc_str =
"wsh(wpkh(" +
EncodeSecret(keys[0]) +
"))";
326 std::string desc_str =
"wsh(wsh(" +
EncodeSecret(keys[0]) +
"))";
351 std::string desc_str =
"wpkh(" +
EncodeSecret(keys[0]) +
")";
356 result = spk_manager->IsMine(scriptPubKey);
384 std::string desc_str =
"wpkh(" +
EncodeSecret(uncompressedKey) +
")";
433 result = spk_manager->IsMine(scriptPubKey);
470 result = spk_manager->IsMine(scriptPubKey);
513 result = spk_manager->IsMine(scriptPubKey);
597 result = spk_manager->IsMine(scriptPubKey);
605 std::string desc_str =
"combo(" +
EncodeSecret(keys[0]) +
")";
620 result = spk_manager->IsMine(scriptPubKey);
625 result = spk_manager->IsMine(scriptPubKey);
631 result = spk_manager->IsMine(scriptPubKey);
641 result = spk_manager->IsMine(scriptPubKey);
649 std::string desc_str =
"tr(" +
EncodeSecret(keys[0]) +
")";
659 result = spk_manager->IsMine(scriptPubKey);
670 scriptPubKey.
clear();
685 scriptPubKey.
clear();
700 scriptPubKey.
clear();
715 scriptPubKey.
clear();
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
#define Assert(val)
Identity function.
An encapsulated private key.
void MakeNewKey(bool fCompressed)
Generate a new private key using a cryptographic PRNG.
CPubKey GetPubKey() const
Compute the public key from a private key.
An encapsulated public key.
Serialized script, used inside transaction inputs and outputs.
virtual bool AddKey(const CKey &key)
RecursiveMutex cs_KeyStore
Utility class to construct Taproot outputs from internal key and script tree.
WitnessV1Taproot GetOutput()
Compute scriptPubKey (after Finalize()).
TaprootBuilder & Finalize(const XOnlyPubKey &internal_key)
Finalize the construction.
bool IsFullyValid() const
Determine if this pubkey is fully valid.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
void SetupLegacyScriptPubKeyMan()
Make a LegacyScriptPubKeyMan and set it for all types, internal, and external.
std::unordered_set< CScript, SaltedSipHasher > GetScriptPubKeys() const override
Returns a set of all the scriptPubKeys that this ScriptPubKeyMan watches.
isminetype IsMine(const CScript &script) const override
bool AddCScript(const CScript &redeemScript) override
Descriptor with some wallet metadata.
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
BOOST_AUTO_TEST_SUITE_END()
std::string EncodeSecret(const CKey &key)
bool error(const char *fmt, const Args &... args)
wallet::ScriptPubKeyMan * CreateDescriptor(CWallet &keystore, const std::string &desc_str, const bool success)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase(MockableData records)
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
BOOST_AUTO_TEST_CASE(bnb_search_test)
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
std::vector< unsigned char > ToByteVector(const T &in)
CScript GetScriptForMultisig(int nRequired, const std::vector< CPubKey > &keys)
Generate a multisig script.
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
std::vector< Byte > ParseHex(std::string_view hex_str)
Like TryParseHex, but returns an empty vector on invalid input.
std::unique_ptr< interfaces::Chain > chain