Skip to content

Instantly share code, notes, and snippets.

View matiu's full-sized avatar

ematiu matiu

  • Bitpay Inc.
  • Tucuman, Argentina
View GitHub Profile
@matiu
matiu / gist:3663f71080002321de9b
Last active August 29, 2015 14:15
bit wallet

Normal Operation

bit create myWallet 2-3
bit address
bit send <>

Client / Sign and extract DER

var clientSign = function(tx, xpriv, n) {
  //Derive proper key to sign, for each input
  var privs = [],
    derived = {};
  var xpriv = new Bitcore.HDPrivateKey(someXPrivKey[0]);

  _.each(tx.inputs, function(i) {
var b = require('bitcore');
var priv = new b.PrivateKey();
var pub = new b.PublicKey(priv);
var inputs =
[ { txid: 'e872a0fda0afd0bce31ddfd9229c9eca2a68e4746615b8a0902b7a657b83676d',
vout: 8,
amount: 100,
scriptPubKey: b.Script.buildPublicKeyHashOut(pub).toBuffer().toString('hex') } ] ;
@matiu
matiu / gist:ca171251d9940c348058
Last active August 29, 2015 14:12
Rejoin broken wallet

The following is a procedure to grab the extended priv key, for copayers that are

  • Open the wallet in Chrome
  • Open the javascript console
  • Inspect an element on the html (could be any element), inspect by using the magnifing glass.

After selecting an item, go back to the javascript console and type:

 var w= angular.element($0).scope().wallet; w?'OK':'';
  1. Insight commit 70fc47f343417a5bd71241d42bd579c2949b54ef Author: Rainer Koirikivi rainer@koirikivi.fi Date: Mon Nov 3 22:59:38 2014 +0200

    Friendlier error reporting for sendRawTransaction

  2. borro emailstorage db

@matiu
matiu / gist:754e02c7c3af54535767
Last active August 29, 2015 14:09
Falcon tests
  1. fetch insight #f2e33fcad34f76bed1e8a60a30751793f9a721cb https://github.com/bitpay/insight-api/commit/f2e33fcad34f76bed1e8a60a30751793f9a721cb
  2. fetch Copay master #9e695863edd31cce9979250f2b625258b787c073
  3. modify config.js to point to localhost
  4. run insight: ENABLE_MAILBOX="true" ENABLE_EMAILSTORE="true" ./insight.js
  5. check that creating a user with password with "!" does not work.
  6. create a profile (3@3.com password 123)
  7. close it and open it to test. Create some address and receive some btcs.
@matiu
matiu / gist:fd16b188fd0fe9025ea0
Last active August 29, 2015 14:08
swipe Tool
 $ git clone -b bug/swipe --single-branch https://github.com/matiu/copay.git
 $ cd copay
 $ bower i
 $ npm i
 $ grunt
 $ util/swipeWallet.js XXX
@matiu
matiu / gist:07786e0d875b4093accb
Last active August 29, 2015 14:07
Copay, joining a wallet overview
Joining a wallet
================
Creator (C) <-> Joining Peer (J)
(J)
<- Hello (secret random, peerPubkey) encrypted with creatorPubkey
(C)
(async._addConnectedPeer, emit 'connect', w.sendWalletId)
@matiu
matiu / gist:cf0a1d65865e544899b6
Last active August 29, 2015 14:07
Two JS Testing Tips
  1. Test only one class at time. Use sinon.stub (.returns & .yields) to create on the fly mockups for dependencies.
  2. Test the API Only. Never access class internals for checking / setting values. Use the API, this prevents to brake test in the future. E.g.:
  class.setName('name');
  class.name.should.equal('name'); // Wrong
  clase.getName().should.equal('name'); //Right
@matiu
matiu / gist:036e8a3ccfb468c97a64
Last active August 29, 2015 14:06
Identity API
var opts = {
blockchain: new Blockchain(...),,
storage: localstorage / insight / drive,
networking: new Async(...),
};
Identity.create(email, password, opts, function(err, iden){
//
})