Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
struct COutputEntry { | struct COutputEntry { | ||||
CTxDestination destination; | CTxDestination destination; | ||||
Amount amount; | Amount amount; | ||||
int vout; | int vout; | ||||
}; | }; | ||||
/** A transaction with a merkle branch linking it to the block chain. */ | /** Legacy class used for deserializing vtxPrev for backwards compatibility. | ||||
deadalnix: reformat | |||||
* vtxPrev was removed in commit 93a18a3650292afbb441a47d1fa1b94aeb0164e3, | |||||
* but old wallet.dat files may still contain vtxPrev vectors of CMerkleTxs. | |||||
* These need to get deserialized for field alignment when deserializing | |||||
* a CWalletTx, but the deserialized values are discarded.**/ | |||||
class CMerkleTx { | class CMerkleTx { | ||||
private: | |||||
/** Constant used in hashBlock to indicate tx has been abandoned */ | |||||
static const BlockHash ABANDON_HASH; | |||||
public: | public: | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
BlockHash hashBlock; | BlockHash hashBlock; | ||||
/** | /** | ||||
* An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest | * An nIndex == -1 means that hashBlock (in nonzero) refers to the earliest | ||||
* block in the chain we know this or any in-wallet dependency conflicts | * block in the chain we know this or any in-wallet dependency conflicts | ||||
* with. Older clients interpret nIndex == -1 as unconfirmed for backward | * with. Older clients interpret nIndex == -1 as unconfirmed for backward | ||||
Show All 24 Lines | public: | ||||
inline void SerializationOp(Stream &s, Operation ser_action) { | inline void SerializationOp(Stream &s, Operation ser_action) { | ||||
// For compatibility with older versions. | // For compatibility with older versions. | ||||
std::vector<uint256> vMerkleBranch; | std::vector<uint256> vMerkleBranch; | ||||
READWRITE(tx); | READWRITE(tx); | ||||
READWRITE(hashBlock); | READWRITE(hashBlock); | ||||
READWRITE(vMerkleBranch); | READWRITE(vMerkleBranch); | ||||
READWRITE(nIndex); | READWRITE(nIndex); | ||||
} | } | ||||
void SetMerkleBranch(const BlockHash &block_hash, int posInBlock); | |||||
/** | |||||
* Return depth of transaction in blockchain: | |||||
* <0 : conflicts with a transaction this deep in the blockchain | |||||
* 0 : in memory pool, waiting to be included in a block | |||||
* >=1 : this many blocks deep in the main chain | |||||
*/ | |||||
int GetDepthInMainChain(interfaces::Chain::Lock &locked_chain) const; | |||||
bool IsInMainChain(interfaces::Chain::Lock &locked_chain) const { | |||||
return GetDepthInMainChain(locked_chain) > 0; | |||||
} | |||||
/** | |||||
* @return number of blocks to maturity for this transaction: | |||||
* 0 : is not a coinbase transaction, or is a mature coinbase transaction | |||||
* >0 : is a coinbase transaction which matures in this many blocks | |||||
*/ | |||||
int GetBlocksToMaturity(interfaces::Chain::Lock &locked_chain) const; | |||||
bool hashUnset() const { | |||||
return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); | |||||
} | |||||
bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } | |||||
void setAbandoned() { hashBlock = ABANDON_HASH; } | |||||
TxId GetId() const { return tx->GetId(); } | |||||
bool IsCoinBase() const { return tx->IsCoinBase(); } | |||||
bool IsImmatureCoinBase(interfaces::Chain::Lock &locked_chain) const; | |||||
}; | }; | ||||
// Get the marginal bytes of spending the specified output | // Get the marginal bytes of spending the specified output | ||||
int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, | int CalculateMaximumSignedInputSize(const CTxOut &txout, const CWallet *pwallet, | ||||
bool use_max_sig = false); | bool use_max_sig = false); | ||||
/** | /** | ||||
* A transaction with a bunch of additional info that only the owner cares | * A transaction with a bunch of additional info that only the owner cares | ||||
* about. It includes any unrecorded transactions needed to link it back to the | * about. It includes any unrecorded transactions needed to link it back to the | ||||
* block chain. | * block chain. | ||||
*/ | */ | ||||
class CWalletTx : public CMerkleTx { | class CWalletTx : public CMerkleTx { | ||||
private: | private: | ||||
const CWallet *pwallet; | const CWallet *pwallet; | ||||
/** Constant used in hashBlock to indicate tx has been abandoned */ | |||||
static const BlockHash ABANDON_HASH; | |||||
public: | public: | ||||
/** | /** | ||||
* Key/value map with information about the transaction. | * Key/value map with information about the transaction. | ||||
* | * | ||||
* The following keys can be read and written through the map and are | * The following keys can be read and written through the map and are | ||||
* serialized in the wallet database: | * serialized in the wallet database: | ||||
* | * | ||||
* "comment", "to" - comment strings provided to sendtoaddress, | * "comment", "to" - comment strings provided to sendtoaddress, | ||||
▲ Show 20 Lines • Show All 174 Lines • ▼ Show 20 Lines | public: | ||||
// TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct | // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct | ||||
// annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation | // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The annotation | ||||
// "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to | // "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid having to | ||||
// resolve the issue of member access into incomplete type CWallet. Note | // resolve the issue of member access into incomplete type CWallet. Note | ||||
// that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)" | // that we still have the runtime check "AssertLockHeld(pwallet->cs_wallet)" | ||||
// in place. | // in place. | ||||
std::set<TxId> GetConflicts() const NO_THREAD_SAFETY_ANALYSIS; | std::set<TxId> GetConflicts() const NO_THREAD_SAFETY_ANALYSIS; | ||||
void SetMerkleBranch(const BlockHash &block_hash, int posInBlock); | |||||
/** | |||||
* Return depth of transaction in blockchain: | |||||
* <0 : conflicts with a transaction this deep in the blockchain | |||||
* 0 : in memory pool, waiting to be included in a block | |||||
* >=1 : this many blocks deep in the main chain | |||||
*/ | |||||
int GetDepthInMainChain(interfaces::Chain::Lock &locked_chain) const; | |||||
bool IsInMainChain(interfaces::Chain::Lock &locked_chain) const { | |||||
return GetDepthInMainChain(locked_chain) > 0; | |||||
} | |||||
/** | |||||
* @return number of blocks to maturity for this transaction: | |||||
* 0 : is not a coinbase transaction, or is a mature coinbase transaction | |||||
* >0 : is a coinbase transaction which matures in this many blocks | |||||
*/ | |||||
int GetBlocksToMaturity(interfaces::Chain::Lock &locked_chain) const; | |||||
bool hashUnset() const { | |||||
return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); | |||||
} | |||||
bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } | |||||
void setAbandoned() { hashBlock = ABANDON_HASH; } | |||||
TxId GetId() const { return tx->GetId(); } | |||||
bool IsCoinBase() const { return tx->IsCoinBase(); } | |||||
bool IsImmatureCoinBase(interfaces::Chain::Lock &locked_chain) const; | |||||
}; | }; | ||||
class COutput { | class COutput { | ||||
public: | public: | ||||
const CWalletTx *tx; | const CWalletTx *tx; | ||||
int i; | int i; | ||||
int nDepth; | int nDepth; | ||||
▲ Show 20 Lines • Show All 1,031 Lines • Show Last 20 Lines |
reformat