20
20
#include < masternode/meta.h>
21
21
#include < messagesigner.h>
22
22
#include < netbase.h>
23
+ #include < node/context.h>
23
24
#include < rpc/blockchain.h>
24
25
#include < rpc/server.h>
25
26
#include < rpc/util.h>
@@ -928,6 +929,8 @@ static UniValue protx_update_service_common_wrapper(const JSONRPCRequest& reques
928
929
929
930
EnsureWalletIsUnlocked (wallet.get ());
930
931
932
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
933
+
931
934
const bool isV19active{DeploymentActiveAfter (WITH_LOCK (cs_main, return chainman.ActiveChain ().Tip ();), Params ().GetConsensus (), Consensus::DEPLOYMENT_V19)};
932
935
const bool is_bls_legacy = !isV19active;
933
936
if (isEvoRequested && !isV19active) {
@@ -966,7 +969,7 @@ static UniValue protx_update_service_common_wrapper(const JSONRPCRequest& reques
966
969
paramIdx += 3 ;
967
970
}
968
971
969
- auto dmn = deterministicMNManager ->GetListAtChainTip ().GetMN (ptx.proTxHash );
972
+ auto dmn = node. dmnman ->GetListAtChainTip ().GetMN (ptx.proTxHash );
970
973
if (!dmn) {
971
974
throw std::runtime_error (strprintf (" masternode with proTxHash %s not found" , ptx.proTxHash .ToString ()));
972
975
}
@@ -1059,10 +1062,12 @@ static UniValue protx_update_registrar_wrapper(const JSONRPCRequest& request, co
1059
1062
1060
1063
EnsureWalletIsUnlocked (wallet.get ());
1061
1064
1065
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
1066
+
1062
1067
CProUpRegTx ptx;
1063
1068
ptx.proTxHash = ParseHashV (request.params [0 ], " proTxHash" );
1064
1069
1065
- auto dmn = deterministicMNManager ->GetListAtChainTip ().GetMN (ptx.proTxHash );
1070
+ auto dmn = node. dmnman ->GetListAtChainTip ().GetMN (ptx.proTxHash );
1066
1071
if (!dmn) {
1067
1072
throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" masternode %s not found" , ptx.proTxHash .ToString ()));
1068
1073
}
@@ -1170,6 +1175,8 @@ static UniValue protx_revoke(const JSONRPCRequest& request, const ChainstateMana
1170
1175
1171
1176
EnsureWalletIsUnlocked (wallet.get ());
1172
1177
1178
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
1179
+
1173
1180
const bool isV19active{DeploymentActiveAfter (WITH_LOCK (cs_main, return chainman.ActiveChain ().Tip ();), Params ().GetConsensus (), Consensus::DEPLOYMENT_V19)};
1174
1181
const bool is_bls_legacy = !isV19active;
1175
1182
CProUpRevTx ptx;
@@ -1186,7 +1193,7 @@ static UniValue protx_revoke(const JSONRPCRequest& request, const ChainstateMana
1186
1193
ptx.nReason = (uint16_t )nReason;
1187
1194
}
1188
1195
1189
- auto dmn = deterministicMNManager ->GetListAtChainTip ().GetMN (ptx.proTxHash );
1196
+ auto dmn = node. dmnman ->GetListAtChainTip ().GetMN (ptx.proTxHash );
1190
1197
if (!dmn) {
1191
1198
throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" masternode %s not found" , ptx.proTxHash .ToString ()));
1192
1199
}
@@ -1281,7 +1288,7 @@ static bool CheckWalletOwnsScript(CWallet* pwallet, const CScript& script) {
1281
1288
}
1282
1289
#endif
1283
1290
1284
- static UniValue BuildDMNListEntry (CWallet* pwallet, const CDeterministicMN& dmn, bool detailed, const ChainstateManager& chainman, const CBlockIndex* pindex = nullptr )
1291
+ static UniValue BuildDMNListEntry (CWallet* pwallet, const CDeterministicMN& dmn, CMasternodeMetaMan& mn_metaman, bool detailed, const ChainstateManager& chainman, const CBlockIndex* pindex = nullptr )
1285
1292
{
1286
1293
if (!detailed) {
1287
1294
return dmn.proTxHash .ToString ();
@@ -1329,8 +1336,7 @@ static UniValue BuildDMNListEntry(CWallet* pwallet, const CDeterministicMN& dmn,
1329
1336
}
1330
1337
#endif
1331
1338
1332
- CHECK_NONFATAL (mmetaman != nullptr );
1333
- auto metaInfo = mmetaman->GetMetaInfo (dmn.proTxHash );
1339
+ const auto metaInfo = mn_metaman.GetMetaInfo (dmn.proTxHash );
1334
1340
o.pushKV (" metaInfo" , metaInfo->ToJson ());
1335
1341
1336
1342
return o;
@@ -1348,6 +1354,8 @@ static UniValue protx_list(const JSONRPCRequest& request, const ChainstateManage
1348
1354
}
1349
1355
#endif
1350
1356
1357
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
1358
+
1351
1359
std::string type = " registered" ;
1352
1360
if (!request.params [0 ].isNull ()) {
1353
1361
type = request.params [0 ].get_str ();
@@ -1384,14 +1392,14 @@ static UniValue protx_list(const JSONRPCRequest& request, const ChainstateManage
1384
1392
setOutpts.emplace (outpt);
1385
1393
}
1386
1394
1387
- CDeterministicMNList mnList = deterministicMNManager ->GetListForBlock (chainman.ActiveChain ()[height]);
1395
+ CDeterministicMNList mnList = node. dmnman ->GetListForBlock (chainman.ActiveChain ()[height]);
1388
1396
mnList.ForEachMN (false , [&](const auto & dmn) {
1389
1397
if (setOutpts.count (dmn.collateralOutpoint ) ||
1390
1398
CheckWalletOwnsKey (wallet.get (), dmn.pdmnState ->keyIDOwner ) ||
1391
1399
CheckWalletOwnsKey (wallet.get (), dmn.pdmnState ->keyIDVoting ) ||
1392
1400
CheckWalletOwnsScript (wallet.get (), dmn.pdmnState ->scriptPayout ) ||
1393
1401
CheckWalletOwnsScript (wallet.get (), dmn.pdmnState ->scriptOperatorPayout )) {
1394
- ret.push_back (BuildDMNListEntry (wallet.get (), dmn, detailed, chainman));
1402
+ ret.push_back (BuildDMNListEntry (wallet.get (), dmn, *node. mn_metaman , detailed, chainman));
1395
1403
}
1396
1404
});
1397
1405
#endif
@@ -1409,12 +1417,12 @@ static UniValue protx_list(const JSONRPCRequest& request, const ChainstateManage
1409
1417
throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid height specified" );
1410
1418
}
1411
1419
1412
- CDeterministicMNList mnList = deterministicMNManager ->GetListForBlock (chainman.ActiveChain ()[height]);
1420
+ CDeterministicMNList mnList = node. dmnman ->GetListForBlock (chainman.ActiveChain ()[height]);
1413
1421
bool onlyValid = type == " valid" ;
1414
1422
bool onlyEvoNodes = type == " evo" ;
1415
1423
mnList.ForEachMN (onlyValid, [&](const auto & dmn) {
1416
1424
if (onlyEvoNodes && dmn.nType != MnType::Evo) return ;
1417
- ret.push_back (BuildDMNListEntry (wallet.get (), dmn, detailed, chainman));
1425
+ ret.push_back (BuildDMNListEntry (wallet.get (), dmn, *node. mn_metaman , detailed, chainman));
1418
1426
});
1419
1427
} else {
1420
1428
throw JSONRPCError (RPC_INVALID_PARAMETER, " invalid type specified" );
@@ -1455,6 +1463,8 @@ static UniValue protx_info(const JSONRPCRequest& request, const ChainstateManage
1455
1463
}
1456
1464
#endif
1457
1465
1466
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
1467
+
1458
1468
if (g_txindex) {
1459
1469
g_txindex->BlockUntilSyncedToCurrentChain ();
1460
1470
}
@@ -1475,12 +1485,12 @@ static UniValue protx_info(const JSONRPCRequest& request, const ChainstateManage
1475
1485
}
1476
1486
}
1477
1487
1478
- auto mnList = deterministicMNManager ->GetListForBlock (pindex);
1488
+ auto mnList = node. dmnman ->GetListForBlock (pindex);
1479
1489
auto dmn = mnList.GetMN (proTxHash);
1480
1490
if (!dmn) {
1481
1491
throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" %s not found" , proTxHash.ToString ()));
1482
1492
}
1483
- return BuildDMNListEntry (wallet.get (), *dmn, true , chainman, pindex);
1493
+ return BuildDMNListEntry (wallet.get (), *dmn, *node. mn_metaman , true , chainman, pindex);
1484
1494
}
1485
1495
1486
1496
static void protx_diff_help (const JSONRPCRequest& request)
@@ -1569,6 +1579,8 @@ static UniValue protx_listdiff(const JSONRPCRequest& request, const ChainstateMa
1569
1579
{
1570
1580
protx_listdiff_help (request);
1571
1581
1582
+ const NodeContext& node = EnsureAnyNodeContext (request.context );
1583
+
1572
1584
LOCK (cs_main);
1573
1585
UniValue ret (UniValue::VOBJ);
1574
1586
@@ -1586,8 +1598,8 @@ static UniValue protx_listdiff(const JSONRPCRequest& request, const ChainstateMa
1586
1598
ret.pushKV (" baseHeight" , pBaseBlockIndex->nHeight );
1587
1599
ret.pushKV (" blockHeight" , pTargetBlockIndex->nHeight );
1588
1600
1589
- auto baseBlockMNList = deterministicMNManager ->GetListForBlock (pBaseBlockIndex);
1590
- auto blockMNList = deterministicMNManager ->GetListForBlock (pTargetBlockIndex);
1601
+ auto baseBlockMNList = node. dmnman ->GetListForBlock (pBaseBlockIndex);
1602
+ auto blockMNList = node. dmnman ->GetListForBlock (pTargetBlockIndex);
1591
1603
1592
1604
auto mnDiff = baseBlockMNList.BuildDiff (blockMNList);
1593
1605
0 commit comments