@@ -27,16 +27,27 @@ class CScriptID : public uint160
27
27
CScriptID (const uint160& in) : uint160(in) {}
28
28
};
29
29
30
- static const unsigned int MAX_OP_RETURN_RELAY = 83 ; // !< bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
30
+ /* *
31
+ * Default setting for nMaxDatacarrierBytes. 80 bytes of data, +1 for OP_RETURN,
32
+ * +2 for the pushdata opcodes.
33
+ */
34
+ static const unsigned int MAX_OP_RETURN_RELAY = 83 ;
35
+
36
+ /* *
37
+ * A data carrying output is an unspendable output containing data. The script
38
+ * type is designated as TX_NULL_DATA.
39
+ */
31
40
extern bool fAcceptDatacarrier ;
41
+
42
+ /* * Maximum size of TX_NULL_DATA scripts that this node considers standard. */
32
43
extern unsigned nMaxDatacarrierBytes;
33
44
34
45
/* *
35
46
* Mandatory script verification flags that all new blocks must comply with for
36
47
* them to be valid. (but old blocks may not comply with) Currently just P2SH,
37
48
* but in the future other flags may be added, such as a soft-fork to enforce
38
49
* strict DER encoding.
39
- *
50
+ *
40
51
* Failing one of these tests may trigger a DoS ban - see CheckInputs() for
41
52
* details.
42
53
*/
@@ -50,7 +61,7 @@ enum txnouttype
50
61
TX_PUBKEYHASH,
51
62
TX_SCRIPTHASH,
52
63
TX_MULTISIG,
53
- TX_NULL_DATA,
64
+ TX_NULL_DATA, // !< unspendable OP_RETURN script that carries data
54
65
TX_WITNESS_V0_SCRIPTHASH,
55
66
TX_WITNESS_V0_KEYHASH,
56
67
};
@@ -61,7 +72,7 @@ class CNoDestination {
61
72
friend bool operator <(const CNoDestination &a, const CNoDestination &b) { return true ; }
62
73
};
63
74
64
- /* *
75
+ /* *
65
76
* A txout script template with a specific destination. It is either:
66
77
* * CNoDestination: no destination set
67
78
* * CKeyID: TX_PUBKEYHASH destination
@@ -70,15 +81,58 @@ class CNoDestination {
70
81
*/
71
82
typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
72
83
84
+ /* * Get the name of a txnouttype as a C string, or nullptr if unknown. */
73
85
const char * GetTxnOutputType (txnouttype t);
74
86
87
+ /* *
88
+ * Parse a scriptPubKey and identify script type for standard scripts. If
89
+ * successful, returns script type and parsed pubkeys or hashes, depending on
90
+ * the type. For example, for a P2SH script, vSolutionsRet will contain the
91
+ * script hash, for P2PKH it will contain the key hash, etc.
92
+ *
93
+ * @param[in] scriptPubKey Script to parse
94
+ * @param[out] typeRet The script type
95
+ * @param[out] vSolutionsRet Vector of parsed pubkeys and hashes
96
+ * @return True if script matches standard template
97
+ */
75
98
bool Solver (const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char > >& vSolutionsRet);
99
+
100
+ /* *
101
+ * Parse a standard scriptPubKey for the destination address. Assigns result to
102
+ * the addressRet parameter and returns true if successful. For multisig
103
+ * scripts, instead use ExtractDestinations. Currently only works for P2PK,
104
+ * P2PKH, and P2SH scripts.
105
+ */
76
106
bool ExtractDestination (const CScript& scriptPubKey, CTxDestination& addressRet);
107
+
108
+ /* *
109
+ * Parse a standard scriptPubKey with one or more destination addresses. For
110
+ * multisig scripts, this populates the addressRet vector with the pubkey IDs
111
+ * and nRequiredRet with the n required to spend. For other destinations,
112
+ * addressRet is populated with a single value and nRequiredRet is set to 1.
113
+ * Returns true if successful. Currently does not extract address from
114
+ * pay-to-witness scripts.
115
+ */
77
116
bool ExtractDestinations (const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int & nRequiredRet);
78
117
118
+ /* *
119
+ * Generate a Bitcoin scriptPubKey for the given CTxDestination. Returns a P2PKH
120
+ * script for a CKeyID destination, a P2SH script for a CScriptID, and an empty
121
+ * script for CNoDestination.
122
+ */
79
123
CScript GetScriptForDestination (const CTxDestination& dest);
124
+
125
+ /* * Generate a P2PK script for the given pubkey. */
80
126
CScript GetScriptForRawPubKey (const CPubKey& pubkey);
127
+
128
+ /* * Generate a multisig script. */
81
129
CScript GetScriptForMultisig (int nRequired, const std::vector<CPubKey>& keys);
130
+
131
+ /* *
132
+ * Generate a pay-to-witness script for the given redeem script. If the redeem
133
+ * script is P2PK or P2PKH, this returns a P2WPKH script, otherwise it returns a
134
+ * P2WSH script.
135
+ */
82
136
CScript GetScriptForWitness (const CScript& redeemscript);
83
137
84
138
#endif // BITCOIN_SCRIPT_STANDARD_H
0 commit comments