@@ -178,7 +178,7 @@ static bool CompareByLastPaid(const CDeterministicMN* _a, const CDeterministicMN
178
178
return CompareByLastPaid (*_a, *_b);
179
179
}
180
180
181
- CDeterministicMNCPtr CDeterministicMNList::GetMNPayee (const CBlockIndex* pIndex) const
181
+ CDeterministicMNCPtr CDeterministicMNList::GetMNPayee (gsl::not_null< const CBlockIndex*> pIndex) const
182
182
{
183
183
if (mnMap.size () == 0 ) {
184
184
return nullptr ;
@@ -214,7 +214,7 @@ CDeterministicMNCPtr CDeterministicMNList::GetMNPayee(const CBlockIndex* pIndex)
214
214
return best;
215
215
}
216
216
217
- std::vector<CDeterministicMNCPtr> CDeterministicMNList::GetProjectedMNPayees (const CBlockIndex* const pindex, int nCount) const
217
+ std::vector<CDeterministicMNCPtr> CDeterministicMNList::GetProjectedMNPayees (gsl::not_null< const CBlockIndex* const > pindex, int nCount) const
218
218
{
219
219
if (nCount < 0 ) {
220
220
return {};
@@ -421,7 +421,7 @@ CDeterministicMNListDiff CDeterministicMNList::BuildDiff(const CDeterministicMNL
421
421
return diffRet;
422
422
}
423
423
424
- CDeterministicMNList CDeterministicMNList::ApplyDiff (const CBlockIndex* pindex, const CDeterministicMNListDiff& diff) const
424
+ CDeterministicMNList CDeterministicMNList::ApplyDiff (gsl::not_null< const CBlockIndex*> pindex, const CDeterministicMNListDiff& diff) const
425
425
{
426
426
CDeterministicMNList result = *this ;
427
427
result.blockHash = pindex->GetBlockHash ();
@@ -594,7 +594,7 @@ void CDeterministicMNList::RemoveMN(const uint256& proTxHash)
594
594
mnInternalIdMap = mnInternalIdMap.erase (dmn->GetInternalId ());
595
595
}
596
596
597
- bool CDeterministicMNManager::ProcessBlock (const CBlock& block, const CBlockIndex* pindex, BlockValidationState& state, const CCoinsViewCache& view, bool fJustCheck )
597
+ bool CDeterministicMNManager::ProcessBlock (const CBlock& block, gsl::not_null< const CBlockIndex*> pindex, BlockValidationState& state, const CCoinsViewCache& view, bool fJustCheck )
598
598
{
599
599
AssertLockHeld (cs_main);
600
600
@@ -660,7 +660,7 @@ bool CDeterministicMNManager::ProcessBlock(const CBlock& block, const CBlockInde
660
660
return true ;
661
661
}
662
662
663
- bool CDeterministicMNManager::UndoBlock (const CBlockIndex* pindex)
663
+ bool CDeterministicMNManager::UndoBlock (gsl::not_null< const CBlockIndex*> pindex)
664
664
{
665
665
int nHeight = pindex->nHeight ;
666
666
uint256 blockHash = pindex->GetBlockHash ();
@@ -696,14 +696,14 @@ bool CDeterministicMNManager::UndoBlock(const CBlockIndex* pindex)
696
696
return true ;
697
697
}
698
698
699
- void CDeterministicMNManager::UpdatedBlockTip (const CBlockIndex* pindex)
699
+ void CDeterministicMNManager::UpdatedBlockTip (gsl::not_null< const CBlockIndex*> pindex)
700
700
{
701
701
LOCK (cs);
702
702
703
703
tipIndex = pindex;
704
704
}
705
705
706
- bool CDeterministicMNManager::BuildNewListFromBlock (const CBlock& block, const CBlockIndex* pindexPrev, BlockValidationState& state, const CCoinsViewCache& view, CDeterministicMNList& mnListRet, bool debugLogs)
706
+ bool CDeterministicMNManager::BuildNewListFromBlock (const CBlock& block, gsl::not_null< const CBlockIndex*> pindexPrev, BlockValidationState& state, const CCoinsViewCache& view, CDeterministicMNList& mnListRet, bool debugLogs)
707
707
{
708
708
int nHeight = pindexPrev->nHeight + 1 ;
709
709
@@ -991,7 +991,7 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
991
991
return true ;
992
992
}
993
993
994
- void CDeterministicMNManager::HandleQuorumCommitment (const llmq::CFinalCommitment& qc, const CBlockIndex* pQuorumBaseBlockIndex, CDeterministicMNList& mnList, bool debugLogs)
994
+ void CDeterministicMNManager::HandleQuorumCommitment (const llmq::CFinalCommitment& qc, gsl::not_null< const CBlockIndex*> pQuorumBaseBlockIndex, CDeterministicMNList& mnList, bool debugLogs)
995
995
{
996
996
// The commitment has already been validated at this point, so it's safe to use members of it
997
997
@@ -1011,7 +1011,7 @@ void CDeterministicMNManager::HandleQuorumCommitment(const llmq::CFinalCommitmen
1011
1011
}
1012
1012
}
1013
1013
1014
- CDeterministicMNList CDeterministicMNManager::GetListForBlockInternal (const CBlockIndex* pindex)
1014
+ CDeterministicMNList CDeterministicMNManager::GetListForBlockInternal (gsl::not_null< const CBlockIndex*> pindex)
1015
1015
{
1016
1016
AssertLockHeld (cs);
1017
1017
CDeterministicMNList snapshot;
@@ -1512,7 +1512,7 @@ static bool CheckHashSig(const ProTx& proTx, const CBLSPublicKey& pubKey, TxVali
1512
1512
return true ;
1513
1513
}
1514
1514
1515
- bool CheckProRegTx (const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1515
+ bool CheckProRegTx (const CTransaction& tx, gsl::not_null< const CBlockIndex*> pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1516
1516
{
1517
1517
if (tx.nType != TRANSACTION_PROVIDER_REGISTER) {
1518
1518
return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-type" );
@@ -1634,7 +1634,7 @@ bool CheckProRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxVali
1634
1634
return true ;
1635
1635
}
1636
1636
1637
- bool CheckProUpServTx (const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, bool check_sigs)
1637
+ bool CheckProUpServTx (const CTransaction& tx, gsl::not_null< const CBlockIndex*> pindexPrev, TxValidationState& state, bool check_sigs)
1638
1638
{
1639
1639
if (tx.nType != TRANSACTION_PROVIDER_UPDATE_SERVICE) {
1640
1640
return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-type" );
@@ -1661,50 +1661,48 @@ bool CheckProUpServTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxV
1661
1661
}
1662
1662
}
1663
1663
1664
- if (pindexPrev) {
1665
- auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1666
- auto mn = mnList.GetMN (ptx.proTxHash );
1667
- if (!mn) {
1668
- return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1669
- }
1670
-
1671
- // don't allow updating to addresses already used by other MNs
1672
- if (mnList.HasUniqueProperty (ptx.addr ) && mnList.GetUniquePropertyMN (ptx.addr )->proTxHash != ptx.proTxHash ) {
1673
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-addr" );
1674
- }
1664
+ auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1665
+ auto mn = mnList.GetMN (ptx.proTxHash );
1666
+ if (!mn) {
1667
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1668
+ }
1675
1669
1676
- // don't allow updating to platformNodeIds already used by other EvoNodes
1677
- if (ptx.nType == MnType::Evo) {
1678
- if (mnList.HasUniqueProperty (ptx.platformNodeID ) && mnList.GetUniquePropertyMN (ptx.platformNodeID )->proTxHash != ptx.proTxHash ) {
1679
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-platformnodeid" );
1680
- }
1681
- }
1670
+ // don't allow updating to addresses already used by other MNs
1671
+ if (mnList.HasUniqueProperty (ptx.addr ) && mnList.GetUniquePropertyMN (ptx.addr )->proTxHash != ptx.proTxHash ) {
1672
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-addr" );
1673
+ }
1682
1674
1683
- if (ptx.scriptOperatorPayout != CScript ()) {
1684
- if (mn->nOperatorReward == 0 ) {
1685
- // don't allow setting operator reward payee in case no operatorReward was set
1686
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-operator-payee" );
1687
- }
1688
- if (!ptx.scriptOperatorPayout .IsPayToPublicKeyHash () && !ptx.scriptOperatorPayout .IsPayToScriptHash ()) {
1689
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-operator-payee" );
1690
- }
1675
+ // don't allow updating to platformNodeIds already used by other EvoNodes
1676
+ if (ptx.nType == MnType::Evo) {
1677
+ if (mnList.HasUniqueProperty (ptx.platformNodeID ) && mnList.GetUniquePropertyMN (ptx.platformNodeID )->proTxHash != ptx.proTxHash ) {
1678
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-platformnodeid" );
1691
1679
}
1680
+ }
1692
1681
1693
- // we can only check the signature if pindexPrev != nullptr and the MN is known
1694
- if (! CheckInputsHash (tx, ptx, state) ) {
1695
- // pass the state returned by the function above
1696
- return false ;
1682
+ if (ptx. scriptOperatorPayout != CScript ()) {
1683
+ if (mn-> nOperatorReward == 0 ) {
1684
+ // don't allow setting operator reward payee in case no operatorReward was set
1685
+ return state. Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-operator-payee " ) ;
1697
1686
}
1698
- if (check_sigs && !CheckHashSig (ptx, mn->pdmnState ->pubKeyOperator .Get (), state)) {
1699
- // pass the state returned by the function above
1700
- return false ;
1687
+ if (!ptx.scriptOperatorPayout .IsPayToPublicKeyHash () && !ptx.scriptOperatorPayout .IsPayToScriptHash ()) {
1688
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-operator-payee" );
1701
1689
}
1702
1690
}
1703
1691
1692
+ // we can only check the signature if pindexPrev != nullptr and the MN is known
1693
+ if (!CheckInputsHash (tx, ptx, state)) {
1694
+ // pass the state returned by the function above
1695
+ return false ;
1696
+ }
1697
+ if (check_sigs && !CheckHashSig (ptx, mn->pdmnState ->pubKeyOperator .Get (), state)) {
1698
+ // pass the state returned by the function above
1699
+ return false ;
1700
+ }
1701
+
1704
1702
return true ;
1705
1703
}
1706
1704
1707
- bool CheckProUpRegTx (const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1705
+ bool CheckProUpRegTx (const CTransaction& tx, gsl::not_null< const CBlockIndex*> pindexPrev, TxValidationState& state, const CCoinsViewCache& view, bool check_sigs)
1708
1706
{
1709
1707
if (tx.nType != TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
1710
1708
return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-type" );
@@ -1726,60 +1724,58 @@ bool CheckProUpRegTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxVa
1726
1724
return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-payee-dest" );
1727
1725
}
1728
1726
1729
- if (pindexPrev) {
1730
- auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1731
- auto dmn = mnList.GetMN (ptx.proTxHash );
1732
- if (!dmn) {
1733
- return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1734
- }
1727
+ auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1728
+ auto dmn = mnList.GetMN (ptx.proTxHash );
1729
+ if (!dmn) {
1730
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1731
+ }
1735
1732
1736
- // don't allow reuse of payee key for other keys (don't allow people to put the payee key onto an online server)
1737
- if (payoutDest == CTxDestination (PKHash (dmn->pdmnState ->keyIDOwner )) || payoutDest == CTxDestination (PKHash (ptx.keyIDVoting ))) {
1738
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-payee-reuse" );
1739
- }
1733
+ // don't allow reuse of payee key for other keys (don't allow people to put the payee key onto an online server)
1734
+ if (payoutDest == CTxDestination (PKHash (dmn->pdmnState ->keyIDOwner )) || payoutDest == CTxDestination (PKHash (ptx.keyIDVoting ))) {
1735
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-payee-reuse" );
1736
+ }
1740
1737
1741
- Coin coin;
1742
- if (!view.GetCoin (dmn->collateralOutpoint , coin) || coin.IsSpent ()) {
1743
- // this should never happen (there would be no dmn otherwise)
1744
- return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-collateral" );
1745
- }
1738
+ Coin coin;
1739
+ if (!view.GetCoin (dmn->collateralOutpoint , coin) || coin.IsSpent ()) {
1740
+ // this should never happen (there would be no dmn otherwise)
1741
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-collateral" );
1742
+ }
1746
1743
1747
- // don't allow reuse of collateral key for other keys (don't allow people to put the collateral key onto an online server)
1748
- CTxDestination collateralTxDest;
1749
- if (!ExtractDestination (coin.out .scriptPubKey , collateralTxDest)) {
1750
- return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-collateral-dest" );
1751
- }
1752
- if (collateralTxDest == CTxDestination (PKHash (dmn->pdmnState ->keyIDOwner )) || collateralTxDest == CTxDestination (PKHash (ptx.keyIDVoting ))) {
1753
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-collateral-reuse" );
1754
- }
1744
+ // don't allow reuse of collateral key for other keys (don't allow people to put the collateral key onto an online server)
1745
+ CTxDestination collateralTxDest;
1746
+ if (!ExtractDestination (coin.out .scriptPubKey , collateralTxDest)) {
1747
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-collateral-dest" );
1748
+ }
1749
+ if (collateralTxDest == CTxDestination (PKHash (dmn->pdmnState ->keyIDOwner )) || collateralTxDest == CTxDestination (PKHash (ptx.keyIDVoting ))) {
1750
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-collateral-reuse" );
1751
+ }
1755
1752
1756
- if (mnList.HasUniqueProperty (ptx.pubKeyOperator )) {
1757
- auto otherDmn = mnList.GetUniquePropertyMN (ptx.pubKeyOperator );
1758
- if (ptx.proTxHash != otherDmn->proTxHash ) {
1759
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-key" );
1760
- }
1753
+ if (mnList.HasUniqueProperty (ptx.pubKeyOperator )) {
1754
+ auto otherDmn = mnList.GetUniquePropertyMN (ptx.pubKeyOperator );
1755
+ if (ptx.proTxHash != otherDmn->proTxHash ) {
1756
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-dup-key" );
1761
1757
}
1758
+ }
1762
1759
1763
- if (!deterministicMNManager->IsDIP3Enforced (pindexPrev->nHeight )) {
1764
- if (dmn->pdmnState ->keyIDOwner != ptx.keyIDVoting ) {
1765
- return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-key-not-same" );
1766
- }
1760
+ if (!deterministicMNManager->IsDIP3Enforced (pindexPrev->nHeight )) {
1761
+ if (dmn->pdmnState ->keyIDOwner != ptx.keyIDVoting ) {
1762
+ return state.Invalid (TxValidationResult::TX_BAD_SPECIAL, " bad-protx-key-not-same" );
1767
1763
}
1764
+ }
1768
1765
1769
- if (!CheckInputsHash (tx, ptx, state)) {
1770
- // pass the state returned by the function above
1771
- return false ;
1772
- }
1773
- if (check_sigs && !CheckHashSig (ptx, PKHash (dmn->pdmnState ->keyIDOwner ), state)) {
1774
- // pass the state returned by the function above
1775
- return false ;
1776
- }
1766
+ if (!CheckInputsHash (tx, ptx, state)) {
1767
+ // pass the state returned by the function above
1768
+ return false ;
1769
+ }
1770
+ if (check_sigs && !CheckHashSig (ptx, PKHash (dmn->pdmnState ->keyIDOwner ), state)) {
1771
+ // pass the state returned by the function above
1772
+ return false ;
1777
1773
}
1778
1774
1779
1775
return true ;
1780
1776
}
1781
1777
1782
- bool CheckProUpRevTx (const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state, bool check_sigs)
1778
+ bool CheckProUpRevTx (const CTransaction& tx, gsl::not_null< const CBlockIndex*> pindexPrev, TxValidationState& state, bool check_sigs)
1783
1779
{
1784
1780
if (tx.nType != TRANSACTION_PROVIDER_UPDATE_REVOKE) {
1785
1781
return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-type" );
@@ -1795,20 +1791,18 @@ bool CheckProUpRevTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxVa
1795
1791
return false ;
1796
1792
}
1797
1793
1798
- if (pindexPrev) {
1799
- auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1800
- auto dmn = mnList.GetMN (ptx.proTxHash );
1801
- if (!dmn)
1802
- return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1794
+ auto mnList = deterministicMNManager->GetListForBlock (pindexPrev);
1795
+ auto dmn = mnList.GetMN (ptx.proTxHash );
1796
+ if (!dmn)
1797
+ return state.Invalid (TxValidationResult::TX_CONSENSUS, " bad-protx-hash" );
1803
1798
1804
- if (!CheckInputsHash (tx, ptx, state)) {
1805
- // pass the state returned by the function above
1806
- return false ;
1807
- }
1808
- if (check_sigs && !CheckHashSig (ptx, dmn->pdmnState ->pubKeyOperator .Get (), state)) {
1809
- // pass the state returned by the function above
1810
- return false ;
1811
- }
1799
+ if (!CheckInputsHash (tx, ptx, state)) {
1800
+ // pass the state returned by the function above
1801
+ return false ;
1802
+ }
1803
+ if (check_sigs && !CheckHashSig (ptx, dmn->pdmnState ->pubKeyOperator .Get (), state)) {
1804
+ // pass the state returned by the function above
1805
+ return false ;
1812
1806
}
1813
1807
1814
1808
return true ;
0 commit comments