Skip to content

Commit 71e7dc3

Browse files
committed
add riaa client sample
1 parent d697c70 commit 71e7dc3

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Electrum Protocol Client for Node.js
44

5+
## what is this
6+
7+
https://electrum.org/
8+
9+
electrum is bitcoin wallet service.
10+
This is a library of Node.js that can communicate with the electrum(x) server.
11+
512
## install
613

714
```
@@ -14,6 +21,8 @@ npm i electrum-client
1421
* TCP / TLS
1522
* JSON-RPC
1623
* Subscribe Message
24+
* High Performance Message
25+
* no dependency for other library
1726

1827
## usage
1928

@@ -34,3 +43,4 @@ const main = async () => {
3443
main()
3544
```
3645

46+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
const ElectrumClient = require('electrum-client');
3+
4+
const createRiaaClient = (port, host, protocol, options) => {
5+
return (params, promise) => {
6+
const name = params.join(':')
7+
const client = new ElectrumClient(port, host, protocol, options)
8+
console.time(name)
9+
return client.connect().then( () => {
10+
return promise(client)
11+
}).catch( e => {
12+
client.close()
13+
console.timeEnd(name)
14+
throw e
15+
}).then( res => {
16+
client.close()
17+
console.timeEnd(name)
18+
return res
19+
})
20+
}
21+
22+
}
23+
24+
const main = async(hex) => {
25+
const connect = createRiaaClient(50001, 'electrumx.tamami-foundation.org', 'tcp')
26+
await connect(['blockchainTransaction_broadcast', hex], async(client) => {
27+
const ver = await client.server_version('2.7.11', '1.0')
28+
console.log(ver)
29+
const result = await client.blockchainTransaction_broadcast(hex)
30+
console.log(result)
31+
})
32+
}
33+
34+
const getopt = () => {
35+
return process.argv.slice(2)[0]
36+
}
37+
38+
main(getopt())

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "electrum-client",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Electrum protocol client for node.js",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
9-
"dependencies": {
10-
},
9+
"dependencies": {},
1110
"repository": {
1211
"type": "git",
1312
"url": "git://github.com/you21979/node-electrum-client.git"
@@ -20,6 +19,9 @@
2019
"electrum",
2120
"bitcoin"
2221
],
22+
"engines": {
23+
"node": ">=6"
24+
},
2325
"author": "Yuki Akiyama",
2426
"license": "MIT"
2527
}

0 commit comments

Comments
 (0)