Auto merge of #3967 - Eirik0:3961-migration-address, r=Eirik0
3961 migration address Closes #3961
This commit is contained in:
commit
f283f2460e
14
src/init.cpp
14
src/init.cpp
|
@ -37,6 +37,7 @@
|
|||
#include "utilmoneystr.h"
|
||||
#include "validationinterface.h"
|
||||
#ifdef ENABLE_WALLET
|
||||
#include "key_io.h"
|
||||
#include "wallet/wallet.h"
|
||||
#include "wallet/walletdb.h"
|
||||
#endif
|
||||
|
@ -405,6 +406,8 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||
strUsage += HelpMessageGroup(_("Wallet options:"));
|
||||
strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
|
||||
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), 100));
|
||||
strUsage += HelpMessageOpt("-migration=<boolean>", _("Set to true to enable the Sprout to Sapling migration."));
|
||||
strUsage += HelpMessageOpt("-migrationdestaddress=<zaddr>", _("Set the Sapling migration address"));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)",
|
||||
CURRENCY_UNIT, FormatMoney(CWallet::minTxFee.GetFeePerK())));
|
||||
|
@ -1070,6 +1073,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);
|
||||
|
||||
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||
// Check Sapling migration address if set and is a valid Sapling address
|
||||
if (mapArgs.count("-migrationdestaddress")) {
|
||||
std::string migrationDestAddress = mapArgs["-migrationdestaddress"];
|
||||
libzcash::PaymentAddress address = DecodePaymentAddress(migrationDestAddress);
|
||||
if (boost::get<libzcash::SaplingPaymentAddress>(&address) == nullptr) {
|
||||
return InitError(_("-migrationdestaddress must be a valid Sapling address."));
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true);
|
||||
|
@ -1671,6 +1682,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||
}
|
||||
}
|
||||
|
||||
// Set sapling migration status
|
||||
pwalletMain->fSaplingMigrationEnabled = GetBoolArg("-migration", false);
|
||||
|
||||
if (fFirstRun)
|
||||
{
|
||||
// Create new keyUser and set as default key
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "boost/variant/static_visitor.hpp"
|
||||
#include "asyncrpcoperation_saplingmigration.h"
|
||||
#include "init.h"
|
||||
#include "key_io.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "random.h"
|
||||
#include "sync.h"
|
||||
|
@ -161,6 +162,13 @@ CAmount AsyncRPCOperation_saplingmigration::chooseAmount(const CAmount& availabl
|
|||
|
||||
// Unless otherwise specified, the migration destination address is the address for Sapling account 0
|
||||
libzcash::SaplingPaymentAddress AsyncRPCOperation_saplingmigration::getMigrationDestAddress(const HDSeed& seed) {
|
||||
if (mapArgs.count("-migrationdestaddress")) {
|
||||
std::string migrationDestAddress = mapArgs["-migrationdestaddress"];
|
||||
auto address = DecodePaymentAddress(migrationDestAddress);
|
||||
auto saplingAddress = boost::get<libzcash::SaplingPaymentAddress>(&address);
|
||||
assert(saplingAddress != nullptr); // This is checked in init.cpp
|
||||
return *saplingAddress;
|
||||
}
|
||||
// Derive the address for Sapling account 0
|
||||
auto m = libzcash::SaplingExtendedSpendingKey::Master(seed);
|
||||
uint32_t bip44CoinType = Params().BIP44CoinType();
|
||||
|
|
Loading…
Reference in New Issue