Enable SendMax to top up debit card
This commit is contained in:
parent
c9bad23b20
commit
28ef9a22dc
5 changed files with 81 additions and 15 deletions
36
src/js/services/sendMax.js
Normal file
36
src/js/services/sendMax.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').service('sendMaxService', function(feeService, configService, walletService) {
|
||||
|
||||
/**
|
||||
* Get sendMaxInfo
|
||||
*
|
||||
* @param {Obj} Wallet
|
||||
* @param {Callback} Function (optional)
|
||||
*
|
||||
*/
|
||||
this.getInfo = function(wallet, cb) {
|
||||
feeService.getCurrentFeeValue(wallet.credentials.network, function(err, feePerKb) {
|
||||
if (err) return cb(err);
|
||||
|
||||
var config = configService.getSync().wallet;
|
||||
|
||||
walletService.getSendMaxInfo(wallet, {
|
||||
feePerKb: feePerKb,
|
||||
excludeUnconfirmedUtxos: !config.spendUnconfirmed,
|
||||
returnInputs: true,
|
||||
}, function(err, resp) {
|
||||
if (err) return cb(err);
|
||||
|
||||
return cb(null, {
|
||||
sendMax: true,
|
||||
amount: resp.amount,
|
||||
inputs: resp.inputs,
|
||||
fee: resp.fee,
|
||||
feePerKb: feePerKb,
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
|
|
@ -184,5 +184,13 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
};
|
||||
};
|
||||
|
||||
root.satToUnit = function(amount) {
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var unitToSatoshi = config.unitToSatoshi;
|
||||
var satToUnit = 1 / unitToSatoshi;
|
||||
var unitDecimals = config.unitDecimals;
|
||||
return parseFloat((amount * satToUnit).toFixed(unitDecimals));
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue