Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofbuilder.h
Show All 12 Lines | |||||
namespace avalanche { | namespace avalanche { | ||||
struct TestProofBuilder; | struct TestProofBuilder; | ||||
class ProofBuilder { | class ProofBuilder { | ||||
uint64_t sequence; | uint64_t sequence; | ||||
int64_t expirationTime; | int64_t expirationTime; | ||||
CKey masterKey; | CKey masterKey; | ||||
CScript payoutScriptPubKey; | |||||
struct StakeSigner { | struct StakeSigner { | ||||
Stake stake; | Stake stake; | ||||
CKey key; | CKey key; | ||||
StakeSigner(Stake stake_, CKey key_) | StakeSigner(Stake stake_, CKey key_) | ||||
: stake(std::move(stake_)), key(std::move(key_)) {} | : stake(std::move(stake_)), key(std::move(key_)) {} | ||||
SignedStake sign(const ProofId &proofid); | SignedStake sign(const ProofId &proofid); | ||||
}; | }; | ||||
struct StakeSignerComparator { | struct StakeSignerComparator { | ||||
bool operator()(const StakeSigner &lhs, const StakeSigner &rhs) const { | bool operator()(const StakeSigner &lhs, const StakeSigner &rhs) const { | ||||
return lhs.stake.getId() < rhs.stake.getId(); | return lhs.stake.getId() < rhs.stake.getId(); | ||||
} | } | ||||
}; | }; | ||||
std::set<StakeSigner, StakeSignerComparator> stakes; | std::set<StakeSigner, StakeSignerComparator> stakes; | ||||
public: | public: | ||||
ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CKey masterKey_) | ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CKey masterKey_, | ||||
const CScript &payoutScriptPubKey_ = CScript()) | |||||
: sequence(sequence_), expirationTime(expirationTime_), | : sequence(sequence_), expirationTime(expirationTime_), | ||||
masterKey(std::move(masterKey_)) {} | masterKey(std::move(masterKey_)), | ||||
payoutScriptPubKey(payoutScriptPubKey_) {} | |||||
[[nodiscard]] bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, | [[nodiscard]] bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, | ||||
bool is_coinbase, CKey key); | bool is_coinbase, CKey key); | ||||
Proof build(); | Proof build(); | ||||
private: | private: | ||||
ProofId getProofId() const; | ProofId getProofId() const; | ||||
friend struct TestProofBuilder; | friend struct TestProofBuilder; | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOFBUILDER_H | #endif // BITCOIN_AVALANCHE_PROOFBUILDER_H |