Merge pull request #1791 from matiu/bug/use-all-funds
Fix #1789 - use all funds button
This commit is contained in:
commit
4726570b7a
8 changed files with 43 additions and 72 deletions
|
|
@ -71,9 +71,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
configurable: true
|
||||
});
|
||||
|
||||
|
||||
$scope.loadTxs = function() {
|
||||
controllerUtils.updateTxs();
|
||||
|
||||
setTimeout(function() {
|
||||
$scope.loading = false;
|
||||
$rootScope.$digest();
|
||||
|
|
@ -120,6 +120,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
if (msg.match('BIG'))
|
||||
msg = 'The transaction have too many inputs. Try creating many transactions for smaller amounts.'
|
||||
|
||||
if (msg.match('totalNeededAmount'))
|
||||
msg = 'Not enough funds.'
|
||||
|
||||
var message = 'The transaction' + (w.isShared() ? ' proposal' : '') + ' could not be created: ' + msg;
|
||||
$scope.error = message;
|
||||
$scope.loading = false;
|
||||
|
|
@ -400,17 +403,8 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.getAvailableAmount = function() {
|
||||
if (!$rootScope.safeUnspentCount) return null;
|
||||
|
||||
var estimatedFee = copay.Wallet.estimatedFee($rootScope.safeUnspentCount);
|
||||
var amount = ((($rootScope.availableBalance * w.settings.unitToSatoshi).toFixed(0) - estimatedFee) / w.settings.unitToSatoshi);
|
||||
|
||||
return amount > 0 ? amount : 0;
|
||||
};
|
||||
|
||||
$scope.topAmount = function(form) {
|
||||
$scope.amount = $scope.getAvailableAmount();
|
||||
$scope.setTopAmount = function() {
|
||||
$scope.amount = $rootScope.topAmount;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -449,6 +443,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
$scope.loadTxs();
|
||||
return;
|
||||
}
|
||||
$scope.error = undefined;
|
||||
|
||||
var p = w.txProposals.getTxProposal(ntxid);
|
||||
if (p.builder.isFullySigned()) {
|
||||
|
|
|
|||
|
|
@ -275,45 +275,6 @@ Identity.prototype.close = function(cb) {
|
|||
}, cb);
|
||||
};
|
||||
|
||||
/**
|
||||
* @desc Imports a wallet from an encrypted string
|
||||
* @param {string} cypherText - the encrypted object
|
||||
* @param {string} passphrase - passphrase to decrypt it
|
||||
* @param {string[]} opts.skipFields - fields to ignore when importing
|
||||
* @param {string[]} opts.salt -
|
||||
* @param {string[]} opts.iterations -
|
||||
* @param {string[]} opts.importFunction - for stubbing
|
||||
* @return {Wallet}
|
||||
*/
|
||||
|
||||
// This is not used in favor of Compatibility. importEncryptedWallet
|
||||
|
||||
// Identity.prototype.importEncryptedWallet = function(cypherText, password, opts, cb) {
|
||||
// var crypto = opts.cryptoUtil || cryptoUtil;
|
||||
// var obj = crypto.decrypt(password, cypherText);
|
||||
// console.log('[Identity.js.290:obj:]',obj); //TODO
|
||||
//
|
||||
// if (!obj) {
|
||||
// // 0.7.3 broken KDF
|
||||
// log.debug('Trying legacy encryption...');
|
||||
// console.log('[Identity.js.296:password:]',password); //TODO
|
||||
// var passphrase = crypto.kdf(password, 'mjuBtGybi/4=', 100);
|
||||
// console.log('[Identity.js.296:passphrase:]',passphrase); //TODO
|
||||
// obj = crypto.decrypt(passphrase, ejson);
|
||||
// console.log('[Identity.js.297:obj:]',obj); //TODO
|
||||
// }
|
||||
// console.log('[Identity.js.300:obj:]',obj); //TOD
|
||||
//
|
||||
// if (!obj)
|
||||
// return cb(new Error('Could not decrypt'));
|
||||
// try {
|
||||
// obj = JSON.parse(obj);
|
||||
// } catch (e) {
|
||||
// return cb(new Error('Could not decrypt'));
|
||||
// }
|
||||
// return this.importWalletFromObj(obj, opts, cb)
|
||||
// };
|
||||
//
|
||||
Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||
var self = this;
|
||||
preconditions.checkArgument(cb);
|
||||
|
|
|
|||
|
|
@ -812,6 +812,7 @@ Wallet.prototype._lockIncomming = function() {
|
|||
Wallet.prototype._setBlockchainListeners = function() {
|
||||
var self = this;
|
||||
self.blockchain.removeAllListeners();
|
||||
self.subscribeToAddresses();
|
||||
|
||||
log.debug('Setting Blockchain listeners for', this.getName());
|
||||
self.blockchain.on('reconnect', function(attempts) {
|
||||
|
|
@ -2179,6 +2180,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
|
|||
|
||||
Wallet.prototype.subscribeToAddresses = function() {
|
||||
var addrInfo = this.publicKeyRing.getAddressesInfo();
|
||||
console.log('[Wallet.js.2181:addrInfo:]',addrInfo); //TODO
|
||||
this.blockchain.subscribe(_.pluck(addrInfo, 'addressStr'));
|
||||
log.debug('Subscribed to ' + addrInfo.length + ' addresses'); //TODO
|
||||
};
|
||||
|
|
|
|||
|
|
@ -268,12 +268,18 @@ angular.module('copayApp.services')
|
|||
r.totalBalance = balanceSat * satToUnit;
|
||||
r.totalBalanceBTC = (balanceSat / COIN);
|
||||
r.availableBalance = safeBalanceSat * satToUnit;
|
||||
r.safeUnspentCount = safeUnspentCount;
|
||||
r.availableBalanceBTC = (safeBalanceSat / COIN);
|
||||
r.safeUnspentCount = safeUnspentCount;
|
||||
|
||||
r.lockedBalance = (balanceSat - safeBalanceSat) * satToUnit;
|
||||
r.lockedBalanceBTC = (balanceSat - safeBalanceSat) / COIN;
|
||||
|
||||
|
||||
if (r.safeUnspentCount){
|
||||
var estimatedFee = copay.Wallet.estimatedFee(r.safeUnspentCount);
|
||||
r.topAmount = (((r.availableBalance * w.settings.unitToSatoshi).toFixed(0) - estimatedFee) / w.settings.unitToSatoshi);
|
||||
}
|
||||
|
||||
var balanceByAddr = {};
|
||||
for (var ii in balanceByAddrSat) {
|
||||
balanceByAddr[ii] = balanceByAddrSat[ii] * satToUnit;
|
||||
|
|
@ -281,6 +287,8 @@ angular.module('copayApp.services')
|
|||
r.balanceByAddr = balanceByAddr;
|
||||
root.updateAddressList();
|
||||
|
||||
|
||||
|
||||
if (rateService.isAvailable()) {
|
||||
r.totalBalanceAlternative = rateService.toFiat(balanceSat, w.settings.alternativeIsoCode);
|
||||
r.alternativeIsoCode = w.settings.alternativeIsoCode;
|
||||
|
|
@ -303,6 +311,7 @@ angular.module('copayApp.services')
|
|||
};
|
||||
|
||||
root.updateBalance = function(w, cb, refreshAll) {
|
||||
|
||||
w = w || $rootScope.wallet;
|
||||
if (!w) return root.onErrorDigest();
|
||||
if (!w.isReady()) return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue