MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AddKeypathToMap

Function AddKeypathToMap

src/wallet/rpcwallet.cpp:4488–4515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4486}
4487
4488void AddKeypathToMap(const CWallet* pwallet, const CKeyID& keyID, std::map<CPubKey, std::vector<uint32_t>>& hd_keypaths)
4489{
4490 CPubKey vchPubKey;
4491 if (!pwallet->GetPubKey(keyID, vchPubKey)) {
4492 return;
4493 }
4494 CKeyMetadata meta;
4495 auto it = pwallet->mapKeyMetadata.find(keyID);
4496 if (it != pwallet->mapKeyMetadata.end()) {
4497 meta = it->second;
4498 }
4499 std::vector<uint32_t> keypath;
4500 if (!meta.hdKeypath.empty()) {
4501 if (!ParseHDKeypath(meta.hdKeypath, keypath)) {
4502 throw JSONRPCError(RPC_INTERNAL_ERROR, "Internal keypath is broken");
4503 }
4504 // Get the proper master key id
4505 CKey key;
4506 pwallet->GetKey(meta.hd_seed_id, key);
4507 CExtKey masterKey;
4508 masterKey.SetSeed(key.begin(), key.size());
4509 // Add to map
4510 keypath.insert(keypath.begin(), ReadLE32(masterKey.key.GetPubKey().GetID().begin()));
4511 } else { // Single pubkeys get the master fingerprint of themselves
4512 keypath.insert(keypath.begin(), ReadLE32(vchPubKey.GetID().begin()));
4513 }
4514 hd_keypaths.emplace(vchPubKey, keypath);
4515}
4516
4517bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, bool no_forkid, int sighash_type, bool sign, bool bip32derivs)
4518{

Callers 1

FillPSBTFunction · 0.85

Calls 13

ParseHDKeypathFunction · 0.85
JSONRPCErrorFunction · 0.85
ReadLE32Function · 0.85
SetSeedMethod · 0.80
GetIDMethod · 0.80
GetPubKeyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
GetKeyMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected