aboutsummaryrefslogtreecommitdiffstats
path: root/bcore.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2018-01-30 18:14:26 -0800
committerAdam Soltys <[email protected]>2018-01-30 18:14:36 -0800
commit709d1f04d073d9b46e42819bd0224da6a4157814 (patch)
tree4799253ecc1f93882e98cbd2f62f56454329c7d8 /bcore.js
parentde4d44a58f6bb49d5762632d2cad96e1dc96c56f (diff)
downloadcoinos-server-709d1f04d073d9b46e42819bd0224da6a4157814.tar.gz
coinos-server-709d1f04d073d9b46e42819bd0224da6a4157814.zip
rpc and zmq demo
Diffstat (limited to 'bcore.js')
-rw-r--r--bcore.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/bcore.js b/bcore.js
new file mode 100644
index 00000000..b1927bfc
--- /dev/null
+++ b/bcore.js
@@ -0,0 +1,22 @@
+import bitcoin from 'bitcoinjs-lib'
+import Bitcoin from 'bitcoin-core'
+import zmq from 'zeromq'
+
+const sock = zmq.socket('sub')
+
+;(async () => {
+ let b = new Bitcoin({
+ username: 'adam',
+ password: 'MPJzfq97',
+ port: 19332,
+ })
+ let res = await b.getBlockCount()
+ console.log(res)
+
+ sock.connect('tcp://127.0.0.1:18501')
+ sock.subscribe('rawtx')
+ sock.on('message', (t, m) => {
+ let tx = bitcoin.Transaction.fromBuffer(m)
+ console.log(tx)
+ })
+})()