Skip to content

Commit

Permalink
Prevent mixing imports and exports
Browse files Browse the repository at this point in the history
  • Loading branch information
miketout authored and Asherda committed May 9, 2024
1 parent 88c0e73 commit 07ff18a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pbaas/pbaas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ bool PrecheckCrossChainExport(const CTransaction &tx, int32_t outNum, CValidatio
CCurrencyValueMap reserveDepositOutput;
CCurrencyValueMap expectedReserveDeposits;
CCurrencyValueMap expectedBurn;
CCrossChainImport cci;
for (int i = 0; i < tx.vout.size(); i++)
{
COptCCParams p;
Expand All @@ -1973,10 +1974,18 @@ bool PrecheckCrossChainExport(const CTransaction &tx, int32_t outNum, CValidatio
p.evalCode == EVAL_RESERVE_DEPOSIT &&
p.vData.size() &&
(rd = CReserveDeposit(p.vData[0])).IsValid() &&
rd.controllingCurrencyID == reserveDepositHolder)
{
rd.controllingCurrencyID == reserveDepositHolder) {
reserveDepositOutput += rd.reserveValues;
}
else if (p.IsValid() &&
p.evalCode == EVAL_CROSSCHAIN_IMPORT &&
!ccx.IsChainDefinition() &&
p.vData.size() &&
(cci = CCrossChainImport(p.vData[0])).IsValid() &&
cci.importCurrencyID == ccx.destCurrencyID)
{
return state.Error("Invalid export combined with import without currency definition");
}
}
// if cross system, we may remove some due to burning
if (isCrossSystem)
Expand Down

0 comments on commit 07ff18a

Please sign in to comment.