Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofbuilder.cpp
Show All 27 Lines | bool ProofBuilder::addUTXO(COutPoint utxo, Amount amount, uint32_t height, | ||||
return stakes | return stakes | ||||
.emplace(Stake(std::move(utxo), amount, height, is_coinbase, | .emplace(Stake(std::move(utxo), amount, height, is_coinbase, | ||||
key.GetPubKey()), | key.GetPubKey()), | ||||
std::move(key)) | std::move(key)) | ||||
.second; | .second; | ||||
} | } | ||||
Proof ProofBuilder::build() { | ProofRef ProofBuilder::build() { | ||||
SchnorrSig proofSignature; | SchnorrSig proofSignature; | ||||
const LimitedProofId limitedProofId = getLimitedProofId(); | const LimitedProofId limitedProofId = getLimitedProofId(); | ||||
if (!masterKey.SignSchnorr(limitedProofId, proofSignature)) { | if (!masterKey.SignSchnorr(limitedProofId, proofSignature)) { | ||||
proofSignature.fill(0); | proofSignature.fill(0); | ||||
} | } | ||||
const ProofId proofid = getProofId(); | const ProofId proofid = getProofId(); | ||||
const StakeCommitment commitment(proofid, expirationTime, | const StakeCommitment commitment(proofid, expirationTime, | ||||
masterKey.GetPubKey()); | masterKey.GetPubKey()); | ||||
std::vector<SignedStake> signedStakes; | std::vector<SignedStake> signedStakes; | ||||
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(commitment)); | signedStakes.push_back(handle.value().sign(commitment)); | ||||
} | } | ||||
return Proof(sequence, expirationTime, masterKey.GetPubKey(), | return std::make_shared<Proof>( | ||||
std::move(signedStakes), payoutScriptPubKey, | sequence, expirationTime, masterKey.GetPubKey(), | ||||
std::move(proofSignature)); | std::move(signedStakes), payoutScriptPubKey, std::move(proofSignature)); | ||||
} | } | ||||
LimitedProofId ProofBuilder::getLimitedProofId() const { | LimitedProofId ProofBuilder::getLimitedProofId() const { | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << sequence; | ss << sequence; | ||||
ss << expirationTime; | ss << expirationTime; | ||||
if (!Proof::useLegacy(gArgs)) { | if (!Proof::useLegacy(gArgs)) { | ||||
Show All 20 Lines |