From 92b795f12247c518fcebdfadde04e8b69590803b Mon Sep 17 00:00:00 2001 From: Dagur Valberg Johannsson Date: Fri, 22 Feb 2019 23:13:05 +0100 Subject: [PATCH] Let version returned from getnetworkinfo be an int This closer mimics the Bitcoin Core RPC interface --- lib/node/rpc.js | 9 ++++++++- test/http-test.js | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/node/rpc.js b/lib/node/rpc.js index 6f5c31971..f8bc09570 100644 --- a/lib/node/rpc.js +++ b/lib/node/rpc.js @@ -302,8 +302,15 @@ class RPC extends RPCBase { }); } + const versionToInt = (version) => { + const majorminor = version.split('.', 3); + return majorminor[0] * 1000000 + + majorminor[1] * 10000 + + majorminor[2] * 100; + }; + return { - version: pkg.version, + version: versionToInt(pkg.version), subversion: this.pool.options.agent, protocolversion: this.pool.options.version, localservices: hex32(this.pool.options.services), diff --git a/test/http-test.js b/test/http-test.js index 36ed4ba9b..49c0129b2 100644 --- a/test/http-test.js +++ b/test/http-test.js @@ -258,6 +258,11 @@ describe('HTTP', function() { }); }); + it('should get version as int from getnetworkinfo', async () => { + const info = await nclient.execute('getnetworkinfo', []); + assert.typeOf(info.version, 'number'); + }); + it('should cleanup', async () => { consensus.COINBASE_MATURITY = 100; await wallet.close();