diff --git a/README.md b/README.md index ed51fc4..22186b4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Electrum Protocol Client for Node.js +## what is this + +https://electrum.org/ + +electrum is bitcoin wallet service. +This is a library of Node.js that can communicate with the electrum(x) server. + ## install ``` @@ -14,6 +21,8 @@ npm i electrum-client * TCP / TLS * JSON-RPC * Subscribe Message +* High Performance Message +* no dependency for other library ## usage @@ -34,3 +43,4 @@ const main = async () => { main() ``` + diff --git a/example/riaa_client_transaction_send.js b/example/riaa_client_transaction_send.js new file mode 100644 index 0000000..1abaace --- /dev/null +++ b/example/riaa_client_transaction_send.js @@ -0,0 +1,38 @@ +'use strict'; +const ElectrumClient = require('electrum-client'); + +const createRiaaClient = (port, host, protocol, options) => { + return (params, promise) => { + const name = params.join(':') + const client = new ElectrumClient(port, host, protocol, options) + console.time(name) + return client.connect().then( () => { + return promise(client) + }).catch( e => { + client.close() + console.timeEnd(name) + throw e + }).then( res => { + client.close() + console.timeEnd(name) + return res + }) + } + +} + +const main = async(hex) => { + const connect = createRiaaClient(50001, 'electrumx.tamami-foundation.org', 'tcp') + await connect(['blockchainTransaction_broadcast', hex], async(client) => { + const ver = await client.server_version('2.7.11', '1.0') + console.log(ver) + const result = await client.blockchainTransaction_broadcast(hex) + console.log(result) + }) +} + +const getopt = () => { + return process.argv.slice(2)[0] +} + +main(getopt()) diff --git a/package.json b/package.json index d885459..ccfca26 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,12 @@ { "name": "electrum-client", - "version": "0.0.4", + "version": "0.0.5", "description": "Electrum protocol client for node.js", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "dependencies": { - }, + "dependencies": {}, "repository": { "type": "git", "url": "git://github.com/you21979/node-electrum-client.git" @@ -20,6 +19,9 @@ "electrum", "bitcoin" ], + "engines": { + "node": ">=6" + }, "author": "Yuki Akiyama", "license": "MIT" }