Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am ryandotsmith on github.
  • I am ryandotsmith (https://keybase.io/ryandotsmith) on keybase.
  • I have a public key whose fingerprint is 2D60 72AC 8048 3B96 6F2E 5211 EC2F C28B D8ED AF6F

To claim this, I am signing this object:

@ryandotsmith
ryandotsmith / index.js
Last active Aug 29, 2015
Chain - Send Transactions API
View index.js
var chain = require('chain-node');
var bitcoin = require('bitcoinjs-lib');
// The Chain API will never accept your private key.
// Keep the private key stored in a safe place alongside
// your program.
var key = new bitcoin.ECKey.fromWIF("Your private key in WIF format.")
var txn = new bitcoin.Transaction()
@ryandotsmith
ryandotsmith / index.html
Last active Aug 29, 2015
An example for how to authenticate against Chain using CORS
View index.html
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<p>Balance: <span id="balance"></span></p>
</body>
View q.sql
select txn_summary(data) from txns limit 1;
View output.txt
$ ruby x.rb
Address: 1FBVmnKtjgA676Xbatqx42dcGzaaPV4BU4 contains 4 transactions.
Address: 17j92xE73rEyexJSB4gwavd2YkpTKZWfAv contains 7 transactions.
@ryandotsmith
ryandotsmith / cond_test.go
Last active Aug 29, 2015
sync.Cond test cases
View cond_test.go
package main
import (
"testing"
"sync"
"sync/atomic"
)
type EasyCond struct {
m *sync.Mutex
@ryandotsmith
ryandotsmith / confidence.js
Last active Aug 29, 2015
Demonstrate transaction confidence using Chain.com's Bitcoin API
View confidence.js
var chain = require('chain-node');
var confidant = function(txid, retries, cb) {
chain.getTransaction(txid, function(err, resp) {
if(resp.propagation_level > 0.9) {
cb(resp.propagation_level);
} else {
if(retries > 60) {
cb(null);
} else {
@ryandotsmith
ryandotsmith / s_queue.rb
Last active Aug 29, 2015
Multi-threaded SQS Ruby Worker. I have tests. Maybe this is a gem? Lemme know if you find it useful.
View s_queue.rb
require 'aws-sdk'
require 'json'
module SQSW
class SQueue
MissingQueue = Class.new(StandardError)
def initialize(url = nil)
raise(MissingQueue, "Missing queue_url") if url.nil?
@q = find_queue(url)
@ryandotsmith
ryandotsmith / chain-notifications.js
Created Nov 29, 2014
Chain Node.js Notifications Example
View chain-notifications.js
var express = require('express');
var bodyParser = require('body-parser');
var chain = require('chain-node');
chain.apiKeyId = 'YOUR-API-KEY-ID';
chain.apiKeySecret = 'YOUR-API-KEY-SECRET';
var app = express();
app.use(bodyParser.json());
app.post('/', function (req, res) {
@ryandotsmith
ryandotsmith / op-return.js
Created Dec 8, 2014
Creating op-return transactions
View op-return.js
var util = require('util');
var bitcoin = require('bitcoinjs-lib');
var Chain = require('chain-node');
var chain = new Chain({blockChain: "testnet3"});
var b = new Buffer("Hello, world.");
var t = new bitcoin.Transaction();
t.addInput("ca7e12c753bd2a268e6f038509d72f3c44fd24064ed5ef8cde13ec987d495a64", 0);