fixing delay in render second button

This commit is contained in:
Gabriel Bazán 2015-10-02 11:58:20 -03:00 committed by Javier
parent 0835f91a42
commit df45a22f18
3 changed files with 18 additions and 19 deletions

View File

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Scan Paper Wallet'; goBackToState = 'preferencesAdvanced';">
ng-init="titleSection='Sweep paper wallet'; goBackToState = 'preferencesAdvanced';">
</div>
<div class="content p20v" ng-controller="paperWalletController as paperWallet">
@ -24,17 +24,18 @@
</div>
<div ng-show="paperWallet.balance">
<label for="totalBalance">
<h2 translate>Total Amount to be recived: {{paperWallet.balance}} BTC</h2>
<h2 translate>Funds founds: {{paperWallet.balance}} BTC</h2>
</label>
</div>
</div>
</div>
<div class="row">
<div class="large-12 medium-12 columns" ng-show="paperWallet.balance">
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.transaction()" translate>Accept</button>
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.transaction()" translate>sweep wallet</button>
<span>Funds will be transfered to the wallet: {{index.alias}} </span>
</div>
<div class="large-12 medium-12 columns" ng-show="!paperWallet.balance" >
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.createTx(privateKey, passphrase)" translate>Create transaction</button>
<button ng-style="{'background-color':index.backgroundColor}" class="button black round expand" ng-click="paperWallet.createTx(privateKey, passphrase)" translate>Scan Wallet Funds</button>
</div>
</div>
</div>

View File

@ -19,7 +19,7 @@
<li class="line-b p20" ng-click="$root.go('paperWallet')">
<i class="icon-arrow-right3 size-24 right text-gray"></i>
<span translate>Scan Paper Wallet</span>
<span translate>Sweep paper wallet</span>
</li>
<li class="line-b p20" ng-click="$root.go('export')">

View File

@ -1,5 +1,5 @@
angular.module('copayApp.controllers').controller('paperWalletController',
function($scope, $http, profileService, addressService) {
function($scope, $http, $timeout, profileService, go, addressService) {
self = this;
var fc = profileService.focusedClient;
@ -7,22 +7,19 @@ angular.module('copayApp.controllers').controller('paperWalletController',
self.onQrCodeScanned = function(data) {
$scope.privateKey = data;
console.log(data);
}
self.createTx = function(privateKey, passphrase) {
console.log("entro");
console.log(privateKey);
console.log(passphrase);
if (!privateKey) self.error = "Enter privateKey or scann for one";
this.getRawTx(privateKey, passphrase, function(err, rawTx, utxos) {
console.log(utxos);
console.log("creada");
self.getRawTx(privateKey, passphrase, function(err, rawtx, utxos) {
if (err) self.error = err.toString();
else {
self.balance = (utxos / 1e8).toFixed(8);
rawTx = rawTx;
rawTx = rawtx;
}
$timeout(function() {
$scope.$apply();
}, 1);
});
};
@ -39,7 +36,6 @@ angular.module('copayApp.controllers').controller('paperWalletController',
fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) {
if (err) return cb(err);
console.log(tx.serialize());
return cb(null, tx.serialize(), utxos);
});
});
@ -54,7 +50,6 @@ angular.module('copayApp.controllers').controller('paperWalletController',
fc.buildTxFromPrivateKey(privateKey, destinationAddress, null, function(err, tx) {
if (err) return cb(err);
console.log(tx.serialize());
return cb(null, tx.serialize(), utxos);
});
});
@ -64,15 +59,18 @@ angular.module('copayApp.controllers').controller('paperWalletController',
self.transaction = function() {
self.doTransaction(rawTx).then(function(response) {
console.log(response); //mostrar pantalla de sent successfully
self.doTransaction(rawTx).then(function(err, response) {
self.goHome();
},
function(err) {
self.error = err;
console.log(err); //mostrar mensaje de error en la pantalla
});
};
self.goHome = function() {
go.walletHome();
};
self.doTransaction = function(rawTx) {
return $http.post('https://insight.bitpay.com/api/tx/send', {
rawtx: rawTx