@@ -1272,7 +1272,8 @@ UniValue scanforunspent(const UniValue& params, bool fHelp)
1272
1272
if (!Address.IsValid ())
1273
1273
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid Gridcoin Address" );
1274
1274
1275
- std::unordered_multimap<int64_t , std::pair<uint256, unsigned int >> uMultisig;
1275
+ // Store as: TXID, VOUT, nValue, nHeight
1276
+ std::vector<std::pair<std::pair<uint256, unsigned int >, std::pair<int64_t , int >>> Multisig;
1276
1277
1277
1278
{
1278
1279
LOCK (cs_main);
@@ -1325,8 +1326,8 @@ UniValue scanforunspent(const UniValue& params, bool fHelp)
1325
1326
if (!txindex.vSpent [dummy.n ].IsNull ())
1326
1327
continue ;
1327
1328
1328
- // Add to multimap
1329
- uMultisig. insert (std::make_pair (txout. nValue , std::make_pair (tx.GetHash (), j)));
1329
+ // Add to vector
1330
+ Multisig. push_back (std::make_pair (std::make_pair (tx.GetHash (), j), std::make_pair (txout. nValue , pblkindex-> nHeight )));
1330
1331
}
1331
1332
}
1332
1333
}
@@ -1340,7 +1341,7 @@ UniValue scanforunspent(const UniValue& params, bool fHelp)
1340
1341
res.pushKV (" Block Start" , nBlockStart);
1341
1342
res.pushKV (" Block End" , nBlockEnd);
1342
1343
// Check the end results
1343
- if (uMultisig .empty ())
1344
+ if (Multisig .empty ())
1344
1345
res.pushKV (" Result" , " No utxos found in specified range" );
1345
1346
1346
1347
else
@@ -1354,25 +1355,26 @@ UniValue scanforunspent(const UniValue& params, bool fHelp)
1354
1355
exportoutput << " <?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n <id>\n " ;
1355
1356
1356
1357
else if (nType == 1 )
1357
- exportoutput << " TXID / VOUT / Value\n " ;
1358
+ exportoutput << " TXID / VOUT / Value / HEIGHT \n " ;
1358
1359
1359
1360
}
1360
1361
1361
1362
int nCount = 0 ;
1362
1363
int64_t nValue = 0 ;
1363
1364
1364
1365
// Process the map
1365
- for (const auto & data : uMultisig )
1366
+ for (const auto & data : Multisig )
1366
1367
{
1367
1368
nCount++;
1368
1369
1369
- nValue += data.first ;
1370
+ nValue += data.second . first ;
1370
1371
1371
1372
UniValue txdata (UniValue::VOBJ);
1372
1373
1373
- txdata.pushKV (" txid" , data.second .first .ToString ());
1374
- txdata.pushKV (" vout" , (int )data.second .second );
1375
- txdata.pushKV (" value" , ValueFromAmount (data.first ));
1374
+ txdata.pushKV (" txid" , data.first .first .ToString ());
1375
+ txdata.pushKV (" vout" , (int )data.first .second );
1376
+ txdata.pushKV (" value" , ValueFromAmount (data.second .first ));
1377
+ txdata.pushKV (" height" , data.second .second );
1376
1378
1377
1379
txres.push_back (txdata);
1378
1380
// Parse into type file here
@@ -1382,14 +1384,15 @@ UniValue scanforunspent(const UniValue& params, bool fHelp)
1382
1384
if (nType == 0 )
1383
1385
{
1384
1386
exportoutput << spacing << " <tx id=\" " << nCount << " \" >\n " ;
1385
- exportoutput << spacing << spacing << " <txid>" << data.second .first .ToString () << " </txid>\n " ;
1386
- exportoutput << spacing << spacing << " <vout>" << data.second .second << " </vout>\n " ;
1387
- exportoutput << spacing << spacing << " <value>" << std::fixed << setprecision (8 ) << data.first / (double )COIN << " </value>\n " ;
1387
+ exportoutput << spacing << spacing << " <txid>" << data.first .first .ToString () << " </txid>\n " ;
1388
+ exportoutput << spacing << spacing << " <vout>" << data.first .second << " </vout>\n " ;
1389
+ exportoutput << spacing << spacing << " <value>" << std::fixed << setprecision (8 ) << data.second .first / (double )COIN << " </value>\n " ;
1390
+ exportoutput << spacing << spacing << " <height>" << data.second .second << " </height>\n " ;
1388
1391
exportoutput << spacing << " </tx>\n " ;
1389
1392
}
1390
1393
1391
1394
else if (nType == 1 )
1392
- exportoutput << data.second .first .ToString () << " / " << data.second .second << " / " << std::fixed << setprecision (8 ) << data.first / (double )COIN << " \n " ;
1395
+ exportoutput << data.first .first .ToString () << " / " << data.first .second << " / " << std::fixed << setprecision (8 ) << data.second . first / (double )COIN << " / " << data. second . second << " \n " ;
1393
1396
}
1394
1397
}
1395
1398
0 commit comments