requeriments to send
This commit is contained in:
parent
5527cccc38
commit
cb64e57e45
6 changed files with 112 additions and 63 deletions
|
|
@ -49,5 +49,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</ion-content>
|
||||
<accept class="accept-slide" ng-if="!hideSlider"></accept>
|
||||
<accept class="accept-slide"></accept>
|
||||
</ion-view>
|
||||
|
|
|
|||
|
|
@ -161,5 +161,5 @@
|
|||
</button>
|
||||
</div>
|
||||
</ion-content>
|
||||
<accept class="accept-slide" ng-if="tx.pendingForUs && canSign && !hideSlider && !loading && !paymentExpired"></accept>
|
||||
<accept class="accept-slide" ng-if="tx.pendingForUs && canSign && !loading && !paymentExpired"></accept>
|
||||
</ion-modal-view>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
throw ('bad params');
|
||||
}
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
$scope.hideSlider = false;
|
||||
$scope.data = {};
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
|
|
@ -78,7 +77,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
};
|
||||
|
||||
$scope.$on('accepted', function(event) {
|
||||
$scope.hideSlider = true;
|
||||
$scope.approve();
|
||||
});
|
||||
|
||||
|
|
@ -268,16 +266,46 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
$state.go('tabs.home');
|
||||
});
|
||||
}
|
||||
|
||||
ongoingProcess.set('creatingTx', true);
|
||||
createTx(wallet, false, function(err, txp) {
|
||||
ongoingProcess.set('creatingTx', false);
|
||||
if (err) return;
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home');
|
||||
|
||||
var config = configService.getSync();
|
||||
var spendingPassEnabled = walletService.isEncrypted(wallet);
|
||||
var touchIdEnabled = config.touchIdFor && !config.touchIdFor[wallet.id];
|
||||
var isCordova = $scope.isCordova;
|
||||
var bigAmount = parseFloat(txFormatService.formatToUSD(txp.amount)) > 20;
|
||||
var message = gettextCatalog.getString('Sending {{fee}} from your {{name}} wallet', {
|
||||
fee: $scope.fee,
|
||||
name: wallet.name
|
||||
});
|
||||
var okText = gettextCatalog.getString('Confirm');
|
||||
var cancelText = gettextCatalog.getString('Cancel');
|
||||
|
||||
if (!spendingPassEnabled && !touchIdEnabled) {
|
||||
if (isCordova && bigAmount) {
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) return;
|
||||
publishAndSign(wallet, txp);
|
||||
});
|
||||
}
|
||||
else {
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) return;
|
||||
publishAndSign(wallet, txp);
|
||||
});
|
||||
}
|
||||
}
|
||||
else publishAndSign(wallet, txp);
|
||||
});
|
||||
};
|
||||
|
||||
function publishAndSign(wallet, txp) {
|
||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||
if (err) return setSendError(err);
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.home');
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
|
||||
$scope.init = function() {
|
||||
$scope.loading = null;
|
||||
$scope.hideSlider = false;
|
||||
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
||||
$scope.isShared = $scope.wallet.credentials.n > 1;
|
||||
$scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal();
|
||||
|
|
@ -50,7 +49,6 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
|||
};
|
||||
|
||||
$scope.$on('accepted', function(event) {
|
||||
$scope.hideSlider = true;
|
||||
$scope.sign();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,10 @@ angular.module('copayApp.directives')
|
|||
});
|
||||
|
||||
scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
|
||||
if (data.slider.activeIndex == 0) scope.$emit('accepted');
|
||||
if (data.slider.activeIndex == 0) {
|
||||
scope.slider.slideNext();
|
||||
scope.$emit('accepted');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,26 @@ angular.module('copayApp.services').factory('txFormatService', function(bwcServi
|
|||
return root.formatAmount(satoshis) + ' ' + config.unitName;
|
||||
};
|
||||
|
||||
root.formatToUSD = function(satoshis, cb) {
|
||||
if (!satoshis) return;
|
||||
var val = function() {
|
||||
var v1 = rateService.toFiat(satoshis, 'USD');
|
||||
if (!v1) return null;
|
||||
|
||||
return v1.toFixed(2);
|
||||
};
|
||||
|
||||
// Async version
|
||||
if (cb) {
|
||||
rateService.whenAvailable(function() {
|
||||
return cb(val());
|
||||
});
|
||||
} else {
|
||||
if (!rateService.isAvailable()) return null;
|
||||
return val();
|
||||
};
|
||||
};
|
||||
|
||||
root.formatAlternativeStr = function(satoshis, cb) {
|
||||
if (!satoshis) return;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
|
@ -76,63 +96,63 @@ angular.module('copayApp.services').factory('txFormatService', function(bwcServi
|
|||
};
|
||||
|
||||
root.formatPendingTxps = function(txps) {
|
||||
$scope.pendingTxProposalsCountForUs = 0;
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
$scope.pendingTxProposalsCountForUs = 0;
|
||||
var now = Math.floor(Date.now() / 1000);
|
||||
|
||||
/* To test multiple outputs...
|
||||
var txp = {
|
||||
message: 'test multi-output',
|
||||
fee: 1000,
|
||||
createdOn: new Date() / 1000,
|
||||
outputs: []
|
||||
};
|
||||
function addOutput(n) {
|
||||
txp.outputs.push({
|
||||
amount: 600,
|
||||
toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK',
|
||||
message: 'output #' + (Number(n) + 1)
|
||||
});
|
||||
};
|
||||
lodash.times(150, addOutput);
|
||||
txps.push(txp);
|
||||
*/
|
||||
/* To test multiple outputs...
|
||||
var txp = {
|
||||
message: 'test multi-output',
|
||||
fee: 1000,
|
||||
createdOn: new Date() / 1000,
|
||||
outputs: []
|
||||
};
|
||||
function addOutput(n) {
|
||||
txp.outputs.push({
|
||||
amount: 600,
|
||||
toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK',
|
||||
message: 'output #' + (Number(n) + 1)
|
||||
});
|
||||
};
|
||||
lodash.times(150, addOutput);
|
||||
txps.push(txp);
|
||||
*/
|
||||
|
||||
lodash.each(txps, function(tx) {
|
||||
lodash.each(txps, function(tx) {
|
||||
|
||||
tx = txFormatService.processTx(tx);
|
||||
tx = txFormatService.processTx(tx);
|
||||
|
||||
// no future transactions...
|
||||
if (tx.createdOn > now)
|
||||
tx.createdOn = now;
|
||||
// no future transactions...
|
||||
if (tx.createdOn > now)
|
||||
tx.createdOn = now;
|
||||
|
||||
tx.wallet = profileService.getWallet(tx.walletId);
|
||||
if (!tx.wallet) {
|
||||
$log.error("no wallet at txp?");
|
||||
return;
|
||||
}
|
||||
tx.wallet = profileService.getWallet(tx.walletId);
|
||||
if (!tx.wallet) {
|
||||
$log.error("no wallet at txp?");
|
||||
return;
|
||||
}
|
||||
|
||||
var action = lodash.find(tx.actions, {
|
||||
copayerId: tx.wallet.copayerId
|
||||
});
|
||||
|
||||
if (!action && tx.status == 'pending') {
|
||||
tx.pendingForUs = true;
|
||||
}
|
||||
|
||||
if (action && action.type == 'accept') {
|
||||
tx.statusForUs = 'accepted';
|
||||
} else if (action && action.type == 'reject') {
|
||||
tx.statusForUs = 'rejected';
|
||||
} else {
|
||||
tx.statusForUs = 'pending';
|
||||
}
|
||||
|
||||
if (!tx.deleteLockTime)
|
||||
tx.canBeRemoved = true;
|
||||
var action = lodash.find(tx.actions, {
|
||||
copayerId: tx.wallet.copayerId
|
||||
});
|
||||
|
||||
return txps;
|
||||
};
|
||||
if (!action && tx.status == 'pending') {
|
||||
tx.pendingForUs = true;
|
||||
}
|
||||
|
||||
if (action && action.type == 'accept') {
|
||||
tx.statusForUs = 'accepted';
|
||||
} else if (action && action.type == 'reject') {
|
||||
tx.statusForUs = 'rejected';
|
||||
} else {
|
||||
tx.statusForUs = 'pending';
|
||||
}
|
||||
|
||||
if (!tx.deleteLockTime)
|
||||
tx.canBeRemoved = true;
|
||||
});
|
||||
|
||||
return txps;
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue