Bitcoin ABC  0.22.13
P2P Digital Currency
proofbuilder.h
Go to the documentation of this file.
1 // Copyright (c) 2020 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_AVALANCHE_PROOFBUILDER_H
6 #define BITCOIN_AVALANCHE_PROOFBUILDER_H
7 
8 #include <avalanche/proof.h>
9 #include <key.h>
10 
11 #include <cstdio>
12 
13 namespace avalanche {
14 
15 class ProofBuilder {
16  uint64_t sequence;
17  int64_t expirationTime;
19 
20  struct StakeSigner {
23 
24  StakeSigner(Stake stake_, CKey key_)
25  : stake(std::move(stake_)), key(std::move(key_)) {}
26 
27  SignedStake sign(const ProofId &proofid);
28  };
29 
30  std::vector<StakeSigner> stakes;
31 
32 public:
33  ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CPubKey master_)
34  : sequence(sequence_), expirationTime(expirationTime_),
35  master(std::move(master_)) {}
36 
37  bool addUTXO(COutPoint utxo, Amount amount, uint32_t height,
38  bool is_coinbase, CKey key);
39 
40  Proof build();
41 
46  static Proof buildRandom(uint32_t score);
47 
48 private:
49  ProofId getProofId() const;
50 };
51 
52 } // namespace avalanche
53 
54 #endif // BITCOIN_AVALANCHE_PROOFBUILDER_H
ProofId getProofId() const
Definition: amount.h:17
static Proof buildRandom(uint32_t score)
Builds a randomized (and therefore invalid) Proof.
StakeSigner(Stake stake_, CKey key_)
Definition: proofbuilder.h:24
An encapsulated public key.
Definition: pubkey.h:31
bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, bool is_coinbase, CKey key)
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:22
std::vector< StakeSigner > stakes
Definition: proofbuilder.h:30
SignedStake sign(const ProofId &proofid)
An encapsulated secp256k1 private key.
Definition: key.h:25
ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CPubKey master_)
Definition: proofbuilder.h:33