rpc-bitcoin
Advanced tools
Comparing version
@@ -24,4 +24,7 @@ { | ||
"camelcase": "off", | ||
"@typescript-eslint/camelcase": ["error", { "properties": "never" }] | ||
"@typescript-eslint/camelcase": [ | ||
"error", | ||
{ "properties": "never", "allow": ["hash_or_height", "include_mempool"] } | ||
] | ||
} | ||
} |
{ | ||
"name": "rpc-bitcoin", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "A TypeScript library to make RPC and HTTP REST requests to Bitcoin Core", | ||
@@ -36,7 +36,7 @@ "main": "build/index.js", | ||
"@types/mocha": "^5.2.7", | ||
"@typescript-eslint/eslint-plugin": "^2.4.0", | ||
"@typescript-eslint/parser": "^2.4.0", | ||
"@typescript-eslint/eslint-plugin": "^2.5.0", | ||
"@typescript-eslint/parser": "^2.5.0", | ||
"eslint": "^6.5.1", | ||
"mocha": "^6.2.2", | ||
"nock": "^11.4.0", | ||
"nock": "^11.5.0", | ||
"prettier": "^1.18.2", | ||
@@ -43,0 +43,0 @@ "ts-node": "^8.4.1", |
@@ -222,2 +222,10 @@ # rpc-bitcoin [](https://travis-ci.com/vansergen/rpc-bitcoin) | ||
### ZMQ | ||
- [`getzmqnotifications`](https://bitcoincore.org/en/doc/0.17.0/rpc/zmq/getzmqnotifications/) | ||
```javascript | ||
const result = await client.getzmqnotifications(); | ||
``` | ||
## [HTTP REST](https://bitcoin.org/en/developer-reference#http-rest) | ||
@@ -224,0 +232,0 @@ |
@@ -258,2 +258,9 @@ import { RESTClient, RESTIniOptions } from "./rest"; | ||
} | ||
/** | ||
* @description Returns information about the active ZeroMQ notifications. | ||
*/ | ||
async getzmqnotifications() { | ||
return this.rpc("getzmqnotifications"); | ||
} | ||
} |
@@ -806,4 +806,4 @@ import { | ||
const action = "start"; | ||
const desc_1 = "addr(mxosQ4CvQR8ipfWdRktyB3u16tauEdamGc)"; | ||
const desc_2: Descriptor = { | ||
const desc1 = "addr(mxosQ4CvQR8ipfWdRktyB3u16tauEdamGc)"; | ||
const desc2: Descriptor = { | ||
desc: | ||
@@ -813,3 +813,3 @@ "wpkh([d34db33f/84'/0'/0']tpubD6NzVbkrYhZ4YTN7usjEzYmfu4JKqnfp9RCbDmdKH78vTyuwgQat8vRw5cX1YaZZvFfQrkHrM2XsyfA8cZE1thA3guTBfTkKqbhCDpcKFLG/0/*)#8gfuh6ex", | ||
}; | ||
const scanobjects = [desc_1, desc_2]; | ||
const scanobjects = [desc1, desc2]; | ||
const params: ScanTxOutSetParams = { action, scanobjects }; | ||
@@ -895,2 +895,31 @@ const request = { params, method: "scantxoutset", id, jsonrpc }; | ||
}); | ||
suite("Zmq", () => { | ||
test(".getzmqnotifications()", async () => { | ||
const params = {}; | ||
const request = { params, method: "getzmqnotifications", id, jsonrpc }; | ||
const result = [ | ||
{ | ||
type: "pubhashblock", | ||
address: "tcp://127.0.0.1:3333", | ||
hwm: 1000 | ||
}, | ||
{ type: "pubhashtx", address: "tcp://127.0.0.1:3333", hwm: 1000 }, | ||
{ | ||
type: "pubrawblock", | ||
address: "tcp://127.0.0.1:3333", | ||
hwm: 1000 | ||
}, | ||
{ type: "pubrawtx", address: "tcp://127.0.0.1:3333", hwm: 1000 } | ||
]; | ||
const response = { result, error, id }; | ||
nock(uri) | ||
.post("/", request) | ||
.times(1) | ||
.basicAuth(auth) | ||
.reply(200, response); | ||
const data = await client.getzmqnotifications(); | ||
assert.deepStrictEqual(data, result); | ||
}); | ||
}); | ||
}); |
275504
0.46%2436
1.54%316
2.6%