Skip to content

Instantly share code, notes, and snippets.

@jachiang
jachiang / gist:99e2894f81f8a52d0f7d984ea6050e10
Created March 21, 2017 12:26
Verifying that "james_chiang.id" is my Blockstack ID. https://onename.com/james_chiang
Verifying that "james_chiang.id" is my Blockstack ID. https://onename.com/james_chiang
@jachiang
jachiang / yjsTest.js
Created December 1, 2017 14:25
yjsTest > Y promise doesn't return anything?
// you need to create and inject a IPFS object
const IPFS = require('ipfs')
const Y = require('yjs')
require('y-ipfs-connector')(Y)
// other Yjs deps:
require('y-memory')(Y)
require('y-array')(Y)
require('y-text')(Y)

Keybase proof

I hereby claim:

  • I am jachiang on github.
  • I am james_ch (https://keybase.io/james_ch) on keybase.
  • I have a public key ASB4bplfzxQ75C-tqpqdA50d_meXJAUpDal5RGoJ__v3BQo

To claim this, I am signing this object:

@jachiang
jachiang / ECPlotting.py
Created January 9, 2018 12:22
Plotting script for Programming Blockchain ch2
# coding: utf-8
# In[81]:
#EC Addition Plot
import math
import numpy as np
### Keybase proof
I hereby claim:
* I am jachiang on github.
* I am digi_james (https://keybase.io/digi_james) on keybase.
* I have a public key ASCPdb4smr5BX6RkdBOMIv9TL57EKN4bgzvac6P40foQgwo
To claim this, I am signing this object:
#include <iostream>
#include <bitcoin/protocol.hpp>
#include <bitcoin/bitcoin.hpp>
int main () {
// Test.
bc::protocol::zmq::context my_context(true); //started
bc::protocol::zmq::socket my_requester(
my_context,

Setup Bitcoin.conf

bitcoin.conf flags for LND integration

rpcpassword= // make a strong password
rpcuser=bitcoinrpc
server=1
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28332
@jachiang
jachiang / libbitcoin_tx_subscriber.cpp
Last active June 22, 2018 08:21
libbitcoin_tx_subscriber.cpp
#include <iostream>
#include <bitcoin/protocol.hpp>
#include <bitcoin/bitcoin.hpp>
// g++ -std=c++11 `pkg-config --cflags libbitcoin libbitcoin-protocol --libs libbitcoin libbitcoin-protocol` -o libbitcoin_tx_sub_test libbitcoin_tx_sub_test.cpp
int main() {
// Setup of zmq context & socket.
bc::protocol::zmq::context my_context(true); //started
#include <bitcoin/bitcoin.hpp>
#include <bitcoin/network.hpp>
int main()
{
// Default network settings.
bc::network::settings settings(bc::config::settings::testnet);
@jachiang
jachiang / derived_from_p2p.cpp
Last active October 18, 2018 16:17
Deriving from p2p class (to attach custom/derived sessions & protocols)
#include <bitcoin/network.hpp>
BC_USE_LIBBITCOIN_MAIN
// Inherit from P2P class.
class derived_from_p2p
: public bc::network::p2p
{
public:
typedef std::shared_ptr<derived_from_p2p> ptr;