From 4d80d428d3b105cf82ce71304c443afa916ca4d6 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 Oct 2023 11:44:19 +0800 Subject: [PATCH 1/2] Fix token check bugs from #2582 --- src/dfi/consensus/tokens.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dfi/consensus/tokens.cpp b/src/dfi/consensus/tokens.cpp index b6897be0dd..f900558e9f 100644 --- a/src/dfi/consensus/tokens.cpp +++ b/src/dfi/consensus/tokens.cpp @@ -10,10 +10,12 @@ #include Res CTokensConsensus::CheckTokenCreationTx() const { - if (tx.vout.size() < 2 || tx.vout[0].nValue < GetTokenCreationFee(height) || tx.vout[0].nTokenId != DCT_ID{0} || - tx.vout[1].nValue != GetTokenCollateralAmount() || tx.vout[1].nTokenId != DCT_ID{0}, - "malformed tx vouts (wrong creation fee or collateral amount)") { - ; + if (tx.vout.size() < 2 || + tx.vout[0].nValue < GetTokenCreationFee(height) || + tx.vout[0].nTokenId != DCT_ID{0} || + tx.vout[1].nValue != GetTokenCollateralAmount() || + tx.vout[1].nTokenId != DCT_ID{0}) { + return Res::Err("malformed tx vouts (wrong creation fee or collateral amount)"); } return Res::Ok(); From 44c18e5c5abab4e7254d94c3e50c9c1b6fc1ea85 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 24 Oct 2023 12:00:44 +0800 Subject: [PATCH 2/2] fix fmt --- src/dfi/consensus/tokens.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/dfi/consensus/tokens.cpp b/src/dfi/consensus/tokens.cpp index f900558e9f..4734b99b13 100644 --- a/src/dfi/consensus/tokens.cpp +++ b/src/dfi/consensus/tokens.cpp @@ -10,11 +10,8 @@ #include Res CTokensConsensus::CheckTokenCreationTx() const { - if (tx.vout.size() < 2 || - tx.vout[0].nValue < GetTokenCreationFee(height) || - tx.vout[0].nTokenId != DCT_ID{0} || - tx.vout[1].nValue != GetTokenCollateralAmount() || - tx.vout[1].nTokenId != DCT_ID{0}) { + if (tx.vout.size() < 2 || tx.vout[0].nValue < GetTokenCreationFee(height) || tx.vout[0].nTokenId != DCT_ID{0} || + tx.vout[1].nValue != GetTokenCollateralAmount() || tx.vout[1].nTokenId != DCT_ID{0}) { return Res::Err("malformed tx vouts (wrong creation fee or collateral amount)"); }