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() {
|
||||
var service = {};
|
||||
|
||||
service.translateAddresses = function(address) {
|
||||
const Address = bchjs.Address;
|
||||
const BitpayFormat = Address.BitpayFormat;
|
||||
const CashAddrFormat = Address.CashAddrFormat;
|
||||
|
||||
service.translateAddresses = function(address) {
|
||||
var result = new Address(address);
|
||||
return {
|
||||
'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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.recipientType = data.stateParams.recipientType || null;
|
||||
$scope.toAddress = data.stateParams.toAddress;
|
||||
$scope.displayAddress = data.stateParams.displayAddress;
|
||||
$scope.toName = data.stateParams.toName;
|
||||
$scope.toEmail = data.stateParams.toEmail;
|
||||
$scope.toColor = data.stateParams.toColor;
|
||||
|
|
@ -415,6 +416,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
|
|||
recipientType: $scope.recipientType,
|
||||
toAmount: amount,
|
||||
toAddress: $scope.toAddress,
|
||||
displayAddress: $scope.displayAddress || $scope.toAddress,
|
||||
toName: $scope.toName,
|
||||
toEmail: $scope.toEmail,
|
||||
toColor: $scope.toColor,
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
sendMax: data.stateParams.useSendMax == 'true' ? true : false,
|
||||
fromWalletId: data.stateParams.fromWalletId,
|
||||
toAddress: data.stateParams.toAddress,
|
||||
displayAddress: data.stateParams.displayAddress,
|
||||
description: data.stateParams.description,
|
||||
paypro: data.stateParams.paypro,
|
||||
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
*/
|
||||
|
||||
.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: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'amountController',
|
||||
|
|
@ -296,7 +296,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.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: {
|
||||
'tab-send@tabs': {
|
||||
controller: 'confirmController',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'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 = {};
|
||||
|
||||
|
|
@ -9,6 +9,18 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
};
|
||||
|
||||
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);
|
||||
|
||||
function sanitizeUri(data) {
|
||||
|
|
@ -57,11 +69,16 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
$state.transitionTo('tabs.send.confirm', {
|
||||
toAmount: amount,
|
||||
toAddress: addr,
|
||||
displayAddress: originalAddress,
|
||||
description: message,
|
||||
coin: coin
|
||||
});
|
||||
} else {
|
||||
var params = { toAddress: addr, coin: coin };
|
||||
var params = {
|
||||
toAddress: addr,
|
||||
coin: coin,
|
||||
displayAddress: originalAddress
|
||||
};
|
||||
if (shapeshiftData) {
|
||||
params['fromWalletId'] = shapeshiftData.fromWalletId;
|
||||
params['minShapeshiftAmount'] = shapeshiftData.minAmount;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<img src="img/contact-placeholder.svg" class="bg"/>
|
||||
</i>
|
||||
</span>
|
||||
<span class="m10l">{{toName || toAddress}}</span>
|
||||
<span class="m10l">{{toName || displayAddress || toAddress}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
<span class="payment-proposal-to" ng-if="!recipientType">
|
||||
<i class="icon icon-svg abs-v-center icon-bitcoinlogoplain"></i>
|
||||
|
||||
<div copy-to-clipboard="tx.toAddress" ng-if="!tx.paypro" class="ellipsis">
|
||||
<contact ng-if="tx.toAddress && !tx.toName" address="{{tx.toAddress}}"></contact>
|
||||
<div copy-to-clipboard="tx.displayAddress" ng-if="!tx.paypro" class="ellipsis">
|
||||
<contact ng-if="tx.displayAddress && !tx.toName" address="{{tx.displayAddress}}"></contact>
|
||||
<span class="m15l size-14" ng-if="tx.toName">{{tx.toName}}</span>
|
||||
</div>
|
||||
|
||||
|
|
@ -50,15 +50,15 @@
|
|||
<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"/>
|
||||
</i>
|
||||
<div copy-to-clipboard="tx.toAddress" class="ellipsis">
|
||||
<contact ng-if="tx.toAddress && !tx.toName" address="{{tx.toAddress}}"></contact>
|
||||
<div copy-to-clipboard="tx.displayAddress" class="ellipsis">
|
||||
<contact ng-if="tx.displayAddress && !tx.toName" address="{{tx.displayAddress}}"></contact>
|
||||
<span ng-if="tx.toName" class="wallet-name">{{tx.toName}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
<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>
|
||||
<a class="item item-icon-right" ng-hide="!wallet" ng-click="showWalletSelector()">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue