Updates bitcore-wallet-client and fix functions

This commit is contained in:
Gustavo Maximiliano Cortez 2016-01-29 16:39:32 -03:00
commit 5dec3249d1
3 changed files with 45 additions and 47 deletions

View file

@ -40,7 +40,7 @@
"url": "https://github.com/bitpay/copay/issues" "url": "https://github.com/bitpay/copay/issues"
}, },
"dependencies": { "dependencies": {
"bitcore-wallet-client": "1.5.0", "bitcore-wallet-client": "2.1.0",
"express": "^4.11.2", "express": "^4.11.2",
"fs": "0.0.2", "fs": "0.0.2",
"grunt": "^0.4.5", "grunt": "^0.4.5",

View file

@ -808,69 +808,67 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
'message': comment 'message': comment
}); });
txSignService.prepare(function(err) { var opts = {
toAddress: address,
amount: amount,
outputs: outputs,
message: comment,
payProUrl: paypro ? paypro.url : null,
lockedCurrentFeePerKb: self.lockedCurrentFeePerKb
};
self.setOngoingProcess(gettextCatalog.getString('Creating transaction'));
txSignService.createTx(opts, function(err, txp) {
self.setOngoingProcess();
if (err) { if (err) {
return self.setSendError(err); return self.setSendError(err);
} }
var opts = { if (!fc.canSign() && !fc.isPrivKeyExternal()) {
toAddress: address,
amount: amount,
outputs: outputs,
message: comment,
payProUrl: paypro ? paypro.url : null,
lockedCurrentFeePerKb: self.lockedCurrentFeePerKb
};
self.setOngoingProcess(gettextCatalog.getString('Creating transaction'));
txSignService.createTx(opts, function(err, txp) {
self.setOngoingProcess(); self.setOngoingProcess();
if (err) { $log.info('No signing proposal: No private key');
return self.setSendError(err); self.resetForm();
} txStatus.notify(txp, function() {
return $scope.$emit('Local/TxProposalAction');
if (!fc.canSign() && !fc.isPrivKeyExternal()) { });
self.setOngoingProcess(); return;
$log.info('No signing proposal: No private key'); } else {
self.resetForm(); $rootScope.$emit('Local/NeedConfirmation', txp, function(accept) {
txStatus.notify(txp, function() { if (accept) self.acceptTx(txp);
return $scope.$emit('Local/TxProposalAction'); else self.resetForm();
}); });
return; }
} else {
$rootScope.$emit('Local/NeedConfirmation', txp, function(accept) {
if (accept) self.acceptTx(txp);
else self.resetForm();
});
}
});
}); });
}, 100); }, 100);
}; };
this.acceptTx = function(txp) { this.acceptTx = function(txp) {
var self = this; var self = this;
this.confirmTxPopup = null; txSignService.prepare(function(err) {
this.setOngoingProcess(gettextCatalog.getString('Sending transaction'));
txSignService.publishTx(txp, function(err) {
self.setOngoingProcess();
if (err) { if (err) {
$log.debug(err); return self.setSendError(err);
self.setSendError(err);
} else {
self.resetForm();
// self.signAndBroadcastTx(txp);
} }
self.setOngoingProcess(gettextCatalog.getString('Sending transaction'));
txSignService.publishTx(txp, function(err, txpPublished) {
if (err) {
self.setOngoingProcess();
self.setSendError(err);
} else {
self.prepareSignAndBroadcastTx(txpPublished);
}
});
}); });
}; };
this.signAndBroadcastTx = function() { this.prepareSignAndBroadcastTx = function(txp) {
var fc = profileService.focusedClient;
var self = this; var self = this;
txSignService.signAndBroadcast(txp, { txSignService.prepareAndSignAndBroadcast(txp, {
reporterFn: self.setOngoingProcess.bind(self) reporterFn: self.setOngoingProcess.bind(self)
}, function(err, txp) { }, function(err, txp) {
self.resetForm(); self.resetForm();
if (err) { if (err) {
self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen'); self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen');
$scope.$emit('Local/TxProposalAction'); $scope.$emit('Local/TxProposalAction');
@ -882,7 +880,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
txStatus.notify(txp, function() { txStatus.notify(txp, function() {
$scope.$emit('Local/TxProposalAction', txp.status == 'broadcasted'); $scope.$emit('Local/TxProposalAction', txp.status == 'broadcasted');
}); });
}; }
}); });
}; };

View file

@ -120,9 +120,9 @@ angular.module('copayApp.services').factory('txSignService', function($rootScope
root.publishTx = function(txp, cb) { root.publishTx = function(txp, cb) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
fc.publishTxProposal({txp: txp}, function(err) { fc.publishTxProposal({txp: txp}, function(err, txp) {
if (err) return cb(err); if (err) return cb(err);
else return cb(); else return cb(null, txp);
}); });
}; };