From 2ede94c85cc26f6e8d5dc810748c1dc68166f2a5 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:34:13 +0300 Subject: [PATCH 01/23] feat(rpc): add createmultisig method --- src/rpc.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index e3d8285..8f2dae4 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -107,6 +107,12 @@ export type SetBanParams = { absolute?: boolean; }; +export type CreateMultiSigParams = { + nrequired: number; + keys: string[]; + address_type?: "legacy" | "p2sh-segwit" | "bech32"; +}; + export class RPCClient extends RESTClient { wallet?: string; fullResponse?: boolean; @@ -514,6 +520,17 @@ export class RPCClient extends RESTClient { return this.rpc("setnetworkactive", { state }); } + /** + * @description Creates a multi-signature address with n signature of m keys required. + */ + async createmultisig({ + nrequired, + keys, + address_type = "legacy" + }: CreateMultiSigParams) { + return this.rpc("createmultisig", { nrequired, keys, address_type }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From 4e13d4fed8bd36fc21db3ee23cde528947f71a98 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:34:38 +0300 Subject: [PATCH 02/23] doc(readme): add createmultisig example --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f99d4ab..c25ba4b 100644 --- a/README.md +++ b/README.md @@ -426,6 +426,20 @@ const state = false; const result = await client.setnetworkactive({ state }); ``` +### Util + +- [`createmultisig`](https://bitcoin.org/en/developer-reference#createmultisig) + +```javascript +const nrequired = 2; +const keys = [ + "03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd", + "03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626" +]; +const address_type = "bech32"; +const result = await client.createmultisig({ nrequired, keys, address_type }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From d27296162bca518c7eff26af4b75c068cc02ef42 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:35:06 +0300 Subject: [PATCH 03/23] test(rpc): add createmultisig --- test/rpc.spec.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index ed17eb2..28c08fb 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1582,6 +1582,32 @@ suite("RPCClient", () => { }); }); + suite("Util", () => { + test(".createmultisig()", async () => { + const nrequired = 2; + const keys = [ + "03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd", + "03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626" + ]; + const address_type: "bech32" = "bech32"; + const params = { nrequired, keys, address_type }; + const request = { params, method: "createmultisig", id, jsonrpc }; + const result = { + address: + "tb1q0jnggjwnn22a4ywxc2pcw86c0d6tghqkgk3hlryrxl7nmxkylmnqdcdsu7", + redeemScript: + "522103789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd2103dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a6162652ae" + }; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.createmultisig(params); + assert.deepStrictEqual(data, result); + }); + }); + suite("Zmq", () => { test(".getzmqnotifications()", async () => { const params = {}; From 1fe894a0e9f85dfaa10ad200a7d9928a96349b39 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:36:01 +0300 Subject: [PATCH 04/23] feat(rpc): add deriveaddresses method --- src/rpc.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 8f2dae4..e50ffbc 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -113,6 +113,11 @@ export type CreateMultiSigParams = { address_type?: "legacy" | "p2sh-segwit" | "bech32"; }; +export type DeriveAddressesParams = { + descriptor: string; + range?: number | [number, number]; +}; + export class RPCClient extends RESTClient { wallet?: string; fullResponse?: boolean; @@ -531,6 +536,13 @@ export class RPCClient extends RESTClient { return this.rpc("createmultisig", { nrequired, keys, address_type }); } + /** + * @description Derives one or more addresses corresponding to an output descriptor. + */ + async deriveaddresses({ descriptor, range }: DeriveAddressesParams) { + return this.rpc("deriveaddresses", { descriptor, range }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From 7ccccf0bdae045642b9b05b276f55ef4eae9e7a9 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:37:05 +0300 Subject: [PATCH 05/23] doc(readme): add deriveaddresses example --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index c25ba4b..43b37fc 100644 --- a/README.md +++ b/README.md @@ -440,6 +440,15 @@ const address_type = "bech32"; const result = await client.createmultisig({ nrequired, keys, address_type }); ``` +- [`deriveaddresses`](https://bitcoin.org/en/developer-reference#deriveaddresses) + +```javascript +const descriptor = + "wpkh([d34db33f/84'/0'/0']tpubD6NzVbkrYhZ4YTN7usjEzYmfu4JKqnfp9RCbDmdKH78vTyuwgQat8vRw5cX1YaZZvFfQrkHrM2XsyfA8cZE1thA3guTBfTkKqbhCDpcKFLG/0/*)#8gfuh6ex"; +const range = [0, 2]; +const result = await client.deriveaddresses({ descriptor, range }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From d7fe4707b9e6b696ba90897651cb5e82084cb21e Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 20:39:12 +0300 Subject: [PATCH 06/23] test(rpc): add deriveaddresses --- test/rpc.spec.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index 28c08fb..cfbec6a 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1606,6 +1606,26 @@ suite("RPCClient", () => { const data = await client.createmultisig(params); assert.deepStrictEqual(data, result); }); + + test(".deriveaddresses()", async () => { + const descriptor = + "wpkh([d34db33f/84'/0'/0']tpubD6NzVbkrYhZ4YTN7usjEzYmfu4JKqnfp9RCbDmdKH78vTyuwgQat8vRw5cX1YaZZvFfQrkHrM2XsyfA8cZE1thA3guTBfTkKqbhCDpcKFLG/0/*)#8gfuh6ex"; + const range: [number, number] = [0, 2]; + const params = { descriptor, range }; + const request = { params, method: "deriveaddresses", id, jsonrpc }; + const result = [ + "tb1q7as9cz0t8rfng5f0xdklfgyp0x6ya0tu6ckaqs", + "tb1q0aducdmz77tfu4dhfez8ayycmp2pz6jwy85hhn", + "tb1qsdqewd8upv66txx48qssr0an5r3llaxtwqzytk" + ]; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.deriveaddresses(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From 223515df4d102e6ef739bedb54a5bef50bed16bd Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:19:22 +0300 Subject: [PATCH 07/23] feat(rpc): add estimatesmartfee method --- src/rpc.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index e50ffbc..84834e7 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -543,6 +543,16 @@ export class RPCClient extends RESTClient { return this.rpc("deriveaddresses", { descriptor, range }); } + /** + * @description Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within `conf_target` blocks if possible and return the number of blocks for which the estimate is valid. + */ + async estimatesmartfee({ + conf_target, + estimate_mode = "CONSERVATIVE" + }: EstimateSmartFeeParams) { + return this.rpc("estimatesmartfee", { conf_target, estimate_mode }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From 28438a92a82c8da05d2f80ac95c88ede026d4cbe Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:20:19 +0300 Subject: [PATCH 08/23] doc(readme): add estimatesmartfee example --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 43b37fc..404f3f4 100644 --- a/README.md +++ b/README.md @@ -449,6 +449,14 @@ const range = [0, 2]; const result = await client.deriveaddresses({ descriptor, range }); ``` +- [`estimatesmartfee`](https://bitcoin.org/en/developer-reference#estimatesmartfee) + +```javascript +const conf_target = 2; +const estimate_mode = "ECONOMICAL"; +const result = await client.estimatesmartfee({ conf_target, estimate_mode }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From 3856f2cfec404423fc0912115b2ece78181b2f33 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:26:48 +0300 Subject: [PATCH 09/23] test(rpc): add estimatesmartfee --- test/rpc.spec.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index cfbec6a..394f0fc 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1626,6 +1626,20 @@ suite("RPCClient", () => { const data = await client.deriveaddresses(params); assert.deepStrictEqual(data, result); }); + + test(".estimatesmartfee()", async () => { + const estimate_mode: "ECONOMICAL" = "ECONOMICAL"; + const params = { conf_target: 2, estimate_mode }; + const request = { params, method: "estimatesmartfee", id, jsonrpc }; + const result = { feerate: 0.00001, blocks: 2 }; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.estimatesmartfee(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From 1bacb3339348623a3981f011844da4ab6a0de1ca Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:28:24 +0300 Subject: [PATCH 10/23] feat(rpc): add getdescriptorinfo method --- src/rpc.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 84834e7..51c392d 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -118,6 +118,11 @@ export type DeriveAddressesParams = { range?: number | [number, number]; }; +export type EstimateSmartFeeParams = { + conf_target: number; + estimate_mode?: "UNSET" | "ECONOMICAL" | "CONSERVATIVE"; +}; + export class RPCClient extends RESTClient { wallet?: string; fullResponse?: boolean; @@ -553,6 +558,13 @@ export class RPCClient extends RESTClient { return this.rpc("estimatesmartfee", { conf_target, estimate_mode }); } + /** + * @description Analyses a descriptor. + */ + async getdescriptorinfo({ descriptor }: { descriptor: string }) { + return this.rpc("getdescriptorinfo", { descriptor }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From dd47e95f7d0a24d21aba820e5d3542aae85f60b0 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:28:42 +0300 Subject: [PATCH 11/23] doc(readme): add getdescriptorinfo example --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 404f3f4..fa34c5e 100644 --- a/README.md +++ b/README.md @@ -457,6 +457,14 @@ const estimate_mode = "ECONOMICAL"; const result = await client.estimatesmartfee({ conf_target, estimate_mode }); ``` +- [`getdescriptorinfo`](https://bitcoin.org/en/developer-reference#getdescriptorinfo) + +```javascript +const descriptor = + "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)"; +const result = await client.getdescriptorinfo({ descriptor }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From 850ca19f88cebead323b5727a27a8e968e8f0396 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:36:06 +0300 Subject: [PATCH 12/23] test(rpc): add getdescriptorinfo --- test/rpc.spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index 394f0fc..85ddfac 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1640,6 +1640,27 @@ suite("RPCClient", () => { const data = await client.estimatesmartfee(params); assert.deepStrictEqual(data, result); }); + + test(".getdescriptorinfo()", async () => { + const descriptor = + "wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)"; + const params = { descriptor }; + const request = { params, method: "getdescriptorinfo", id, jsonrpc }; + const result = { + descriptor: + "wpkh([d34db33f/84'/0'/0']0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)#n9g43y4k", + isrange: false, + issolvable: true, + hasprivatekeys: false + }; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.getdescriptorinfo(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From 3a2790968c7d685ea0b5377a464a33dc50182e3e Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:37:44 +0300 Subject: [PATCH 13/23] feat(rpc): add signmessagewithprivkey method --- src/rpc.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 51c392d..3059025 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -565,6 +565,16 @@ export class RPCClient extends RESTClient { return this.rpc("getdescriptorinfo", { descriptor }); } + /** + * @description Sign a message with the private key of an address. + */ + async signmessagewithprivkey({ + privkey, + message + }: SignMessageWithPrivKeyParams) { + return this.rpc("signmessagewithprivkey", { privkey, message }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From 46be0dea09f2017f4db759425069d783c8a4e5f2 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:51:18 +0300 Subject: [PATCH 14/23] doc(readme): add signmessagewithprivkey example --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index fa34c5e..16718ac 100644 --- a/README.md +++ b/README.md @@ -465,6 +465,14 @@ const descriptor = const result = await client.getdescriptorinfo({ descriptor }); ``` +- [`signmessagewithprivkey`](https://bitcoin.org/en/developer-reference#signmessagewithprivkey) + +```javascript +const privkey = "yourPrivateKey"; +const message = "Hello World"; +const result = await client.signmessagewithprivkey({ privkey, message }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From 9b99a98a6389593a0c4fc5c6ae2f875c9de52008 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:51:55 +0300 Subject: [PATCH 15/23] test(rpc): add signmessagewithprivkey --- src/rpc.ts | 5 +++++ test/rpc.spec.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 3059025..3fc7bb7 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -123,6 +123,11 @@ export type EstimateSmartFeeParams = { estimate_mode?: "UNSET" | "ECONOMICAL" | "CONSERVATIVE"; }; +export type SignMessageWithPrivKeyParams = { + privkey: string; + message: string; +}; + export class RPCClient extends RESTClient { wallet?: string; fullResponse?: boolean; diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index 85ddfac..d5af5d5 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1661,6 +1661,22 @@ suite("RPCClient", () => { const data = await client.getdescriptorinfo(params); assert.deepStrictEqual(data, result); }); + + test(".signmessagewithprivkey()", async () => { + const privkey = "cPGLkRL4zvHfpcEkjPb93GEHth8WZpTJH2YCCoYWS7kHcFFarn8U"; + const message = "Hello World"; + const params = { privkey, message }; + const request = { params, method: "signmessagewithprivkey", id, jsonrpc }; + const result = + "IIXi7nhOGKbW2uOW2cmV/BbOvlIDzVu0KTZdvntP634/BRL2DmFSvtwifkDMa+pDKd+eRrTbEi6XVAc82JKTiwA="; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.signmessagewithprivkey(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From b0580dfb5b6d97842729caa1aa7a1487e661332e Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:52:36 +0300 Subject: [PATCH 16/23] feat(rpc): add validateaddress method --- src/rpc.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 3fc7bb7..9cff01e 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -580,6 +580,13 @@ export class RPCClient extends RESTClient { return this.rpc("signmessagewithprivkey", { privkey, message }); } + /** + * @description Return information about the given bitcoin address. + */ + async validateaddress({ address }: { address: string }) { + return this.rpc("validateaddress", { address }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From 7d6d3a91e8e215f545cab1963be5c4e3a3ae7949 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:53:15 +0300 Subject: [PATCH 17/23] doc(readme): add validateaddress example --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 16718ac..6b4b8fa 100644 --- a/README.md +++ b/README.md @@ -473,6 +473,13 @@ const message = "Hello World"; const result = await client.signmessagewithprivkey({ privkey, message }); ``` +- [`validateaddress`](https://bitcoin.org/en/developer-reference#validateaddress) + +```javascript +const address = "1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1"; +const result = await client.validateaddress({ address }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From 319a43b02cc9a058bd17f3b05097fe3e8423c178 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:58:02 +0300 Subject: [PATCH 18/23] test(rpc): add validateaddress --- test/rpc.spec.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index d5af5d5..919cf89 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1677,6 +1677,27 @@ suite("RPCClient", () => { const data = await client.signmessagewithprivkey(params); assert.deepStrictEqual(data, result); }); + + test(".validateaddress()", async () => { + const params = { address: "tb1qmv634mfk34sks9z3tcwwncd9ug0why3a0pl4px" }; + const request = { params, method: "validateaddress", id, jsonrpc }; + const result = { + isvalid: true, + address: "tb1qmv634mfk34sks9z3tcwwncd9ug0why3a0pl4px", + scriptPubKey: "0014db351aed368d616814515e1ce9e1a5e21eeb923d", + isscript: false, + iswitness: true, + witness_version: 0, + witness_program: "db351aed368d616814515e1ce9e1a5e21eeb923d" + }; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.validateaddress(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From 4c70291ec012fc972a1357762e9e8502f9c6095f Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:58:23 +0300 Subject: [PATCH 19/23] feat(rpc): add verifymessage method --- src/rpc.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/rpc.ts b/src/rpc.ts index 9cff01e..00dbf82 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -128,6 +128,12 @@ export type SignMessageWithPrivKeyParams = { message: string; }; +export type VerifyMessageParams = { + address: string; + signature: string; + message: string; +}; + export class RPCClient extends RESTClient { wallet?: string; fullResponse?: boolean; @@ -587,6 +593,13 @@ export class RPCClient extends RESTClient { return this.rpc("validateaddress", { address }); } + /** + * @description Verify a signed message + */ + async verifymessage({ address, signature, message }: VerifyMessageParams) { + return this.rpc("verifymessage", { address, signature, message }); + } + /** * @description Returns information about the active ZeroMQ notifications. */ From cdbe5527bfd76da7c04726f0647441a99b131204 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 22:58:52 +0300 Subject: [PATCH 20/23] doc(readme): add verifymessage example --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6b4b8fa..edb0bcc 100644 --- a/README.md +++ b/README.md @@ -480,6 +480,16 @@ const address = "1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1"; const result = await client.validateaddress({ address }); ``` +- [`verifymessage`](https://bitcoin.org/en/developer-reference#verifymessage) + +```javascript +const address = "myv3xs1BBBhaDVU62LFNBho2zSp4KLBkgK"; +const message = "Hello World"; +const signature = + "H14/QyrMj8e63GyEXBDDWnWrplXK3OORnMc3B+fEOOisbNFEAQuNB9myAH9qs7h1VNJb1xq1ytPQqiLcmSwwPv8="; +const result = await client.verifymessage({ address, message, signature }); +``` + ### ZMQ - [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) From 78302dc7a61b1f23ebcd3cb7454c40500c6b1cd7 Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 23:01:56 +0300 Subject: [PATCH 21/23] test(rpc): add verifymessage --- test/rpc.spec.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/rpc.spec.ts b/test/rpc.spec.ts index 919cf89..c3dba6a 100644 --- a/test/rpc.spec.ts +++ b/test/rpc.spec.ts @@ -1698,6 +1698,23 @@ suite("RPCClient", () => { const data = await client.validateaddress(params); assert.deepStrictEqual(data, result); }); + + test(".verifymessage()", async () => { + const address = "myv3xs1BBBhaDVU62LFNBho2zSp4KLBkgK"; + const signature = + "H14/QyrMj8e63GyEXBDDWnWrplXK3OORnMc3B+fEOOisbNFEAQuNB9myAH9qs7h1VNJb1xq1ytPQqiLcmSwwPv8="; + const message = "Hello World"; + const params = { address, signature, message }; + const request = { params, method: "verifymessage", id, jsonrpc }; + const result = true; + nock(uri) + .post("/", request) + .times(1) + .basicAuth(auth) + .reply(200, { result, error, id }); + const data = await client.verifymessage(params); + assert.deepStrictEqual(data, result); + }); }); suite("Zmq", () => { From 7de61cbd3775c8e6cbc78d1aeb9e74cbebd2e93e Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 23:02:31 +0300 Subject: [PATCH 22/23] chore(eslint): add camelcase exceptions --- .eslintrc.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index bd3056e..6bb0b5d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -29,7 +29,10 @@ "hash_or_height", "include_mempool", "template_request", - "fee_delta" + "fee_delta", + "address_type", + "estimate_mode", + "conf_target" ] } ] From 4f8abe6854de2c3ca47e2f8b32e9015ea2cac99f Mon Sep 17 00:00:00 2001 From: Sergey Bakulin Date: Thu, 24 Oct 2019 23:08:45 +0300 Subject: [PATCH 23/23] metadata: bump version to 1.8.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 89e1682..88b0fc1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rpc-bitcoin", - "version": "1.7.0", + "version": "1.8.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 44ab22a..1a1cbdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rpc-bitcoin", - "version": "1.7.0", + "version": "1.8.0", "description": "A TypeScript library to make RPC and HTTP REST requests to Bitcoin Core", "main": "build/index.js", "type": "module",