Create method for getting HD seed in RPCs
This commit is contained in:
parent
f283f2460e
commit
52cfa9c1ee
|
@ -348,12 +348,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||||
// generate a common one from the HD seed. This ensures the data is
|
// generate a common one from the HD seed. This ensures the data is
|
||||||
// recoverable, while keeping it logically separate from the ZIP 32
|
// recoverable, while keeping it logically separate from the ZIP 32
|
||||||
// Sapling key hierarchy, which the user might not be using.
|
// Sapling key hierarchy, which the user might not be using.
|
||||||
HDSeed seed;
|
HDSeed seed = pwalletMain->GetHDSeedForRPC();
|
||||||
if (!pwalletMain->GetHDSeed(seed)) {
|
|
||||||
throw JSONRPCError(
|
|
||||||
RPC_WALLET_ERROR,
|
|
||||||
"AsyncRPCOperation_sendmany: HD seed not found");
|
|
||||||
}
|
|
||||||
ovk = ovkForShieldingFromTaddr(seed);
|
ovk = ovkForShieldingFromTaddr(seed);
|
||||||
}
|
}
|
||||||
if (!ovk) {
|
if (!ovk) {
|
||||||
|
|
|
@ -85,13 +85,7 @@ bool AsyncRPCOperation_saplingmigration::main_impl() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HDSeed seed;
|
HDSeed seed = pwalletMain->GetHDSeedForRPC();
|
||||||
if (!pwalletMain->GetHDSeed(seed)) {
|
|
||||||
throw JSONRPCError(
|
|
||||||
RPC_WALLET_ERROR,
|
|
||||||
"AsyncRPCOperation_AsyncRPCOperation_saplingmigration: HD seed not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
libzcash::SaplingPaymentAddress migrationDestAddress = getMigrationDestAddress(seed);
|
libzcash::SaplingPaymentAddress migrationDestAddress = getMigrationDestAddress(seed);
|
||||||
|
|
||||||
auto consensusParams = Params().GetConsensus();
|
auto consensusParams = Params().GetConsensus();
|
||||||
|
|
|
@ -381,12 +381,7 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
||||||
// generate a common one from the HD seed. This ensures the data is
|
// generate a common one from the HD seed. This ensures the data is
|
||||||
// recoverable, while keeping it logically separate from the ZIP 32
|
// recoverable, while keeping it logically separate from the ZIP 32
|
||||||
// Sapling key hierarchy, which the user might not be using.
|
// Sapling key hierarchy, which the user might not be using.
|
||||||
HDSeed seed;
|
HDSeed seed = pwalletMain->GetHDSeedForRPC();
|
||||||
if (!pwalletMain->GetHDSeed(seed)) {
|
|
||||||
throw JSONRPCError(
|
|
||||||
RPC_WALLET_ERROR,
|
|
||||||
"AsyncRPCOperation_sendmany::main_impl(): HD seed not found");
|
|
||||||
}
|
|
||||||
ovk = ovkForShieldingFromTaddr(seed);
|
ovk = ovkForShieldingFromTaddr(seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,12 +247,7 @@ bool ShieldToAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) c
|
||||||
// generate a common one from the HD seed. This ensures the data is
|
// generate a common one from the HD seed. This ensures the data is
|
||||||
// recoverable, while keeping it logically separate from the ZIP 32
|
// recoverable, while keeping it logically separate from the ZIP 32
|
||||||
// Sapling key hierarchy, which the user might not be using.
|
// Sapling key hierarchy, which the user might not be using.
|
||||||
HDSeed seed;
|
HDSeed seed = pwalletMain->GetHDSeedForRPC();
|
||||||
if (!pwalletMain->GetHDSeed(seed)) {
|
|
||||||
throw JSONRPCError(
|
|
||||||
RPC_WALLET_ERROR,
|
|
||||||
"CWallet::GenerateNewSaplingZKey(): HD seed not found");
|
|
||||||
}
|
|
||||||
uint256 ovk = ovkForShieldingFromTaddr(seed);
|
uint256 ovk = ovkForShieldingFromTaddr(seed);
|
||||||
|
|
||||||
// Add transparent inputs
|
// Add transparent inputs
|
||||||
|
|
|
@ -506,8 +506,7 @@ UniValue dumpwallet_impl(const UniValue& params, bool fHelp, bool fDumpZKeys)
|
||||||
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
|
||||||
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
|
||||||
{
|
{
|
||||||
HDSeed hdSeed;
|
HDSeed hdSeed = pwalletMain->GetHDSeedForRPC();
|
||||||
pwalletMain->GetHDSeed(hdSeed);
|
|
||||||
auto rawSeed = hdSeed.RawSeed();
|
auto rawSeed = hdSeed.RawSeed();
|
||||||
file << strprintf("# HDSeed=%s fingerprint=%s", HexStr(rawSeed.begin(), rawSeed.end()), hdSeed.Fingerprint().GetHex());
|
file << strprintf("# HDSeed=%s fingerprint=%s", HexStr(rawSeed.begin(), rawSeed.end()), hdSeed.Fingerprint().GetHex());
|
||||||
file << "\n";
|
file << "\n";
|
||||||
|
|
|
@ -2156,6 +2156,14 @@ bool CWallet::SetCryptedHDSeed(const uint256& seedFp, const std::vector<unsigned
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HDSeed CWallet::GetHDSeedForRPC() const {
|
||||||
|
HDSeed seed;
|
||||||
|
if (!pwalletMain->GetHDSeed(seed)) {
|
||||||
|
throw JSONRPCError(RPC_WALLET_ERROR, "HD seed not found");
|
||||||
|
}
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
void CWallet::SetHDChain(const CHDChain& chain, bool memonly)
|
void CWallet::SetHDChain(const CHDChain& chain, bool memonly)
|
||||||
{
|
{
|
||||||
LOCK(cs_wallet);
|
LOCK(cs_wallet);
|
||||||
|
|
|
@ -1288,6 +1288,9 @@ public:
|
||||||
bool SetHDSeed(const HDSeed& seed);
|
bool SetHDSeed(const HDSeed& seed);
|
||||||
bool SetCryptedHDSeed(const uint256& seedFp, const std::vector<unsigned char> &vchCryptedSecret);
|
bool SetCryptedHDSeed(const uint256& seedFp, const std::vector<unsigned char> &vchCryptedSecret);
|
||||||
|
|
||||||
|
/* Returns the wallet's HD seed or throw JSONRPCError(...) */
|
||||||
|
HDSeed GetHDSeedForRPC() const;
|
||||||
|
|
||||||
/* Set the HD chain model (chain child index counters) */
|
/* Set the HD chain model (chain child index counters) */
|
||||||
void SetHDChain(const CHDChain& chain, bool memonly);
|
void SetHDChain(const CHDChain& chain, bool memonly);
|
||||||
const CHDChain& GetHDChain() const { return hdChain; }
|
const CHDChain& GetHDChain() const { return hdChain; }
|
||||||
|
|
Loading…
Reference in New Issue