Changeset View
Changeset View
Standalone View
Standalone View
src/test/util/wallet.cpp
Show All 24 Lines | std::string getnewaddress(const Config &config, CWallet &w) { | ||||
return EncodeDestination(dest, config); | return EncodeDestination(dest, config); | ||||
} | } | ||||
void importaddress(CWallet &wallet, const std::string &address) { | void importaddress(CWallet &wallet, const std::string &address) { | ||||
auto spk_man = wallet.GetLegacyScriptPubKeyMan(); | auto spk_man = wallet.GetLegacyScriptPubKeyMan(); | ||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
AssertLockHeld(spk_man->cs_wallet); | AssertLockHeld(spk_man->cs_wallet); | ||||
const auto dest = DecodeDestination(address, wallet.chainParams); | const auto dest = DecodeDestination(address, wallet.chainParams()); | ||||
assert(IsValidDestination(dest)); | assert(IsValidDestination(dest)); | ||||
const auto script = GetScriptForDestination(dest); | const auto script = GetScriptForDestination(dest); | ||||
wallet.MarkDirty(); | wallet.MarkDirty(); | ||||
assert(!spk_man->HaveWatchOnly(script)); | assert(!spk_man->HaveWatchOnly(script)); | ||||
if (!spk_man->AddWatchOnly(script, 0 /* nCreateTime */)) { | if (!spk_man->AddWatchOnly(script, 0 /* nCreateTime */)) { | ||||
assert(false); | assert(false); | ||||
} | } | ||||
wallet.SetAddressBook(dest, /* label */ "", "receive"); | wallet.SetAddressBook(dest, /* label */ "", "receive"); | ||||
} | } | ||||
#endif // ENABLE_WALLET | #endif // ENABLE_WALLET |