Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.h
Show All 33 Lines | |||||
/** 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; | using StakeId = uint256; | ||||
struct StakeCommitment : public uint256 { | |||||
explicit StakeCommitment() : uint256() {} | |||||
explicit StakeCommitment(const uint256 &b) : uint256(b) {} | |||||
}; | |||||
class Stake { | class Stake { | ||||
COutPoint utxo; | COutPoint utxo; | ||||
Amount amount; | Amount amount; | ||||
uint32_t height; | uint32_t height; | ||||
CPubKey pubkey; | CPubKey pubkey; | ||||
StakeId stakeid; | StakeId stakeid; | ||||
Show All 14 Lines | public: | ||||
} | } | ||||
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 StakeCommitment &commitment) const; | ||||
const StakeId &getId() const { return stakeid; } | 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; | ||||
SignedStake(Stake stake_, SchnorrSig sig_) | SignedStake(Stake stake_, SchnorrSig sig_) | ||||
: stake(std::move(stake_)), sig(std::move(sig_)) {} | : stake(std::move(stake_)), sig(std::move(sig_)) {} | ||||
SERIALIZE_METHODS(SignedStake, obj) { READWRITE(obj.stake, obj.sig); } | SERIALIZE_METHODS(SignedStake, obj) { READWRITE(obj.stake, obj.sig); } | ||||
const Stake &getStake() const { return stake; } | const Stake &getStake() const { return stake; } | ||||
const SchnorrSig &getSignature() const { return sig; } | const SchnorrSig &getSignature() const { return sig; } | ||||
bool verify(const ProofId &proofid) const; | bool verify(const StakeCommitment &commitment) const; | ||||
}; | }; | ||||
class Proof { | class Proof { | ||||
uint64_t sequence; | uint64_t sequence; | ||||
int64_t expirationTime; | int64_t expirationTime; | ||||
CPubKey master; | CPubKey master; | ||||
std::vector<SignedStake> stakes; | std::vector<SignedStake> stakes; | ||||
CScript payoutScriptPubKey; | CScript payoutScriptPubKey; | ||||
Show All 33 Lines | public: | ||||
uint64_t getSequence() const { return sequence; } | uint64_t getSequence() const { return sequence; } | ||||
int64_t getExpirationTime() const { return expirationTime; } | int64_t getExpirationTime() const { return expirationTime; } | ||||
const CPubKey &getMaster() const { return master; } | const CPubKey &getMaster() const { return master; } | ||||
const std::vector<SignedStake> &getStakes() const { return stakes; } | const std::vector<SignedStake> &getStakes() const { return stakes; } | ||||
const ProofId &getId() const { return proofid; } | const ProofId &getId() const { return proofid; } | ||||
const LimitedProofId &getLimitedId() const { return limitedProofId; } | const LimitedProofId &getLimitedId() const { return limitedProofId; } | ||||
const StakeCommitment getStakeCommitment() const { | |||||
return StakeCommitment(proofid); | |||||
} | |||||
uint32_t getScore() const; | uint32_t getScore() const; | ||||
bool verify(ProofValidationState &state) const; | bool verify(ProofValidationState &state) const; | ||||
bool verify(ProofValidationState &state, const CCoinsView &view) const; | bool verify(ProofValidationState &state, const CCoinsView &view) const; | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOF_H | #endif // BITCOIN_AVALANCHE_PROOF_H |