mirror of https://github.com/BTCPrivate/copay.git
bp to walletService
This commit is contained in:
parent
410153a2da
commit
aa42db1458
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, fingerprintService, ongoingProcess, bwcError, bitcore, pbkdf2Service, moment, platformInfo) {
|
angular.module('copayApp.controllers').controller('bitpayCardController', function($scope, $rootScope, $timeout, $log, $ionicModal, lodash, bitpayCardService, configService, profileService, walletService, ongoingProcess, pbkdf2Service, moment, platformInfo) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var wallet;
|
var wallet;
|
||||||
|
@ -205,7 +205,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = bwcError.msg(err);
|
self.error = bwcError.msg(err);
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
@ -213,10 +212,9 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.confirmTx(createdTxp, function(err, tx) {
|
walletService.publishAndSign(createdTxp, function(err, tx) {
|
||||||
ongoingProcess.set('Processing Transaction...', false);
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = bwcError.msg(err);
|
self.error = err;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
|
@ -234,55 +232,6 @@ angular.module('copayApp.controllers').controller('bitpayCardController', functi
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.confirmTx = function(txp, cb) {
|
|
||||||
|
|
||||||
fingerprintService.check(wallet, function(err) {
|
|
||||||
if (err) {
|
|
||||||
$log.debug(err);
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
walletService.handleEncryptedWallet(wallet, function(err) {
|
|
||||||
if (err) {
|
|
||||||
$log.debug(err);
|
|
||||||
return bwcError.cb(err, null, cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
ongoingProcess.set('Processing Transaction...', true);
|
|
||||||
walletService.publishTx(wallet, txp, function(err, publishedTxp) {
|
|
||||||
if (err) {
|
|
||||||
$log.debug(err);
|
|
||||||
return bwcError.cb(err, null, cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
walletService.signTx(wallet, publishedTxp, function(err, signedTxp) {
|
|
||||||
walletService.lock(wallet);
|
|
||||||
if (err) {
|
|
||||||
$log.debug(err);
|
|
||||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
|
||||||
if (err) $log.debug(err);
|
|
||||||
});
|
|
||||||
return bwcError.cb(err, null, cb);
|
|
||||||
}
|
|
||||||
|
|
||||||
walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
|
||||||
if (err) {
|
|
||||||
$log.debug(err);
|
|
||||||
walletService.removeTx(wallet, broadcastedTxp, function(err) {
|
|
||||||
if (err) $log.debug(err);
|
|
||||||
});
|
|
||||||
return bwcError.cb(err, null, cb);
|
|
||||||
}
|
|
||||||
$timeout(function() {
|
|
||||||
return cb(null, broadcastedTxp);
|
|
||||||
}, 5000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.authenticate = function() {
|
this.authenticate = function() {
|
||||||
self.error = null;
|
self.error = null;
|
||||||
|
|
||||||
|
|
|
@ -48,10 +48,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
|
||||||
walletService.lock($scope.wallet);
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.reject = function(txp) {
|
$scope.reject = function(txp) {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
|
|
|
@ -208,18 +208,11 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
self.error = err.message || bwcError.msg(err);
|
self.error = err.message || bwcError.msg(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fingerprintService.check(wallet, function(err) {
|
walletService.prepare(wallet, txp, function(err, password) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err.message || bwcError.msg(err);
|
self.error = err.message || bwcError.msg(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
walletService.handleEncryptedWallet(wallet, function(err) {
|
|
||||||
if (err) {
|
|
||||||
self.error = err.message || bwcError.msg(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ongoingProcess.set('signingTx', true);
|
ongoingProcess.set('signingTx', true);
|
||||||
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
walletService.publishTx(wallet, createdTxp, function(err, publishedTxp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -227,8 +220,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
self.error = err.message || bwcError.msg(err);
|
self.error = err.message || bwcError.msg(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
walletService.signTx(wallet, publishedTxp, function(err, signedTxp) {
|
walletService.signTx(wallet, publishedTxp, function(err, password, signedTxp) {
|
||||||
walletService.lock(wallet);
|
|
||||||
walletService.removeTx(wallet, signedTxp, function(err) {
|
walletService.removeTx(wallet, signedTxp, function(err) {
|
||||||
if (err) $log.debug(err);
|
if (err) $log.debug(err);
|
||||||
});
|
});
|
||||||
|
@ -261,6 +253,5 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue