Skip to content

Instantly share code, notes, and snippets.

@jgarzik
jgarzik / paychanproto.md
Last active August 29, 2015 13:57
Payment channel JSON-RPC protocol

This protocol describes a simple payment channel protocol, such as the one presented in https://en.bitcoin.it/wiki/Contracts#Example_7:_Rapidly-adjusted_.28micro.29payments_to_a_pre-determined_party

JSON-RPC methods shown here may be sent via HTTPS or stratum protocol. It is easily adaptable to protocol buffers or another favored marshalling method.

Open channel

Client requests a public key. Server responds with a public key (K2). K2, converted to a bitcoin address, forms the unique identifier for this payment channel. Each public key returned must be unique.

@jgarzik
jgarzik / mmx-test.c
Created August 14, 2014 13:19
storing data in registers
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
Verifying that +jgarzik is my openname (Bitcoin username). https://onename.io/jgarzik
@jgarzik
jgarzik / chomp.pl
Created April 30, 2012 18:58
Remove trailing whitespaces; files edited in-place.
#!/usr/bin/perl -w
use strict;
my ($argv_fn);
my $bytes_saved = 0;
while ($argv_fn = shift @ARGV) {
&chomp_file($argv_fn);
}
@jgarzik
jgarzik / mx.cc
Created May 15, 2012 14:48
Boost mutex static initialization example
/*
[jgarzik@bd tmp]$ g++ -O2 -Wall -g -o mx mx.cc -lboost_thread-mt
[jgarzik@bd tmp]$ ./mx
1. foo = 42
2. foo = 10
3. foo = 20
*/
#include <cstdio>
#include <boost/thread.hpp>
@jgarzik
jgarzik / getnetstats.txt
Created June 24, 2012 01:49
bitcoin 'getnetstats' output
Sample getnetstats JSON-RPC output, just after startup and 9-block sync-up:
{
"messages" : {
"addr" : [
"15",
"286929"
],
"alert" : [
"4",
@jgarzik
jgarzik / getpeerinfo-pmsg-example.txt
Created June 30, 2012 02:03
bitcoin 'getpeerinfo' per-message statistics
[
{
"addr" : "173.74.129.35:8333",
"services" : "00000001",
"lastsend" : 1341021734,
"lastrecv" : 1341021734,
"conntime" : 1341021329,
"recvbytes" : 37248,
"sendbytes" : 2823,
"version" : 32400,
@jgarzik
jgarzik / samples.cfg
Created August 4, 2012 03:50
sample pynode configs
Example mainnet configuration
-----------------------------
db=/spare/tmp/chaindb
log=/spare/tmp/chaindb/debug.log
Example testnet configuration
-----------------------------
port=18333
@jgarzik
jgarzik / pynode-ripemd.patch
Created August 4, 2012 04:02
pynode patch for hashlib ripemd160
diff --git a/bitcoin/serialize.py b/bitcoin/serialize.py
index 6d7fc6d..13a3afd 100644
--- a/bitcoin/serialize.py
+++ b/bitcoin/serialize.py
@@ -7,6 +7,7 @@
#
import struct
+import hashlib
from Crypto.Hash import SHA256, RIPEMD160

hello test test.

test test test my home page test test test.

test test