Skip to content

Commit 23a0184

Browse files
committed
Wallet: add default responses & fix endpoints bug
1 parent 3cc801a commit 23a0184

File tree

1 file changed

+45
-3
lines changed

1 file changed

+45
-3
lines changed

src/stores/wallet.js

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export default class Wallet {
5454

5555
/** Refresh network info every 3s until there are at least 3 peers. */
5656
autorunAsync(() => {
57-
if (this.peers.length < 3) {
57+
if (
58+
this.peers.length < 3 ||
59+
this.info.getnetworkinfo.endpoints.length === 0
60+
) {
5861
this.restart('getNetworkInfo')
5962
}
6063
}, 3 * 1000)
@@ -266,6 +269,11 @@ export default class Wallet {
266269
*/
267270
@computed get info () {
268271
return this.responses.entries().reduce((responses, [key, value]) => {
272+
/** RPC getnetworkinfo returns null if endpoints array is empty. */
273+
if (key === 'getnetworkinfo' && value.endpoints === null) {
274+
value.endpoints = []
275+
}
276+
269277
responses[key] = value
270278
return responses
271279
}, {
@@ -281,14 +289,48 @@ export default class Wallet {
281289
'proof-of-work': 0,
282290
'proof-of-stake': 0
283291
},
292+
'getmininginfo': {
293+
blocks: 0,
294+
currentblocksize: 0,
295+
currentblocktx: 0,
296+
difficulty: 0,
297+
errors: '',
298+
generate: null,
299+
genproclimit: 0,
300+
hashespersec: 0,
301+
networkhashps: 0,
302+
pooledtx: 0,
303+
testnet: null
304+
},
284305
'getincentiveinfo': {
285-
collateralbalance: 0
306+
walletaddress: '',
307+
collateralrequired: 0,
308+
collateralbalance: 0,
309+
networkstatus: '',
310+
votecandidate: false,
311+
votescore: 0
286312
},
287313
'getinfo': {
314+
version: ':',
315+
protocolversion: 0,
316+
walletversion: 0,
288317
balance: 0,
289-
version: ':'
318+
newmint: 0,
319+
stake: 0,
320+
blocks: 0,
321+
moneysupply: 0,
322+
connections: 0,
323+
ip: '',
324+
port: 0,
325+
difficulty: 0,
326+
testnet: false,
327+
keypoolsize: 0,
328+
paytxfee: 0,
329+
relayfee: 0
290330
},
291331
'getnetworkinfo': {
332+
collateralized: 0,
333+
endpoints: [],
292334
tcp: { connections: 0 },
293335
udp: { connections: 0 }
294336
}

0 commit comments

Comments
 (0)