Skip to content

Commit 3d235df

Browse files
committed
Implement a function to add KeyOriginInfo to a wallet
1 parent eab63bc commit 3d235df

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4550,3 +4550,13 @@ bool CWallet::GetKeyOrigin(const CKeyID& keyID, KeyOriginInfo& info) const
45504550
}
45514551
return true;
45524552
}
4553+
4554+
bool CWallet::AddKeyOrigin(const CPubKey& pubkey, const KeyOriginInfo& info)
4555+
{
4556+
LOCK(cs_wallet);
4557+
std::copy(info.fingerprint, info.fingerprint + 4, mapKeyMetadata[pubkey.GetID()].key_origin.fingerprint);
4558+
mapKeyMetadata[pubkey.GetID()].key_origin.path = info.path;
4559+
mapKeyMetadata[pubkey.GetID()].has_key_origin = true;
4560+
mapKeyMetadata[pubkey.GetID()].hdKeypath = WriteHDKeypath(info.path);
4561+
return WriteKeyMetadata(mapKeyMetadata[pubkey.GetID()], pubkey, true);
4562+
}

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,9 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
12191219

12201220
/** Implement lookup of key origin information through wallet key metadata. */
12211221
bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
1222+
1223+
/** Add a KeyOriginInfo to the wallet */
1224+
bool AddKeyOrigin(const CPubKey& pubkey, const KeyOriginInfo& info);
12221225
};
12231226

12241227
/** A key allocated from the key pool. */

0 commit comments

Comments
 (0)