7 #ifndef ANONCOIN_CORE_H
8 #define ANONCOIN_CORE_H
20 static const int64_t MAX_MONEY = 84000000 * COIN;
21 inline bool MoneyRange(int64_t nValue) {
return (nValue >= 0 && nValue <= MAX_MONEY); }
33 void SetNull() { hash = 0; n = (
unsigned int) -1; }
34 bool IsNull()
const {
return (hash == 0 && n == (
unsigned int) -1); }
64 void SetNull() { ptx = NULL; n = (
unsigned int) -1; }
65 bool IsNull()
const {
return (ptx == NULL && n == (
unsigned int) -1); }
81 nSequence = std::numeric_limits<unsigned int>::max();
85 CTxIn(
uint256 hashPrevTx,
unsigned int nOut,
CScript scriptSigIn=
CScript(),
unsigned int nSequenceIn=std::numeric_limits<unsigned int>::max());
96 return (nSequence == std::numeric_limits<unsigned int>::max());
143 scriptPubKey.clear();
148 return (nValue == -1);
153 bool IsDust(int64_t nMinRelayTxFee)
const
214 return (vin.empty() && vout.empty());
226 double ComputePriority(
double dPriorityInputs,
unsigned int nTxSize=0)
const;
230 return (vin.size() == 1 && vin[0].prevout.IsNull());
291 CTxInUndo() : txout(), fCoinBase(false), nHeight(0), nVersion(0) {}
292 CTxInUndo(
const CTxOut &txoutIn,
bool fCoinBaseIn =
false,
unsigned int nHeightIn = 0,
int nVersionIn = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn), nVersion(nVersionIn) { }
300 template<
typename Stream>
301 void Serialize(Stream &s,
int nType,
int nVersion)
const {
308 template<
typename Stream>
310 unsigned int nCode = 0;
313 fCoinBase = nCode & 1;
344 static const int CURRENT_VERSION=2;
360 nVersion = this->nVersion;
389 return (int64_t)nTime;
398 std::vector<CTransaction>
vtx;
422 CBlockHeader::SetNull();
439 uint256 BuildMerkleTree()
const;
442 assert(vMerkleTree.size() > 0);
443 assert(nIndex < vtx.size());
444 return vMerkleTree[nIndex];
447 std::vector<uint256> GetMerkleBranch(
int nIndex)
const;
448 static uint256 CheckMerkleBranch(
uint256 hash,
const std::vector<uint256>& vMerkleBranch,
int nIndex);
482 return vHave.empty();
bool IsDust(int64_t nMinRelayTxFee) const
int64_t GetValueOut() const
friend bool operator!=(const COutPoint &a, const COutPoint &b)
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
double ComputePriority(double dPriorityInputs, unsigned int nTxSize=0) const
CBlock(const CBlockHeader &header)
wrapper for CTxOut that provides a more compact serialization
unsigned int GetSerializeSize(int nType, int nVersion) const
void Serialize(Stream &s, char a, int, int=0)
friend bool operator==(const CTxOut &a, const CTxOut &b)
IMPLEMENT_SERIALIZE(READWRITE(prevout);READWRITE(scriptSig);READWRITE(nSequence);) bool IsFinal() const
bool MoneyRange(int64_t nValue)
#define IMPLEMENT_SERIALIZE(statements)
Compact serializer for scripts.
friend bool operator!=(const CTxOut &a, const CTxOut &b)
CTxOutCompressor(CTxOut &txoutIn)
static int64_t nMinTxFee
Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) ...
Undo information for a CTxIn.
std::string ToString() const
bool IsNewerThan(const CTransaction &old) const
friend bool operator==(const COutPoint &a, const COutPoint &b)
IMPLEMENT_SERIALIZE(READWRITE(this->nVersion);nVersion=this->nVersion;READWRITE(vin);READWRITE(vout);READWRITE(nLockTime);) void SetNull()
void Serialize(Stream &s, int nType, int nVersion) const
unsigned int GetSerializeSize(char a, int, int=0)
An input of a transaction.
std::vector< CTxOut > vout
void Unserialize(Stream &s, char &a, int, int=0)
CBlockHeader GetBlockHeader() const
CInPoint(const CTransaction *ptxIn, unsigned int nIn)
std::vector< uint256 > vMerkleTree
An output of a transaction.
std::vector< uint256 > vHave
static uint64_t CompressAmount(uint64_t nAmount)
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxInUndo > vprevout
CBlockLocator(const std::vector< uint256 > &vHaveIn)
std::string ToString() const
std::string ToString() const
IMPLEMENT_SERIALIZE(READWRITE(FLATDATA(*this));) void SetNull()
const uint256 & GetTxHash(unsigned int nIndex) const
COutPoint(uint256 hashIn, unsigned int nIn)
static uint64_t DecompressAmount(uint64_t nAmount)
std::string ToString() const
IMPLEMENT_SERIALIZE(READWRITE(nValue);READWRITE(scriptPubKey);) void SetNull()
void Unserialize(Stream &s, int nType, int nVersion)
Serialized script, used inside transaction inputs and outputs.
Undo information for a CTransaction.
An inpoint - a combination of a transaction and an index n into its vin.
static int64_t nMinRelayTxFee
Fees smaller than this (in satoshi) are considered zero fee (for relaying and mining) ...
std::vector< CTransaction > vtx
friend bool operator<(const COutPoint &a, const COutPoint &b)
The basic transaction that is broadcasted on the network and contained in blocks. ...
static const int CURRENT_VERSION
friend bool operator==(const CTxIn &a, const CTxIn &b)
CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn=false, unsigned int nHeightIn=0, int nVersionIn=0)
friend bool operator!=(const CTxIn &a, const CTxIn &b)
friend bool operator==(const CTransaction &a, const CTransaction &b)
friend bool operator!=(const CTransaction &a, const CTransaction &b)