PIVX Core  5.6.99
P2P Digital Currency
descriptor.h
Go to the documentation of this file.
1 // Copyright (c) 2018 The Bitcoin Core developers
2 // Copyright (c) 2022 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_SCRIPT_DESCRIPTOR_H
7 #define PIVX_SCRIPT_DESCRIPTOR_H
8 
9 #include <script/script.h>
10 #include <script/sign.h>
11 
12 #include <vector>
13 
14 // Descriptors are strings that describe a set of scriptPubKeys, together with
15 // all information necessary to solve them. By combining all information into
16 // one, they avoid the need to separately import keys and scripts.
17 //
18 // Descriptors may be ranged, which occurs when the public keys inside are
19 // specified in the form of HD chains (xpubs).
20 //
21 // Descriptors always represent public information - public keys and scripts -
22 // but in cases where private keys need to be conveyed along with a descriptor,
23 // they can be included inside by changing public keys to private keys (WIF
24 // format), and changing xpubs by xprvs.
25 //
26 // Reference documentation about the descriptor language can be found in
27 // doc/descriptors.md.
28 
30 struct Descriptor {
31  virtual ~Descriptor() = default;
32 
34  virtual bool IsRange() const = 0;
35 
37  virtual std::string ToString() const = 0;
38 
40  virtual bool ToPrivateString(const SigningProvider& provider, std::string& out) const = 0;
41 
49  virtual bool Expand(int pos, const SigningProvider& provider, std::vector<CScript>& output_scripts, FlatSigningProvider& out) const = 0;
50 };
51 
53 std::unique_ptr<Descriptor> Parse(const std::string& descriptor, FlatSigningProvider& out);
54 
55 #endif // PIVX_SCRIPT_DESCRIPTOR_H
An interface to be implemented by keystores that support signing.
Definition: sign.h:23
std::unique_ptr< Descriptor > Parse(const std::string &descriptor, FlatSigningProvider &out)
Parse a descriptor string.
Definition: descriptor.cpp:540
Interface for parsed descriptor objects.
Definition: descriptor.h:30
virtual std::string ToString() const =0
Convert the descriptor back to a string, undoing parsing.
virtual ~Descriptor()=default
virtual bool Expand(int pos, const SigningProvider &provider, std::vector< CScript > &output_scripts, FlatSigningProvider &out) const =0
Expand a descriptor at a specified position.
virtual bool IsRange() const =0
Whether the expansion of this descriptor depends on the position.
virtual bool ToPrivateString(const SigningProvider &provider, std::string &out) const =0
Convert the descriptor to a private string.