Skip to content

Instantly share code, notes, and snippets.

@matiu
Last active August 29, 2015 14:16
Show Gist options
  • Save matiu/b9df093eaf81a6fbc879 to your computer and use it in GitHub Desktop.
Save matiu/b9df093eaf81a6fbc879 to your computer and use it in GitHub Desktop.

Hoy

  var storage = new Client.FileStorage({
    filename: args.file || process.env['BIT_FILE'],
  });
  var c = new Client({
    storage: storage,
    baseUrl: args.host || process.env['BIT_HOST'],
    verbose: args.verbose,
  });

  c.createWallet...

Propuesta:

  var storage = new Client.FileStorage({
    filename: args.file || process.env['BIT_FILE'],
  });
//u otro storage con load & save async


var wcd = new WCD();

storage.save(wcd.toObject());

//...

  var c = new Client({
    wcd: wcd,
    baseUrl: args.host || process.env['BIT_HOST'],
    verbose: args.verbose,
  });


c.on('wcdChange', function(newWcd) {
   // check newWcd match wcd? (or is already checked on client lib)

   storage.save(wcd.toObject());  // or
   storage.save(wcd.fullEncrypted(password), ); //or 
   storage.save(wcd.keyEncrypted(password), ); 
       
});



c.getBalance
 -> err: noncomplete

c.complete
 -> err: copayers not there yet

c.status (
  -> wallet.status: "notComplete"
     missingCopeyers:x


c.complete
 -> err:  null
 -> emit('wcdCompleted')


// Luego en otra session
var storage = xxx...;

storage.load(, function(err,data) {

  if (WCD.isEncrypted(data)) {
     password =...;
  }
  wcd = WCD.fromObject(data, password); // throws if cannot decrypt... // or returns unencrypted fields...
 

});

Asyncs: can throw 'NOAUTH' or 'NEEDPASSWORD'

wcd.signTX(rawTx) wcd.signReadRequest(request) wcd.signWriteRequest(request) wcd.addressForPath(path)

wcd.






Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment