Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.h
Show All 25 Lines | |||||
namespace avalanche { | namespace avalanche { | ||||
/** Minimum amount per utxo */ | /** Minimum amount per utxo */ | ||||
static constexpr Amount PROOF_DUST_THRESHOLD = 1 * COIN; | static constexpr Amount PROOF_DUST_THRESHOLD = 1 * COIN; | ||||
class ProofValidationState; | class ProofValidationState; | ||||
using StakeId = uint256; | |||||
class Stake { | class Stake { | ||||
COutPoint utxo; | COutPoint utxo; | ||||
Amount amount; | Amount amount; | ||||
uint32_t height; | uint32_t height; | ||||
CPubKey pubkey; | CPubKey pubkey; | ||||
StakeId stakeid; | |||||
void computeStakeId(); | |||||
public: | public: | ||||
explicit Stake() = default; | explicit Stake() = default; | ||||
Stake(COutPoint utxo_, Amount amount_, uint32_t height_, bool is_coinbase, | Stake(COutPoint utxo_, Amount amount_, uint32_t height_, bool is_coinbase, | ||||
CPubKey pubkey_) | CPubKey pubkey_) | ||||
: utxo(utxo_), amount(amount_), height(height_ << 1 | is_coinbase), | : utxo(utxo_), amount(amount_), height(height_ << 1 | is_coinbase), | ||||
pubkey(std::move(pubkey_)) {} | pubkey(std::move(pubkey_)) { | ||||
computeStakeId(); | |||||
} | |||||
SERIALIZE_METHODS(Stake, obj) { | SERIALIZE_METHODS(Stake, obj) { | ||||
READWRITE(obj.utxo, obj.amount, obj.height, obj.pubkey); | READWRITE(obj.utxo, obj.amount, obj.height, obj.pubkey); | ||||
SER_READ(obj, obj.computeStakeId()); | |||||
} | } | ||||
const COutPoint &getUTXO() const { return utxo; } | const COutPoint &getUTXO() const { return utxo; } | ||||
Amount getAmount() const { return amount; } | Amount getAmount() const { return amount; } | ||||
uint32_t getHeight() const { return height >> 1; } | uint32_t getHeight() const { return height >> 1; } | ||||
bool isCoinbase() const { return height & 1; } | bool isCoinbase() const { return height & 1; } | ||||
const CPubKey &getPubkey() const { return pubkey; } | const CPubKey &getPubkey() const { return pubkey; } | ||||
uint256 getHash(const ProofId &proofid) const; | uint256 getHash(const ProofId &proofid) const; | ||||
const StakeId &getId() const { return stakeid; } | |||||
}; | }; | ||||
class SignedStake { | class SignedStake { | ||||
Stake stake; | Stake stake; | ||||
SchnorrSig sig; | SchnorrSig sig; | ||||
public: | public: | ||||
explicit SignedStake() = default; | explicit SignedStake() = default; | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |