From 890302ab2088f1c5554bd4e834a7a2cdb2f1fc5b Mon Sep 17 00:00:00 2001 From: emjshrx Date: Sun, 25 Jun 2023 13:07:39 +0530 Subject: [PATCH 1/3] feat: align 'estimatesmartfee' rpc with bitcoind --- lib/node/rpc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node/rpc.js b/lib/node/rpc.js index f200f216b..84cbb578a 100644 --- a/lib/node/rpc.js +++ b/lib/node/rpc.js @@ -2231,7 +2231,7 @@ class RPC extends RPCBase { fee = Amount.btc(fee, true); return { - fee: fee, + feerate: fee, blocks: blocks }; } From c50db1bd1513e29d14e62697a7eb8f9b1ad16502 Mon Sep 17 00:00:00 2001 From: emjshrx Date: Sat, 15 Jul 2023 10:38:57 +0530 Subject: [PATCH 2/3] docs: add change to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16bdadd50..7f33d5ad0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ node ./migrate/walletdb7to8.js /path/to/bcoin/wallet #### RPC - Added `getnodeaddresses` which returns entries from the hostlist. +- Updated `estimatesmartfee` to return attribute `feerate` (previously `fee`). ### Indexer changes From 350e6b09da86466f970d2c44f1b1c2a2d48bee0d Mon Sep 17 00:00:00 2001 From: emjshrx Date: Sat, 15 Jul 2023 10:43:42 +0530 Subject: [PATCH 3/3] test: add test for estimatesmartfee --- test/node-rpc-test.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/node-rpc-test.js b/test/node-rpc-test.js index 823203db3..7288cf64e 100644 --- a/test/node-rpc-test.js +++ b/test/node-rpc-test.js @@ -542,16 +542,22 @@ describe('RPC', function() { }); describe('utilities', function() { - // 0-in, 2-out - const rawTX1 = - '0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420cc' + - 'f0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722' + - '510fce9f37f0423b88ac00000000'; - it('should decoderawtransaction', async () => { + // 0-in, 2-out + const rawTX1 = + '0100000000024e61bc00000000001976a914fbdd46898a6d70a682cbd34420cc' + + 'f0b6bb64493788acf67e4929010000001976a9141b002b6fc0f457bf8d092722' + + '510fce9f37f0423b88ac00000000'; const result = await nclient.execute('decoderawtransaction', [rawTX1]); assert.strictEqual(result.vin.length, 0); assert.strictEqual(result.vout.length, 2); }); + it('should estimate fee rate', async () => { + const result = await nclient.execute('estimatesmartfee', [6]); + assert.deepStrictEqual(result, { + blocks: 6, + feerate: -1 + }); + }); }); });