Skip to content

Commit 1e6ce40

Browse files
committed
[Ed25519] Fix createrawbdapaccount issue where Secp and Ed25519 keys were not being paired correctly.
1 parent 0d46e63 commit 1e6ce40

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/bdap/rpcrawbdap.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,41 +87,31 @@ UniValue createrawbdapaccount(const JSONRPCRequest& request)
8787
throw std::runtime_error("BDAP_CREATE_RAW_TX_RPC_ERROR: ERRCODE: 4503 - " + txDomainEntry.GetFullObjectPath() + _(" entry already exists. Can not add duplicate."));
8888

8989
// TODO: Add ability to pass in the wallet address
90-
//now using GetKeyFromPool instead of MakeNewKey
91-
std::vector<unsigned char> newEdKey;
90+
std::vector<unsigned char> vchDHTPubKey;
9291
CPubKey pubWalletKey;
93-
if (!pwalletMain->GetKeysFromPool(pubWalletKey, newEdKey, true))
92+
if (!pwalletMain->GetKeysFromPool(pubWalletKey, vchDHTPubKey, true))
9493
throw std::runtime_error("Error: Keypool ran out, please call keypoolrefill first");
9594
CKeyID keyWalletID = pubWalletKey.GetID();
9695
CDynamicAddress walletAddress = CDynamicAddress(keyWalletID);
9796

98-
9997
pwalletMain->SetAddressBook(keyWalletID, strObjectID, "bdap-wallet");
10098

10199
CharString vchWalletAddress = vchFromString(walletAddress.ToString());
102100
txDomainEntry.WalletAddress = vchWalletAddress;
103101

104-
// TODO: Add ability to pass in the DHT public key
105-
CKeyEd25519 privDHTKey;
106-
CharString vchDHTPubKey = privDHTKey.GetPubKey();
107-
108-
if (pwalletMain && !pwalletMain->AddDHTKey(privDHTKey, vchDHTPubKey))
109-
throw std::runtime_error("BDAP_CREATE_RAW_TX_RPC_ERROR: ERRCODE: 4505 - " + _("Error adding ed25519 key to wallet for BDAP"));
110-
102+
CKeyID vchDHTPubKeyID = GetIdFromCharVector(vchDHTPubKey);
111103
txDomainEntry.DHTPublicKey = vchDHTPubKey;
112-
pwalletMain->SetAddressBook(privDHTKey.GetID(), strObjectID, "bdap-dht-key");
104+
pwalletMain->SetAddressBook(vchDHTPubKeyID, strObjectID, "bdap-dht-key");
113105

114106
// TODO: Add ability to pass in the link address
115107
// TODO: Use stealth address for the link address so linking will be private
116-
//now using GetKeyFromPool instead of MakeNewKey
117108
CPubKey pubLinkKey;
118109
std::vector<unsigned char> newEdKey2;
119110
if (!pwalletMain->GetKeysFromPool(pubLinkKey, newEdKey2, true))
120111
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
121112
CKeyID keyLinkID = pubLinkKey.GetID();
122113
CDynamicAddress linkAddress = CDynamicAddress(keyLinkID);
123114

124-
125115
pwalletMain->SetAddressBook(keyLinkID, strObjectID, "bdap-link");
126116

127117
CharString vchLinkAddress = vchFromString(linkAddress.ToString());

0 commit comments

Comments
 (0)