File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -823,8 +823,11 @@ class PKDescriptor final : public DescriptorImpl
823
823
private:
824
824
const bool m_xonly;
825
825
protected:
826
- std::vector<CScript> MakeScripts (const std::vector<CPubKey>& keys, Span<const CScript>, FlatSigningProvider&) const override
826
+ std::vector<CScript> MakeScripts (const std::vector<CPubKey>& keys, Span<const CScript>, FlatSigningProvider& out ) const override
827
827
{
828
+ CKeyID id = keys[0 ].GetID ();
829
+ out.pubkeys .emplace (id, keys[0 ]);
830
+
828
831
if (m_xonly) {
829
832
CScript script = CScript () << ToByteVector (XOnlyPubKey (keys[0 ])) << OP_CHECKSIG;
830
833
return Vector (std::move (script));
Original file line number Diff line number Diff line change @@ -402,6 +402,23 @@ std::vector<WalletDestination> LegacyScriptPubKeyMan::MarkUnusedAddresses(const
402
402
return result;
403
403
}
404
404
405
+ bool LegacyScriptPubKeyMan::IsKeyActive (const CScript& script) const
406
+ {
407
+ LOCK (cs_KeyStore);
408
+
409
+ if (!IsMine (script)) return false ; // Not in the keystore at all
410
+
411
+ for (const auto & key_id : GetAffectedKeys (script, *this )) {
412
+ const auto it = mapKeyMetadata.find (key_id);
413
+ if (it == mapKeyMetadata.end ()) return false ; // This key must be really old
414
+
415
+ if (!it->second .hd_seed_id .IsNull () && it->second .hd_seed_id == m_hd_chain.seed_id ) return true ;
416
+ }
417
+
418
+ // Imported or dumped for a new keypool
419
+ return false ;
420
+ }
421
+
405
422
void LegacyScriptPubKeyMan::UpgradeKeyMetadata ()
406
423
{
407
424
LOCK (cs_KeyStore);
Original file line number Diff line number Diff line change @@ -205,6 +205,9 @@ class ScriptPubKeyMan
205
205
*/
206
206
virtual std::vector<WalletDestination> MarkUnusedAddresses (const CScript& script) { return {}; }
207
207
208
+ /* Determines if address is derived from active key manager */
209
+ virtual bool IsKeyActive (const CScript& script) const = 0;
210
+
208
211
/* * Sets up the key generation stuff, i.e. generates new HD seeds and sets them as active.
209
212
* Returns false if already setup or setup fails, true if setup is successful
210
213
* Set force=true to make it re-setup if already setup, used for upgrades
@@ -462,6 +465,8 @@ class LegacyScriptPubKeyMan : public LegacyDataSPKM
462
465
463
466
std::vector<WalletDestination> MarkUnusedAddresses (const CScript& script) override ;
464
467
468
+ [[nodiscard]] bool IsKeyActive (const CScript& script) const override ;
469
+
465
470
// ! Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo
466
471
void UpgradeKeyMetadata ();
467
472
@@ -650,6 +655,8 @@ class DescriptorScriptPubKeyMan : public ScriptPubKeyMan
650
655
651
656
std::vector<WalletDestination> MarkUnusedAddresses (const CScript& script) override ;
652
657
658
+ [[nodiscard]] bool IsKeyActive (const CScript& script) const override { return IsMine (script); }
659
+
653
660
bool IsHDEnabled () const override ;
654
661
655
662
// ! Setup descriptors based on the given CExtkey
You can’t perform that action at this time.
0 commit comments