requeriments to send

This commit is contained in:
Gabriel Bazán 2016-09-21 11:47:19 -03:00
commit cb64e57e45
6 changed files with 112 additions and 63 deletions

View file

@ -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;
});