@@ -228,6 +228,7 @@ class GetinfoRequestHandler: public BaseRequestHandler
228
228
const int ID_NETWORKINFO = 0 ;
229
229
const int ID_BLOCKCHAININFO = 1 ;
230
230
const int ID_WALLETINFO = 2 ;
231
+ const int ID_BALANCES = 3 ;
231
232
232
233
/* * Create a simulated `getinfo` request. */
233
234
UniValue PrepareRequest (const std::string& method, const std::vector<std::string>& args) override
@@ -239,16 +240,17 @@ class GetinfoRequestHandler: public BaseRequestHandler
239
240
result.push_back (JSONRPCRequestObj (" getnetworkinfo" , NullUniValue, ID_NETWORKINFO));
240
241
result.push_back (JSONRPCRequestObj (" getblockchaininfo" , NullUniValue, ID_BLOCKCHAININFO));
241
242
result.push_back (JSONRPCRequestObj (" getwalletinfo" , NullUniValue, ID_WALLETINFO));
243
+ result.push_back (JSONRPCRequestObj (" getbalances" , NullUniValue, ID_BALANCES));
242
244
return result;
243
245
}
244
246
245
247
/* * Collect values from the batch and form a simulated `getinfo` reply. */
246
248
UniValue ProcessReply (const UniValue &batch_in) override
247
249
{
248
250
UniValue result (UniValue::VOBJ);
249
- std::vector<UniValue> batch = JSONRPCProcessBatchReply (batch_in, 3 );
250
- // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on
251
- // getwalletinfo() is allowed to fail in case there is no wallet.
251
+ std::vector<UniValue> batch = JSONRPCProcessBatchReply (batch_in, batch_in. size () );
252
+ // Errors in getnetworkinfo() and getblockchaininfo() are fatal, pass them on;
253
+ // getwalletinfo() and getbalances() are allowed to fail if there is no wallet.
252
254
if (!batch[ID_NETWORKINFO][" error" ].isNull ()) {
253
255
return batch[ID_NETWORKINFO];
254
256
}
@@ -265,13 +267,15 @@ class GetinfoRequestHandler: public BaseRequestHandler
265
267
result.pushKV (" difficulty" , batch[ID_BLOCKCHAININFO][" result" ][" difficulty" ]);
266
268
result.pushKV (" chain" , UniValue (batch[ID_BLOCKCHAININFO][" result" ][" chain" ]));
267
269
if (!batch[ID_WALLETINFO][" result" ].isNull ()) {
268
- result.pushKV (" balance" , batch[ID_WALLETINFO][" result" ][" balance" ]);
269
270
result.pushKV (" keypoolsize" , batch[ID_WALLETINFO][" result" ][" keypoolsize" ]);
270
271
if (!batch[ID_WALLETINFO][" result" ][" unlocked_until" ].isNull ()) {
271
272
result.pushKV (" unlocked_until" , batch[ID_WALLETINFO][" result" ][" unlocked_until" ]);
272
273
}
273
274
result.pushKV (" paytxfee" , batch[ID_WALLETINFO][" result" ][" paytxfee" ]);
274
275
}
276
+ if (!batch[ID_BALANCES][" result" ].isNull ()) {
277
+ result.pushKV (" balance" , batch[ID_BALANCES][" result" ][" mine" ][" trusted" ]);
278
+ }
275
279
result.pushKV (" relayfee" , batch[ID_NETWORKINFO][" result" ][" relayfee" ]);
276
280
result.pushKV (" warnings" , batch[ID_NETWORKINFO][" result" ][" warnings" ]);
277
281
return JSONRPCReplyObj (result, NullUniValue, 1 );
0 commit comments