mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-18 11:30:44 +01:00
This introduces two command line flags (-addresstype and -changetype) which control the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow overriding these (`getnewaddress` and `getrawchangeaddress`). Supported types are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig), and "bech32" (P2WPKH and P2WSH-multisig). A few utility functions are added to the wallet to construct different address type and to add the necessary entries to the wallet file to be compatible with earlier versions (see `CWallet::LearnRelatedScripts`, `GetDestinationForKey`, `GetAllDestinationsForKey`, `CWallet::AddAndGetDestinationForScript`).
33 lines
937 B
C++
33 lines
937 B
C++
// Copyright (c) 2016 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <wallet/test/wallet_test_fixture.h>
|
|
|
|
#include <rpc/server.h>
|
|
#include <wallet/db.h>
|
|
|
|
WalletTestingSetup::WalletTestingSetup(const std::string& chainName):
|
|
TestingSetup(chainName)
|
|
{
|
|
bitdb.MakeMock();
|
|
|
|
bool fFirstRun;
|
|
g_address_type = OUTPUT_TYPE_DEFAULT;
|
|
g_change_type = OUTPUT_TYPE_DEFAULT;
|
|
std::unique_ptr<CWalletDBWrapper> dbw(new CWalletDBWrapper(&bitdb, "wallet_test.dat"));
|
|
pwalletMain = MakeUnique<CWallet>(std::move(dbw));
|
|
pwalletMain->LoadWallet(fFirstRun);
|
|
RegisterValidationInterface(pwalletMain.get());
|
|
|
|
RegisterWalletRPCCommands(tableRPC);
|
|
}
|
|
|
|
WalletTestingSetup::~WalletTestingSetup()
|
|
{
|
|
UnregisterValidationInterface(pwalletMain.get());
|
|
|
|
bitdb.Flush(true);
|
|
bitdb.Reset();
|
|
}
|