better tx create at confirm
This commit is contained in:
parent
0ed46f1f65
commit
d7e025c2d0
7 changed files with 34 additions and 29 deletions
|
|
@ -49,7 +49,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<button class="item button button-block button-balanced" ng-click="approve()" ng-disabled="!txp">
|
||||
<button class="item button button-block button-balanced" ng-click="approve()">
|
||||
<span translate>Send</span>
|
||||
</button>
|
||||
</ion-content>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<ion-spinner icon="lines"></ion-spinner>
|
||||
<div translate>Updating activity. Please stand by</div>
|
||||
</span>
|
||||
<a ng-if="!fetchingNotifications" class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
||||
<a ng-if="notifications[0]" class="item" ng-repeat="x in notifications" ng-click="x.action()">
|
||||
<span ng-include="'views/includes/walletActivity.html'"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
@ -118,5 +118,9 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<p class="padding" style="text-align:center; color:#999">
|
||||
{{name}} v{{version}}
|
||||
</p>
|
||||
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -17,13 +17,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.commentPopupSave = function(description) {
|
||||
$log.debug('Saving description: ' + description);
|
||||
$scope.description = description;
|
||||
$scope.txp = null;
|
||||
|
||||
createTx($scope.wallet, function(err, txp) {
|
||||
if (err) return;
|
||||
cachedTxp[$scope.wallet.id] = txp;
|
||||
apply(txp);
|
||||
});
|
||||
commentPopup.close();
|
||||
};
|
||||
};
|
||||
|
|
@ -165,7 +158,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
apply(cachedTxp[wallet.id]);
|
||||
} else {
|
||||
stop = $timeout(function() {
|
||||
createTx(wallet, function(err, txp) {
|
||||
createTx(wallet, true, function(err, txp) {
|
||||
if (err) return;
|
||||
cachedTxp[wallet.id] = txp;
|
||||
apply(txp);
|
||||
|
|
@ -184,7 +177,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$scope.$apply();
|
||||
};
|
||||
|
||||
var createTx = function(wallet, cb) {
|
||||
var createTx = function(wallet, dryRun, cb) {
|
||||
var config = configService.getSync().wallet;
|
||||
var currentSpendUnconfirmed = config.spendUnconfirmed;
|
||||
var outputs = [];
|
||||
|
|
@ -227,6 +220,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
txp.payProUrl = paypro;
|
||||
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
||||
txp.feeLevel = config.settings.feeLevel || 'normal';
|
||||
txp.dryRun = dryRun;
|
||||
|
||||
walletService.createTx(wallet, txp, function(err, ctxp) {
|
||||
if (err) {
|
||||
|
|
@ -247,14 +241,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
|
||||
$scope.approve = function() {
|
||||
var wallet = $scope.wallet;
|
||||
var txp = $scope.txp;
|
||||
if (!wallet) {
|
||||
return setSendError(gettextCatalog.getString('No wallet selected'));
|
||||
};
|
||||
|
||||
if (!txp) {
|
||||
return setSendError(gettextCatalog.getString('No transaction'));
|
||||
};
|
||||
|
||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||
$log.info('No signing proposal: No private key');
|
||||
|
|
@ -265,9 +255,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
}
|
||||
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$state.transitionTo('tabs.home');
|
||||
createTx(wallet, false, function(err, txp) {
|
||||
if (err) return;
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$state.transitionTo('tabs.home');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -32,12 +32,9 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
$scope.sign = function() {
|
||||
$scope.loading = true;
|
||||
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
||||
|
||||
console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
||||
|
||||
$scope.$emit('UpdateTx');
|
||||
if (err) return setSendError(err);
|
||||
$scope.close(txp);
|
||||
$scope.close(true);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -53,7 +50,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
if (err)
|
||||
return setError(err, gettextCatalog.getString('Could not reject payment'));
|
||||
|
||||
$scope.close(txpr);
|
||||
$scope.close(true);
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -73,7 +70,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
return setError(err, gettextCatalog.getString('Could not delete payment proposal'));
|
||||
}
|
||||
|
||||
$scope.close();
|
||||
$scope.close(true);
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
|
@ -90,7 +87,7 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
return setError(err, gettextCatalog.getString('Could not broadcast payment'));
|
||||
}
|
||||
|
||||
$scope.close(txpb);
|
||||
$scope.close(true);
|
||||
});
|
||||
}, 10);
|
||||
};
|
||||
|
|
@ -175,7 +172,10 @@ console.log('[txpDetails.js.35] AFTER publush'); //TODO
|
|||
});
|
||||
};
|
||||
|
||||
$scope.close = function(txp) {
|
||||
$scope.close = function(shouldEmit) {
|
||||
if (shouldEmit)
|
||||
$rootScope.$emit('Local/TxAction', $scope.wallet.id);
|
||||
|
||||
$scope.loading = null;
|
||||
$scope.txpDetailsModal.hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesAbout',
|
||||
function($scope, $version, $ionicNavBarDelegate, gettextCatalog) {
|
||||
function($scope, $window, $ionicNavBarDelegate, gettextCatalog) {
|
||||
$ionicNavBarDelegate.title(gettextCatalog.getString('About Copay'));
|
||||
|
||||
$scope.version = $window.version;
|
||||
$scope.commit = $window.commitHash;
|
||||
$scope.commitHash = $window.commitHash;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService, txpModalService) {
|
||||
function($rootScope, $timeout, $scope, $state, $ionicScrollDelegate, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log, platformInfo, storageService, txpModalService, $window) {
|
||||
|
||||
$scope.externalServices = {};
|
||||
$scope.bitpayCardEnabled = true; // TODO
|
||||
|
|
@ -81,9 +81,11 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
}
|
||||
wallet.status = status;
|
||||
|
||||
$scope.fetchingNotifications = true;
|
||||
profileService.getNotifications({
|
||||
limit: 3
|
||||
}, function(err, notifications) {
|
||||
$scope.fetchingNotifications = false;
|
||||
if (err) {
|
||||
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||
return;
|
||||
|
|
@ -143,5 +145,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
|
||||
$scope.openTxpModal = txpModalService.open;
|
||||
|
||||
$scope.version = $window.version;
|
||||
$scope.name = $window.appConfig.nameCase;
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -852,6 +852,8 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
askPassword(wallet.name, gettext('Enter Spending Password'), function(password) {
|
||||
if (!password) return cb('no password');
|
||||
if (!wallet.checkPassword(password)) return cb('wrong password');
|
||||
|
||||
|
||||
return cb(null, password);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue