diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -24,6 +25,11 @@ */ static constexpr int AVALANCHE_MAX_PROOF_STAKES = 1000; +/** + * Whether the legacy proof format should be used by default. + */ +static constexpr bool AVALANCHE_DEFAULT_LEGACY_PROOF = true; + namespace avalanche { /** Minimum amount per utxo */ @@ -90,25 +96,38 @@ int64_t expirationTime; CPubKey master; std::vector stakes; + CScript payoutScriptPubKey; LimitedProofId limitedProofId; ProofId proofid; void computeProofId(); public: - Proof() : sequence(0), expirationTime(0), master(), stakes(), proofid() {} + Proof() + : sequence(0), expirationTime(0), master(), stakes(), + payoutScriptPubKey(CScript()), limitedProofId(), proofid() {} + Proof(uint64_t sequence_, int64_t expirationTime_, CPubKey master_, - std::vector stakes_) + std::vector stakes_, const CScript &payoutScriptPubKey_) : sequence(sequence_), expirationTime(expirationTime_), - master(std::move(master_)), stakes(std::move(stakes_)) { + master(std::move(master_)), stakes(std::move(stakes_)), + payoutScriptPubKey(payoutScriptPubKey_) { computeProofId(); } SERIALIZE_METHODS(Proof, obj) { READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); + if (!useLegacy(gArgs)) { + READWRITE(obj.payoutScriptPubKey); + } SER_READ(obj, obj.computeProofId()); } + static bool useLegacy(const ArgsManager &argsman) { + return argsman.GetBoolArg("-legacyavaproof", + AVALANCHE_DEFAULT_LEGACY_PROOF); + } + static bool FromHex(Proof &proof, const std::string &hexProof, bilingual_str &errorOut); diff --git a/src/avalanche/proof.cpp b/src/avalanche/proof.cpp --- a/src/avalanche/proof.cpp +++ b/src/avalanche/proof.cpp @@ -6,7 +6,9 @@ #include #include +#include #include +#include #include