@@ -441,12 +441,13 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
441
441
vTxHashes.emplace_back (hash, newit);
442
442
newit->vTxHashesIdx = vTxHashes.size () - 1 ;
443
443
444
+ // Invalid ProTxes should never get this far because transactions should be
445
+ // fully checked by AcceptToMemoryPool() at this point, so we just assume that
446
+ // everything is fine here.
444
447
if (tx.nType == TRANSACTION_PROVIDER_REGISTER) {
445
448
CProRegTx proTx;
446
- if (!GetTxPayload (tx, proTx)) {
447
- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
448
- return false ;
449
- }
449
+ bool ok = GetTxPayload (tx, proTx);
450
+ assert (ok);
450
451
if (!proTx.collateralOutpoint .hash .IsNull ()) {
451
452
mapProTxRefs.emplace (tx.GetHash (), proTx.collateralOutpoint .hash );
452
453
}
@@ -458,36 +459,29 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
458
459
}
459
460
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
460
461
CProUpServTx proTx;
461
- if (!GetTxPayload (tx, proTx)) {
462
- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
463
- return false ;
464
- }
462
+ bool ok = GetTxPayload (tx, proTx);
463
+ assert (ok);
465
464
mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
466
465
mapProTxAddresses.emplace (proTx.addr , tx.GetHash ());
467
466
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) {
468
467
CProUpRegTx proTx;
469
- if (!GetTxPayload (tx, proTx)) {
470
- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
471
- return false ;
472
- }
468
+ bool ok = GetTxPayload (tx, proTx);
469
+ assert (ok);
473
470
mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
474
471
mapProTxBlsPubKeyHashes.emplace (proTx.pubKeyOperator .GetHash (), tx.GetHash ());
475
-
476
472
auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
477
- assert (dmn); // we should never get such a ProTx into the mempool
473
+ assert (dmn);
478
474
newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
479
475
if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
480
476
newit->isKeyChangeProTx = true ;
481
477
}
482
478
} else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) {
483
479
CProUpRevTx proTx;
484
- if (!GetTxPayload (tx, proTx)) {
485
- LogPrintf (" %s: ERROR: Invalid transaction payload, tx: %s" , __func__, tx.ToString ());
486
- return false ;
487
- }
480
+ bool ok = GetTxPayload (tx, proTx);
481
+ assert (ok);
488
482
mapProTxRefs.emplace (proTx.proTxHash , tx.GetHash ());
489
483
auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
490
- assert (dmn); // we should never get such a ProTx into the mempool
484
+ assert (dmn);
491
485
newit->validForProTxKey = ::SerializeHash (dmn->pdmnState ->pubKeyOperator );
492
486
if (dmn->pdmnState ->pubKeyOperator != CBLSPublicKey ()) {
493
487
newit->isKeyChangeProTx = true ;
@@ -1306,9 +1300,13 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
1306
1300
return true ; // i.e. can't decode payload == conflict
1307
1301
}
1308
1302
1309
- // only allow one operator key change in the mempool
1303
+ // this method should only be called with validated ProTxs
1310
1304
auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
1311
- assert (dmn); // this method should only be called with validated ProTxs
1305
+ if (!dmn) {
1306
+ LogPrintf (" %s: ERROR: Masternode is not in the list, proTxHash: %s" , __func__, proTx.proTxHash .ToString ());
1307
+ return true ; // i.e. failed to find validated ProTx == conflict
1308
+ }
1309
+ // only allow one operator key change in the mempool
1312
1310
if (dmn->pdmnState ->pubKeyOperator != proTx.pubKeyOperator ) {
1313
1311
if (hasKeyChangeInMempool (proTx.proTxHash )) {
1314
1312
return true ;
@@ -1324,9 +1322,13 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const {
1324
1322
return true ; // i.e. can't decode payload == conflict
1325
1323
}
1326
1324
1327
- // only allow one operator key change in the mempool
1325
+ // this method should only be called with validated ProTxs
1328
1326
auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (proTx.proTxHash );
1329
- assert (dmn); // this method should only be called with validated ProTxs
1327
+ if (!dmn) {
1328
+ LogPrintf (" %s: ERROR: Masternode is not in the list, proTxHash: %s" , __func__, proTx.proTxHash .ToString ());
1329
+ return true ; // i.e. failed to find validated ProTx == conflict
1330
+ }
1331
+ // only allow one operator key change in the mempool
1330
1332
if (dmn->pdmnState ->pubKeyOperator != CBLSPublicKey ()) {
1331
1333
if (hasKeyChangeInMempool (proTx.proTxHash )) {
1332
1334
return true ;
0 commit comments