Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.h
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#ifndef BITCOIN_AVALANCHE_PROOF_H | #ifndef BITCOIN_AVALANCHE_PROOF_H | ||||
#define BITCOIN_AVALANCHE_PROOF_H | #define BITCOIN_AVALANCHE_PROOF_H | ||||
#include <amount.h> | #include <amount.h> | ||||
#include <avalanche/proofid.h> | #include <avalanche/proofid.h> | ||||
#include <key.h> | #include <key.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <pubkey.h> | #include <pubkey.h> | ||||
#include <serialize.h> | #include <serialize.h> | ||||
#include <util/system.h> | |||||
#include <util/translation.h> | |||||
#include <array> | #include <array> | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <vector> | #include <vector> | ||||
class ArgsManager; | |||||
class CCoinsView; | class CCoinsView; | ||||
struct bilingual_str; | |||||
/** | /** | ||||
* How many UTXOs can be used for a single proof. | * How many UTXOs can be used for a single proof. | ||||
*/ | */ | ||||
static constexpr int AVALANCHE_MAX_PROOF_STAKES = 1000; | static constexpr int AVALANCHE_MAX_PROOF_STAKES = 1000; | ||||
/** | /** | ||||
* Whether the legacy proof format should be used by default. | * Whether the legacy proof format should be used by default. | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | Proof(uint64_t sequence_, int64_t expirationTime_, CPubKey master_, | ||||
: sequence(sequence_), expirationTime(expirationTime_), | : sequence(sequence_), expirationTime(expirationTime_), | ||||
master(std::move(master_)), stakes(std::move(stakes_)), | master(std::move(master_)), stakes(std::move(stakes_)), | ||||
payoutScriptPubKey(payoutScriptPubKey_) { | payoutScriptPubKey(payoutScriptPubKey_) { | ||||
computeProofId(); | computeProofId(); | ||||
} | } | ||||
SERIALIZE_METHODS(Proof, obj) { | SERIALIZE_METHODS(Proof, obj) { | ||||
READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); | READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); | ||||
if (!useLegacy(gArgs)) { | if (!useLegacy()) { | ||||
READWRITE(obj.payoutScriptPubKey); | READWRITE(obj.payoutScriptPubKey); | ||||
} | } | ||||
SER_READ(obj, obj.computeProofId()); | SER_READ(obj, obj.computeProofId()); | ||||
} | } | ||||
static bool useLegacy(const ArgsManager &argsman) { | static bool useLegacy(); | ||||
return argsman.GetBoolArg("-legacyavaproof", | static bool useLegacy(const ArgsManager &argsman); | ||||
AVALANCHE_DEFAULT_LEGACY_PROOF); | |||||
} | |||||
static bool FromHex(Proof &proof, const std::string &hexProof, | static bool FromHex(Proof &proof, const std::string &hexProof, | ||||
bilingual_str &errorOut); | bilingual_str &errorOut); | ||||
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; } | ||||
Show All 15 Lines |