mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-01 00:34:01 +02:00
Add GetNewDestination to CWallet to fetch new destinations
Instead of having the same multiple lines of code everywhere that new destinations are fetched, introduce GetNewDestination as a member function of CWallet which does the key fetching, label setting, script generation, and destination generation.
This commit is contained in:
@@ -25,14 +25,9 @@ const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqq
|
||||
std::string getnewaddress(CWallet& w)
|
||||
{
|
||||
constexpr auto output_type = OutputType::BECH32;
|
||||
|
||||
CPubKey new_key;
|
||||
if (!w.GetKeyFromPool(new_key)) assert(false);
|
||||
|
||||
w.LearnRelatedScripts(new_key, output_type);
|
||||
const auto dest = GetDestinationForKey(new_key, output_type);
|
||||
|
||||
w.SetAddressBook(dest, /* label */ "", "receive");
|
||||
CTxDestination dest;
|
||||
std::string error;
|
||||
if (!w.GetNewDestination(output_type, "", dest, error)) assert(false);
|
||||
|
||||
return EncodeDestination(dest);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user