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