new address and copay address working in receive / send / scan
This commit is contained in:
parent
14fecbf1ac
commit
205f70dd8c
7 changed files with 63 additions and 13 deletions
|
|
@ -8,11 +8,11 @@ bitcoinCashJsModule.provider('bitcoinCashJsService', function() {
|
||||||
|
|
||||||
provider.$get = function() {
|
provider.$get = function() {
|
||||||
var service = {};
|
var service = {};
|
||||||
|
const Address = bchjs.Address;
|
||||||
|
const BitpayFormat = Address.BitpayFormat;
|
||||||
|
const CashAddrFormat = Address.CashAddrFormat;
|
||||||
|
|
||||||
service.translateAddresses = function(address) {
|
service.translateAddresses = function(address) {
|
||||||
const Address = bchjs.Address;
|
|
||||||
const BitpayFormat = Address.BitpayFormat;
|
|
||||||
const CashAddrFormat = Address.CashAddrFormat;
|
|
||||||
var result = new Address(address);
|
var result = new Address(address);
|
||||||
return {
|
return {
|
||||||
'legacy': result.toString(),
|
'legacy': result.toString(),
|
||||||
|
|
@ -21,6 +21,36 @@ bitcoinCashJsModule.provider('bitcoinCashJsService', function() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service.readAddress = function(address) {
|
||||||
|
var a = address.replace('bitcoincash:', '');
|
||||||
|
var result = {};
|
||||||
|
if (a[0] == '1') {
|
||||||
|
result = Address.fromString(a, 'livenet', 'pubkeyhash');
|
||||||
|
} else if (a[0] == '3') {
|
||||||
|
result = Address.fromString(a, 'livenet', 'scripthash');
|
||||||
|
} else if (a[0] == 'C') {
|
||||||
|
result = Address.fromString(a, 'livenet', 'pubkeyhash', BitpayFormat);
|
||||||
|
} else if (a[0] == 'H') {
|
||||||
|
result = Address.fromString(a, 'livenet', 'scripthash', BitpayFormat);
|
||||||
|
} else if (a[0] == 'q') {
|
||||||
|
result = Address.fromString(address, 'livenet', 'pubkeyhash', CashAddrFormat);
|
||||||
|
} else if (a[0] == 'p') {
|
||||||
|
result = Address.fromString(address, 'livenet', 'scripthash', CashAddrFormat);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
'legacy': result.toString(),
|
||||||
|
'bitpay': result.toString(BitpayFormat),
|
||||||
|
'cashaddr': result.toString(CashAddrFormat).replace('bitcoincash:', '')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
service.getBitcoinCashJs = function() {
|
||||||
|
return bchjs;
|
||||||
|
}
|
||||||
|
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
$scope.showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || $ionicHistory.backView().stateName == 'tabs.bitpayCard');
|
$scope.showMenu = $ionicHistory.backView() && ($ionicHistory.backView().stateName == 'tabs.send' || $ionicHistory.backView().stateName == 'tabs.bitpayCard');
|
||||||
$scope.recipientType = data.stateParams.recipientType || null;
|
$scope.recipientType = data.stateParams.recipientType || null;
|
||||||
$scope.toAddress = data.stateParams.toAddress;
|
$scope.toAddress = data.stateParams.toAddress;
|
||||||
|
$scope.displayAddress = data.stateParams.displayAddress;
|
||||||
$scope.toName = data.stateParams.toName;
|
$scope.toName = data.stateParams.toName;
|
||||||
$scope.toEmail = data.stateParams.toEmail;
|
$scope.toEmail = data.stateParams.toEmail;
|
||||||
$scope.toColor = data.stateParams.toColor;
|
$scope.toColor = data.stateParams.toColor;
|
||||||
|
|
@ -415,6 +416,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
||||||
recipientType: $scope.recipientType,
|
recipientType: $scope.recipientType,
|
||||||
toAmount: amount,
|
toAmount: amount,
|
||||||
toAddress: $scope.toAddress,
|
toAddress: $scope.toAddress,
|
||||||
|
displayAddress: $scope.displayAddress || $scope.toAddress,
|
||||||
toName: $scope.toName,
|
toName: $scope.toName,
|
||||||
toEmail: $scope.toEmail,
|
toEmail: $scope.toEmail,
|
||||||
toColor: $scope.toColor,
|
toColor: $scope.toColor,
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
sendMax: data.stateParams.useSendMax == 'true' ? true : false,
|
sendMax: data.stateParams.useSendMax == 'true' ? true : false,
|
||||||
fromWalletId: data.stateParams.fromWalletId,
|
fromWalletId: data.stateParams.fromWalletId,
|
||||||
toAddress: data.stateParams.toAddress,
|
toAddress: data.stateParams.toAddress,
|
||||||
|
displayAddress: data.stateParams.displayAddress,
|
||||||
description: data.stateParams.description,
|
description: data.stateParams.description,
|
||||||
paypro: data.stateParams.paypro,
|
paypro: data.stateParams.paypro,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.state('tabs.send.amount', {
|
.state('tabs.send.amount', {
|
||||||
url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:fromWalletId/:minShapeshiftAmount/:maxShapeshiftAmount/:shapeshiftOrderId',
|
url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:fromWalletId/:minShapeshiftAmount/:maxShapeshiftAmount/:shapeshiftOrderId/:displayAddress',
|
||||||
views: {
|
views: {
|
||||||
'tab-send@tabs': {
|
'tab-send@tabs': {
|
||||||
controller: 'amountController',
|
controller: 'amountController',
|
||||||
|
|
@ -296,7 +296,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('tabs.send.confirm', {
|
.state('tabs.send.confirm', {
|
||||||
url: '/confirm/:recipientType/:toAddress/:toName/:toAmount/:toEmail/:toColor/:description/:coin/:useSendMax/:fromWalletId',
|
url: '/confirm/:recipientType/:toAddress/:toName/:toAmount/:toEmail/:toColor/:description/:coin/:useSendMax/:fromWalletId/:displayAddress',
|
||||||
views: {
|
views: {
|
||||||
'tab-send@tabs': {
|
'tab-send@tabs': {
|
||||||
controller: 'confirmController',
|
controller: 'confirmController',
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog) {
|
angular.module('copayApp.services').factory('incomingData', function($log, $state, $timeout, $ionicHistory, bitcore, bitcoreCash, $rootScope, payproService, scannerService, appConfigService, popupService, gettextCatalog, bitcoinCashJsService) {
|
||||||
|
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
@ -9,6 +9,18 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
};
|
};
|
||||||
|
|
||||||
root.redir = function(data, shapeshiftData) {
|
root.redir = function(data, shapeshiftData) {
|
||||||
|
var originalAddress = null;
|
||||||
|
if (typeof(data) == 'string' && (data.toLowerCase().indexOf('bitcoincash:') >= 0 || data[0] == 'C' || data[0] == 'H')) {
|
||||||
|
try {
|
||||||
|
if (data.indexOf('BITCOINCASH:') >= 0) {
|
||||||
|
data = data.toLowerCase();
|
||||||
|
}
|
||||||
|
originalAddress = data.replace('bitcoincash:', '');
|
||||||
|
var legacyAddress = bitcoinCashJsService.readAddress(data).legacy;
|
||||||
|
data = 'bitcoincash:' + legacyAddress;
|
||||||
|
} catch (ex) {}
|
||||||
|
}
|
||||||
|
|
||||||
$log.debug('Processing incoming data: ' + data);
|
$log.debug('Processing incoming data: ' + data);
|
||||||
|
|
||||||
function sanitizeUri(data) {
|
function sanitizeUri(data) {
|
||||||
|
|
@ -57,11 +69,16 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
$state.transitionTo('tabs.send.confirm', {
|
$state.transitionTo('tabs.send.confirm', {
|
||||||
toAmount: amount,
|
toAmount: amount,
|
||||||
toAddress: addr,
|
toAddress: addr,
|
||||||
|
displayAddress: originalAddress,
|
||||||
description: message,
|
description: message,
|
||||||
coin: coin
|
coin: coin
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var params = { toAddress: addr, coin: coin };
|
var params = {
|
||||||
|
toAddress: addr,
|
||||||
|
coin: coin,
|
||||||
|
displayAddress: originalAddress
|
||||||
|
};
|
||||||
if (shapeshiftData) {
|
if (shapeshiftData) {
|
||||||
params['fromWalletId'] = shapeshiftData.fromWalletId;
|
params['fromWalletId'] = shapeshiftData.fromWalletId;
|
||||||
params['minShapeshiftAmount'] = shapeshiftData.minAmount;
|
params['minShapeshiftAmount'] = shapeshiftData.minAmount;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
<img src="img/contact-placeholder.svg" class="bg"/>
|
<img src="img/contact-placeholder.svg" class="bg"/>
|
||||||
</i>
|
</i>
|
||||||
</span>
|
</span>
|
||||||
<span class="m10l">{{toName || toAddress}}</span>
|
<span class="m10l">{{toName || displayAddress || toAddress}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@
|
||||||
<span class="payment-proposal-to" ng-if="!recipientType">
|
<span class="payment-proposal-to" ng-if="!recipientType">
|
||||||
<i class="icon icon-svg abs-v-center icon-bitcoinlogoplain"></i>
|
<i class="icon icon-svg abs-v-center icon-bitcoinlogoplain"></i>
|
||||||
|
|
||||||
<div copy-to-clipboard="tx.toAddress" ng-if="!tx.paypro" class="ellipsis">
|
<div copy-to-clipboard="tx.displayAddress" ng-if="!tx.paypro" class="ellipsis">
|
||||||
<contact ng-if="tx.toAddress && !tx.toName" address="{{tx.toAddress}}"></contact>
|
<contact ng-if="tx.displayAddress && !tx.toName" address="{{tx.displayAddress}}"></contact>
|
||||||
<span class="m15l size-14" ng-if="tx.toName">{{tx.toName}}</span>
|
<span class="m15l size-14" ng-if="tx.toName">{{tx.toName}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -50,15 +50,15 @@
|
||||||
<i class="icon big-icon-svg">
|
<i class="icon big-icon-svg">
|
||||||
<img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !toColor}" ng-style="{'background-color': toColor}" class="bg"/>
|
<img src="img/icon-wallet.svg" ng-class="{'wallet-background-color-default': !toColor}" ng-style="{'background-color': toColor}" class="bg"/>
|
||||||
</i>
|
</i>
|
||||||
<div copy-to-clipboard="tx.toAddress" class="ellipsis">
|
<div copy-to-clipboard="tx.displayAddress" class="ellipsis">
|
||||||
<contact ng-if="tx.toAddress && !tx.toName" address="{{tx.toAddress}}"></contact>
|
<contact ng-if="tx.displayAddress && !tx.toName" address="{{tx.displayAddress}}"></contact>
|
||||||
<span ng-if="tx.toName" class="wallet-name">{{tx.toName}}</span>
|
<span ng-if="tx.toName" class="wallet-name">{{tx.toName}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="recipientType == 'contact' && !isChromeApp" class="gravatar-contact toggle" ng-click="toggleAddress()">
|
<div ng-if="recipientType == 'contact' && !isChromeApp" class="gravatar-contact toggle" ng-click="toggleAddress()">
|
||||||
<gravatar class="send-gravatar" name="{{tx.toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
|
<gravatar class="send-gravatar" name="{{tx.toName}}" height="30" width="30" email="{{toEmail}}"></gravatar>
|
||||||
<span ng-if="tx.toName && !showAddress">{{tx.toName}}</span>
|
<span ng-if="tx.toName && !showAddress">{{tx.toName}}</span>
|
||||||
<span ng-if="tx.toName && showAddress">{{tx.toAddress}}</span>
|
<span ng-if="tx.toName && showAddress">{{tx.displayAddress}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a class="item item-icon-right" ng-hide="!wallet" ng-click="showWalletSelector()">
|
<a class="item item-icon-right" ng-hide="!wallet" ng-click="showWalletSelector()">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue