Skip to content

Commit

Permalink
load walletDefinedByKeys later
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyofbyteball committed Jul 15, 2018
1 parent 8d98ac9 commit b9975a3
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -8,7 +8,6 @@ if (process.browser){
conf.program_version = appPackageJson.version;
}

var walletDefinedByKeys;
var ecdsaSig = require('byteballcore/signature.js');
var breadcrumbs = require('byteballcore/breadcrumbs.js');
var constants = require('byteballcore/constants.js');
Expand Down Expand Up @@ -39,7 +38,6 @@ function API(opts) {
opts = opts || {};
this.verbose = !!opts.verbose;
this.timeout = opts.timeout || 50000;
walletDefinedByKeys = require('byteballcore/wallet_defined_by_keys.js');

if (this.verbose)
log.setLevel('debug');
Expand Down Expand Up @@ -454,6 +452,7 @@ API.prototype.createWallet = function(walletName, m, n, opts, cb) {
//self.credentials.account = account;
}

var walletDefinedByKeys = require('byteballcore/wallet_defined_by_keys.js');
walletDefinedByKeys.createWalletByDevices(self.credentials.xPubKey, opts.account || 0, m, opts.cosigners || [], walletName, opts.isSingleAddress, function(wallet){
self.credentials.walletId = wallet;
console.log("wallet created: " + JSON.stringify(self.credentials));
Expand Down Expand Up @@ -500,6 +499,7 @@ API.prototype.createAddress = function(is_change, cb) {
var coin = (this.credentials.network == 'livenet' ? "0" : "1");
var self = this;
breadcrumbs.add('createAddress wallet='+this.credentials.walletId+', is_change='+is_change);
var walletDefinedByKeys = require('byteballcore/wallet_defined_by_keys.js');
walletDefinedByKeys.issueOrSelectNextAddress(this.credentials.walletId, is_change, function(addressInfo){
var path = "m/44'/" + coin + "'/" + self.credentials.account + "'/0/"+addressInfo.address_index;
cb(null, {address: addressInfo.address, path: path, createdOn: addressInfo.creation_ts});
Expand Down Expand Up @@ -536,6 +536,7 @@ API.prototype.getSignerWithLocalPrivateKey = function(){
API.prototype.sendMultiPayment = function(opts, cb) {
var self = this;
var Wallet = require('byteballcore/wallet.js');
var walletDefinedByKeys = require('byteballcore/wallet_defined_by_keys.js');

opts.signWithLocalPrivateKey = this.getSignerWithLocalPrivateKey();

Expand Down Expand Up @@ -572,6 +573,7 @@ API.prototype.signMessage = function(from_address, message, arrSigningDeviceAddr
};

API.prototype.getAddresses = function(opts, cb) {
var walletDefinedByKeys = require('byteballcore/wallet_defined_by_keys.js');
var coin = (this.credentials.network == 'livenet' ? "0" : "1");
var self = this;
walletDefinedByKeys.readAddresses(this.credentials.walletId, opts, function(arrAddressInfos){
Expand Down

0 comments on commit b9975a3

Please sign in to comment.