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>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
<accept class="accept-slide" ng-if="!hideSlider"></accept>
|
<accept class="accept-slide"></accept>
|
||||||
</ion-view>
|
</ion-view>
|
||||||
|
|
|
||||||
|
|
@ -161,5 +161,5 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</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>
|
</ion-modal-view>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
throw ('bad params');
|
throw ('bad params');
|
||||||
}
|
}
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.hideSlider = false;
|
|
||||||
$scope.data = {};
|
$scope.data = {};
|
||||||
|
|
||||||
var config = configService.getSync().wallet;
|
var config = configService.getSync().wallet;
|
||||||
|
|
@ -78,7 +77,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on('accepted', function(event) {
|
$scope.$on('accepted', function(event) {
|
||||||
$scope.hideSlider = true;
|
|
||||||
$scope.approve();
|
$scope.approve();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -268,16 +266,46 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
$state.go('tabs.home');
|
$state.go('tabs.home');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ongoingProcess.set('creatingTx', true);
|
ongoingProcess.set('creatingTx', true);
|
||||||
createTx(wallet, false, function(err, txp) {
|
createTx(wallet, false, function(err, txp) {
|
||||||
ongoingProcess.set('creatingTx', false);
|
ongoingProcess.set('creatingTx', false);
|
||||||
if (err) return;
|
if (err) return;
|
||||||
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
|
||||||
if (err) return setSendError(err);
|
var config = configService.getSync();
|
||||||
$ionicHistory.clearHistory();
|
var spendingPassEnabled = walletService.isEncrypted(wallet);
|
||||||
$state.go('tabs.home');
|
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.init = function() {
|
||||||
$scope.loading = null;
|
$scope.loading = null;
|
||||||
$scope.hideSlider = false;
|
|
||||||
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
||||||
$scope.isShared = $scope.wallet.credentials.n > 1;
|
$scope.isShared = $scope.wallet.credentials.n > 1;
|
||||||
$scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal();
|
$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.$on('accepted', function(event) {
|
||||||
$scope.hideSlider = true;
|
|
||||||
$scope.sign();
|
$scope.sign();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,10 @@ angular.module('copayApp.directives')
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
|
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;
|
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) {
|
root.formatAlternativeStr = function(satoshis, cb) {
|
||||||
if (!satoshis) return;
|
if (!satoshis) return;
|
||||||
var config = configService.getSync().wallet.settings;
|
var config = configService.getSync().wallet.settings;
|
||||||
|
|
@ -76,63 +96,63 @@ angular.module('copayApp.services').factory('txFormatService', function(bwcServi
|
||||||
};
|
};
|
||||||
|
|
||||||
root.formatPendingTxps = function(txps) {
|
root.formatPendingTxps = function(txps) {
|
||||||
$scope.pendingTxProposalsCountForUs = 0;
|
$scope.pendingTxProposalsCountForUs = 0;
|
||||||
var now = Math.floor(Date.now() / 1000);
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
/* To test multiple outputs...
|
/* To test multiple outputs...
|
||||||
var txp = {
|
var txp = {
|
||||||
message: 'test multi-output',
|
message: 'test multi-output',
|
||||||
fee: 1000,
|
fee: 1000,
|
||||||
createdOn: new Date() / 1000,
|
createdOn: new Date() / 1000,
|
||||||
outputs: []
|
outputs: []
|
||||||
};
|
};
|
||||||
function addOutput(n) {
|
function addOutput(n) {
|
||||||
txp.outputs.push({
|
txp.outputs.push({
|
||||||
amount: 600,
|
amount: 600,
|
||||||
toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK',
|
toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK',
|
||||||
message: 'output #' + (Number(n) + 1)
|
message: 'output #' + (Number(n) + 1)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
lodash.times(150, addOutput);
|
lodash.times(150, addOutput);
|
||||||
txps.push(txp);
|
txps.push(txp);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lodash.each(txps, function(tx) {
|
lodash.each(txps, function(tx) {
|
||||||
|
|
||||||
tx = txFormatService.processTx(tx);
|
tx = txFormatService.processTx(tx);
|
||||||
|
|
||||||
// no future transactions...
|
// no future transactions...
|
||||||
if (tx.createdOn > now)
|
if (tx.createdOn > now)
|
||||||
tx.createdOn = now;
|
tx.createdOn = now;
|
||||||
|
|
||||||
tx.wallet = profileService.getWallet(tx.walletId);
|
tx.wallet = profileService.getWallet(tx.walletId);
|
||||||
if (!tx.wallet) {
|
if (!tx.wallet) {
|
||||||
$log.error("no wallet at txp?");
|
$log.error("no wallet at txp?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var action = lodash.find(tx.actions, {
|
var action = lodash.find(tx.actions, {
|
||||||
copayerId: tx.wallet.copayerId
|
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;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue