Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofbuilder.cpp
Show All 38 Lines | Proof ProofBuilder::build() { | ||||
signedStakes.reserve(stakes.size()); | signedStakes.reserve(stakes.size()); | ||||
while (!stakes.empty()) { | while (!stakes.empty()) { | ||||
auto handle = stakes.extract(stakes.begin()); | auto handle = stakes.extract(stakes.begin()); | ||||
signedStakes.push_back(handle.value().sign(proofid)); | signedStakes.push_back(handle.value().sign(proofid)); | ||||
} | } | ||||
return Proof(sequence, expirationTime, masterKey.GetPubKey(), | return Proof(sequence, expirationTime, masterKey.GetPubKey(), | ||||
std::move(signedStakes)); | std::move(signedStakes), payoutScriptPubKey); | ||||
} | } | ||||
ProofId ProofBuilder::getProofId() const { | ProofId ProofBuilder::getProofId() const { | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << sequence; | ss << sequence; | ||||
ss << expirationTime; | ss << expirationTime; | ||||
if (!Proof::useLegacy(gArgs)) { | |||||
ss << payoutScriptPubKey; | |||||
} | |||||
WriteCompactSize(ss, stakes.size()); | WriteCompactSize(ss, stakes.size()); | ||||
for (const auto &s : stakes) { | for (const auto &s : stakes) { | ||||
ss << s.stake; | ss << s.stake; | ||||
} | } | ||||
CHashWriter ss2(SER_GETHASH, 0); | CHashWriter ss2(SER_GETHASH, 0); | ||||
ss2 << ss.GetHash(); | ss2 << ss.GetHash(); | ||||
ss2 << masterKey.GetPubKey(); | ss2 << masterKey.GetPubKey(); | ||||
return ProofId(ss2.GetHash()); | return ProofId(ss2.GetHash()); | ||||
} | } | ||||
} // namespace avalanche | } // namespace avalanche |