mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-21 00:46:14 -03:00
da894ab5da
Previously only one PUSHDATA was allowed, needlessly limiting applications such as matching OP_RETURN contents with bloom filters that operate on a per-PUSHDATA level. Now any combination that passes IsPushOnly() is allowed, so long as the total size of the scriptPubKey is less than 42 bytes. (unchanged modulo non-minimal PUSHDATA encodings) Also, this fixes the odd bug where previously the PUSHDATA could be replaced by any single opcode, even sigops consuming opcodes such as CHECKMULTISIG. (20 sigops!)
79 lines
2.7 KiB
C++
79 lines
2.7 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_SCRIPT_STANDARD_H
|
|
#define BITCOIN_SCRIPT_STANDARD_H
|
|
|
|
#include "script/interpreter.h"
|
|
#include "uint256.h"
|
|
|
|
#include <boost/variant.hpp>
|
|
|
|
#include <stdint.h>
|
|
|
|
class CKeyID;
|
|
class CScript;
|
|
|
|
/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
|
|
class CScriptID : public uint160
|
|
{
|
|
public:
|
|
CScriptID() : uint160() {}
|
|
CScriptID(const CScript& in);
|
|
CScriptID(const uint160& in) : uint160(in) {}
|
|
};
|
|
|
|
static const unsigned int MAX_OP_RETURN_RELAY = 83; //! bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
|
|
extern unsigned nMaxDatacarrierBytes;
|
|
|
|
/**
|
|
* Mandatory script verification flags that all new blocks must comply with for
|
|
* them to be valid. (but old blocks may not comply with) Currently just P2SH,
|
|
* but in the future other flags may be added, such as a soft-fork to enforce
|
|
* strict DER encoding.
|
|
*
|
|
* Failing one of these tests may trigger a DoS ban - see CheckInputs() for
|
|
* details.
|
|
*/
|
|
static const unsigned int MANDATORY_SCRIPT_VERIFY_FLAGS = SCRIPT_VERIFY_P2SH;
|
|
|
|
enum txnouttype
|
|
{
|
|
TX_NONSTANDARD,
|
|
// 'standard' transaction types:
|
|
TX_PUBKEY,
|
|
TX_PUBKEYHASH,
|
|
TX_SCRIPTHASH,
|
|
TX_MULTISIG,
|
|
TX_NULL_DATA,
|
|
};
|
|
|
|
class CNoDestination {
|
|
public:
|
|
friend bool operator==(const CNoDestination &a, const CNoDestination &b) { return true; }
|
|
friend bool operator<(const CNoDestination &a, const CNoDestination &b) { return true; }
|
|
};
|
|
|
|
/**
|
|
* A txout script template with a specific destination. It is either:
|
|
* * CNoDestination: no destination set
|
|
* * CKeyID: TX_PUBKEYHASH destination
|
|
* * CScriptID: TX_SCRIPTHASH destination
|
|
* A CTxDestination is the internal data type encoded in a CBitcoinAddress
|
|
*/
|
|
typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination;
|
|
|
|
const char* GetTxnOutputType(txnouttype t);
|
|
|
|
bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<std::vector<unsigned char> >& vSolutionsRet);
|
|
int ScriptSigArgsExpected(txnouttype t, const std::vector<std::vector<unsigned char> >& vSolutions);
|
|
bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
|
|
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector<CTxDestination>& addressRet, int& nRequiredRet);
|
|
|
|
CScript GetScriptForDestination(const CTxDestination& dest);
|
|
CScript GetScriptForRawPubKey(const CPubKey& pubkey);
|
|
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);
|
|
|
|
#endif // BITCOIN_SCRIPT_STANDARD_H
|