Skip to content

Commit

Permalink
Add revert for PaybackV2 (#1316)
Browse files Browse the repository at this point in the history
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
Mixa84 and prasannavl authored May 31, 2022
1 parent 2dd940d commit bd1c278
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
auto balances = attributes->GetValue(liveKey, CBalances{});

// Can be removed after the hard fork, since it will be backward compatible
// but have to keep it around for pre 2.8.0 nodes for now
// but have to keep it around for pre 2.8.0 nodes for now
if (height >= static_cast<uint32_t>(consensus.FortCanningCrunchHeight)) {
CalculateOwnerRewards(obj.owner);
}
Expand Down Expand Up @@ -3693,6 +3693,16 @@ class CCustomTxRevertVisitor : public CCustomTxVisitor
return EraseHistory(vault->ownerAddress);
}

Res operator()(const CLoanPaybackLoanV2Message& obj) const {
const auto vault = mnview.GetVault(obj.vaultId);
if (!vault)
return Res::Err("Vault <%s> not found", obj.vaultId.GetHex());

EraseHistory(obj.from);
EraseHistory(consensus.burnAddress);
return EraseHistory(vault->ownerAddress);
}

Res operator()(const CAuctionBidMessage& obj) const {
if (auto bid = mnview.GetAuctionBid({obj.vaultId, obj.index}))
EraseHistory(bid->first);
Expand Down

0 comments on commit bd1c278

Please sign in to comment.