@@ -1712,6 +1712,20 @@ std::optional<uint32_t> ParseKeyPathNum(std::span<const char> elem, bool& apostr
1712
1712
return true ;
1713
1713
}
1714
1714
1715
+ static DeriveType ParseDeriveType (std::vector<std::span<const char >>& split, bool & apostrophe)
1716
+ {
1717
+ DeriveType type = DeriveType::NO;
1718
+ if (std::ranges::equal (split.back (), std::span{" *" }.first (1 ))) {
1719
+ split.pop_back ();
1720
+ type = DeriveType::UNHARDENED;
1721
+ } else if (std::ranges::equal (split.back (), std::span{" *'" }.first (2 )) || std::ranges::equal (split.back (), std::span{" *h" }.first (2 ))) {
1722
+ apostrophe = std::ranges::equal (split.back (), std::span{" *'" }.first (2 ));
1723
+ split.pop_back ();
1724
+ type = DeriveType::HARDENED;
1725
+ }
1726
+ return type;
1727
+ }
1728
+
1715
1729
/* * Parse a public key that excludes origin information. */
1716
1730
std::vector<std::unique_ptr<PubkeyProvider>> ParsePubkeyInner (uint32_t key_exp_index, const std::span<const char >& sp, ParseScriptContext ctx, FlatSigningProvider& out, bool & apostrophe, std::string& error)
1717
1731
{
@@ -1775,15 +1789,7 @@ std::vector<std::unique_ptr<PubkeyProvider>> ParsePubkeyInner(uint32_t key_exp_i
1775
1789
return {};
1776
1790
}
1777
1791
std::vector<KeyPath> paths;
1778
- DeriveType type = DeriveType::NO;
1779
- if (std::ranges::equal (split.back (), std::span{" *" }.first (1 ))) {
1780
- split.pop_back ();
1781
- type = DeriveType::UNHARDENED;
1782
- } else if (std::ranges::equal (split.back (), std::span{" *'" }.first (2 )) || std::ranges::equal (split.back (), std::span{" *h" }.first (2 ))) {
1783
- apostrophe = std::ranges::equal (split.back (), std::span{" *'" }.first (2 ));
1784
- split.pop_back ();
1785
- type = DeriveType::HARDENED;
1786
- }
1792
+ DeriveType type = ParseDeriveType (split, apostrophe);
1787
1793
if (!ParseKeyPath (split, paths, apostrophe, error, /* allow_multipath=*/ true )) return {};
1788
1794
if (extkey.key .IsValid ()) {
1789
1795
extpubkey = extkey.Neuter ();
0 commit comments