Compare commits
34 commits
master
...
wallet/tas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a94bc2f49 |
||
|
|
8ef930a0a9 | ||
|
|
dd61e72bcf | ||
|
|
6c0cf4d622 | ||
|
|
8f67fde60b | ||
|
|
621c60a2ce | ||
|
|
7a78eb1261 |
||
|
|
4f7004f5a3 | ||
|
|
390f8b2427 | ||
|
|
b9a4e11e69 |
||
|
|
eacf207b2c | ||
|
|
a426a5abc0 | ||
|
|
a9b84f3942 | ||
|
|
6bf0de9974 | ||
|
|
5b7eb57d76 | ||
|
|
c657cc5bfb | ||
|
|
fac91ff4f3 | ||
|
|
b5cd9faca7 | ||
|
|
acacb5660b |
||
|
|
fb41fca601 |
||
|
|
8039ea26da | ||
|
|
5401bf9a09 | ||
|
|
0598a07af7 |
||
|
|
9f904bb098 |
||
|
|
37596c3a25 |
||
|
|
dbe920a67b |
||
|
|
d2178d670f | ||
|
|
8f8027d573 | ||
|
|
babdc8a13b | ||
|
|
6452a0c7f4 | ||
|
|
1b0541a7b5 | ||
|
|
c661798cd1 | ||
|
|
a5a1d3edb6 | ||
|
|
0ba4db83e0 |
13 changed files with 243 additions and 162 deletions
|
|
@ -71,7 +71,7 @@ module.exports = function(grunt) {
|
||||||
sign_android: {
|
sign_android: {
|
||||||
// When the build log outputs "Built the following apk(s):", it seems to need the filename to start with "android-release".
|
// When the build log outputs "Built the following apk(s):", it seems to need the filename to start with "android-release".
|
||||||
// It looks like it simply lists all apk files starting with "android-release"
|
// It looks like it simply lists all apk files starting with "android-release"
|
||||||
command: 'rm -f platforms/android/build/outputs/apk/android-release-signed-*.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk bitcoin-com && zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/bitcoin-com-wallet-<%= pkg.fullVersion %>-android-signed-aligned.apk',
|
command: 'rm -f platforms/android/build/outputs/apk/release/*-android-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../bitcoin-com-release-key.jks -signedjar platforms/android/build/outputs/apk/release/android-release-signed.apk platforms/android/build/outputs/apk/release/android-release-unsigned.apk bitcoin-com && zipalign -v 4 platforms/android/build/outputs/apk/release/android-release-signed.apk platforms/android/build/outputs/apk/release/bitcoin-com-wallet-<%= pkg.fullVersion %>-android-signed-aligned.apk',
|
||||||
stdin: true,
|
stdin: true,
|
||||||
},
|
},
|
||||||
sign_desktop_dist: {
|
sign_desktop_dist: {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- Supported Platforms -->
|
<!-- Supported Platforms -->
|
||||||
<engine name="ios" spec="~4.5.3" />
|
<engine name="ios" spec="~4.5.3" />
|
||||||
<engine name="android" spec="~6.3.0" />
|
<engine name="android" spec="~6.4.0" />
|
||||||
<engine name="windows" spec="~5.0.0" />
|
<engine name="windows" spec="~5.0.0" />
|
||||||
|
|
||||||
<!-- Platform Specific Settings -->
|
<!-- Platform Specific Settings -->
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
ext {
|
ext {
|
||||||
ANDROID_SUPPORT_V4_VERSION = '26.1.0'
|
ANDROID_SUPPORT_V4_VERSION = '26.1.0'
|
||||||
|
ANDROID_SUPPORT_ANNOTATIONS_VERSION = '26.1.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
|
|
||||||
|
|
@ -9,30 +9,6 @@ angular
|
||||||
function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) {
|
function amountController(configService, $filter, gettextCatalog, $ionicHistory, $ionicModal, $ionicScrollDelegate, lodash, $log, nodeWebkitService, rateService, $scope, $state, $timeout, sendFlowService, shapeshiftService, txFormatService, platformInfo, ongoingProcess, popupService, profileService, walletService, $window) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
// Variables
|
|
||||||
vm.allowSend = false;
|
|
||||||
vm.altCurrencyList = [];
|
|
||||||
vm.alternativeAmount = '';
|
|
||||||
vm.alternativeUnit = '';
|
|
||||||
vm.amount = '0';
|
|
||||||
vm.availableFunds = '';
|
|
||||||
vm.canSendAllAvailableFunds = true;
|
|
||||||
vm.errorMessage = '';
|
|
||||||
// Use insufficient for logic, as when the amount is invalid, funds being
|
|
||||||
// either sufficent or insufficient doesn't make sense.
|
|
||||||
vm.fundsAreInsufficient = false;
|
|
||||||
vm.globalResult = '';
|
|
||||||
vm.isRequestingSpecificAmount = false;
|
|
||||||
vm.listComplete = false;
|
|
||||||
vm.lastUsedPopularList = [];
|
|
||||||
vm.maxAmount = 0;
|
|
||||||
vm.minAmount = 0;
|
|
||||||
vm.sendableFunds = '';
|
|
||||||
vm.showSendMaxButton = false;
|
|
||||||
vm.showSendLimitMaxButton = false;
|
|
||||||
vm.thirdParty = false;
|
|
||||||
vm.unit = '';
|
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
vm.changeUnit = changeUnit;
|
vm.changeUnit = changeUnit;
|
||||||
vm.close = close;
|
vm.close = close;
|
||||||
|
|
@ -47,7 +23,6 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
vm.save = save;
|
vm.save = save;
|
||||||
vm.sendMax = sendMax;
|
vm.sendMax = sendMax;
|
||||||
|
|
||||||
|
|
||||||
$scope.$on('$ionicView.beforeEnter', onBeforeEnter);
|
$scope.$on('$ionicView.beforeEnter', onBeforeEnter);
|
||||||
$scope.$on('$ionicView.leave', onLeave);
|
$scope.$on('$ionicView.leave', onLeave);
|
||||||
|
|
||||||
|
|
@ -79,8 +54,55 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
satoshis: null
|
satoshis: null
|
||||||
};
|
};
|
||||||
|
|
||||||
function onLeave() {
|
function initVariables() {
|
||||||
angular.element($window).off('keydown');
|
// Private variables
|
||||||
|
altCurrencyModal = null;
|
||||||
|
altUnitIndex = 0;
|
||||||
|
availableUnits = [];
|
||||||
|
canSendMax = true;
|
||||||
|
fiatCode;
|
||||||
|
isNW = platformInfo.isNW;
|
||||||
|
isAndroid = platformInfo.isAndroid;
|
||||||
|
isIos = platformInfo.isIOS;
|
||||||
|
lastUsedAltCurrencyList = [];
|
||||||
|
passthroughParams = {};
|
||||||
|
satToUnit;
|
||||||
|
transactionSendableAmount = {
|
||||||
|
crypto: '',
|
||||||
|
satoshis: null
|
||||||
|
};
|
||||||
|
unitDecimals;
|
||||||
|
unitIndex = 0;
|
||||||
|
unitToSatoshi;
|
||||||
|
useSendMax = false;
|
||||||
|
walletSpendableAmount = {
|
||||||
|
crypto: '',
|
||||||
|
satoshis: null
|
||||||
|
};
|
||||||
|
|
||||||
|
// Public variables
|
||||||
|
vm.allowSend = false;
|
||||||
|
vm.altCurrencyList = [];
|
||||||
|
vm.alternativeAmount = '';
|
||||||
|
vm.alternativeUnit = '';
|
||||||
|
vm.amount = '0';
|
||||||
|
vm.availableFunds = '';
|
||||||
|
vm.canSendAllAvailableFunds = true;
|
||||||
|
vm.errorMessage = '';
|
||||||
|
// Use insufficient for logic, as when the amount is invalid, funds being
|
||||||
|
// either sufficent or insufficient doesn't make sense.
|
||||||
|
vm.fundsAreInsufficient = false;
|
||||||
|
vm.globalResult = '';
|
||||||
|
vm.isRequestingSpecificAmount = false;
|
||||||
|
vm.listComplete = false;
|
||||||
|
vm.lastUsedPopularList = [];
|
||||||
|
vm.maxAmount = 0;
|
||||||
|
vm.minAmount = 0;
|
||||||
|
vm.sendableFunds = '';
|
||||||
|
vm.showSendMaxButton = false;
|
||||||
|
vm.showSendLimitMaxButton = false;
|
||||||
|
vm.thirdParty = null;
|
||||||
|
vm.unit = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
|
|
@ -88,11 +110,19 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
sendFlowService.state.pop();
|
sendFlowService.state.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Init before entering on this screen
|
||||||
|
initVariables();
|
||||||
initCurrencies();
|
initCurrencies();
|
||||||
|
// Then start
|
||||||
|
|
||||||
passthroughParams = sendFlowService.state.getClone();
|
passthroughParams = sendFlowService.state.getClone();
|
||||||
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
console.log('amount onBeforeEnter after back sendflow ', passthroughParams);
|
||||||
|
|
||||||
|
|
||||||
|
// Init thirdParty, should be done for all the variable
|
||||||
|
vm.thirdParty = null;
|
||||||
|
|
||||||
vm.fromWalletId = passthroughParams.fromWalletId;
|
vm.fromWalletId = passthroughParams.fromWalletId;
|
||||||
vm.toWalletId = passthroughParams.toWalletId;
|
vm.toWalletId = passthroughParams.toWalletId;
|
||||||
vm.minAmount = parseFloat(passthroughParams.minAmount);
|
vm.minAmount = parseFloat(passthroughParams.minAmount);
|
||||||
|
|
@ -218,6 +248,10 @@ function amountController(configService, $filter, gettextCatalog, $ionicHistory,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onLeave() {
|
||||||
|
angular.element($window).off('keydown');
|
||||||
|
}
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
sendFlowService.router.goBack();
|
sendFlowService.router.goBack();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,53 @@ angular
|
||||||
.module('copayApp.controllers')
|
.module('copayApp.controllers')
|
||||||
.controller('reviewController', reviewController);
|
.controller('reviewController', reviewController);
|
||||||
|
|
||||||
function reviewController(addressbookService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
|
function reviewController(addressbookService, externalLinkService, bitcoinCashJsService, bitcore, bitcoreCash, bwcError, clipboardService, configService, feeService, gettextCatalog, $interval, $ionicHistory, $ionicModal, ionicToast, lodash, $log, ongoingProcess, platformInfo, popupService, profileService, $scope, sendFlowService, shapeshiftService, soundService, $state, $timeout, txConfirmNotification, txFormatService, walletService) {
|
||||||
var vm = this;
|
var vm = this;
|
||||||
|
|
||||||
|
var sendFlowData;
|
||||||
|
var config = null;
|
||||||
|
var coin = '';
|
||||||
|
var countDown = null;
|
||||||
|
var defaults = {};
|
||||||
|
var usingCustomFee = false;
|
||||||
|
var usingMerchantFee = false;
|
||||||
|
var destinationWalletId = '';
|
||||||
|
var lastTxId = '';
|
||||||
|
var originWalletId = '';
|
||||||
|
var priceDisplayIsFiat = true;
|
||||||
|
var satoshis = null;
|
||||||
|
var toAddress = '';
|
||||||
|
var tx = {};
|
||||||
|
var txPayproData = null;
|
||||||
|
var unitFromSat = 0;
|
||||||
|
|
||||||
|
var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15;
|
||||||
|
|
||||||
|
// Functions
|
||||||
|
vm.goBack = goBack;
|
||||||
|
vm.onSuccessConfirm = onSuccessConfirm;
|
||||||
|
vm.onShareTransaction = onShareTransaction;
|
||||||
|
|
||||||
|
function initVariables() {
|
||||||
|
// Private variables
|
||||||
|
sendFlowData;
|
||||||
|
config = null;
|
||||||
|
coin = '';
|
||||||
|
countDown = null;
|
||||||
|
defaults = {};
|
||||||
|
usingCustomFee = false;
|
||||||
|
usingMerchantFee = false;
|
||||||
|
destinationWalletId = '';
|
||||||
|
lastTxId = '';
|
||||||
|
originWalletId = '';
|
||||||
|
priceDisplayIsFiat = true;
|
||||||
|
satoshis = null;
|
||||||
|
toAddress = '';
|
||||||
|
tx = {};
|
||||||
|
txPayproData = null;
|
||||||
|
unitFromSat = 0;
|
||||||
|
|
||||||
|
// Public variables
|
||||||
vm.buttonText = '';
|
vm.buttonText = '';
|
||||||
vm.destination = {
|
vm.destination = {
|
||||||
address: '',
|
address: '',
|
||||||
|
|
@ -49,50 +93,24 @@ angular
|
||||||
vm.sendingTitle = gettextCatalog.getString('You are sending');
|
vm.sendingTitle = gettextCatalog.getString('You are sending');
|
||||||
vm.sendStatus = '';
|
vm.sendStatus = '';
|
||||||
vm.showAddress = true;
|
vm.showAddress = true;
|
||||||
vm.thirdParty = false;
|
vm.thirdParty = null;
|
||||||
vm.wallet = null;
|
vm.wallet = null;
|
||||||
vm.memoExpanded = false;
|
vm.memoExpanded = false;
|
||||||
|
}
|
||||||
// Functions
|
|
||||||
vm.goBack = goBack;
|
|
||||||
vm.onSuccessConfirm = onSuccessConfirm;
|
|
||||||
vm.onShareTransaction = onShareTransaction;
|
|
||||||
|
|
||||||
var sendFlowData;
|
|
||||||
var config = null;
|
|
||||||
var coin = '';
|
|
||||||
var countDown = null;
|
|
||||||
var defaults = {};
|
|
||||||
var usingCustomFee = false;
|
|
||||||
var usingMerchantFee = false;
|
|
||||||
var destinationWalletId = '';
|
|
||||||
var lastTxId = '';
|
|
||||||
var originWalletId = '';
|
|
||||||
var priceDisplayIsFiat = true;
|
|
||||||
var satoshis = null;
|
|
||||||
var toAddress = '';
|
|
||||||
var tx = {};
|
|
||||||
var txPayproData = null;
|
|
||||||
var unitFromSat = 0;
|
|
||||||
|
|
||||||
var FEE_TOO_HIGH_LIMIT_PERCENTAGE = 15;
|
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
||||||
|
|
||||||
|
|
||||||
function onBeforeEnter(event, data) {
|
function onBeforeEnter(event, data) {
|
||||||
console.log('review onBeforeEnter sendflow ', sendFlowService.state);
|
$log.debug('reviewController onBeforeEnter sendflow ', sendFlowService.state);
|
||||||
// Reset from last time
|
|
||||||
vm.memo = '';
|
// Init before entering on this screen
|
||||||
|
initVariables();
|
||||||
|
// Then start
|
||||||
|
|
||||||
defaults = configService.getDefaults();
|
defaults = configService.getDefaults();
|
||||||
sendFlowData = sendFlowService.state.getClone();
|
sendFlowData = sendFlowService.state.getClone();
|
||||||
originWalletId = sendFlowData.fromWalletId;
|
originWalletId = sendFlowData.fromWalletId;
|
||||||
if (typeof sendFlowData.amount === 'string') {
|
|
||||||
satoshis = parseInt(sendFlowData.amount, 10);
|
satoshis = parseInt(sendFlowData.amount, 10);
|
||||||
} else {
|
|
||||||
satoshis = sendFlowData.amount;
|
|
||||||
}
|
|
||||||
toAddress = sendFlowData.toAddress;
|
toAddress = sendFlowData.toAddress;
|
||||||
destinationWalletId = sendFlowData.toWalletId;
|
destinationWalletId = sendFlowData.toWalletId;
|
||||||
|
|
||||||
|
|
@ -105,11 +123,14 @@ angular
|
||||||
vm.thirdParty = sendFlowData.thirdParty;
|
vm.thirdParty = sendFlowData.thirdParty;
|
||||||
switch (vm.thirdParty.id) {
|
switch (vm.thirdParty.id) {
|
||||||
case 'shapeshift':
|
case 'shapeshift':
|
||||||
initShapeshift(function (err) {
|
initShapeshift(function onInitShapeshift(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
// Error stop here
|
// Error stop here
|
||||||
ongoingProcess.set('connectingShapeshift', false);
|
ongoingProcess.set('connectingShapeshift', false);
|
||||||
popupService.showAlert(gettextCatalog.getString('Shapeshift Error'), err.toString(), function () {
|
popupService.showConfirm(gettextCatalog.getString('Shapeshift Error'), err.toString(), gettextCatalog.getString('Open') + " Shapeshift", gettextCatalog.getString('Go Back'), function onConfirm(hasConfirm) {
|
||||||
|
if (hasConfirm) {
|
||||||
|
externalLinkService.open("https://shapeshift.io");
|
||||||
|
}
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -135,7 +156,6 @@ angular
|
||||||
config = configCache;
|
config = configCache;
|
||||||
priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat';
|
priceDisplayIsFiat = config.wallet.settings.priceDisplay === 'fiat';
|
||||||
vm.origin.currencyColor = (vm.originWallet.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor);
|
vm.origin.currencyColor = (vm.originWallet.coin === 'btc' ? defaults.bitcoinWalletColor : defaults.bitcoinCashWalletColor);
|
||||||
console.log("coin", vm.originWallet.coin, vm.origin.currencyColor, config.bitcoinWalletColor, vm.originWallet.coin === 'btc');
|
|
||||||
unitFromSat = 1 / config.wallet.settings.unitToSatoshi;
|
unitFromSat = 1 / config.wallet.settings.unitToSatoshi;
|
||||||
}
|
}
|
||||||
updateSendAmounts();
|
updateSendAmounts();
|
||||||
|
|
@ -152,18 +172,18 @@ angular
|
||||||
if (!tx || !vm.originWallet) return;
|
if (!tx || !vm.originWallet) return;
|
||||||
|
|
||||||
if (vm.paymentExpired) {
|
if (vm.paymentExpired) {
|
||||||
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.', function () {
|
popupService.showAlert(null, gettextCatalog.getString('This bitcoin payment request has expired.', function onAlert() {
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
}));
|
}));
|
||||||
vm.sendStatus = '';
|
vm.sendStatus = '';
|
||||||
$timeout(function() {
|
$timeout(function onTimeout() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ongoingProcess.set('creatingTx', true, statusChangeHandler);
|
ongoingProcess.set('creatingTx', true, statusChangeHandler);
|
||||||
getTxp(lodash.clone(tx), vm.originWallet, false, function(err, txp) {
|
getTxp(lodash.clone(tx), vm.originWallet, false, function onGetTxp(err, txp) {
|
||||||
ongoingProcess.set('creatingTx', false, statusChangeHandler);
|
ongoingProcess.set('creatingTx', false, statusChangeHandler);
|
||||||
if (err) return;
|
if (err) return;
|
||||||
|
|
||||||
|
|
@ -180,12 +200,12 @@ angular
|
||||||
if (!vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) {
|
if (!vm.originWallet.canSign() && !vm.originWallet.isPrivKeyExternal()) {
|
||||||
$log.info('No signing proposal: No private key');
|
$log.info('No signing proposal: No private key');
|
||||||
|
|
||||||
return walletService.onlyPublish(vm.originWallet, txp, function(err) {
|
return walletService.onlyPublish(vm.originWallet, txp, function onOnlyPublish(err) {
|
||||||
if (err) setSendError(err);
|
if (err) setSendError(err);
|
||||||
}, statusChangeHandler);
|
}, statusChangeHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
walletService.publishAndSign(vm.originWallet, txp, function(err, txp) {
|
walletService.publishAndSign(vm.originWallet, txp, function onPublishAndSign(err, txp) {
|
||||||
if (err) return setSendError(err);
|
if (err) return setSendError(err);
|
||||||
if (config.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) {
|
if (config.confirmedTxsNotifications && config.confirmedTxsNotifications.enabled) {
|
||||||
txConfirmNotification.subscribe(vm.originWallet, {
|
txConfirmNotification.subscribe(vm.originWallet, {
|
||||||
|
|
@ -199,7 +219,7 @@ angular
|
||||||
confirmTx(function(nok) {
|
confirmTx(function(nok) {
|
||||||
if (nok) {
|
if (nok) {
|
||||||
vm.sendStatus = '';
|
vm.sendStatus = '';
|
||||||
$timeout(function() {
|
$timeout(function onTimeout() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
@ -256,7 +276,6 @@ angular
|
||||||
};
|
};
|
||||||
|
|
||||||
function createVanityTransaction(data) {
|
function createVanityTransaction(data) {
|
||||||
console.log('createVanityTransaction()');
|
|
||||||
var configFeeLevel = config.wallet.settings.feeLevel ? config.wallet.settings.feeLevel : 'normal';
|
var configFeeLevel = config.wallet.settings.feeLevel ? config.wallet.settings.feeLevel : 'normal';
|
||||||
|
|
||||||
// Grab stateParams
|
// Grab stateParams
|
||||||
|
|
@ -280,6 +299,9 @@ angular
|
||||||
txp: {},
|
txp: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (vm.thirdParty && vm.thirdParty.id === "shapeshift") {
|
||||||
|
tx.toAddress = vm.thirdParty.toAddress;
|
||||||
|
}
|
||||||
|
|
||||||
if (data.stateParams.requiredFeeRate) {
|
if (data.stateParams.requiredFeeRate) {
|
||||||
vm.usingMerchantFee = true;
|
vm.usingMerchantFee = true;
|
||||||
|
|
@ -293,29 +315,35 @@ angular
|
||||||
var B = tx.coin === 'bch' ? bitcoreCash : bitcore;
|
var B = tx.coin === 'bch' ? bitcoreCash : bitcore;
|
||||||
var networkName;
|
var networkName;
|
||||||
try {
|
try {
|
||||||
if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer
|
// Final destination is a wallet, but this transaction must go to an address for the first stage of the exchange.
|
||||||
|
if (sendFlowData.thirdParty && sendFlowData.thirdParty.id === 'shapeshift') {
|
||||||
|
networkName = (new B.Address(tx.toAddress)).network.name;
|
||||||
|
tx.network = networkName;
|
||||||
|
setupTx(tx);
|
||||||
|
|
||||||
|
} else if (vm.destination.kind === 'wallet') { // This is a wallet-to-wallet transfer
|
||||||
ongoingProcess.set('generatingNewAddress', true);
|
ongoingProcess.set('generatingNewAddress', true);
|
||||||
var toWallet = profileService.getWallet(destinationWalletId);
|
var toWallet = profileService.getWallet(destinationWalletId);
|
||||||
|
|
||||||
// We need an address to send to, so we ask the walletService to create a new address for the toWallet.
|
// We need an address to send to, so we ask the walletService to create a new address for the toWallet.
|
||||||
console.log('Getting address for wallet...');
|
|
||||||
walletService.getAddress(toWallet, true, function onWalletAddress(err, addr) {
|
walletService.getAddress(toWallet, true, function onWalletAddress(err, addr) {
|
||||||
console.log('getAddress cb called', err);
|
if (err) {
|
||||||
|
$log.error('Error getting address for wallet.', err);
|
||||||
|
throw new Error(err.message);
|
||||||
|
}
|
||||||
ongoingProcess.set('generatingNewAddress', false);
|
ongoingProcess.set('generatingNewAddress', false);
|
||||||
tx.toAddress = addr;
|
tx.toAddress = addr;
|
||||||
networkName = (new B.Address(tx.toAddress)).network.name;
|
networkName = (new B.Address(tx.toAddress)).network.name;
|
||||||
tx.network = networkName;
|
tx.network = networkName;
|
||||||
console.log('calling setupTx() for wallet.');
|
|
||||||
setupTx(tx);
|
setupTx(tx);
|
||||||
});
|
});
|
||||||
} else { // This is a Wallet-to-address transfer
|
} else { // This is a Wallet-to-address transfer
|
||||||
networkName = (new B.Address(tx.toAddress)).network.name;
|
networkName = (new B.Address(tx.toAddress)).network.name;
|
||||||
tx.network = networkName;
|
tx.network = networkName;
|
||||||
console.log('calling setupTx() for address.');
|
|
||||||
setupTx(tx);
|
setupTx(tx);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error setting up tx', e);
|
$log.error('Error setting up tx', e);
|
||||||
var message = gettextCatalog.getString('Invalid address');
|
var message = gettextCatalog.getString('Invalid address');
|
||||||
popupService.showAlert(null, message, function () {
|
popupService.showAlert(null, message, function () {
|
||||||
$ionicHistory.nextViewOptions({
|
$ionicHistory.nextViewOptions({
|
||||||
|
|
@ -385,7 +413,7 @@ angular
|
||||||
}
|
}
|
||||||
txp.excludeUnconfirmedUtxos = !tx.spendUnconfirmed;
|
txp.excludeUnconfirmedUtxos = !tx.spendUnconfirmed;
|
||||||
txp.dryRun = dryRun;
|
txp.dryRun = dryRun;
|
||||||
walletService.createTx(wallet, txp, function(err, ctxp) {
|
walletService.createTx(wallet, txp, function onCreateTx(err, ctxp) {
|
||||||
if (err) {
|
if (err) {
|
||||||
setSendError(err);
|
setSendError(err);
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
|
@ -405,7 +433,7 @@ angular
|
||||||
var walletStatus = null;
|
var walletStatus = null;
|
||||||
if (wallet.status && wallet.status.isValid) {
|
if (wallet.status && wallet.status.isValid) {
|
||||||
walletStatus = wallet.status;
|
walletStatus = wallet.status;
|
||||||
} else if (wallet.cachedStatus.isValid) {
|
} else if (wallet.cachedStatus && wallet.cachedStatus.isValid) {
|
||||||
walletStatus = wallet.cachedStatus;
|
walletStatus = wallet.cachedStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -444,7 +472,7 @@ angular
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the recipient is a contact
|
// Check if the recipient is a contact
|
||||||
addressbookService.get(originCoin + address, function(err, contact) {
|
addressbookService.get(originCoin + address, function onGetContact(err, contact) {
|
||||||
if (!err && contact) {
|
if (!err && contact) {
|
||||||
handleDestinationAsAddressOfContact(contact);
|
handleDestinationAsAddressOfContact(contact);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -517,7 +545,6 @@ angular
|
||||||
vm.destination.color = toWallet.color;
|
vm.destination.color = toWallet.color;
|
||||||
vm.destination.currency = toWallet.coin.toUpperCase();
|
vm.destination.currency = toWallet.coin.toUpperCase();
|
||||||
|
|
||||||
|
|
||||||
ongoingProcess.set('connectingShapeshift', true);
|
ongoingProcess.set('connectingShapeshift', true);
|
||||||
walletService.getAddress(vm.originWallet, false, function onReturnWalletAddress(err, returnAddr) {
|
walletService.getAddress(vm.originWallet, false, function onReturnWalletAddress(err, returnAddr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -535,9 +562,8 @@ angular
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
} else {
|
} else {
|
||||||
vm.destination.kind = 'shapeshift';
|
// Want it to appear like a wallet-to-wallet transfer, so don't set the main toAddress.
|
||||||
vm.destination.address = toAddress;
|
vm.thirdParty.toAddress = shapeshiftData.toAddress;
|
||||||
tx.toAddress = shapeshiftData.toAddress;
|
|
||||||
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
vm.memo = 'ShapeShift Order:\nhttps://www.shapeshift.io/#/status/' + shapeshiftData.orderId;
|
||||||
vm.memoExpanded = !!vm.memo;
|
vm.memoExpanded = !!vm.memo;
|
||||||
ongoingProcess.set('connectingShapeshift', false);
|
ongoingProcess.set('connectingShapeshift', false);
|
||||||
|
|
@ -572,7 +598,6 @@ angular
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
function setExpirationTime() {
|
function setExpirationTime() {
|
||||||
console.log('setExpirationTime()');
|
|
||||||
var now = Math.floor(Date.now() / 1000);
|
var now = Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
if (now > expirationTime) {
|
if (now > expirationTime) {
|
||||||
|
|
@ -690,7 +715,7 @@ angular
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
});
|
});
|
||||||
popupService.showAlert(gettextCatalog.getString('Error at confirm'), bwcError.msg(msg), function () {
|
popupService.showAlert(gettextCatalog.getString('Error at confirm'), bwcError.msg(msg), function onAlert() {
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -702,7 +727,7 @@ angular
|
||||||
tx.displayAddress = tx.toAddress;
|
tx.displayAddress = tx.toAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
addressbookService.get(tx.coin+tx.toAddress, function(err, addr) { // Check if the recipient is a contact
|
addressbookService.get(tx.coin+tx.toAddress, function onGetContact(err, addr) { // Check if the recipient is a contact
|
||||||
if (!err && addr) {
|
if (!err && addr) {
|
||||||
tx.toName = addr.name;
|
tx.toName = addr.name;
|
||||||
tx.toEmail = addr.email;
|
tx.toEmail = addr.email;
|
||||||
|
|
@ -721,23 +746,10 @@ angular
|
||||||
updateTx(tx, vm.originWallet, {
|
updateTx(tx, vm.originWallet, {
|
||||||
dryRun: true
|
dryRun: true
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
$timeout(function() {
|
$timeout(function onTimeout() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 10);
|
}, 10);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// setWalletSelector(tx.coin, tx.network, tx.amount, function(err) {
|
|
||||||
// if (err) {
|
|
||||||
// return exitWithError('Could not update wallets');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (vm.wallets.length > 1) {
|
|
||||||
// vm.showWalletSelector();
|
|
||||||
// } else if (vm.wallets.length) {
|
|
||||||
// setWallet(vm.wallets[0], tx);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showSendMaxWarning(wallet, sendMaxInfo) {
|
function showSendMaxWarning(wallet, sendMaxInfo) {
|
||||||
|
|
@ -848,7 +860,7 @@ angular
|
||||||
// refresh();
|
// refresh();
|
||||||
|
|
||||||
var feeServiceLevel = usingMerchantFee && vm.originWallet.coin == 'btc' ? 'urgent' : tx.feeLevel;
|
var feeServiceLevel = usingMerchantFee && vm.originWallet.coin == 'btc' ? 'urgent' : tx.feeLevel;
|
||||||
feeService.getFeeRate(vm.originWallet.coin, tx.network, feeServiceLevel, function(err, feeRate) {
|
feeService.getFeeRate(vm.originWallet.coin, tx.network, feeServiceLevel, function onGetFeeRate(err, feeRate) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('calculatingFee', false);
|
ongoingProcess.set('calculatingFee', false);
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
|
@ -867,7 +879,7 @@ angular
|
||||||
tx.feeRate = feeRate;
|
tx.feeRate = feeRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSendMaxInfo(lodash.clone(tx), wallet, function(err, sendMaxInfo) {
|
getSendMaxInfo(lodash.clone(tx), wallet, function onGetSendmaxInfo(err, sendMaxInfo) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('calculatingFee', false);
|
ongoingProcess.set('calculatingFee', false);
|
||||||
var msg = gettextCatalog.getString('Error getting SendMax information');
|
var msg = gettextCatalog.getString('Error getting SendMax information');
|
||||||
|
|
@ -881,7 +893,7 @@ angular
|
||||||
if (tx.sendMax && sendMaxInfo.amount == 0) {
|
if (tx.sendMax && sendMaxInfo.amount == 0) {
|
||||||
ongoingProcess.set('calculatingFee', false);
|
ongoingProcess.set('calculatingFee', false);
|
||||||
setNotReady(gettextCatalog.getString('Insufficient confirmed funds'));
|
setNotReady(gettextCatalog.getString('Insufficient confirmed funds'));
|
||||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'), function () {
|
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Not enough funds for fee'), function onAlert() {
|
||||||
$ionicHistory.goBack();
|
$ionicHistory.goBack();
|
||||||
});
|
});
|
||||||
return cb('no_funds');
|
return cb('no_funds');
|
||||||
|
|
@ -906,8 +918,7 @@ angular
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('calling getTxp() from getSendMaxInfo cb.');
|
getTxp(lodash.clone(tx), wallet, opts.dryRun, function onGetTxp(err, txp) {
|
||||||
getTxp(lodash.clone(tx), wallet, opts.dryRun, function(err, txp) {
|
|
||||||
ongoingProcess.set('calculatingFee', false);
|
ongoingProcess.set('calculatingFee', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.message == 'Insufficient funds') {
|
if (err.message == 'Insufficient funds') {
|
||||||
|
|
@ -919,7 +930,7 @@ angular
|
||||||
}
|
}
|
||||||
|
|
||||||
txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee);
|
txp.feeStr = txFormatService.formatAmountStr(wallet.coin, txp.fee);
|
||||||
txFormatService.formatAlternativeStr(wallet.coin, txp.fee, function(v) {
|
txFormatService.formatAlternativeStr(wallet.coin, txp.fee, function onFormatAlternativeStr(v) {
|
||||||
// txp.alternativeFeeStr = v;
|
// txp.alternativeFeeStr = v;
|
||||||
// if (txp.alternativeFeeStr.substring(0, 4) == '0.00')
|
// if (txp.alternativeFeeStr.substring(0, 4) == '0.00')
|
||||||
// txp.alternativeFeeStr = '< ' + txp.alternativeFeeStr;
|
// txp.alternativeFeeStr = '< ' + txp.alternativeFeeStr;
|
||||||
|
|
@ -929,8 +940,6 @@ angular
|
||||||
vm.feeLessThanACent = true;
|
vm.feeLessThanACent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("fiat", vm.feeFiat);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var per = (txp.fee / (txp.amount + txp.fee) * 100);
|
var per = (txp.fee / (txp.amount + txp.fee) * 100);
|
||||||
|
|
@ -939,14 +948,11 @@ angular
|
||||||
txp.feeToHigh = per > FEE_TOO_HIGH_LIMIT_PERCENTAGE;
|
txp.feeToHigh = per > FEE_TOO_HIGH_LIMIT_PERCENTAGE;
|
||||||
vm.feeCrypto = (unitFromSat * txp.fee).toFixed(8);
|
vm.feeCrypto = (unitFromSat * txp.fee).toFixed(8);
|
||||||
vm.feeIsHigh = txp.feeToHigh;
|
vm.feeIsHigh = txp.feeToHigh;
|
||||||
console.log("crypto", vm.feeCrypto);
|
|
||||||
|
|
||||||
|
|
||||||
tx.txp[wallet.id] = txp;
|
tx.txp[wallet.id] = txp;
|
||||||
$log.debug('Confirm. TX Fully Updated for wallet:' + wallet.id, tx);
|
$log.debug('Confirm. TX Fully Updated for wallet:' + wallet.id, tx);
|
||||||
vm.readyToSend = true;
|
vm.readyToSend = true;
|
||||||
updateSendAmounts();
|
updateSendAmounts();
|
||||||
console.log('readyToSend:', vm.readyToSend);
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
return cb();
|
return cb();
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,17 @@ angular
|
||||||
var unitDecimals = 0;
|
var unitDecimals = 0;
|
||||||
var unitsFromSatoshis = 0;
|
var unitsFromSatoshis = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Needs to migrate $scope to vm.
|
||||||
|
//
|
||||||
|
function initVariables() {
|
||||||
|
// Private variables
|
||||||
|
fromWalletId = '';
|
||||||
|
priceDisplayAsFiat = false;
|
||||||
|
unitDecimals = 0;
|
||||||
|
unitsFromSatoshis = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
$scope.$on("$ionicView.beforeEnter", onBeforeEnter);
|
||||||
$scope.$on("$ionicView.enter", onEnter);
|
$scope.$on("$ionicView.enter", onEnter);
|
||||||
|
|
||||||
|
|
@ -20,6 +31,10 @@ angular
|
||||||
sendFlowService.state.pop();
|
sendFlowService.state.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init before entering on this screen
|
||||||
|
initVariables();
|
||||||
|
// Then start
|
||||||
|
|
||||||
$scope.params = sendFlowService.state.getClone();
|
$scope.params = sendFlowService.state.getClone();
|
||||||
|
|
||||||
console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
|
console.log('walletSelector onBeforeEnter after back sendflow', $scope.params);
|
||||||
|
|
@ -52,9 +67,6 @@ angular
|
||||||
$scope.specificAmount = $scope.specificAlternativeAmount = '';
|
$scope.specificAmount = $scope.specificAlternativeAmount = '';
|
||||||
$scope.isPaymentRequest = true;
|
$scope.isPaymentRequest = true;
|
||||||
}
|
}
|
||||||
if ($scope.params.thirdParty) {
|
|
||||||
$scope.thirdParty = $scope.params.thirdParty;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function onEnter (event, data) {
|
function onEnter (event, data) {
|
||||||
|
|
@ -62,7 +74,7 @@ angular
|
||||||
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
$scope.selectedPriceDisplay = config.wallet.settings.priceDisplay;
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($scope.thirdParty) {
|
if ($scope.params.thirdParty) {
|
||||||
// Third party services specific logic
|
// Third party services specific logic
|
||||||
handleThirdPartyIfShapeshift();
|
handleThirdPartyIfShapeshift();
|
||||||
}
|
}
|
||||||
|
|
@ -102,8 +114,8 @@ angular
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleThirdPartyIfShapeshift() {
|
function handleThirdPartyIfShapeshift() {
|
||||||
console.log($scope.thirdParty, $scope.coin);
|
console.log($scope.params.thirdParty, $scope.coin);
|
||||||
if ($scope.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the
|
if ($scope.params.thirdParty.id === 'shapeshift' && $scope.type === 'destination') { // Shapeshift wants to know the
|
||||||
$scope.coin = profileService.getWallet(fromWalletId).coin;
|
$scope.coin = profileService.getWallet(fromWalletId).coin;
|
||||||
if ($scope.coin === 'bch') {
|
if ($scope.coin === 'bch') {
|
||||||
$scope.coin = 'btc';
|
$scope.coin = 'btc';
|
||||||
|
|
@ -117,6 +129,8 @@ angular
|
||||||
var walletsAll = [];
|
var walletsAll = [];
|
||||||
var walletsSufficientFunds = [];
|
var walletsSufficientFunds = [];
|
||||||
$scope.walletsInsufficientFunds = []; // For origin screen
|
$scope.walletsInsufficientFunds = []; // For origin screen
|
||||||
|
$scope.walletsBtc = [];
|
||||||
|
$scope.walletsBch = [];
|
||||||
|
|
||||||
if ($scope.type === 'origin') {
|
if ($scope.type === 'origin') {
|
||||||
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from');
|
$scope.headerTitle = gettextCatalog.getString('Choose a wallet to send from');
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ angular.module('copayApp.directives')
|
||||||
scope.type = "url";
|
scope.type = "url";
|
||||||
} else if (scope.data.parsed.publicAddress) {
|
} else if (scope.data.parsed.publicAddress) {
|
||||||
scope.type = "bitcoinAddress";
|
scope.type = "bitcoinAddress";
|
||||||
var prefix = scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:';
|
var prefix = scope.data.coin === 'bch' ? (scope.data.parsed.isTestnet ? 'bchtest:' : 'bitcoincash:') : '';
|
||||||
scope.data.toAddress = (prefix + scope.data.parsed.publicAddress.cashAddr) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
|
scope.data.toAddress = (scope.data.parsed.publicAddress.cashAddr ? prefix + scope.data.parsed.publicAddress.cashAddr : false) || scope.data.parsed.publicAddress.legacy || scope.data.parsed.publicAddress.bitpay;
|
||||||
} else {
|
} else {
|
||||||
scope.type = "text";
|
scope.type = "text";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,7 @@
|
||||||
hasPassphrase: false,
|
hasPassphrase: false,
|
||||||
type: 1,
|
type: 1,
|
||||||
},
|
},
|
||||||
|
isTestnet: false,
|
||||||
isValid: false,
|
isValid: false,
|
||||||
label: '',
|
label: '',
|
||||||
message: '',
|
message: '',
|
||||||
|
|
@ -170,7 +171,6 @@
|
||||||
"req-param0": '',
|
"req-param0": '',
|
||||||
"req-param1": ''
|
"req-param1": ''
|
||||||
},
|
},
|
||||||
testnet: false,
|
|
||||||
url: '' // For BIP70
|
url: '' // For BIP70
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -204,7 +204,13 @@
|
||||||
|
|
||||||
} else if (/^(?:bitcoincash)|(?:bitcoin-cash)$/.test(preColonLower)) {
|
} else if (/^(?:bitcoincash)|(?:bitcoin-cash)$/.test(preColonLower)) {
|
||||||
parsed.coin = 'bch';
|
parsed.coin = 'bch';
|
||||||
parsed.test = false;
|
parsed.isTestnet = false;
|
||||||
|
addressAndParams = colonSplit[2].trim();
|
||||||
|
console.log('Is bch');
|
||||||
|
|
||||||
|
} else if (/^(?:bch)$/.test(preColonLower)) {
|
||||||
|
parsed.coin = 'bch';
|
||||||
|
parsed.isTestnet = false;
|
||||||
addressAndParams = colonSplit[2].trim();
|
addressAndParams = colonSplit[2].trim();
|
||||||
console.log('Is bch');
|
console.log('Is bch');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ describe('bitcoinUriService', function() {
|
||||||
expect(parsed.isValid).toBe(true);
|
expect(parsed.isValid).toBe(true);
|
||||||
expect(parsed.coin).toBe('bch');
|
expect(parsed.coin).toBe('bch');
|
||||||
expect(parsed.publicAddress).toBeUndefined();
|
expect(parsed.publicAddress).toBeUndefined();
|
||||||
expect(parsed.isTestnet).toBeUndefined();
|
expect(parsed.isTestnet).toBe(false);
|
||||||
expect(parsed.url).toBe('https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu');
|
expect(parsed.url).toBe('https://bitpay.com/i/SmHdie5dvBnG5kouZzEPzu');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -171,6 +171,16 @@ describe('bitcoinUriService', function() {
|
||||||
expect(parsed.isTestnet).toBe(false);
|
expect(parsed.isTestnet).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('legacy address with bch prefix', function() {
|
||||||
|
|
||||||
|
var parsed = bitcoinUriService.parse('bch:19yUdM2H7sADrabR6Afu9zTpmwqr6WYprX');
|
||||||
|
|
||||||
|
expect(parsed.isValid).toBe(true);
|
||||||
|
expect(parsed.coin).toBe('bch');
|
||||||
|
expect(parsed.publicAddress.legacy).toBe('19yUdM2H7sADrabR6Afu9zTpmwqr6WYprX');
|
||||||
|
expect(parsed.isTestnet).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('cashAddr testnet with prefix', function() {
|
it('cashAddr testnet with prefix', function() {
|
||||||
|
|
||||||
var parsed = bitcoinUriService.parse('bchtest:qpcz6pmurq9ctg5848trzz9zmuuygj4q5qam7ph3gt');
|
var parsed = bitcoinUriService.parse('bchtest:qpcz6pmurq9ctg5848trzz9zmuuygj4q5qam7ph3gt');
|
||||||
|
|
@ -191,6 +201,16 @@ describe('bitcoinUriService', function() {
|
||||||
expect(parsed.isTestnet).toBe(false);
|
expect(parsed.isTestnet).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('cashAddr with bch prefix', function() {
|
||||||
|
|
||||||
|
var parsed = bitcoinUriService.parse('bch:qpqzqtjqqc00nsxj0e3kevz65ujg4yt5z5w99jap5f');
|
||||||
|
|
||||||
|
expect(parsed.isValid).toBe(true);
|
||||||
|
expect(parsed.coin).toBe('bch');
|
||||||
|
expect(parsed.publicAddress.cashAddr).toBe('qpqzqtjqqc00nsxj0e3kevz65ujg4yt5z5w99jap5f');
|
||||||
|
expect(parsed.isTestnet).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('cashAddr with dash', function() {
|
it('cashAddr with dash', function() {
|
||||||
|
|
||||||
var parsed = bitcoinUriService.parse('bitcoin-cash:qpshfu3dk5s3e7zdcgdcun6xgxtra6uyxs7g580js0');
|
var parsed = bitcoinUriService.parse('bitcoin-cash:qpshfu3dk5s3e7zdcgdcun6xgxtra6uyxs7g580js0');
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ angular
|
||||||
// Detect some merchant that we know
|
// Detect some merchant that we know
|
||||||
if (payProData.memo.indexOf('eGifter') > -1) {
|
if (payProData.memo.indexOf('eGifter') > -1) {
|
||||||
name = 'eGifter'
|
name = 'eGifter'
|
||||||
} else if (paymentUrl.indexOf('https://bitpay.com') > -1) {
|
} else if (payProData.url.indexOf('https://bitpay.com') > -1) {
|
||||||
name = 'BitPay';
|
name = 'BitPay';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ var ShapeShift = (function() {
|
||||||
var parsedResponse = JP(xmlhttp.responseText);
|
var parsedResponse = JP(xmlhttp.responseText);
|
||||||
cb.apply(null, [parsedResponse]);
|
cb.apply(null, [parsedResponse]);
|
||||||
} else {
|
} else {
|
||||||
cb.apply(null, [new Error('Request Failed')])
|
cb.apply(null, [new Error('Request Failed')]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ angular
|
||||||
} else if (amount > service.marketData.maxLimit) {
|
} else if (amount > service.marketData.maxLimit) {
|
||||||
cb(new Error(gettextCatalog.getString('Amount is above the limit')));
|
cb(new Error(gettextCatalog.getString('Amount is above the limit')));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Init service data
|
// Init service data
|
||||||
service.withdrawalAddress = withdrawalAddress;
|
service.withdrawalAddress = withdrawalAddress;
|
||||||
service.returnAddress = returnAddress;
|
service.returnAddress = returnAddress;
|
||||||
|
|
@ -72,7 +73,7 @@ angular
|
||||||
|
|
||||||
// Check the address
|
// Check the address
|
||||||
shapeshiftApiService
|
shapeshiftApiService
|
||||||
.ValidateAddress(withdrawalAddress, coinOut)
|
.ValidateAddress(returnAddress, coinOut)
|
||||||
.then(function onSuccess(response) {
|
.then(function onSuccess(response) {
|
||||||
if (response && response.isvalid) {
|
if (response && response.isvalid) {
|
||||||
// Prepare the transaction shapeshift side
|
// Prepare the transaction shapeshift side
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
.factory('walletHistoryService', walletHistoryService);
|
.factory('walletHistoryService', walletHistoryService);
|
||||||
|
|
||||||
function walletHistoryService(configService, storageService, lodash, $log, txFormatService) {
|
function walletHistoryService(configService, storageService, lodash, $log, txFormatService) {
|
||||||
//var PAGE_SIZE = 50;
|
var PAGE_SIZE = 50;
|
||||||
var PAGE_SIZE = 20; // For dev only
|
//var PAGE_SIZE = 20; // For dev only
|
||||||
// How much to overlap on each end of the page, for mitigating inconsistent sort order.
|
// How much to overlap on each end of the page, for mitigating inconsistent sort order.
|
||||||
var PAGE_OVERLAP_FRACTION = 0.2;
|
var PAGE_OVERLAP_FRACTION = 0.2;
|
||||||
var PAGE_OVERLAP = Math.floor(PAGE_SIZE * PAGE_OVERLAP_FRACTION);
|
var PAGE_OVERLAP = Math.floor(PAGE_SIZE * PAGE_OVERLAP_FRACTION);
|
||||||
|
|
@ -28,8 +28,8 @@
|
||||||
function addEarlyTransactions(walletId, cachedTxs, newTxs) {
|
function addEarlyTransactions(walletId, cachedTxs, newTxs) {
|
||||||
|
|
||||||
var cachedTxIndexFromId = {};
|
var cachedTxIndexFromId = {};
|
||||||
cachedTxs.forEach(function forCachedTx(tx){
|
cachedTxs.forEach(function forCachedTx(tx, txIndex){
|
||||||
cachedTxIndexFromId[tx.txid] = true;
|
cachedTxIndexFromId[tx.txid] = txIndex;
|
||||||
});
|
});
|
||||||
|
|
||||||
var confirmationsUpdated = false;
|
var confirmationsUpdated = false;
|
||||||
|
|
@ -49,8 +49,9 @@
|
||||||
|
|
||||||
var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP);
|
var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP);
|
||||||
console.log('overlappingTxFraction:', overlappingTxFraction);
|
console.log('overlappingTxFraction:', overlappingTxFraction);
|
||||||
|
console.log('overlappingTxsCount:', overlappingTxsCount);
|
||||||
|
|
||||||
if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good
|
if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION || (someTransactionsWereNew && overlappingTxsCount === 0)) { // We are good
|
||||||
if (someTransactionsWereNew) {
|
if (someTransactionsWereNew) {
|
||||||
saveTxHistory(walletId, cachedTxs);
|
saveTxHistory(walletId, cachedTxs);
|
||||||
} else if (confirmationsUpdated) {
|
} else if (confirmationsUpdated) {
|
||||||
|
|
@ -93,7 +94,7 @@
|
||||||
|
|
||||||
var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP);
|
var overlappingTxFraction = overlappingTxsCount / Math.min(cachedTxs.length, PAGE_OVERLAP);
|
||||||
|
|
||||||
if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION) { // We are good
|
if (overlappingTxFraction >= MIN_KNOWN_TX_OVERLAP_FRACTION || (someTransactionsWereNew && overlappingTxsCount === 0)) { // We are good
|
||||||
if (someTransactionsWereNew) {
|
if (someTransactionsWereNew) {
|
||||||
var allTxs = uniqueNewTxs.concat(cachedTxs);
|
var allTxs = uniqueNewTxs.concat(cachedTxs);
|
||||||
saveTxHistory(walletId, allTxs);
|
saveTxHistory(walletId, allTxs);
|
||||||
|
|
@ -147,7 +148,6 @@
|
||||||
* @param {function(error, txs)} cb - txs is always an array, may be empty
|
* @param {function(error, txs)} cb - txs is always an array, may be empty
|
||||||
*/
|
*/
|
||||||
function getCachedTxHistory(walletId, cb) {
|
function getCachedTxHistory(walletId, cb) {
|
||||||
console.log('txhistory updateLocalTxHistoryByPage()');
|
|
||||||
storageService.getTxHistory(walletId, function onGetTxHistory(err, txHistoryString){
|
storageService.getTxHistory(walletId, function onGetTxHistory(err, txHistoryString){
|
||||||
if (err) {
|
if (err) {
|
||||||
return cb(err, []);
|
return cb(err, []);
|
||||||
|
|
@ -230,7 +230,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) {
|
function updateLocalTxHistoryByPage(wallet, getLatest, flushCacheOnNew, cb) {
|
||||||
console.log('txhistory updaetLocalTxHistoryByPage()');
|
|
||||||
if (flushCacheOnNew) {
|
if (flushCacheOnNew) {
|
||||||
fetchTxHistoryByPage(wallet, 0, function onFetchTxHistory(err, txs){
|
fetchTxHistoryByPage(wallet, 0, function onFetchTxHistory(err, txs){
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue