Merge pull request #3801 from bitpay/v1.7
Updating master with v1.7 patches
This commit is contained in:
commit
ec8f588e69
19 changed files with 341 additions and 357 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<widget id="com.bitpay.copay"
|
<widget id="com.bitpay.copay"
|
||||||
version="1.7.1"
|
version="1.7.2"
|
||||||
android-versionCode="63"
|
android-versionCode="64"
|
||||||
ios-CFBundleVersion="1.7.1">
|
ios-CFBundleVersion="1.7.2">
|
||||||
<name>Copay</name>
|
<name>Copay</name>
|
||||||
<description>
|
<description>
|
||||||
A secure bitcoin wallet for friends and companies.
|
A secure bitcoin wallet for friends and companies.
|
||||||
|
|
|
||||||
|
|
@ -57,11 +57,11 @@
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.7.1</string>
|
<string>1.7.2</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.7.1</string>
|
<string>1.7.2</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSMainNibFile</key>
|
<key>NSMainNibFile</key>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
|
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
|
||||||
<Identity Name="18C7659D.CopayWallet" Publisher="CN=F89609D1-EB3E-45FD-A58A-C2E3895FCE7B" Version="1.7.1.0" />
|
<Identity Name="18C7659D.CopayWallet" Publisher="CN=F89609D1-EB3E-45FD-A58A-C2E3895FCE7B" Version="1.7.2.0" />
|
||||||
<mp:PhoneIdentity PhoneProductId="5381aa50-9069-11e4-84cc-293caf9cbdc8" PhonePublisherId="F89609D1-EB3E-45FD-A58A-C2E3895FCE7B" />
|
<mp:PhoneIdentity PhoneProductId="5381aa50-9069-11e4-84cc-293caf9cbdc8" PhonePublisherId="F89609D1-EB3E-45FD-A58A-C2E3895FCE7B" />
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>Copay Bitcoin Wallet</DisplayName>
|
<DisplayName>Copay Bitcoin Wallet</DisplayName>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<Language code="es" />
|
<Language code="es" />
|
||||||
<Language code="ru" />
|
<Language code="ru" />
|
||||||
</Languages>
|
</Languages>
|
||||||
<App Author="Bitpay Inc." BitsPerPixel="32" Description="A multisignature Bitcoin Wallet" Genre="apps.normal" ProductID="{5381aa50-9069-11e4-84cc-293caf9cbdc8}" Publisher="Copay Bitcoin Wallet" PublisherID="{31cdd08b-457c-413d-b440-f6665eec847d}" RuntimeType="Silverlight" Title="Copay Bitcoin Wallet" Version="1.7.1.0" xmlns="" NotificationService="MPN">
|
<App Author="Bitpay Inc." BitsPerPixel="32" Description="A multisignature Bitcoin Wallet" Genre="apps.normal" ProductID="{5381aa50-9069-11e4-84cc-293caf9cbdc8}" Publisher="Copay Bitcoin Wallet" PublisherID="{31cdd08b-457c-413d-b440-f6665eec847d}" RuntimeType="Silverlight" Title="Copay Bitcoin Wallet" Version="1.7.2.0" xmlns="" NotificationService="MPN">
|
||||||
<IconPath IsRelative="true" IsResource="false">Assets\icon@2.png</IconPath>
|
<IconPath IsRelative="true" IsResource="false">Assets\icon@2.png</IconPath>
|
||||||
<Capabilities>
|
<Capabilities>
|
||||||
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "copay",
|
"name": "copay",
|
||||||
"description": "A multisignature wallet",
|
"description": "A multisignature wallet",
|
||||||
"author": "BitPay",
|
"author": "BitPay",
|
||||||
"version": "1.7.1",
|
"version": "1.7.2",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"wallet",
|
"wallet",
|
||||||
"copay",
|
"copay",
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div ng-show="wordsC.step == 1">
|
<div ng-show="wordsC.step == 1">
|
||||||
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)">
|
<div ng-show="wordsC.mnemonicWords || (wordsC.credentialsEncrypted && !wordsC.deleted)" class="row">
|
||||||
<h5 class="text-center" translate>Write your wallet seed</h5>
|
<h5 class="text-center" translate>Write your wallet seed</h5>
|
||||||
<div class="size-14 text-gray" ng-show="(index.n>1 && index.m != index.n )">
|
<div class="size-14 text-gray columns" ng-show="(index.n>1 && index.m != index.n )">
|
||||||
<span translate>
|
<span translate>
|
||||||
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
|
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
|
||||||
</span>:
|
</span>:
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
</ol>
|
</ol>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="size-14 text-gray" ng-show="(index.n>1 && index.m == index.n )">
|
<div class="size-14 text-gray columns" ng-show="(index.n>1 && index.m == index.n )">
|
||||||
<span translate>
|
<span translate>
|
||||||
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
|
To restore this {{index.m}}-{{index.n}} <b>shared</b> wallet you will need
|
||||||
</span>:
|
</span>:
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
<span class="payment-proposal-to"
|
<span class="payment-proposal-to"
|
||||||
ng-click="copyAddress(tx.toAddress)">
|
ng-click="copyAddress(tx.toAddress)">
|
||||||
<i class="fi-bitcoin left"></i>
|
<i class="fi-bitcoin left"></i>
|
||||||
<contact ng-if="!tx.hasMultiplesOutputs" class="dib enable_text_select ellipsis m5t size-14" address="{{tx.toAddress}}"></contact>
|
<contact ng-if="!tx.hasMultiplesOutputs" class="dib enable_text_select ellipsis m5t m5b size-14" address="{{tx.toAddress}}"></contact>
|
||||||
<span ng-if="tx.hasMultiplesOutputs" translate>
|
<span ng-if="tx.hasMultiplesOutputs" translate>
|
||||||
Multiple recipients
|
Multiple recipients
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="oh p20t white" ng-if="tx.pendingForUs">
|
<div class="oh p20t white" ng-if="tx.pendingForUs">
|
||||||
<div class="large-6 medium-6 small-6 columns">
|
<div class="large-6 medium-6 small-6 columns" ng-show="isShared">
|
||||||
<button class="button outline round dark-gray expand" ng-click="reject(tx);"
|
<button class="button outline round dark-gray expand" ng-click="reject(tx);"
|
||||||
ng-disabled="loading">
|
ng-disabled="loading">
|
||||||
<i class="fi-x"></i>
|
<i class="fi-x"></i>
|
||||||
|
|
@ -170,12 +170,12 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="columns text-center m20t" ng-if="tx.canBeRemoved">
|
<div class="columns text-center m20t" ng-if="tx.canBeRemoved || (tx.status == 'accepted' && !tx.broadcastedOn)">
|
||||||
<div class="text-gray size-12 m20b" ng-if="!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)"
|
<button class="tiny round outline dark-gray warning" ng-click="remove(tx)"
|
||||||
ng-disabled="loading" ng-show="tx.canBeRemoved">
|
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>
|
||||||
|
|
|
||||||
|
|
@ -324,10 +324,10 @@
|
||||||
<div class="large-12 columns">
|
<div class="large-12 columns">
|
||||||
<h2 class="text-center m10t" translate>My Bitcoin address</h2>
|
<h2 class="text-center m10t" translate>My Bitcoin address</h2>
|
||||||
<div class="text-center" ng-click="home.copyAddress(home.addr[index.walletId])" ng-show="home.addr[index.walletId] || home.generatingAddress">
|
<div class="text-center" ng-click="home.copyAddress(home.addr[index.walletId])" ng-show="home.addr[index.walletId] || home.generatingAddress">
|
||||||
<qrcode size="180" data="bitcoin:{{home.addr[index.walletId]}}"></qrcode>
|
<qrcode size="220" data="bitcoin:{{home.addr[index.walletId]}}"></qrcode>
|
||||||
<div ng-show="home.generatingAddress" style="position:relative; top:-186px; height:0px">
|
<div ng-show="home.generatingAddress" style="position:relative; top:-226px; height:0px">
|
||||||
<div style="height:180px; width:180px; margin:auto; background: white">
|
<div style="height:220px; width:220px; margin:auto; background: white">
|
||||||
<div class="spinner" style="margin-top:60px">
|
<div class="spinner" style="margin-top:85px">
|
||||||
<div class="rect1"></div>
|
<div class="rect1"></div>
|
||||||
<div class="rect2"></div>
|
<div class="rect2"></div>
|
||||||
<div class="rect3"></div>
|
<div class="rect3"></div>
|
||||||
|
|
@ -364,7 +364,7 @@
|
||||||
<span translate>Request a specific amount</span>
|
<span translate>Request a specific amount</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 columns" ng-show="index.isCordova">
|
<div class="small-12 columns" ng-show="index.isCordova && !home.generatingAddress && home.addr[index.walletId]">
|
||||||
<span class="button outline light-gray small round expand"
|
<span class="button outline light-gray small round expand"
|
||||||
ng-click="home.shareAddress(home.addr[index.walletId])">
|
ng-click="home.shareAddress(home.addr[index.walletId])">
|
||||||
<span translate>Share address</span>
|
<span translate>Share address</span>
|
||||||
|
|
|
||||||
|
|
@ -784,12 +784,12 @@ textarea:focus
|
||||||
}
|
}
|
||||||
|
|
||||||
.payment-proposal-to i {
|
.payment-proposal-to i {
|
||||||
margin-right: 10px;
|
position: absolute;
|
||||||
|
left: 25px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
border-right: 1px solid;
|
border-right: 1px solid;
|
||||||
border-color: rgba(255, 255, 255, 0.1);
|
border-color: rgba(255, 255, 255, 0.1);
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
vertical-align: middle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
::-webkit-input-placeholder {
|
::-webkit-input-placeholder {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
angular.module('copayApp.controllers').controller('glideraController',
|
angular.module('copayApp.controllers').controller('glideraController',
|
||||||
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, isChromeApp, animationService, lodash) {
|
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, isChromeApp, animationService, lodash) {
|
||||||
|
|
||||||
window.ignoreMobilePause = true;
|
|
||||||
|
|
||||||
this.getAuthenticateUrl = function() {
|
this.getAuthenticateUrl = function() {
|
||||||
return glideraService.getOauthCodeUrl();
|
return glideraService.getOauthCodeUrl();
|
||||||
|
|
|
||||||
|
|
@ -1463,20 +1463,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.setTab(tab, reset);
|
self.setTab(tab, reset);
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('Local/RequestTouchid', function(event, cb) {
|
|
||||||
window.plugins.touchid.verifyFingerprint(
|
|
||||||
gettextCatalog.getString('Scan your fingerprint please'),
|
|
||||||
function(msg) {
|
|
||||||
// OK
|
|
||||||
return cb();
|
|
||||||
},
|
|
||||||
function(msg) {
|
|
||||||
// ERROR
|
|
||||||
return cb(gettext('Invalid Touch ID'));
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
$rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) {
|
$rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) {
|
||||||
self.askPassword = {
|
self.askPassword = {
|
||||||
isSetup: isSetup,
|
isSetup: isSetup,
|
||||||
|
|
@ -1485,6 +1471,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
return cb(err, pass);
|
return cb(err, pass);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
$timeout(function() {
|
||||||
|
$rootScope.$apply();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
lodash.each(['NewCopayer', 'CopayerUpdated'], function(eventName) {
|
lodash.each(['NewCopayer', 'CopayerUpdated'], function(eventName) {
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,7 @@ angular.module('copayApp.controllers').controller('paymentUriController',
|
||||||
|
|
||||||
this.selectWallet = function(wid) {
|
this.selectWallet = function(wid) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (wid != profileService.focusedClient.credentials.walletId) {
|
profileService.setAndStoreFocus(wid, function() {});
|
||||||
profileService.setAndStoreFocus(wid, function() {});
|
|
||||||
}
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$rootScope.$emit('paymentUri', self.bitcoinURI);
|
$rootScope.$emit('paymentUri', self.bitcoinURI);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('sellGlideraController',
|
angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
function($scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, isChromeApp, animationService) {
|
function($scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, isChromeApp, animationService, txSignService) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var config = configService.getSync();
|
var config = configService.getSync();
|
||||||
|
|
@ -38,7 +38,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
$log.debug(e);
|
$log.debug(e);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -57,12 +57,14 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
|
|
||||||
$scope.selectWallet = function(walletId, walletName) {
|
$scope.selectWallet = function(walletId, walletName) {
|
||||||
if (!profileService.getClient(walletId).isComplete()) {
|
if (!profileService.getClient(walletId).isComplete()) {
|
||||||
self.error = bwsError.msg({'code': 'WALLET_NOT_COMPLETE'}, 'Could not choose the wallet');
|
self.error = bwsError.msg({
|
||||||
|
'code': 'WALLET_NOT_COMPLETE'
|
||||||
|
}, 'Could not choose the wallet');
|
||||||
$modalInstance.dismiss('cancel');
|
$modalInstance.dismiss('cancel');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$modalInstance.close({
|
$modalInstance.close({
|
||||||
'walletId': walletId,
|
'walletId': walletId,
|
||||||
'walletName': walletName,
|
'walletName': walletName,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -70,8 +72,8 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
|
|
||||||
var modalInstance = $modal.open({
|
var modalInstance = $modal.open({
|
||||||
templateUrl: 'views/modals/glidera-wallets.html',
|
templateUrl: 'views/modals/glidera-wallets.html',
|
||||||
windowClass: animationService.modalAnimated.slideUp,
|
windowClass: animationService.modalAnimated.slideUp,
|
||||||
controller: ModalInstanceCtrl,
|
controller: ModalInstanceCtrl,
|
||||||
});
|
});
|
||||||
|
|
||||||
modalInstance.result.finally(function() {
|
modalInstance.result.finally(function() {
|
||||||
|
|
@ -101,24 +103,22 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
self.gettingSellPrice = false;
|
self.gettingSellPrice = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = 'Could not get exchange information. Please, try again.';
|
self.error = 'Could not get exchange information. Please, try again.';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
self.error = null;
|
self.error = null;
|
||||||
self.sellPrice = sellPrice;
|
self.sellPrice = sellPrice;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.get2faCode = function(token) {
|
this.get2faCode = function(token) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.loading = 'Sending 2FA code...';
|
self.loading = 'Sending 2FA code...';
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.get2faCode(token, function(err, sent) {
|
glideraService.get2faCode(token, function(err, sent) {
|
||||||
self.loading = null;
|
self.loading = null;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = 'Could not send confirmation code to your phone';
|
self.error = 'Could not send confirmation code to your phone';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
self.show2faCodeInput = sent;
|
self.show2faCodeInput = sent;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -129,107 +129,86 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
|
||||||
var self = this;
|
var self = this;
|
||||||
self.error = null;
|
self.error = null;
|
||||||
|
|
||||||
this.loading = 'Selling Bitcoin...';
|
|
||||||
$timeout(function() {
|
txSignService.prepare(function(err) {
|
||||||
addressService.getAddress(fc.credentials.walletId, null, function(err, refundAddress) {
|
if (err) {
|
||||||
if (!refundAddress) {
|
self.error = err;
|
||||||
self.loading = null;
|
return;
|
||||||
self.error = bwsError.msg(err, 'Could not create address');
|
}
|
||||||
return;
|
self.loading = 'Selling Bitcoin...';
|
||||||
}
|
$timeout(function() {
|
||||||
glideraService.getSellAddress(token, function(error, sellAddress) {
|
addressService.getAddress(fc.credentials.walletId, null, function(err, refundAddress) {
|
||||||
if (!sellAddress) {
|
if (!refundAddress) {
|
||||||
self.loading = null;
|
self.loading = null;
|
||||||
self.error = 'Could not get the destination bitcoin address';
|
self.error = bwsError.msg(err, 'Could not create address');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
|
glideraService.getSellAddress(token, function(error, sellAddress) {
|
||||||
|
if (!sellAddress) {
|
||||||
|
self.loading = null;
|
||||||
|
self.error = 'Could not get the destination bitcoin address';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
|
||||||
|
|
||||||
feeService.getCurrentFeeValue(self.currentFeeLevel, function(err, feePerKb) {
|
feeService.getCurrentFeeValue(self.currentFeeLevel, function(err, feePerKb) {
|
||||||
if (err) $log.debug(err);
|
if (err) $log.debug(err);
|
||||||
fc.sendTxProposal({
|
fc.sendTxProposal({
|
||||||
toAddress: sellAddress,
|
toAddress: sellAddress,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
message: 'Glidera transaction',
|
message: 'Glidera transaction',
|
||||||
customData: {'glideraToken': token},
|
customData: {
|
||||||
payProUrl: null,
|
'glideraToken': token
|
||||||
feePerKb: feePerKb,
|
},
|
||||||
excludeUnconfirmedUtxos: self.currentSpendUnconfirmed ? false : true
|
payProUrl: null,
|
||||||
}, function(err, txp) {
|
feePerKb: feePerKb,
|
||||||
if (err) {
|
excludeUnconfirmedUtxos: self.currentSpendUnconfirmed ? false : true
|
||||||
profileService.lockFC();
|
}, function(err, txp) {
|
||||||
$log.error(err);
|
|
||||||
$timeout(function() {
|
|
||||||
self.loading = null;
|
|
||||||
self.error = bwsError.msg(err, 'Error');
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fc.canSign()) {
|
|
||||||
self.loading = null;
|
|
||||||
$log.info('No signing proposal: No private key');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_signTx(txp, function(err, txp, rawTx) {
|
|
||||||
profileService.lockFC();
|
|
||||||
if (err) {
|
if (err) {
|
||||||
self.loading = null;
|
profileService.lockFC();
|
||||||
self.error = err;
|
$log.error(err);
|
||||||
$scope.$apply();
|
$timeout(function() {
|
||||||
}
|
|
||||||
else {
|
|
||||||
var data = {
|
|
||||||
refundAddress: refundAddress,
|
|
||||||
signedTransaction: rawTx,
|
|
||||||
priceUuid: self.sellPrice.priceUuid,
|
|
||||||
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
|
||||||
ip: null
|
|
||||||
};
|
|
||||||
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
|
||||||
self.loading = null;
|
self.loading = null;
|
||||||
if (err) {
|
self.error = bwsError.msg(err, 'Error');
|
||||||
self.error = err;
|
}, 1);
|
||||||
fc.removeTxProposal(txp, function(err, txpb) {
|
return;
|
||||||
$timeout(function() {
|
|
||||||
$scope.$emit('Local/GlideraError');
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.success = data;
|
|
||||||
$scope.$emit('Local/GlideraTx');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
txSignService.sign(txp, function(err, txp) {
|
||||||
|
if (err) {
|
||||||
|
self.loading = null;
|
||||||
|
self.error = err;
|
||||||
|
$scope.$apply();
|
||||||
|
} else {
|
||||||
|
var rawTx = txp.raw;
|
||||||
|
var data = {
|
||||||
|
refundAddress: refundAddress,
|
||||||
|
signedTransaction: rawTx,
|
||||||
|
priceUuid: self.sellPrice.priceUuid,
|
||||||
|
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
|
||||||
|
ip: null
|
||||||
|
};
|
||||||
|
glideraService.sell(token, twoFaCode, data, function(err, data) {
|
||||||
|
self.loading = null;
|
||||||
|
if (err) {
|
||||||
|
self.error = err;
|
||||||
|
fc.removeTxProposal(txp, function(err, txp) {
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$emit('Local/GlideraError');
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
self.success = data;
|
||||||
|
$scope.$emit('Local/GlideraTx');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 100);
|
||||||
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
var _signTx = function(txp, cb) {
|
|
||||||
var self = this;
|
|
||||||
fc.signTxProposal(txp, function(err, signedTx) {
|
|
||||||
profileService.lockFC();
|
|
||||||
if (err) {
|
|
||||||
err = bwsError.msg(err, 'Could not accept payment');
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (signedTx.status == 'accepted') {
|
|
||||||
return cb(null, txp, signedTx.raw);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return cb('The transaction could not be signed');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService) {
|
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, txSignService) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
window.ignoreMobilePause = false;
|
window.ignoreMobilePause = false;
|
||||||
|
|
@ -87,16 +87,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$rootScope.hideMenuBar = false;
|
$rootScope.hideMenuBar = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
var requestTouchid = function(cb) {
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
config.touchIdFor = config.touchIdFor || {};
|
|
||||||
if (window.touchidAvailable && config.touchIdFor[fc.credentials.walletId]) {
|
|
||||||
$rootScope.$emit('Local/RequestTouchid', cb);
|
|
||||||
} else {
|
|
||||||
return cb();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.onQrCodeScanned = function(data) {
|
this.onQrCodeScanned = function(data) {
|
||||||
if (data) go.send();
|
if (data) go.send();
|
||||||
$rootScope.$emit('dataScanned', data);
|
$rootScope.$emit('dataScanned', data);
|
||||||
|
|
@ -335,72 +325,26 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
|
|
||||||
$scope.sign = function(txp) {
|
$scope.sign = function(txp) {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
|
|
||||||
if (!fc.canSign() && !fc.isPrivKeyExternal())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (fc.isPrivKeyEncrypted()) {
|
|
||||||
profileService.unlockFC(function(err) {
|
|
||||||
if (err) {
|
|
||||||
$scope.error = bwsError.msg(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return $scope.sign(txp);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
self._setOngoingForSigning();
|
|
||||||
$scope.loading = true;
|
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
$timeout(function() {
|
$scope.loading = true;
|
||||||
requestTouchid(function(err) {
|
|
||||||
if (err) {
|
txSignService.prepareAndSignAndBroadcast(txp, {
|
||||||
self.setOngoingProcess();
|
reporterFn: self.setOngoingProcess.bind(self)
|
||||||
$scope.loading = false;
|
}, function(err, txp) {
|
||||||
profileService.lockFC();
|
$scope.loading = false;
|
||||||
$scope.error = err;
|
$scope.$emit('UpdateTx');
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
$scope.error = err;
|
||||||
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
profileService.signTxProposal(txp, function(err, txpsi) {
|
|
||||||
self.setOngoingProcess();
|
|
||||||
if (err) {
|
|
||||||
$scope.$emit('UpdateTx');
|
|
||||||
$scope.loading = false;
|
|
||||||
$scope.error = bwsError.msg(err, gettextCatalog.getString('Could not accept payment'));
|
|
||||||
$scope.$digest();
|
|
||||||
} else {
|
|
||||||
//if txp has required signatures then broadcast it
|
|
||||||
var txpHasRequiredSignatures = txpsi.status == 'accepted';
|
|
||||||
if (txpHasRequiredSignatures) {
|
|
||||||
self.setOngoingProcess(gettextCatalog.getString('Broadcasting transaction'));
|
|
||||||
$scope.loading = true;
|
|
||||||
fc.broadcastTxProposal(txpsi, function(err, txpsb, memo) {
|
|
||||||
self.setOngoingProcess();
|
|
||||||
$scope.loading = false;
|
|
||||||
if (err) {
|
|
||||||
$scope.$emit('UpdateTx');
|
|
||||||
$scope.error = bwsError.msg(err, gettextCatalog.getString('Could not broadcast payment'));
|
|
||||||
$scope.$digest();
|
|
||||||
} else {
|
|
||||||
$log.debug('Transaction signed and broadcasted')
|
|
||||||
if (memo)
|
|
||||||
$log.info(memo);
|
|
||||||
|
|
||||||
refreshUntilItChanges = true;
|
|
||||||
$modalInstance.close(txpsb);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$scope.loading = false;
|
|
||||||
$modalInstance.close(txpsi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
return;
|
||||||
}, 100);
|
}
|
||||||
|
refreshUntilItChanges = true;
|
||||||
|
$modalInstance.close(txp);
|
||||||
|
return;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.reject = function(txp) {
|
$scope.reject = function(txp) {
|
||||||
|
|
@ -833,6 +777,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
|
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
|
||||||
var currentFeeLevel = walletSettings.feeLevel || 'normal';
|
var currentFeeLevel = walletSettings.feeLevel || 'normal';
|
||||||
|
|
||||||
|
this.resetError();
|
||||||
|
|
||||||
if (isCordova && this.isWindowsPhoneApp) {
|
if (isCordova && this.isWindowsPhoneApp) {
|
||||||
this.hideAddress = false;
|
this.hideAddress = false;
|
||||||
this.hideAmount = false;
|
this.hideAmount = false;
|
||||||
|
|
@ -844,14 +790,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fc.isPrivKeyEncrypted()) {
|
|
||||||
profileService.unlockFC(function(err) {
|
|
||||||
if (err) return self.setSendError(err);
|
|
||||||
return self.submitForm();
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
var comment = form.comment.$modelValue;
|
var comment = form.comment.$modelValue;
|
||||||
|
|
||||||
// ToDo: use a credential's (or fc's) function for this
|
// ToDo: use a credential's (or fc's) function for this
|
||||||
|
|
@ -869,7 +807,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.setOngoingProcess(gettextCatalog.getString('Creating transaction'));
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
var paypro = self._paypro;
|
var paypro = self._paypro;
|
||||||
var address, amount;
|
var address, amount;
|
||||||
|
|
@ -877,17 +814,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
address = form.address.$modelValue;
|
address = form.address.$modelValue;
|
||||||
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
|
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
|
||||||
|
|
||||||
requestTouchid(function(err) {
|
txSignService.prepare(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
profileService.lockFC();
|
return self.setSendError(err);
|
||||||
self.setOngoingProcess();
|
|
||||||
self.error = err;
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
}, 1);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
self.setOngoingProcess(gettextCatalog.getString('Creating transaction'));
|
||||||
getFee(function(err, feePerKb) {
|
getFee(function(err, feePerKb) {
|
||||||
if (err) $log.debug(err);
|
if (err) $log.debug(err);
|
||||||
fc.sendTxProposal({
|
fc.sendTxProposal({
|
||||||
|
|
@ -900,13 +831,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}, function(err, txp) {
|
}, function(err, txp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.setOngoingProcess();
|
self.setOngoingProcess();
|
||||||
profileService.lockFC();
|
|
||||||
return self.setSendError(err);
|
return self.setSendError(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fc.canSign() && !fc.isPrivKeyExternal()) {
|
if (!fc.canSign() && !fc.isPrivKeyExternal()) {
|
||||||
$log.info('No signing proposal: No private key')
|
|
||||||
self.setOngoingProcess();
|
self.setOngoingProcess();
|
||||||
|
$log.info('No signing proposal: No private key')
|
||||||
self.resetForm();
|
self.resetForm();
|
||||||
txStatus.notify(txp, function() {
|
txStatus.notify(txp, function() {
|
||||||
return $scope.$emit('Local/TxProposalAction');
|
return $scope.$emit('Local/TxProposalAction');
|
||||||
|
|
@ -914,8 +844,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.signAndBroadcast(txp, function(err) {
|
txSignService.signAndBroadcast(txp, {
|
||||||
self.setOngoingProcess();
|
reporterFn: self.setOngoingProcess.bind(self)
|
||||||
|
}, function(err, txp) {
|
||||||
self.resetForm();
|
self.resetForm();
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen');
|
self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen');
|
||||||
|
|
@ -923,7 +854,12 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
}, 1);
|
}, 1);
|
||||||
} else go.walletHome();
|
} else {
|
||||||
|
go.walletHome();
|
||||||
|
txStatus.notify(txp, function() {
|
||||||
|
$scope.$emit('Local/TxProposalAction', true);
|
||||||
|
});
|
||||||
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -931,56 +867,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
this._setOngoingForSigning = function() {
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
|
|
||||||
if (fc.isPrivKeyExternal() && fc.getPrivKeyExternalSourceName() == 'ledger') {
|
|
||||||
self.setOngoingProcess(gettextCatalog.getString('Requesting Ledger Wallet to sign'));
|
|
||||||
} else {
|
|
||||||
self.setOngoingProcess(gettextCatalog.getString('Signing payment'));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.signAndBroadcast = function(txp, cb) {
|
|
||||||
var fc = profileService.focusedClient;
|
|
||||||
|
|
||||||
this._setOngoingForSigning();
|
|
||||||
profileService.signTxProposal(txp, function(err, signedTx) {
|
|
||||||
self.setOngoingProcess();
|
|
||||||
if (err) {
|
|
||||||
if (!lodash.isObject(err)) {
|
|
||||||
err = { message: err};
|
|
||||||
}
|
|
||||||
err.message = bwsError.msg(err, gettextCatalog.getString('The payment was created but could not be signed. Please try again from home screen'));
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (signedTx.status == 'accepted') {
|
|
||||||
self.setOngoingProcess(gettextCatalog.getString('Broadcasting transaction'));
|
|
||||||
fc.broadcastTxProposal(signedTx, function(err, btx, memo) {
|
|
||||||
self.setOngoingProcess();
|
|
||||||
if (err) {
|
|
||||||
err.message = bwsError.msg(err, gettextCatalog.getString('The payment was signed but could not be broadcasted. Please try again from home screen'));
|
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
if (memo)
|
|
||||||
$log.info(memo);
|
|
||||||
|
|
||||||
txStatus.notify(btx, function() {
|
|
||||||
$scope.$emit('Local/TxProposalAction', true);
|
|
||||||
return cb();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
self.setOngoingProcess();
|
|
||||||
txStatus.notify(signedTx, function() {
|
|
||||||
$scope.$emit('Local/TxProposalAction');
|
|
||||||
return cb();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setForm = function(to, amount, comment) {
|
this.setForm = function(to, amount, comment) {
|
||||||
var form = $scope.sendForm;
|
var form = $scope.sendForm;
|
||||||
if (to) {
|
if (to) {
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ angular.element(document).ready(function() {
|
||||||
}
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var loc = window.location;
|
var loc = window.location;
|
||||||
var ignoreMobilePause = loc.toString().match(/(glidera|buy|sell)/) ? true : false;
|
var ignoreMobilePause = loc.toString().match(/(buy|sell|uri-payment)/) ? true : false;
|
||||||
window.ignoreMobilePause = ignoreMobilePause;
|
window.ignoreMobilePause = ignoreMobilePause;
|
||||||
}, 100);
|
}, 100);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
angular.module('copayApp.services')
|
angular.module('copayApp.services')
|
||||||
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, isChromeApp, isCordova, gettext, gettextCatalog, nodeWebkit, bwsError, uxLanguage, ledger, bitcore, trezor) {
|
.factory('profileService', function profileServiceFactory($rootScope, $location, $timeout, $filter, $log, lodash, storageService, bwcService, configService, notificationService, isChromeApp, isCordova, gettext, gettextCatalog, nodeWebkit, bwsError, uxLanguage, bitcore) {
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
@ -99,6 +99,11 @@ angular.module('copayApp.services')
|
||||||
root.walletClients[credentials.walletId].started = true;
|
root.walletClients[credentials.walletId].started = true;
|
||||||
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
root.walletClients[credentials.walletId].doNotVerifyPayPro = isChromeApp;
|
||||||
|
|
||||||
|
if (client.hasPrivKeyEncrypted() && !client.isPrivKeyEncrypted()) {
|
||||||
|
$log.warn('Auto locking unlocked wallet:' + credentials.walletId);
|
||||||
|
client.lock();
|
||||||
|
}
|
||||||
|
|
||||||
client.initialize({}, function(err) {
|
client.initialize({}, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
$log.error('Could not init notifications err:', err);
|
$log.error('Could not init notifications err:', err);
|
||||||
|
|
@ -110,8 +115,8 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.setWalletClients = function() {
|
root.setWalletClients = function() {
|
||||||
var credentials = root.profile.credentials;
|
var credentials = root.profile.credentials;
|
||||||
lodash.each(credentials, function(credentials) {
|
lodash.each(credentials, function(credential) {
|
||||||
root.setWalletClient(credentials);
|
root.setWalletClient(credential);
|
||||||
});
|
});
|
||||||
$rootScope.$emit('Local/WalletListUpdated');
|
$rootScope.$emit('Local/WalletListUpdated');
|
||||||
};
|
};
|
||||||
|
|
@ -630,6 +635,10 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
root.unlockFC = function(cb) {
|
root.unlockFC = function(cb) {
|
||||||
var fc = root.focusedClient;
|
var fc = root.focusedClient;
|
||||||
|
|
||||||
|
if (!fc.isPrivKeyEncrypted())
|
||||||
|
return cb();
|
||||||
|
|
||||||
$log.debug('Wallet is encrypted');
|
$log.debug('Wallet is encrypted');
|
||||||
$rootScope.$emit('Local/NeedsPassword', false, function(err2, password) {
|
$rootScope.$emit('Local/NeedsPassword', false, function(err2, password) {
|
||||||
if (err2 || !password) {
|
if (err2 || !password) {
|
||||||
|
|
@ -645,12 +654,6 @@ angular.module('copayApp.services')
|
||||||
message: gettext('Wrong password')
|
message: gettext('Wrong password')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
|
||||||
if (fc.hasPrivKeyEncrypted()) {
|
|
||||||
$log.debug('Locking wallet automatically');
|
|
||||||
root.lockFC();
|
|
||||||
};
|
|
||||||
}, 2000);
|
|
||||||
return cb();
|
return cb();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -680,59 +683,5 @@ angular.module('copayApp.services')
|
||||||
return lodash.sortBy(ret, 'name');
|
return lodash.sortBy(ret, 'name');
|
||||||
};
|
};
|
||||||
|
|
||||||
root._signWithLedger = function(txp, cb) {
|
|
||||||
var fc = root.focusedClient;
|
|
||||||
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
|
||||||
|
|
||||||
ledger.signTx(txp, fc.credentials.account, function(result) {
|
|
||||||
$log.debug('Ledger response', result);
|
|
||||||
if (!result.success)
|
|
||||||
return cb(result.message || result.error);
|
|
||||||
|
|
||||||
txp.signatures = lodash.map(result.signatures, function(s) {
|
|
||||||
return s.substring(0, s.length - 2);
|
|
||||||
});
|
|
||||||
return fc.signTxProposal(txp, cb);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
root._signWithTrezor = function(txp, cb) {
|
|
||||||
var fc = root.focusedClient;
|
|
||||||
$log.info('Requesting Trezor to sign the transaction');
|
|
||||||
|
|
||||||
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing, 'xPubKey');
|
|
||||||
trezor.signTx(xPubKeys, txp, fc.credentials.account, function(err, result) {
|
|
||||||
if (err) return cb(err);
|
|
||||||
|
|
||||||
$log.debug('Trezor response', result);
|
|
||||||
txp.signatures = result.signatures;
|
|
||||||
return fc.signTxProposal(txp, cb);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
root.signTxProposal = function(txp, cb) {
|
|
||||||
var fc = root.focusedClient;
|
|
||||||
|
|
||||||
if (fc.isPrivKeyExternal()) {
|
|
||||||
switch (fc.getPrivKeyExternalSourceName()) {
|
|
||||||
case 'ledger':
|
|
||||||
return root._signWithLedger(txp, cb);
|
|
||||||
case 'trezor':
|
|
||||||
return root._signWithTrezor(txp, cb);
|
|
||||||
default:
|
|
||||||
var msg = 'Unsupported External Key:' + fc.getPrivKeyExternalSourceName();
|
|
||||||
$log.error(msg);
|
|
||||||
return cb(msg);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return fc.signTxProposal(txp, function(err, signedTxp) {
|
|
||||||
root.lockFC();
|
|
||||||
return cb(err, signedTxp);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
184
src/js/services/txSignService.js
Normal file
184
src/js/services/txSignService.js
Normal file
|
|
@ -0,0 +1,184 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
angular.module('copayApp.services').factory('txSignService', function($rootScope, profileService, gettextCatalog, lodash, trezor, ledger, configService, bwsError, $log) {
|
||||||
|
var root = {};
|
||||||
|
var config = configService.getSync();
|
||||||
|
|
||||||
|
var reportSigningStatus = function(opts) {
|
||||||
|
if (!opts.reporterFn) return;
|
||||||
|
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
|
||||||
|
if (fc.isPrivKeyExternal()) {
|
||||||
|
if (fc.getPrivKeyExternalSourceName() == 'ledger') {
|
||||||
|
opts.reporterFn(gettextCatalog.getString('Requesting Ledger Wallet to sign'));
|
||||||
|
} else if (fc.getPrivKeyExternalSourceName() == 'trezor') {
|
||||||
|
opts.reporterFn(gettextCatalog.getString('Requesting Trezor Wallet to sign'));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
opts.reporterFn(gettextCatalog.getString('Signing payment'));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var reportBroadcastingStatus = function(opts) {
|
||||||
|
if (!opts.reporterFn) return;
|
||||||
|
|
||||||
|
opts.reporterFn(gettextCatalog.getString('Broadcasting transaction'));
|
||||||
|
};
|
||||||
|
|
||||||
|
var stopReport = function(opts) {
|
||||||
|
if (!opts.reporterFn) return;
|
||||||
|
|
||||||
|
opts.reporterFn();
|
||||||
|
};
|
||||||
|
|
||||||
|
var requestTouchId = function(cb) {
|
||||||
|
try {
|
||||||
|
window.plugins.touchid.verifyFingerprint(
|
||||||
|
gettextCatalog.getString('Scan your fingerprint please'),
|
||||||
|
function(msg) {
|
||||||
|
$log.debug('Touch ID OK');
|
||||||
|
return cb();
|
||||||
|
},
|
||||||
|
function(msg) {
|
||||||
|
$log.debug('Touch ID Failed:' + msg);
|
||||||
|
return cb(gettext('Touch ID Failed:') + msg);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
$log.debug('Touch ID Failed:' + e);
|
||||||
|
return cb(gettext('Touch ID Failed:') + e);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
root.checkTouchId = function(cb) {
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
config.touchIdFor = config.touchIdFor || {};
|
||||||
|
if (window.touchidAvailable && config.touchIdFor[fc.credentials.walletId]) {
|
||||||
|
requestTouchId(cb);
|
||||||
|
} else {
|
||||||
|
return cb();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
root.prepare = function(cb) {
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
if (!fc.canSign() && !fc.isPrivKeyExternal())
|
||||||
|
return cb('Cannot sign'); // should never happen, no need to translate
|
||||||
|
|
||||||
|
root.checkTouchId(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
};
|
||||||
|
|
||||||
|
profileService.unlockFC(function(err) {
|
||||||
|
if (err) {
|
||||||
|
return cb(bwsError.msg(err));
|
||||||
|
};
|
||||||
|
|
||||||
|
return cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var _signWithLedger = function(txp, cb) {
|
||||||
|
var fc = root.focusedClient;
|
||||||
|
$log.info('Requesting Ledger Chrome app to sign the transaction');
|
||||||
|
|
||||||
|
ledger.signTx(txp, fc.credentials.account, function(result) {
|
||||||
|
$log.debug('Ledger response', result);
|
||||||
|
if (!result.success)
|
||||||
|
return cb(result.message || result.error);
|
||||||
|
|
||||||
|
txp.signatures = lodash.map(result.signatures, function(s) {
|
||||||
|
return s.substring(0, s.length - 2);
|
||||||
|
});
|
||||||
|
return fc.signTxProposal(txp, cb);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var _signWithTrezor = function(txp, cb) {
|
||||||
|
var fc = root.focusedClient;
|
||||||
|
$log.info('Requesting Trezor to sign the transaction');
|
||||||
|
|
||||||
|
var xPubKeys = lodash.pluck(fc.credentials.publicKeyRing, 'xPubKey');
|
||||||
|
trezor.signTx(xPubKeys, txp, fc.credentials.account, function(err, result) {
|
||||||
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
$log.debug('Trezor response', result);
|
||||||
|
txp.signatures = result.signatures;
|
||||||
|
return fc.signTxProposal(txp, cb);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.sign = function(txp, cb) {
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
|
||||||
|
if (fc.isPrivKeyExternal()) {
|
||||||
|
switch (fc.getPrivKeyExternalSourceName()) {
|
||||||
|
case 'ledger':
|
||||||
|
return _signWithLedger(txp, cb);
|
||||||
|
case 'trezor':
|
||||||
|
return _signWithTrezor(txp, cb);
|
||||||
|
default:
|
||||||
|
var msg = 'Unsupported External Key:' + fc.getPrivKeyExternalSourceName();
|
||||||
|
$log.error(msg);
|
||||||
|
return cb(msg);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fc.signTxProposal(txp, function(err, signedTxp) {
|
||||||
|
profileService.lockFC();
|
||||||
|
return cb(err, signedTxp);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
root.signAndBroadcast = function(txp, opts, cb) {
|
||||||
|
reportSigningStatus(opts);
|
||||||
|
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
root.sign(txp, function(err, txp) {
|
||||||
|
if (err) {
|
||||||
|
stopReport(opts);
|
||||||
|
return cb(bwsError.msg(err), gettextCatalog.getString('Could not accept payment'));
|
||||||
|
};
|
||||||
|
|
||||||
|
if (txp.status != 'accepted')
|
||||||
|
return (null, txp);
|
||||||
|
|
||||||
|
reportBroadcastingStatus(opts);
|
||||||
|
fc.broadcastTxProposal(txp, function(err, txp, memo) {
|
||||||
|
stopReport(opts);
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
return cb(bwsError.msg(err, gettextCatalog.getString('Could not broadcast payment')));
|
||||||
|
};
|
||||||
|
|
||||||
|
$log.debug('Transaction signed and broadcasted')
|
||||||
|
|
||||||
|
if (memo)
|
||||||
|
$log.info(memo);
|
||||||
|
|
||||||
|
return cb(null, txp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
root.prepareAndSignAndBroadcast = function(txp, opts, cb) {
|
||||||
|
reportSigningStatus(opts);
|
||||||
|
root.prepare(function(err) {
|
||||||
|
if (err) {
|
||||||
|
stopReport(opts);
|
||||||
|
return cb(err);
|
||||||
|
};
|
||||||
|
root.signAndBroadcast(txp, opts, function(err, txp) {
|
||||||
|
if (err) {
|
||||||
|
stopReport(opts);
|
||||||
|
return cb(err);
|
||||||
|
};
|
||||||
|
return cb(null, txp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return root;
|
||||||
|
});
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Version=1.7.1
|
Version=1.7.2
|
||||||
Name=Copay
|
Name=Copay
|
||||||
Comment=A multisignature wallet
|
Comment=A multisignature wallet
|
||||||
Exec=copay
|
Exec=copay
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||||
|
|
||||||
#define MyAppName "Copay"
|
#define MyAppName "Copay"
|
||||||
#define MyAppVersion "1.7.1"
|
#define MyAppVersion "1.7.2"
|
||||||
#define MyAppPublisher "BitPay"
|
#define MyAppPublisher "BitPay"
|
||||||
#define MyAppURL "https://copay.io"
|
#define MyAppURL "https://copay.io"
|
||||||
#define MyAppExeName "Copay.exe"
|
#define MyAppExeName "Copay.exe"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue