Skip to content

Commit 69b3a0b

Browse files
committed
[Ed25519] Restore Ed25519 keypool state after importing mnemonic. WIP
1 parent 2e90d72 commit 69b3a0b

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/bdap/rpcdomainentry.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ static UniValue AddDomainEntry(const JSONRPCRequest& request, BDAP::ObjectType b
5454
CPubKey pubWalletKey;
5555
CharString vchDHTPubKey;
5656
if (!pwalletMain->GetEdKeyFromPool(pubWalletKey, vchDHTPubKey, true))
57-
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
57+
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: EdKeypool ran out, please call edkeypoolrefill first");
58+
59+
while (pDomainEntryDB->DomainEntryExistsPubKey(vchDHTPubKey)) {
60+
if (!pwalletMain->GetEdKeyFromPool(pubWalletKey, vchDHTPubKey, true))
61+
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: EdKeypool ran out, please call edkeypoolrefill first");
62+
};
63+
5864
CKeyID keyWalletID = pubWalletKey.GetID();
5965
CDynamicAddress walletAddress = CDynamicAddress(keyWalletID);
6066

@@ -84,8 +90,12 @@ static UniValue AddDomainEntry(const JSONRPCRequest& request, BDAP::ObjectType b
8490
// TODO: Use stealth address for the link address so linking will be private
8591
//now using GetKeyFromPool instead of MakeNewKey
8692
CPubKey pubLinkKey;
87-
if (!pwalletMain->GetKeyFromPool(pubLinkKey, true))
88-
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
93+
CharString NAvchDHTPubKey; //not really used
94+
if (!pwalletMain->GetEdKeyFromPool(pubLinkKey, NAvchDHTPubKey, true))
95+
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: EdKeypool ran out, please call edkeypoolrefill first");
96+
97+
// if (!pwalletMain->GetKeyFromPool(pubLinkKey, true))
98+
// throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
8999

90100
CKeyID keyLinkID = pubLinkKey.GetID();
91101
CDynamicAddress linkAddress = CDynamicAddress(keyLinkID);
@@ -879,7 +889,7 @@ UniValue mybdapaccounts(const JSONRPCRequest& request)
879889
uint32_t nCount = 1;
880890
for (const std::vector<unsigned char>& vchPubKey : vvchDHTPubKeys) {
881891
CDomainEntry entry;
882-
LogPrintf("DEBUGGER ED %s - PubKey [%s]\n",__func__,stringFromVch(vchPubKey));
892+
//LogPrintf("DEBUGGER ED %s - PubKey [%s]\n",__func__,stringFromVch(vchPubKey));
883893
if (pDomainEntryDB->ReadDomainEntryPubKey(vchPubKey, entry)) {
884894
UniValue oAccount(UniValue::VOBJ);
885895
if (BuildBDAPJson(entry, oAccount, false)) {

src/wallet/wallet.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -4382,6 +4382,8 @@ bool CWallet::SetDefaultKey(const CPubKey& vchPubKey)
43824382
bool CWallet::NewKeyPool()
43834383
{
43844384
{
4385+
LogPrintf("DEBUGGER ED %s - made it here!\n",__func__);
4386+
43854387
LOCK(cs_wallet);
43864388
CWalletDB walletdb(strWalletFile);
43874389
BOOST_FOREACH (int64_t nIndex, setInternalKeyPool) {
@@ -4406,6 +4408,8 @@ bool CWallet::NewKeyPool()
44064408
bool CWallet::NewEdKeyPool()
44074409
{
44084410
{
4411+
LogPrintf("DEBUGGER ED %s - made it here!\n",__func__);
4412+
44094413
LOCK(cs_wallet);
44104414
CWalletDB walletdb(strWalletFile);
44114415
BOOST_FOREACH (int64_t nIndex, setInternalEdKeyPool) {

0 commit comments

Comments
 (0)