approve
This commit is contained in:
parent
78b51ff938
commit
09425dc344
11 changed files with 390 additions and 281 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en" ng-controller="indexController as index">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
<div class="row collapse last-transactions-content line-b"
|
|
||||||
ng-class="{'text-gray':!tx.pendingForUs}"
|
|
||||||
ng-click="home.openTxpModal(tx, index.copayers, !!index.glideraStatus)">
|
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
|
||||||
<div class="m10r left pr">
|
|
||||||
<i class="icon-circle-active size-10" ng-show="tx.pendingForUs" ng-style="{'color':index.backgroundColor}"></i>
|
|
||||||
<img src="img/icon-proposal.svg" alt="sync" width="40">
|
|
||||||
</div>
|
|
||||||
<div class="m10t">
|
|
||||||
<div ng-show="!tx.merchant">
|
|
||||||
<span ng-show="index.addressbook[tx.toAddress] && !tx.message">
|
|
||||||
{{index.addressbook[tx.toAddress]}}
|
|
||||||
</span>
|
|
||||||
<span class="ellipsis" ng-show="!index.addressbook[tx.toAddress] && tx.message">
|
|
||||||
{{tx.message}}
|
|
||||||
</span>
|
|
||||||
<span ng-show="!index.addressbook[tx.toAddress] && !tx.message" translate>
|
|
||||||
Sending
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div ng-show="tx.merchant">
|
|
||||||
<span ng-show="tx.merchant.pr.ca"><i class="fi-lock"></i> {{tx.merchant.domain}}</span>
|
|
||||||
<span ng-show="!tx.merchant.pr.ca"><i class="fi-unlock"></i> {{tx.merchant.domain}}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-5 medium-5 small-5 columns text-right">
|
|
||||||
<span class="size-16">
|
|
||||||
- {{tx.amountStr}}
|
|
||||||
</span>
|
|
||||||
<div class="size-12 text-gray">
|
|
||||||
<time>{{ (tx.ts || tx.createdOn ) * 1000 | amTimeAgo}}</time>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="large-1 medium-1 small-1 columns text-right m10t">
|
|
||||||
<i class="icon-arrow-right3 size-18"></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
@ -8,8 +8,10 @@
|
||||||
<h1 class="title ellipsis" translate>Payment Proposal</h1>
|
<h1 class="title ellipsis" translate>Payment Proposal</h1>
|
||||||
</ion-header-bar>
|
</ion-header-bar>
|
||||||
|
|
||||||
<ion-content ng-style="{'background-color': '#F6F7F9'}">
|
<ion-content ng-style="{'background-color': '#F6F7F9'}" ng-init="updateCopayerList()">
|
||||||
<div class="modal-content fix-modals-touch" ng-init="updateCopayerList()">
|
<div class="list card">
|
||||||
|
<ul>
|
||||||
|
<li class="item" >
|
||||||
<div class="payment-proposal-head" ng-style="{'background-color':color}">
|
<div class="payment-proposal-head" ng-style="{'background-color':color}">
|
||||||
<div class="size-36">{{tx.amountStr}}</div>
|
<div class="size-36">{{tx.amountStr}}</div>
|
||||||
<div class="size-14 text-light" ng-show="tx.alternativeAmountStr">{{tx.alternativeAmountStr}}</div>
|
<div class="size-14 text-light" ng-show="tx.alternativeAmountStr">{{tx.alternativeAmountStr}}</div>
|
||||||
|
|
@ -21,8 +23,9 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="oh">
|
</li>
|
||||||
<div class="box-notification" ng-show="error">
|
<li class="item">
|
||||||
|
<div class="assertive" ng-show="error">
|
||||||
<span class="text-warning size-14">{{error|translate}}</span>
|
<span class="text-warning size-14">{{error|translate}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -31,27 +34,28 @@
|
||||||
The payment was removed by creator
|
The payment was removed by creator
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="item">
|
||||||
|
|
||||||
<div class="row p20t white" ng-if="tx.pendingForUs">
|
<div class="button-bar" ng-if="tx.pendingForUs">
|
||||||
<div class="large-6 medium-6 small-6 columns" ng-show="isShared">
|
<button class="button button-assertive button-block" ng-click="reject()" ng-disabled="loading" ng-show="isShared">
|
||||||
<button class="button outline round dark-gray expand" ng-click="reject(tx)" ng-disabled="loading">
|
<i class="fi-x"></i>
|
||||||
<i class="fi-x"></i>
|
<span translate>Reject</span>
|
||||||
<span translate>Reject</span>
|
</button>
|
||||||
</button>
|
<button class="button button-balanced button-block" ng-click="sign()" ng-style="{'background-color':color}" ng-disabled="loading || paymentExpired" ng-show="canSign">
|
||||||
</div>
|
<i class="fi-check"></i>
|
||||||
<div class="large-6 medium-6 small-6 columns text-right" ng-show="canSign">
|
<span translate>Accept</span>
|
||||||
<button class="button primary round expand" ng-click="sign(tx)" ng-style="{'background-color':color}" ng-disabled="loading || paymentExpired">
|
</button>
|
||||||
<i class="fi-check"></i>
|
|
||||||
<span translate>Accept</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-center text-gray size-12 m20t" ng-show="tx.status != 'pending'">
|
</li>
|
||||||
|
<li class="item">
|
||||||
|
|
||||||
|
<div ng-show="tx.status != 'pending'">
|
||||||
<div ng-show="tx.status=='accepted' && !tx.isGlidera">
|
<div ng-show="tx.status=='accepted' && !tx.isGlidera">
|
||||||
<div class="m10b" translate>Payment accepted, but not yet broadcasted</div>
|
<div class="m10b" translate>Payment accepted, but not yet broadcasted</div>
|
||||||
|
|
||||||
<button class="primary round m0" ng-style="{'background-color':color}" ng-click="broadcast(tx)" ng-disabled="loading">
|
<button class="button button-balanced button-block" ng-style="{'background-color':color}" ng-click="broadcast(tx)" ng-disabled="loading">
|
||||||
<i class="fi-upload-cloud"></i>
|
<i class="fi-upload-cloud"></i>
|
||||||
<span translate>Broadcast Payment</span>
|
<span translate>Broadcast Payment</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -59,11 +63,11 @@
|
||||||
<div ng-show="tx.status=='accepted' && tx.isGlidera" >
|
<div ng-show="tx.status=='accepted' && tx.isGlidera" >
|
||||||
<div class="m10h" translate>Payment accepted. It will be broadcasted by Glidera. In case there is a problem, it can be deleted 6 hours after it was created.</div>
|
<div class="m10h" translate>Payment accepted. It will be broadcasted by Glidera. In case there is a problem, it can be deleted 6 hours after it was created.</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-success" ng-show="tx.status == 'broadcasted'" translate>Payment Sent</div>
|
<div class="balanced" ng-show="tx.status == 'broadcasted'" translate>Payment Sent</div>
|
||||||
<div class="text-warning" ng-show="tx.status=='rejected'" translate>Payment Rejected</div>
|
<div class="assertive" ng-show="tx.status=='rejected'" translate>Payment Rejected</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</li>
|
||||||
|
<li class="item">
|
||||||
<h4 class="title m0" translate>Details</h4>
|
<h4 class="title m0" translate>Details</h4>
|
||||||
|
|
||||||
<ul class="no-bullet size-14 m0">
|
<ul class="no-bullet size-14 m0">
|
||||||
|
|
@ -105,6 +109,8 @@
|
||||||
<div class="p10 text-center size-12" ng-show="!currentSpendUnconfirmed && tx.hasUnconfirmedInputs">
|
<div class="p10 text-center size-12" ng-show="!currentSpendUnconfirmed && tx.hasUnconfirmedInputs">
|
||||||
<span class="text-warning" translate>Warning: this transaction has unconfirmed inputs</span>
|
<span class="text-warning" translate>Warning: this transaction has unconfirmed inputs</span>
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
|
<li class="item">
|
||||||
|
|
||||||
<div ng-if="tx.paypro">
|
<div ng-if="tx.paypro">
|
||||||
<h4 class="title m0" translate>Payment details</h4>
|
<h4 class="title m0" translate>Payment details</h4>
|
||||||
|
|
@ -138,7 +144,8 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="tx.actions[0] && !txRejected && !txBroadcasted">
|
</li>
|
||||||
|
<li class="item" ng-if="tx.actions[0] && !txRejected && !txBroadcasted">
|
||||||
<h4 class="title m0">
|
<h4 class="title m0">
|
||||||
<div class="right size-12 text-gray m10r">
|
<div class="right size-12 text-gray m10r">
|
||||||
{{tx.requiredSignatures}}/{{tx.walletN}}
|
{{tx.requiredSignatures}}/{{tx.walletN}}
|
||||||
|
|
@ -157,15 +164,17 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns text-center m20t" ng-if="tx.canBeRemoved || (tx.status == 'accepted' && !tx.broadcastedOn)">
|
</li>
|
||||||
|
<li class="item" ng-if="tx.canBeRemoved || (tx.status == 'accepted' && !tx.broadcastedOn)">
|
||||||
<div class="text-gray size-12 m20b" ng-show="!tx.isGlidera && isShared" translate>
|
<div class="text-gray size-12 m20b" ng-show="!tx.isGlidera && isShared" translate>
|
||||||
* A payment proposal can be deleted if 1) you are the creator, and no other copayer has signed, or 2) 24 hours have passed since the proposal was created.
|
* A payment proposal can be deleted if 1) you are the creator, and no other copayer has signed, or 2) 24 hours have passed since the proposal was created.
|
||||||
</div>
|
</div>
|
||||||
<button class="tiny round outline dark-gray warning" ng-click="remove(tx)" ng-disabled="loading">
|
<button class="button button-assertive button-block" ng-click="remove()" ng-disabled="loading">
|
||||||
<i class="fi-trash size-14 m5r"></i>
|
<i class="fi-trash size-14 m5r"></i>
|
||||||
<span translate>Delete Payment Proposal</span>
|
<span translate>Delete Payment Proposal</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-modal-view>
|
</ion-modal-view>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,48 @@
|
||||||
<ion-nav-title>Home</ion-nav-title>
|
<ion-nav-title>Home</ion-nav-title>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content class="padding home" ng-controller="tabHomeController">
|
<ion-content class="padding home" ng-controller="tabHomeController">
|
||||||
|
|
||||||
|
<h2 class="title m0" translate>Payment Proposals</h2>
|
||||||
|
<div class="list card" ng-if="txps[0]">
|
||||||
|
<ul>
|
||||||
|
<li ng-repeat="tx in txps" class="item item-icon-left"
|
||||||
|
ng-click="openTxpModal(tx)">
|
||||||
|
<i class="icon ion-ios-circle-filled" ng-show="tx.pendingForUs" ng-style="{'color':tx.wallet.color}"></i>
|
||||||
|
<span ng-show="!tx.merchant">
|
||||||
|
<span ng-show="addressbook[tx.toAddress] && !tx.message">
|
||||||
|
{{addressbook[tx.toAddress]}}
|
||||||
|
</span>
|
||||||
|
<span class="ellipsis" ng-show="!addressbook[tx.toAddress] && tx.message">
|
||||||
|
{{tx.message}}
|
||||||
|
</span>
|
||||||
|
<span ng-show="!addressbook[tx.toAddress] && !tx.message" translate>
|
||||||
|
Sending
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span ng-show="tx.merchant">
|
||||||
|
<span ng-show="tx.merchant.pr.ca"><i class="fi-lock"></i> {{tx.merchant.domain}}</span>
|
||||||
|
<span ng-show="!tx.merchant.pr.ca"><i class="fi-unlock"></i> {{tx.merchant.domain}}</span>
|
||||||
|
</span>
|
||||||
|
<span >
|
||||||
|
<span>
|
||||||
|
- {{tx.amountStr}}
|
||||||
|
</span>
|
||||||
|
<div class="item item-divider">
|
||||||
|
{{tx.wallet.name}} · <time>{{ (tx.ts || tx.createdOn ) * 1000 | amTimeAgo}}</time>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div ng-show="lockedBalanceSat">
|
||||||
|
<span translate>Total Locked Balance</span>:
|
||||||
|
<b>{{lockedBalanceStr}} </b>
|
||||||
|
<span> {{lockedBalanceAlternative}} {{alternativeIsoCode}} </span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="#/add"><i class="ion-ios-plus-outline right"></i></a>
|
<a href="#/add"><i class="ion-ios-plus-outline right"></i></a>
|
||||||
<h2>Wallets </h2>
|
<h2>Wallets </h2>
|
||||||
<div class="list card">
|
<div class="list card">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, ongoingProcess, fingerprintService, gettext) {
|
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, go, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext) {
|
||||||
|
|
||||||
// An alert dialog
|
// An alert dialog
|
||||||
var showAlert = function(title, msg, cb) {
|
var showAlert = function(title, msg, cb) {
|
||||||
|
|
@ -16,49 +16,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// An alert dialog
|
|
||||||
var askPassword = function(name, cb) {
|
|
||||||
$scope.data = [];
|
|
||||||
var pass = $ionicPopup.show({
|
|
||||||
template: '<input type="password" ng-model="data.pass">',
|
|
||||||
title: 'Enter Spending Password',
|
|
||||||
subTitle: name,
|
|
||||||
scope: $scope,
|
|
||||||
buttons: [{
|
|
||||||
text: 'Cancel'
|
|
||||||
}, {
|
|
||||||
text: '<b>OK</b>',
|
|
||||||
type: 'button-positive',
|
|
||||||
onTap: function(e) {
|
|
||||||
|
|
||||||
console.log('[confirm.js.32]', $scope, $scope.data); //TODO
|
|
||||||
if (!$scope.data.pass) {
|
|
||||||
//don't allow the user to close unless he enters wifi password
|
|
||||||
e.preventDefault();
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $scope.data.pass;
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
});
|
|
||||||
pass.then(function(res) {
|
|
||||||
console.log('Tapped!', res);
|
|
||||||
return cb(res);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var handleEncryptedWallet = function(wallet, cb) {
|
|
||||||
if (!walletService.isEncrypted(wallet)) return cb();
|
|
||||||
|
|
||||||
askPassword(wallet.name, function(password) {
|
|
||||||
if (!password) return cb('no password');
|
|
||||||
return cb(walletService.unlock(wallet, password));
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var unitToSatoshi;
|
var unitToSatoshi;
|
||||||
var satToUnit;
|
var satToUnit;
|
||||||
|
|
@ -118,6 +76,7 @@ console.log('[confirm.js.32]', $scope, $scope.data); //TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
var createTx = function(toAddress, toAmount, comment) {
|
var createTx = function(toAddress, toAmount, comment) {
|
||||||
|
console.log('[confirm.js.78:toAddress:]',toAddress); //TODO
|
||||||
//
|
//
|
||||||
var currentSpendUnconfirmed = config.spendUnconfirmed;
|
var currentSpendUnconfirmed = config.spendUnconfirmed;
|
||||||
|
|
||||||
|
|
@ -146,37 +105,39 @@ console.log('[confirm.js.32]', $scope, $scope.data); //TODO
|
||||||
return setSendError(gettext(msg));
|
return setSendError(gettext(msg));
|
||||||
};
|
};
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
outputs.push({
|
outputs.push({
|
||||||
'toAddress': toAddress,
|
'toAddress': toAddress,
|
||||||
'amount': toAmount,
|
'amount': toAmount,
|
||||||
'message': comment
|
'message': comment
|
||||||
});
|
});
|
||||||
|
|
||||||
var txp = {};
|
var txp = {};
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
if (!lodash.isEmpty($scope.sendMaxInfo)) {
|
if (!lodash.isEmpty($scope.sendMaxInfo)) {
|
||||||
txp.sendMax = true;
|
txp.sendMax = true;
|
||||||
txp.inputs = $scope.sendMaxInfo.inputs;
|
txp.inputs = $scope.sendMaxInfo.inputs;
|
||||||
txp.fee = $scope.sendMaxInfo.fee;
|
txp.fee = $scope.sendMaxInfo.fee;
|
||||||
|
}
|
||||||
|
|
||||||
|
txp.outputs = outputs;
|
||||||
|
txp.message = comment;
|
||||||
|
txp.payProUrl = paypro ? paypro.url : null;
|
||||||
|
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
||||||
|
txp.feeLevel = config.feeLevel || 'normal';
|
||||||
|
|
||||||
|
|
||||||
|
console.log('[confirm.js.129]'); //TODO
|
||||||
|
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
||||||
|
|
||||||
|
console.log('[confirm.js.132]', err); //TODO
|
||||||
|
if (err) {
|
||||||
|
return setSendError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
txp.outputs = outputs;
|
$scope.fee = ((createdTxp.fee) * satToUnit).toFixed(unitDecimals);
|
||||||
txp.message = comment;
|
$scope.txp = createdTxp;
|
||||||
txp.payProUrl = paypro ? paypro.url : null;
|
$scope.$apply();
|
||||||
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
|
|
||||||
txp.feeLevel = config.feeLevel || 'normal';
|
|
||||||
|
|
||||||
|
|
||||||
walletService.createTx(wallet, txp, function(err, createdTxp) {
|
|
||||||
if (err) {
|
|
||||||
return setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.fee = ((createdTxp.fee) * satToUnit).toFixed(unitDecimals);
|
|
||||||
$scope.txp = createdTxp;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -196,76 +157,16 @@ console.log('[confirm.js.32]', $scope, $scope.data); //TODO
|
||||||
|
|
||||||
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
|
||||||
$log.info('No signing proposal: No private key');
|
$log.info('No signing proposal: No private key');
|
||||||
ongoingProcess.set('sendingTx', true);
|
|
||||||
walletService.publishTx(wallet, txp, function(err, publishedTxp) {
|
|
||||||
ongoingProcess.set('sendingTx', false);
|
|
||||||
if (err) {
|
|
||||||
return setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
$state.transitionTo('tab.home');
|
return walletService.onlyPublish(wallet,txp, function(err, txp){
|
||||||
|
if (err) return setSendError(err);
|
||||||
var type = txStatus.notify(createdTxp);
|
$state.transitionTo('tabs.home');
|
||||||
$scope.openStatusModal(type, createdTxp, function() {
|
|
||||||
return $scope.$emit('Local/TxProposalAction');
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fingerprintService.check(wallet, function(err) {
|
walletService.publishAndSign(wallet, txp, function(err, txp) {
|
||||||
if (err) {
|
if (err) return setSendError(err);
|
||||||
return setSendError(err);
|
$state.transitionTo('tabs.home');
|
||||||
}
|
|
||||||
|
|
||||||
handleEncryptedWallet(wallet, function(err) {
|
|
||||||
if (err) {
|
|
||||||
return setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
ongoingProcess.set('sendingTx', true);
|
|
||||||
walletService.publishTx(wallet, txp, function(err, publishedTxp) {
|
|
||||||
ongoingProcess.set('sendingTx', false);
|
|
||||||
if (err) {
|
|
||||||
return setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
ongoingProcess.set('signingTx', true);
|
|
||||||
walletService.signTx(wallet, txp, function(err, signedTxp) {
|
|
||||||
ongoingProcess.set('signingTx', false);
|
|
||||||
walletService.lock(wallet);
|
|
||||||
if (err) {
|
|
||||||
$scope.$emit('Local/TxProposalAction');
|
|
||||||
return setSendError(
|
|
||||||
err.message ?
|
|
||||||
err.message :
|
|
||||||
gettext('The payment was created but could not be completed. Please try again from home screen'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (signedTxp.status == 'accepted') {
|
|
||||||
ongoingProcess.set('broadcastingTx', true);
|
|
||||||
walletService.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
|
||||||
ongoingProcess.set('broadcastingTx', false);
|
|
||||||
if (err) {
|
|
||||||
return setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
$state.transitionTo('tabs.send');
|
|
||||||
var type = txStatus.notify(broadcastedTxp);
|
|
||||||
$scope.openStatusModal(type, broadcastedTxp, function() {
|
|
||||||
$scope.$emit('Local/TxProposalAction', broadcastedTxp.status == 'broadcasted');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$state.transitionTo('tabs.send');
|
|
||||||
var type = txStatus.notify(signedTxp);
|
|
||||||
$scope.openStatusModal(type, signedTxp, function() {
|
|
||||||
$scope.$emit('Local/TxProposalAction');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,18 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, profileService, walletService) {
|
angular.module('copayApp.controllers').controller('txpDetailsController', function($scope, $rootScope, $timeout, $interval, $ionicModal, ongoingProcess, platformInfo, txStatus, $ionicScrollDelegate, txFormatService, fingerprintService, bwcError, gettextCatalog, lodash, walletService) {
|
||||||
var self = $scope.self;
|
var self = $scope.self;
|
||||||
var tx = $scope.tx;
|
var tx = $scope.tx;
|
||||||
var copayers = $scope.copayers;
|
var copayers = $scope.copayers;
|
||||||
var isGlidera = $scope.isGlidera;
|
var isGlidera = $scope.isGlidera;
|
||||||
var now = Math.floor(Date.now() / 1000);
|
var now = Math.floor(Date.now() / 1000);
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
$scope.loading = null;
|
$scope.loading = null;
|
||||||
$scope.copayerId = fc.credentials.copayerId;
|
|
||||||
$scope.isShared = fc.credentials.n > 1;
|
|
||||||
$scope.canSign = fc.canSign() || fc.isPrivKeyExternal();
|
$scope.copayerId = $scope.wallet.credentials.copayerId;
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.isShared = $scope.wallet.credentials.n > 1;
|
||||||
|
$scope.canSign = $scope.wallet.canSign() || $scope.wallet.isPrivKeyExternal();
|
||||||
|
$scope.color = $scope.wallet.color;
|
||||||
|
|
||||||
checkPaypro();
|
checkPaypro();
|
||||||
|
|
||||||
|
|
@ -23,51 +24,18 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.sign = function(txp) {
|
var setSendError = function(msg) {
|
||||||
|
$scope.error = msg || gettextCatalog.getString('Could not send payment');
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.sign = function() {
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
walletService.publishAndSign($scope.wallet, $scope.tx, function(err, txp) {
|
||||||
$timeout(function() {
|
$scope.$emit('UpdateTx');
|
||||||
fingerprintService.check(fc, function(err) {
|
if (err) return setSendError(err);
|
||||||
if (err) {
|
$scope.close(signedTxp);
|
||||||
$scope.error = gettextCatalog.getString('Could not send payment');
|
});
|
||||||
$scope.loading = false;
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
handleEncryptedWallet(function(err) {
|
|
||||||
if (err) {
|
|
||||||
return setError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
ongoingProcess.set('signingTx', true);
|
|
||||||
walletService.signTx(fc, txp, function(err, signedTxp) {
|
|
||||||
ongoingProcess.set('signingTx', false);
|
|
||||||
if (err) {
|
|
||||||
return setError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (signedTxp.status == 'accepted') {
|
|
||||||
ongoingProcess.set('broadcastingTx', true);
|
|
||||||
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
|
|
||||||
ongoingProcess.set('broadcastingTx', false);
|
|
||||||
$scope.$emit('UpdateTx');
|
|
||||||
$scope.close(broadcastedTxp);
|
|
||||||
if (err) {
|
|
||||||
return setError(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$scope.$emit('UpdateTx');
|
|
||||||
$scope.close(signedTxp);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 10);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function setError(err, prefix) {
|
function setError(err, prefix) {
|
||||||
|
|
@ -79,7 +47,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.$on('$destroy', function() {
|
$scope.$on('$destroy', function() {
|
||||||
walletService.lock(fc);
|
walletService.lock($scope.wallet);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.reject = function(txp) {
|
$scope.reject = function(txp) {
|
||||||
|
|
@ -88,7 +56,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
ongoingProcess.set('rejectTx', true);
|
ongoingProcess.set('rejectTx', true);
|
||||||
walletService.rejectTx(fc, txp, function(err, txpr) {
|
walletService.rejectTx($scope.wallet, $scope.tx, function(err, txpr) {
|
||||||
ongoingProcess.set('rejectTx', false);
|
ongoingProcess.set('rejectTx', false);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -101,13 +69,13 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
}, 10);
|
}, 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.remove = function(txp) {
|
$scope.remove = function() {
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
ongoingProcess.set('removeTx', true);
|
ongoingProcess.set('removeTx', true);
|
||||||
walletService.removeTx(fc, txp, function(err) {
|
walletService.removeTx($scope.wallet, $scope.tx, function(err) {
|
||||||
ongoingProcess.set('removeTx', false);
|
ongoingProcess.set('removeTx', false);
|
||||||
|
|
||||||
// Hacky: request tries to parse an empty response
|
// Hacky: request tries to parse an empty response
|
||||||
|
|
@ -127,7 +95,7 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
ongoingProcess.set('broadcastTx', true);
|
ongoingProcess.set('broadcastTx', true);
|
||||||
walletService.broadcastTx(fc, txp, function(err, txpb) {
|
walletService.broadcastTx($scope.wallet, $scope.tx, function(err, txpb) {
|
||||||
ongoingProcess.set('broadcastTx', false);
|
ongoingProcess.set('broadcastTx', false);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService ) {
|
function($rootScope, $timeout, $scope, $state, lodash, profileService, walletService, configService, txFormatService, $ionicModal, $log) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -23,10 +23,88 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.wallets = profileService.getWallets();
|
$scope.wallets = profileService.getWallets();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var setPendingTxps = function(txps) {
|
||||||
|
$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);
|
||||||
|
*/
|
||||||
|
|
||||||
|
lodash.each(txps, function(tx) {
|
||||||
|
|
||||||
|
tx = txFormatService.processTx(tx);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (tx.creatorId != tx.wallet.copayerId) {
|
||||||
|
$scope.pendingTxProposalsCountForUs = $scope.pendingTxProposalsCountForUs + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$scope.txps = txps;
|
||||||
|
};
|
||||||
|
|
||||||
self.updateAllClients = function() {
|
self.updateAllClients = function() {
|
||||||
lodash.each(profileService.getWallets(), function(wallet) {
|
var txps = [];
|
||||||
walletService.updateStatus(wallet, {}, function(err, status) {
|
var wallets = profileService.getWallets();
|
||||||
if (err) {} // TODO
|
var l = wallets.length,
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
lodash.each(wallets, function(wallet) {
|
||||||
|
walletService.updateStatus(wallet, {}, function(err) {
|
||||||
|
var status = wallet.status;
|
||||||
|
if (err) {
|
||||||
|
console.log('[tab-home.js.35:err:]',$log.error(err)); //TODO
|
||||||
|
return;
|
||||||
|
} // TODO
|
||||||
|
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||||
|
txps = txps.concat(status.pendingTxps);
|
||||||
|
}
|
||||||
|
if (++i == l) {
|
||||||
|
setPendingTxps(txps);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -36,5 +114,28 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
$scope.bitpayCardEnabled = true; // TODO
|
$scope.bitpayCardEnabled = true; // TODO
|
||||||
|
|
||||||
|
|
||||||
// $state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
|
var config = configService.getSync().wallet;
|
||||||
|
|
||||||
|
var GLIDERA_LOCK_TIME = 6 * 60 * 60;
|
||||||
|
|
||||||
|
var glideraActive = true; // TODO TODO TODO
|
||||||
|
// isGlidera flag is a security measure so glidera status is not
|
||||||
|
// only determined by the tx.message
|
||||||
|
$scope.openTxpModal = function(tx) {
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
scope.tx = tx;
|
||||||
|
scope.wallet = tx.wallet;
|
||||||
|
scope.copayers = tx.wallet.copayers;
|
||||||
|
scope.isGlidera = glideraActive;
|
||||||
|
scope.currentSpendUnconfirmed = config.spendUnconfirmed;
|
||||||
|
|
||||||
|
$ionicModal.fromTemplateUrl('views/modals/txp-details.html', {
|
||||||
|
scope: scope
|
||||||
|
}).then(function(modal) {
|
||||||
|
scope.txpDetailsModal = modal;
|
||||||
|
scope.txpDetailsModal.show();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// $state.transitionTo('confirm', {toAmount:555500, toAddress: 'mvfAwUJohJWibGzBZgAUGsDarsr4Z4NovU', toName: 'bla bla'});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ angular.module('copayApp.services')
|
||||||
c.name = config.aliasFor[walletId] || client.credentials.walletName;
|
c.name = config.aliasFor[walletId] || client.credentials.walletName;
|
||||||
c.color = config.colorFor[walletId] || '#4A90E2';
|
c.color = config.colorFor[walletId] || '#4A90E2';
|
||||||
c.network = client.credentials.network;
|
c.network = client.credentials.network;
|
||||||
|
c.copayerId = client.credentials.copayerId;
|
||||||
c.m = client.credentials.m;
|
c.m = client.credentials.m;
|
||||||
c.n = client.credentials.n;
|
c.n = client.credentials.n;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('txFormatService', function(profileService, rateService, configService, lodash) {
|
angular.module('copayApp.services').factory('txFormatService', function(walletService, rateService, configService, lodash) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
var formatAmountStr = function(amount) {
|
var formatAmountStr = function(amount) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// DO NOT INCLUDE STORAGE HERE \/ \/
|
// DO NOT INCLUDE STORAGE HERE \/ \/
|
||||||
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError) {
|
angular.module('copayApp.services').factory('walletService', function($log, $timeout, lodash, trezor, ledger, storageService, configService, rateService, uxLanguage, bwcService, $filter, gettextCatalog, bwcError, $ionicPopup, fingerprintService, ongoingProcess, gettext, $rootScope, txStatus) {
|
||||||
// DO NOT INCLUDE STORAGE HERE ^^
|
// DO NOT INCLUDE STORAGE HERE ^^
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
@ -10,6 +10,26 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
||||||
|
// UI Related
|
||||||
|
root.openStatusModal = function(type, txp, cb) {
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
scope.type = type;
|
||||||
|
scope.tx = txFormatService.processTx(txp);
|
||||||
|
scope.color = txp.color;
|
||||||
|
scope.cb = cb;
|
||||||
|
|
||||||
|
$ionicModal.fromTemplateUrl('views/modals/tx-status.html', {
|
||||||
|
scope: scope,
|
||||||
|
animation: 'slide-in-up'
|
||||||
|
}).then(function(modal) {
|
||||||
|
scope.txStatusModal = modal;
|
||||||
|
scope.txStatusModal.show();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // RECEIVE
|
// // RECEIVE
|
||||||
// // Check address
|
// // Check address
|
||||||
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
// root.isUsed(wallet.walletId, balance.byAddress, function(err, used) {
|
||||||
|
|
@ -108,12 +128,12 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
self.notAuthorized = true;
|
self.notAuthorized = true;
|
||||||
go.walletHome();
|
go.walletHome();
|
||||||
} else if (err instanceof errors.NOT_FOUND) {
|
} else if (err instanceof errors.NOT_FOUND) {
|
||||||
self.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
root.showErrorPopup(gettext('Could not access Wallet Service: Not found'));
|
||||||
} else {
|
} else {
|
||||||
var msg = ""
|
var msg = ""
|
||||||
$scope.$emit('Local/ClientError', (err.error ? err.error : err));
|
$rootScope.$emit('Local/ClientError', (err.error ? err.error : err));
|
||||||
var msg = bwcError.msg(err, gettext('Error at Wallet Service'));
|
var msg = bwcError.msg(err, gettext('Error at Wallet Service'));
|
||||||
self.showErrorPopup(msg);
|
root.showErrorPopup(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
root.handleError = lodash.debounce(_handleError, 1000);
|
root.handleError = lodash.debounce(_handleError, 1000);
|
||||||
|
|
@ -183,6 +203,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
wallet.isValid = true;
|
wallet.isValid = true;
|
||||||
root.setBalance(wallet, status.balance);
|
root.setBalance(wallet, status.balance);
|
||||||
wallet.email = status.preferences.email;
|
wallet.email = status.preferences.email;
|
||||||
|
wallet.copayers = status.wallet.copayers;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.updateStatus = function(wallet, opts, cb, initStatusHash, tries) {
|
root.updateStatus = function(wallet, opts, cb, initStatusHash, tries) {
|
||||||
|
|
@ -692,26 +713,18 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
root.updateHistory();
|
root.updateHistory();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
self.showErrorPopup = function(msg, cb) {
|
root.showErrorPopup = function(msg, cb) {
|
||||||
$log.warn('Showing err popup:' + msg);
|
$log.warn('Showing err popup:' + msg);
|
||||||
|
|
||||||
function openErrorPopup(msg, cb) {
|
// An alert dialog
|
||||||
$scope.msg = msg;
|
var alertPopup = $ionicPopup.alert({
|
||||||
|
title: title,
|
||||||
self.errorPopup = $ionicPopup.show({
|
template: msg
|
||||||
templateUrl: 'views/includes/alert.html',
|
|
||||||
scope: $scope,
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.close = function() {
|
|
||||||
return cb();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
openErrorPopup(msg, function() {
|
|
||||||
self.errorPopup.close();
|
|
||||||
if (cb) return cb();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!cb) cb = function() {};
|
||||||
|
|
||||||
|
alertPopup.then(cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.recreate = function(wallet, cb) {
|
root.recreate = function(wallet, cb) {
|
||||||
|
|
@ -841,12 +854,124 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// An alert dialog
|
||||||
|
var askPassword = function(name, cb) {
|
||||||
|
var scope = $rootScope.$new(true);
|
||||||
|
scope.data = [];
|
||||||
|
var pass = $ionicPopup.show({
|
||||||
|
template: '<input type="password" ng-model="data.pass">',
|
||||||
|
title: 'Enter Spending Password',
|
||||||
|
subTitle: name,
|
||||||
|
scope: scope,
|
||||||
|
buttons: [{
|
||||||
|
text: 'Cancel'
|
||||||
|
}, {
|
||||||
|
text: '<b>OK</b>',
|
||||||
|
type: 'button-positive',
|
||||||
|
onTap: function(e) {
|
||||||
|
if (!scope.data.pass) {
|
||||||
|
//don't allow the user to close unless he enters wifi password
|
||||||
|
e.preventDefault();
|
||||||
|
return;
|
||||||
|
|
||||||
root.handleEncryptedWallet = function(client, cb) {
|
}
|
||||||
if (!root.isEncrypted(client)) return cb();
|
|
||||||
$rootScope.$emit('Local/NeedsPassword', false, function(err, password) {
|
return scope.data.pass;
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
pass.then(function(res) {
|
||||||
|
console.log('Tapped!', res);
|
||||||
|
return cb(res);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.handleEncryptedWallet = function(wallet, cb) {
|
||||||
|
if (!root.isEncrypted(wallet)) return cb();
|
||||||
|
|
||||||
|
askPassword(wallet.name, function(password) {
|
||||||
|
if (!password) return cb('no password');
|
||||||
|
return cb(root.unlock(wallet, password));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.onlyPublish = function(wallet, txp, cb) {
|
||||||
|
ongoingProcess.set('sendingTx', true);
|
||||||
|
root.publishTx(wallet, txp, function(err, publishedTxp) {
|
||||||
|
ongoingProcess.set('sendingTx', false);
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
return cb(walletService.unlock(client, password));
|
|
||||||
|
var type = txStatus.notify(createdTxp);
|
||||||
|
root.openStatusModal(type, createdTxp, function() {
|
||||||
|
// TODO?
|
||||||
|
//return $scope.$emit('Local/TxProposalAction');
|
||||||
|
});
|
||||||
|
|
||||||
|
return cb(null, publishedTxp);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.publishAndSign = function(wallet, txp, cb) {
|
||||||
|
|
||||||
|
var publishFn = root.publishTx;
|
||||||
|
|
||||||
|
// Already published?
|
||||||
|
if (txp.status == 'pending') {
|
||||||
|
publishFn = function(wallet, txp, cb) {
|
||||||
|
return cb(null, txp);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fingerprintService.check(wallet, function(err) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
root.handleEncryptedWallet(wallet, function(err) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
ongoingProcess.set('sendingTx', true);
|
||||||
|
publishFn(wallet, txp, function(err, publishedTxp) {
|
||||||
|
ongoingProcess.set('sendingTx', false);
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
ongoingProcess.set('signingTx', true);
|
||||||
|
root.signTx(wallet, txp, function(err, signedTxp) {
|
||||||
|
ongoingProcess.set('signingTx', false);
|
||||||
|
root.lock(wallet);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
// TODO?
|
||||||
|
//$scope.$emit('Local/TxProposalAction');
|
||||||
|
var msg = err.message ?
|
||||||
|
err.message :
|
||||||
|
gettext('The payment was created but could not be completed. Please try again from home screen');
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (signedTxp.status == 'accepted') {
|
||||||
|
ongoingProcess.set('broadcastingTx', true);
|
||||||
|
root.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
||||||
|
ongoingProcess.set('broadcastingTx', false);
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
var type = txStatus.notify(broadcastedTxp);
|
||||||
|
root.openStatusModal(type, broadcastedTxp, function() {
|
||||||
|
// TODO?
|
||||||
|
//$scope.$emit('Local/TxProposalAction', broadcastedTxp.status == 'broadcasted');
|
||||||
|
});
|
||||||
|
|
||||||
|
return cb(null, broadcastedTxp)
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var type = txStatus.notify(signedTxp);
|
||||||
|
root.openStatusModal(type, signedTxp, function() {
|
||||||
|
// TODO?
|
||||||
|
//$scope.$emit('Local/TxProposalAction');
|
||||||
|
});
|
||||||
|
return cb(null, signedTxp);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue