@@ -27,16 +27,27 @@ class CScriptID : public uint160
2727 CScriptID (const uint160& in) : uint160(in) {}
2828};
2929
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+ */
3140extern bool fAcceptDatacarrier ;
41+
42+ /* * Maximum size of TX_NULL_DATA scripts that this node considers standard. */
3243extern unsigned nMaxDatacarrierBytes;
3344
3445/* *
3546 * Mandatory script verification flags that all new blocks must comply with for
3647 * them to be valid. (but old blocks may not comply with) Currently just P2SH,
3748 * but in the future other flags may be added, such as a soft-fork to enforce
3849 * strict DER encoding.
39- *
50+ *
4051 * Failing one of these tests may trigger a DoS ban - see CheckInputs() for
4152 * details.
4253 */
@@ -50,7 +61,7 @@ enum txnouttype
5061 TX_PUBKEYHASH,
5162 TX_SCRIPTHASH,
5263 TX_MULTISIG,
53- TX_NULL_DATA,
64+ TX_NULL_DATA, // !< unspendable OP_RETURN script that carries data
5465 TX_WITNESS_V0_SCRIPTHASH,
5566 TX_WITNESS_V0_KEYHASH,
5667};
@@ -61,7 +72,7 @@ class CNoDestination {
6172 friend bool operator <(const CNoDestination &a, const CNoDestination &b) { return true ; }
6273};
6374
64- /* *
75+ /* *
6576 * A txout script template with a specific destination. It is either:
6677 * * CNoDestination: no destination set
6778 * * CKeyID: TX_PUBKEYHASH destination
@@ -70,15 +81,58 @@ class CNoDestination {
7081 */
7182typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
7283
84+ /* * Get the name of a txnouttype as a C string, or nullptr if unknown. */
7385const char * GetTxnOutputType (txnouttype t);
7486
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+ */
7598bool 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+ */
76106bool 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+ */
77116bool ExtractDestinations (const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int & nRequiredRet);
78117
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+ */
79123CScript GetScriptForDestination (const CTxDestination& dest);
124+
125+ /* * Generate a P2PK script for the given pubkey. */
80126CScript GetScriptForRawPubKey (const CPubKey& pubkey);
127+
128+ /* * Generate a multisig script. */
81129CScript 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+ */
82136CScript GetScriptForWitness (const CScript& redeemscript);
83137
84138#endif // BITCOIN_SCRIPT_STANDARD_H
0 commit comments