incomingData, bip70 & bitpay
This commit is contained in:
parent
6c46ec2bca
commit
c800e8efe5
1 changed files with 54 additions and 62 deletions
|
|
@ -82,37 +82,33 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
});
|
});
|
||||||
// Timeout is required to enable the "Back" button
|
// Timeout is required to enable the "Back" button
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
|
var params = {};
|
||||||
|
|
||||||
if (amount) {
|
if (amount) {
|
||||||
$state.transitionTo('tabs.send.origin', {
|
params.amount = amount;
|
||||||
amount: amount,
|
}
|
||||||
toAddress: addr,
|
|
||||||
description: message,
|
|
||||||
coin: coin
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var params = {
|
|
||||||
toAddress: addr,
|
|
||||||
coin: coin,
|
|
||||||
displayAddress: originalAddress ? originalAddress : addr,
|
|
||||||
noPrefix: noPrefixInAddress
|
|
||||||
};
|
|
||||||
if (serviceId) {
|
|
||||||
if (!params['thirdParty']) {
|
|
||||||
params['thirdParty'] = [];
|
|
||||||
}
|
|
||||||
params['thirdParty']['id'] = serviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceData) {
|
if (addr) {
|
||||||
params['thirdParty']['data'] = serviceData;
|
params.toAddress = addr;
|
||||||
// params['thirdParty']['minShapeshiftAmount'] = serviceData.minAmount;
|
params.displayAddress = originalAddress ? originalAddress : addr;
|
||||||
// params['thirdParty']['maxShapeshiftAmount'] = serviceData.maxAmount;
|
}
|
||||||
// params['thirdParty']['shapeshiftOrderId'] = serviceData.orderId;
|
|
||||||
params['thirdParty'] = JSON.stringify(params['thirdParty']);
|
if (coin) {
|
||||||
$state.transitionTo('tabs.send.amount', params);
|
params.coin = coin;
|
||||||
} else {
|
}
|
||||||
$state.transitionTo('tabs.send.origin', params);
|
|
||||||
}
|
if (noPrefixInAddress) {
|
||||||
|
params.noPrefixInAddress = noPrefixInAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serviceId) {
|
||||||
|
params.thirdParty = [];
|
||||||
|
params.thirdParty.id = serviceId;
|
||||||
|
params.thirdParty.data = serviceData;
|
||||||
|
params.thirdParty = JSON.stringify(params.thirdParty);
|
||||||
|
$state.transitionTo('tabs.send.amount', params);
|
||||||
|
} else {
|
||||||
|
$state.transitionTo('tabs.send.origin', params);
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +126,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
}
|
}
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), message)
|
popupService.showAlert(gettextCatalog.getString('Error'), message)
|
||||||
} else {
|
} else {
|
||||||
handlePayPro(createBchPayProObject(details), coin);
|
handlePayPro(details, coin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -399,14 +395,30 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBchPayProObject(payProData) {
|
function handlePayPro(payProData, coin) {
|
||||||
var displayAddr = payProData.outputs[0].address;
|
|
||||||
var toAddr = bitcoinCashJsService.readAddress('bitcoincash:' + displayAddr).legacy;
|
var toAddr = payProData.toAddress;
|
||||||
return {
|
var amount = payProData.amount;
|
||||||
amount: payProData.outputs[0].amount,
|
var paymentUrl = payProData.url;
|
||||||
|
|
||||||
|
if (coin === 'bch') {
|
||||||
|
var displayAddr = payProData.outputs[0].address;
|
||||||
|
toAddr = bitcoinCashJsService.readAddress('bitcoincash:' + displayAddr).legacy;
|
||||||
|
amount = payProData.outputs[0].amount;
|
||||||
|
paymentUrl = payProData.paymentUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = payProData.domain;
|
||||||
|
if (paymentUrl.indexOf('https://bitpay.com') > -1) {
|
||||||
|
name = 'bitpay';
|
||||||
|
}
|
||||||
|
|
||||||
|
var thirdPartyData = {
|
||||||
|
id: 'bip70',
|
||||||
|
amount: amount,
|
||||||
caTrusted: true,
|
caTrusted: true,
|
||||||
name: 'bitpay',
|
name: name,
|
||||||
domain: 'bitpay.com',
|
domain: payProData.domain,
|
||||||
expires: Math.floor(new Date(payProData.expires).getTime() / 1000),
|
expires: Math.floor(new Date(payProData.expires).getTime() / 1000),
|
||||||
memo: payProData.memo,
|
memo: payProData.memo,
|
||||||
network: 'livenet',
|
network: 'livenet',
|
||||||
|
|
@ -415,40 +427,20 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
time: Math.ceil(new Date(payProData.time).getTime() / 1000),
|
time: Math.ceil(new Date(payProData.time).getTime() / 1000),
|
||||||
displayAddress: displayAddr,
|
displayAddress: displayAddr,
|
||||||
toAddress: toAddr,
|
toAddress: toAddr,
|
||||||
url: payProData.paymentUrl,
|
url: paymentUrl,
|
||||||
verified: true
|
verified: true
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
function handlePayPro(payProDetails, coin) {
|
|
||||||
var thirdPartyData = {
|
|
||||||
id: 'bip70',
|
|
||||||
name: payProDetails.name,
|
|
||||||
caName: payProDetails.caName,
|
|
||||||
caTrusted: payProDetails.caTrusted,
|
|
||||||
coin: coin,
|
|
||||||
domain: payProDetails.domain,
|
|
||||||
expires: payProDetails.expires,
|
|
||||||
memo: payProDetails.memo,
|
|
||||||
merchant_data: payProDetails.merchant_data,
|
|
||||||
network: payProDetails.network,
|
|
||||||
requiredFeeRate: payProDetails.requiredFeeRate,
|
|
||||||
selfSigned: payProDetails.selfSigned,
|
|
||||||
time: payProDetails.time,
|
|
||||||
url: payProDetails.url,
|
|
||||||
verified: payProDetails.verified
|
|
||||||
};
|
|
||||||
|
|
||||||
var stateParams = {
|
var stateParams = {
|
||||||
amount: payProDetails.amount,
|
amount: thirdPartyData.amount,
|
||||||
toAddress: payProDetails.toAddress,
|
toAddress: thirdPartyData.toAddress,
|
||||||
coin: coin,
|
coin: coin,
|
||||||
thirdParty: JSON.stringify(thirdPartyData)
|
thirdParty: JSON.stringify(thirdPartyData)
|
||||||
};
|
};
|
||||||
|
|
||||||
// fee
|
// fee
|
||||||
if (payProDetails.requiredFeeRate) {
|
if (thirdPartyData.requiredFeeRate) {
|
||||||
stateParams.requiredFeeRate = payProDetails.requiredFeeRate * 1024;
|
stateParams.requiredFeeRate = thirdPartyData.requiredFeeRate * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
scannerService.pausePreview();
|
scannerService.pausePreview();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue