Skip to content

Instantly share code, notes, and snippets.

View justmoon's full-sized avatar

Stefan Thomas justmoon

View GitHub Profile
(((B))) BitcoinJS Daemon v0.2.1 (node-bitcoin-p2p)
Copyright (c) 2011 BitcoinJS Project
LICENSE This program is free software; you can redistribute it and/or modify
it under the terms of the MIT license.
2 Jan 03:13:47 - info: Loading configuration
2 Jan 03:13:47 - info: Initializing LevelDB (leveldb:///home/moon/.bitcoinjs/leveldb/)
2 Jan 03:13:47 - info: Listening for Bitcoin connections on port 8333
@justmoon
justmoon / test.html
Created August 19, 2012 19:50
SJCL secp256k1
<script src="https://raw.github.com/bitwiseshiftleft/sjcl/master/sjcl.js"></script>
<script src="https://raw.github.com/bitwiseshiftleft/sjcl/master/core/bn.js"></script>
<script src="https://raw.github.com/bitwiseshiftleft/sjcl/master/core/ecc.js"></script>
<script>
// Overwrite NIST-P256 with secp256k1
sjcl.ecc.curves.c256 = new sjcl.ecc.curve(
sjcl.bn.pseudoMersennePrime(256, [[0,-1],[4,-1],[6,-1],[7,-1],[8,-1],[9,-1],[32,-1]]),
"0x14551231950b75fc4402da1722fc9baee",
0,
7,
@justmoon
justmoon / gist:3440704
Created August 23, 2012 19:38
SJCL BN divInt
/** this /= (int) that */
sjcl.bn.prototype.divIntM = function (that) {
var i, limbs = this.limbs, ll = limbs.length, carry = 0, quotient;
if (this.sign() === -1) {
throw (new sjcl.exception.invalid("divIntM: dividend must be > 0"));
}
if ("number" !== typeof that ||
@justmoon
justmoon / index.html
Created August 29, 2012 07:51
node-webkit Crash/Error with node-buffertools
<script type="text/javascript">
require("buffertools");
console.log("It gets this far.");
new Buffer(32).clear();
console.log("But never this far.");
</script>
@justmoon
justmoon / index.html
Created September 10, 2012 07:51
node-webkit Crash/Error with node-bignum
<script type="text/javascript">
var bignum = require("bignum");
console.log("It gets this far.");
bignum(2).pow(256);
console.log("But never this far.");
</script>
@justmoon
justmoon / gist:3927036
Created October 21, 2012 13:54
bitcoinjs-lib 0.1 Script Inclusion Order
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/crypto-js/crypto.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/crypto-js/sha256.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/crypto-js/ripemd160.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/jsbn/prng4.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/jsbn/rng.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/jsbn/jsbn.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/jsbn/jsbn2.js"></script>
<script type="text/javascript" src="scripts/vendor/bitcoinjs-lib/src/jsbn/ec.js"></script>
@justmoon
justmoon / gist:5524519
Last active December 17, 2015 00:58
Ripple Client refactoring notes, May 6th 2013

Turning client classes into services/controllers

Old New Comment
src/js/client/model.js src/js/controllers/app.js The model stuff was moved to a global controller.
src/js/client/status.js src/js/controllers/status.js The status module is now a controller, see "Status controller" below.
src/js/client/network.js src/js/services/network.js
src/js/client/id.js src/js/services/id.js
src/js/client/blob.js src/js/services/blob.js
src/js/client/angular.js src/js/entry/desktop.js Which modules are used might be target-specific, so the loading has been moved to entry/.
@justmoon
justmoon / parse_invoice.py
Created June 28, 2013 17:30
Decode Bitcoin address from Ripple InvoiceID
import Crypto.Hash.SHA256 as SHA256
__b58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
__b58base = len(__b58chars)
def b58encode(v):
""" encode v, which is a string of bytes, to base58.
"""
long_value = 0L
@justmoon
justmoon / send.js
Created August 29, 2013 09:33
Sending a transaction with ripple-lib
var ripple = require('ripple-lib');
// Example destination and amount
// --------------------------------------------------
var destination = "rfbKLd1VLB3o6fpkhCJexckArjoMmBm2wG";
var amount = "1/CNY/rJL724ibxVFb9EKkTe2StQ4u6ViWAQm1Wc";
// --------------------------------------------------
@justmoon
justmoon / watch.js
Created August 29, 2013 09:36
Watching for transactions with ripple-lib
var ripple = require('ripple-lib');
var remote = ripple.Remote.from_config({
// "trace" : true,
"websocket_ip" : "122.70.133.11",
"websocket_port" : 5006,
"websocket_ssl" : false
});
remote.connect();