Skip to content

Instantly share code, notes, and snippets.

View itoonx's full-sized avatar
👻
Deep

Makkhawan Voraboot itoonx

👻
Deep
View GitHub Profile
#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2011 thomasv@gitorious
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
@itoonx
itoonx / bitcoinjs-lib.js
Created September 15, 2016 08:35 — forked from fanatid/bitcoinjs-lib.js
bitcoin multisig transaction demo
var bitcoin = require('bitcoinjs-lib') // 1.4.x ?
var privKeys = [
'L2ALJznyt2croGHs8duBK2TZMB3Bc5ZpFZQSmR5QQUMPDDcUWeTw', // n2t8F1D41xy6f3d2B6DtjXRRsn8dgUzQ6C
'L3gM5giJqPAJcWyD8eKv94d4QgqyzqrYeAA9DnuJe23FszsnqD1w', // mjgF67B4pyEHuGTLU5jS333EasUrZBaxMB
'KwdYxYAbxntKvrMQtDHAamPT1pyuYkDRfAwESBqCGRdz9abQo3dW', // mwzPpNMFwLoJPXw2ez8mz6RrdYGaqZDind
'L5LTWMRBt27dHde1mnvV1RzW1mxQuQBxpm2TvNHsMaNvAQKqKov2', // mt7K2ChnJSp96k93HYdC8B9oqUmqLyESpL
'L4qQgxEbKJFJKans2UxFRzXisS7o3oBkyJGirAUgTxS9CfTo9Cd4', // mmvbfVqYrXdy1i4x9UzWc4PtgN7VjMNjeY
]
{
"statusCode": 200,
"message": {
"tx": {
"block_height": -1,
"block_index": -1,
"hash": "7877c5fc288a5984832d111724ac0ad35bc1a5c633f1e0a611342a2c27cb8fe5",
"addresses": [
"1KPPDJzqNi1XgUjZi3ESRDEagRLnTyEn7t",
"1BTNjcBniDy1MpBZvpBc1JWQg8B4wQeGcJ"
{
"statusCode": 200,
"message": {
"tx": {
"block_height": -1,
"block_index": -1,
"hash": "461cd90e47bef13b806e769057df8b474ba56d7ddd26386c795d2c2cd902b381",
"addresses": [
"1P4A58A3EpuYPvH6gvp94fL7A6YVjnwoU5",
"17u8seFNUxiEpxBs3dKwghV4iuJThdyS4B"
version: '2'
services:
wordpress:
image: wordpress:latest
volumes:
- ./src/public_html:/var/www/html
ports:
- "8000:80"
links:
@itoonx
itoonx / Clear Docker
Last active September 24, 2017 10:24
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
version: '2'
services:
wordpress:
image: wordpress:4.8.0-php7.0-apache
volumes:
- ./src/public_html:/var/www/html
ports:
- "8000:80"
links:
For mining software developers
Stratum protocol is based on JSON-RPC 2.0. In this chapter I expect that you're familiar with this protocol and you understand terms like "request", "response" and "notification". Please read JSON-RPC specification for more details.
For high level image of the Stratum protocol concept, please read Stratum protocol specification on Google docs. This document needs some care, but give you the basic examples how to connect to Stratum server.
Exception handling
Stratum defines simple exception handling. Example of rejected share looks like:
{"id": 10, "result": null, "error": (21, "Job not found", null)}
01000000 ................................... Version
01 ......................................... Number of inputs
|
| 7b1eabe0209b1fe794124575ef807057
| c77ada2138ae4fa8d6c4de0398a14f3f ......... Outpoint TXID
| 00000000 ................................. Outpoint index number
|
| 49 ....................................... Bytes in sig. script: 73
| | 48 ..................................... Push 72 bytes as data
tep-by-step description:
We start creating a new transaction which we hash and sign.
Add four-byte version field: 01000000
One-byte varint specifying the number of inputs: 01
32-byte hash of the transaction from which we want to redeem an output (reverse order): be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396
Four-byte field denoting the output index we want to redeem from the transaction with the above hash (counting from zero): 00000000
Now comes the scriptSig. For the purpose of signing the transaction, this is temporarily filled with the scriptPubKey of the output we want to redeem. First we write a one-byte varint which denotes the length of the scriptSig (0x19 = 25 bytes): 19
Then we write the actual scriptSig (which is the scriptPubKey of the output we want to redeem): 76 a9 14 dd6cce9f255a8cc17bda8ba0373df8e861cb866e 88 ac (look to the bottom line line on https://blockchain.info/tx/96534da2f213367a6d589f18d7d6d1689748cd911f8c33a9aee754a80de166be?show_adv=true )