Seems I am able to create a wallet...but I would like to get the Address

(Vo R0220) #1

Hey there. So here is my code, running on Ubuntu 14.04 LTS. I’m trying to run this out of the client package so I made the example script, but I would like to know what would be the process for generating an address. So far this is what I have tried by simply adding onto the example (with a couple of changes):

var Client = require('bitcore-wallet-client');
var fs = require('fs');
var BWS_INSTANCE_URL = 'http://localhost:3232/bws/api';

var client = new Client({
   verbose: false,

client.createWallet("My Wallet", "RJ", 2, 2, {network: 'testnet'}, function(err, secret) {
  // Handle err
    console.log('Wallet Created. Share this secret with your copayers: ' + secret);
    fs.writeFileSync('RJ.dat', client.export());

client.createAddress(function(err, addr){
    fs.writeFileSync('RJaddr.dat', addr);	

But then I get the following error when running it:

[info] Generating new keys
      throw new Error(msg);
Error: Illegal State.
    at Object.validatorFunctions.checkState (/home/vor0220/node_modules/bitcore-wallet-client/node_modules/preconditions/src/validatorFunctions.js:198:13)
    at API.createAddress (/home/vor0220/node_modules/bitcore-wallet-client/lib/api.js:827:5)
    at Object.<anonymous> (/home/vor0220/BitcorePlayground/BitcoinRelatedProjects/address-gen.js:16:8)
    at Module._compile (module.js:462:26)
    at Object.Module._extensions..js (module.js:480:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:503:10)
    at startup (node.js:132:16)
    at node.js:817:3

(BitAlias) #2

Got the same error. Wallet is complete but ‘Error: Illegal State.’. Please help!

UPDATE: found the bug in my code.

(Paludis) #3

Can you enlighten us with what the bug was? I have the exact same problem.