@@ -212,7 +212,7 @@ struct PubkeyProvider
212
212
virtual bool ToNormalizedString (const SigningProvider& arg, std::string& out, const DescriptorCache* cache = nullptr ) const = 0;
213
213
214
214
/* * Derive a private key, if private data is available in arg. */
215
- virtual bool GetPrivKey (int pos, const SigningProvider& arg, CKey& key ) const = 0;
215
+ virtual void GetPrivKey (int pos, const SigningProvider& arg, FlatSigningProvider& out ) const = 0;
216
216
217
217
/* * Return the non-extended public key for this PubkeyProvider, if it has one. */
218
218
virtual std::optional<CPubKey> GetRootPubKey () const = 0;
@@ -274,9 +274,9 @@ class OriginPubkeyProvider final : public PubkeyProvider
274
274
}
275
275
return true ;
276
276
}
277
- bool GetPrivKey (int pos, const SigningProvider& arg, CKey& key ) const override
277
+ void GetPrivKey (int pos, const SigningProvider& arg, FlatSigningProvider& out ) const override
278
278
{
279
- return m_provider->GetPrivKey (pos, arg, key );
279
+ m_provider->GetPrivKey (pos, arg, out );
280
280
}
281
281
std::optional<CPubKey> GetRootPubKey () const override
282
282
{
@@ -332,9 +332,12 @@ class ConstPubkeyProvider final : public PubkeyProvider
332
332
ret = ToString (StringType::PUBLIC);
333
333
return true ;
334
334
}
335
- bool GetPrivKey (int pos, const SigningProvider& arg, CKey& key ) const override
335
+ void GetPrivKey (int pos, const SigningProvider& arg, FlatSigningProvider& out ) const override
336
336
{
337
- return arg.GetKey (m_pubkey.GetID (), key);
337
+ CKeyID id = m_pubkey.GetID ();
338
+ CKey key;
339
+ if (!arg.GetKey (id, key)) return ;
340
+ out.keys .emplace (id, key);
338
341
}
339
342
std::optional<CPubKey> GetRootPubKey () const override
340
343
{
@@ -552,15 +555,14 @@ class BIP32PubkeyProvider final : public PubkeyProvider
552
555
}
553
556
return true ;
554
557
}
555
- bool GetPrivKey (int pos, const SigningProvider& arg, CKey& key ) const override
558
+ void GetPrivKey (int pos, const SigningProvider& arg, FlatSigningProvider& out ) const override
556
559
{
557
560
CExtKey extkey;
558
561
CExtKey dummy;
559
- if (!GetDerivedExtKey (arg, extkey, dummy)) return false ;
560
- if (m_derive == DeriveType::UNHARDENED && !extkey.Derive (extkey, pos)) return false ;
561
- if (m_derive == DeriveType::HARDENED && !extkey.Derive (extkey, pos | 0x80000000UL )) return false ;
562
- key = extkey.key ;
563
- return true ;
562
+ if (!GetDerivedExtKey (arg, extkey, dummy)) return ;
563
+ if (m_derive == DeriveType::UNHARDENED && !extkey.Derive (extkey, pos)) return ;
564
+ if (m_derive == DeriveType::HARDENED && !extkey.Derive (extkey, pos | 0x80000000UL )) return ;
565
+ out.keys .emplace (extkey.key .GetPubKey ().GetID (), extkey.key );
564
566
}
565
567
std::optional<CPubKey> GetRootPubKey () const override
566
568
{
@@ -747,8 +749,7 @@ class DescriptorImpl : public Descriptor
747
749
{
748
750
for (const auto & p : m_pubkey_args) {
749
751
CKey key;
750
- if (!p->GetPrivKey (pos, provider, key)) continue ;
751
- out.keys .emplace (key.GetPubKey ().GetID (), key);
752
+ p->GetPrivKey (pos, provider, out);
752
753
}
753
754
for (const auto & arg : m_subdescriptor_args) {
754
755
arg->ExpandPrivate (pos, provider, out);
0 commit comments