| 4486 | } |
| 4487 | |
| 4488 | void 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 | |
| 4517 | bool FillPSBT(const CWallet* pwallet, PartiallySignedTransaction& psbtx, bool no_forkid, int sighash_type, bool sign, bool bip32derivs) |
| 4518 | { |
no test coverage detected