Bitcoin Core  22.99.0
P2P Digital Currency
wallet.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 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 <util/translation.h>
12 #include <wallet/wallet.h>
13 #endif
14 
15 using wallet::CWallet;
16 
17 const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj";
18 
19 #ifdef ENABLE_WALLET
20 std::string getnewaddress(CWallet& w)
21 {
22  constexpr auto output_type = OutputType::BECH32;
23  CTxDestination dest;
25  if (!w.GetNewDestination(output_type, "", dest, error)) assert(false);
26 
27  return EncodeDestination(dest);
28 }
29 
30 #endif // ENABLE_WALLET
assert
assert(!tx.IsCoinBase())
ADDRESS_BCRT1_UNSPENDABLE
const std::string ADDRESS_BCRT1_UNSPENDABLE
Definition: wallet.cpp:17
wallet.h
key_io.h
bilingual_str
Bilingual messages:
Definition: translation.h:16
outputtype.h
wallet::CWallet::GetNewDestination
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, bilingual_str &error)
Definition: wallet.cpp:2263
getnewaddress
std::string getnewaddress(wallet::CWallet &w)
Returns a new address from the wallet.
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:232
standard.h
OutputType::BECH32
@ BECH32
translation.h
error
bool error(const char *fmt, const Args &... args)
Definition: system.h:49
EncodeDestination
std::string EncodeDestination(const CTxDestination &dest)
Definition: key_io.cpp:276
wallet.h