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++) {
52 std::unique_ptr<interfaces::Chain>& chain =
m_node.
chain;
79 std::string desc_str =
"pk(" +
EncodeSecret(keys[0]) +
")";
84 result = spk_manager->IsMine(scriptPubKey);
110 std::string desc_str =
"pk(" +
EncodeSecret(uncompressedKey) +
")";
115 result = spk_manager->IsMine(scriptPubKey);
141 std::string desc_str =
"pkh(" +
EncodeSecret(keys[0]) +
")";
146 result = spk_manager->IsMine(scriptPubKey);
172 std::string desc_str =
"pkh(" +
EncodeSecret(uncompressedKey) +
")";
177 result = spk_manager->IsMine(scriptPubKey);
211 std::string desc_str =
"sh(pkh(" +
EncodeSecret(keys[0]) +
"))";
217 result = spk_manager->IsMine(scriptPubKey);
243 std::string desc_str =
"sh(sh(" +
EncodeSecret(keys[0]) +
"))";
271 std::string desc_str =
"wsh(sh(" +
EncodeSecret(keys[0]) +
"))";
297 std::string desc_str =
"wsh(wpkh(" +
EncodeSecret(keys[0]) +
"))";
325 std::string desc_str =
"wsh(wsh(" +
EncodeSecret(keys[0]) +
"))";
350 std::string desc_str =
"wpkh(" +
EncodeSecret(keys[0]) +
")";
355 result = spk_manager->IsMine(scriptPubKey);
383 std::string desc_str =
"wpkh(" +
EncodeSecret(uncompressedKey) +
")";
432 result = spk_manager->IsMine(scriptPubKey);
469 result = spk_manager->IsMine(scriptPubKey);
512 result = spk_manager->IsMine(scriptPubKey);
596 result = spk_manager->IsMine(scriptPubKey);
604 std::string desc_str =
"combo(" +
EncodeSecret(keys[0]) +
")";
619 result = spk_manager->IsMine(scriptPubKey);
624 result = spk_manager->IsMine(scriptPubKey);
630 result = spk_manager->IsMine(scriptPubKey);
640 result = spk_manager->IsMine(scriptPubKey);
648 std::string desc_str =
"tr(" +
EncodeSecret(keys[0]) +
")";
658 result = spk_manager->IsMine(scriptPubKey);
669 scriptPubKey.
clear();
684 scriptPubKey.
clear();
699 scriptPubKey.
clear();
714 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()
CKey GenerateRandomKey(bool compressed) noexcept
std::string EncodeSecret(const CKey &key)
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