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