LCOV - code coverage report
Current view: top level - src/test/util - wallet.cpp (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 18 18 100.0 %
Date: 2020-09-26 01:30:44 Functions: 3 3 100.0 %

          Line data    Source code
       1             : // Copyright (c) 2019 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #include <test/util/wallet.h>
       6             : 
       7             : #include <key_io.h>
       8             : #include <outputtype.h>
       9             : #include <script/standard.h>
      10             : #ifdef ENABLE_WALLET
      11             : #include <wallet/wallet.h>
      12             : #endif
      13             : 
      14           1 : const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj";
      15             : 
      16             : #ifdef ENABLE_WALLET
      17           3 : std::string getnewaddress(CWallet& w)
      18             : {
      19             :     constexpr auto output_type = OutputType::BECH32;
      20           3 :     CTxDestination dest;
      21           3 :     std::string error;
      22           3 :     if (!w.GetNewDestination(output_type, "", dest, error)) assert(false);
      23             : 
      24           3 :     return EncodeDestination(dest);
      25           3 : }
      26             : 
      27           3 : void importaddress(CWallet& wallet, const std::string& address)
      28             : {
      29           3 :     auto spk_man = wallet.GetLegacyScriptPubKeyMan();
      30           3 :     LOCK2(wallet.cs_wallet, spk_man->cs_KeyStore);
      31           3 :     const auto dest = DecodeDestination(address);
      32           3 :     assert(IsValidDestination(dest));
      33           3 :     const auto script = GetScriptForDestination(dest);
      34           3 :     wallet.MarkDirty();
      35           3 :     assert(!spk_man->HaveWatchOnly(script));
      36           3 :     if (!spk_man->AddWatchOnly(script, 0 /* nCreateTime */)) assert(false);
      37           3 :     wallet.SetAddressBook(dest, /* label */ "", "receive");
      38           3 : }
      39             : #endif // ENABLE_WALLET

Generated by: LCOV version 1.15