mirror of
https://github.com/alexgo-io/electrum-client.git
synced 2026-01-12 22:43:15 +08:00
add riaa client sample
This commit is contained in:
10
README.md
10
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()
|
||||
```
|
||||
|
||||
|
||||
|
||||
38
example/riaa_client_transaction_send.js
Normal file
38
example/riaa_client_transaction_send.js
Normal file
@@ -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())
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user