mirror of https://github.com/BTCPrivate/copay.git
bitcoin: working. paypro todo
This commit is contained in:
parent
2fe6ec4c6a
commit
80e22c59a0
2
TODO
2
TODO
|
@ -1,2 +1,2 @@
|
||||||
- join. on walletComplete!
|
- join. on walletComplete!
|
||||||
|
- paypro fetch-> return TIMEOUT
|
||||||
|
|
|
@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
// Global go. This should be in a better place TODO
|
// Global go. This should be in a better place TODO
|
||||||
// We dont do a 'go' directive, to use the benefits of ng-touch with ng-click
|
// We dont do a 'go' directive, to use the benefits of ng-touch with ng-click
|
||||||
$rootScope.go = function (path) {
|
$rootScope.go = function (path) {
|
||||||
go.go(path);
|
go.path(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _credentials, _firstpin;
|
var _credentials, _firstpin;
|
||||||
|
|
|
@ -30,12 +30,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
$scope.isMobile = isMobile.any();
|
$scope.isMobile = isMobile.any();
|
||||||
|
|
||||||
if ($rootScope.pendingPayment) {
|
if ($rootScope.pendingPayment) {
|
||||||
var value;
|
$scope.setFromUri($rootScope.pendingPayment)
|
||||||
var pp = $rootScope.pendingPayment;
|
|
||||||
var amount = (pp.data && pp.data.amount) ?
|
|
||||||
pp.data.amount * 100000000 * satToUnit : 0;
|
|
||||||
$scope.setForm(pp.address, amount, pp.data.message)
|
|
||||||
_onAddressChange(pp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.setInputs();
|
$scope.setInputs();
|
||||||
|
@ -95,8 +90,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
return this._address;
|
return this._address;
|
||||||
},
|
},
|
||||||
set: function(newValue) {
|
set: function(newValue) {
|
||||||
this._address = newValue;
|
this._address = $scope.onAddressChange(newValue);
|
||||||
_onAddressChange();
|
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
|
@ -343,16 +337,21 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
$scope.setForm = function(to, amount, comment) {
|
$scope.setForm = function(to, amount, comment) {
|
||||||
var form = $scope.sendForm;
|
var form = $scope.sendForm;
|
||||||
form.address.$setViewValue(merchantData.domain);
|
form.address.$setViewValue(to);
|
||||||
form.address.$render();
|
form.address.$render();
|
||||||
form.address.$isValid = true;
|
form.address.$isValid = true;
|
||||||
|
$scope.lockAddress = true;
|
||||||
|
|
||||||
form.amount.$setViewValue(merchantData.unitTotal);
|
if (amount) {
|
||||||
form.amount.$render();
|
form.amount.$setViewValue(amount);
|
||||||
form.amount.$isValid = true;
|
form.amount.$render();
|
||||||
|
form.amount.$isValid = true;
|
||||||
|
$scope.lockAmount = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (comment)
|
if (comment) {
|
||||||
$scope.commentText = comment;
|
form.commentText.$setViewValue(comment);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancelSend = function(error) {
|
$scope.cancelSend = function(error) {
|
||||||
|
@ -388,50 +387,18 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$scope.setFromPayPro = function(uri) {
|
||||||
|
console.log('[send.js.391:uri:]', uri); //TODO
|
||||||
|
|
||||||
var _onAddressChange = function(pp) {
|
$scope.fetchingURL = uri;
|
||||||
var value;
|
|
||||||
value = value || $scope.address || '';
|
|
||||||
var uri;
|
|
||||||
|
|
||||||
$scope.error = $scope.success = null;
|
|
||||||
|
|
||||||
if (value.indexOf('bitcoin:') === 0) {
|
|
||||||
uri = new bitcore.BIP21(value);
|
|
||||||
} else if (/^https?:\/\//.test(value)) {
|
|
||||||
uri = {
|
|
||||||
data: {
|
|
||||||
merchant: value
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!uri || !uri.data.merchant) {
|
|
||||||
if (uri && uri.address) {
|
|
||||||
var amount = (uri.data && uri.data.amount) ? uri.data.amount * 100000000 * satToUnit : 0;
|
|
||||||
var address = uri.address.data;
|
|
||||||
if (amount && address) {
|
|
||||||
$scope.isPayUri = {fixedAmount: true} ;
|
|
||||||
}
|
|
||||||
$timeout(function() {
|
|
||||||
$scope.amount = amount;
|
|
||||||
}, 1000);
|
|
||||||
$scope.commentText = uri.data.message;
|
|
||||||
$scope.address = address;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.fetchingURL = uri.data.merchant;
|
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
|
|
||||||
|
|
||||||
var balance = w.balanceInfo.availableBalance;
|
var balance = w.balanceInfo.availableBalance;
|
||||||
var available = +(balance * unitToSat).toFixed(0);
|
var available = +(balance * unitToSat).toFixed(0);
|
||||||
|
|
||||||
// Payment Protocol URI (BIP-72)
|
// Payment Protocol URI (BIP-72)
|
||||||
$scope.wallet.fetchPaymentRequest({
|
w.fetchPaymentRequest({
|
||||||
url: uri.data.merchant
|
url: uri
|
||||||
}, function(err, merchantData) {
|
}, function(err, merchantData) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.fetchingURL = null;
|
$scope.fetchingURL = null;
|
||||||
|
@ -442,18 +409,53 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
} else {
|
} else {
|
||||||
$scope.cancelSend(err.toString());
|
$scope.cancelSend(err.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (merchantData && available < +merchantData.total) {
|
} else if (merchantData && available < +merchantData.total) {
|
||||||
$scope.cancelSend(err.toString('Insufficient funds'));
|
$scope.cancelSend('Insufficient funds');
|
||||||
} else {
|
} else {
|
||||||
$scope.setForm(merchantData.domain, merchantData.unitTotal)
|
$scope.setForm(merchantData.domain, merchantData.unitTotal)
|
||||||
}
|
}
|
||||||
$timeout(function() {
|
|
||||||
$scope.$digest();
|
|
||||||
}, 1);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.setFromUri = function(uri) {
|
||||||
|
var form = $scope.sendForm;
|
||||||
|
|
||||||
|
var parsed = new bitcore.BIP21(uri);
|
||||||
|
if (!parsed.isValid() || !parsed.address.isValid()) {
|
||||||
|
$scope.error = 'Invalid bitcoin URL';
|
||||||
|
form.address.$isValid = false;
|
||||||
|
return uri;
|
||||||
|
};
|
||||||
|
|
||||||
|
var addr = parsed.address.toString();
|
||||||
|
|
||||||
|
console.log('[send.js.430:parsed:]',addr,parsed.data); //TODO
|
||||||
|
|
||||||
|
if (parsed.data.merchant)
|
||||||
|
return $scope.setFromPayPro(parsed.data.merchant);
|
||||||
|
|
||||||
|
var amount = (parsed.data && parsed.data.amount) ?
|
||||||
|
parsed.data.amount * 100000000 * satToUnit : 0;
|
||||||
|
|
||||||
|
$scope.setForm(addr, amount, parsed.data.message, true);
|
||||||
|
return addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.onAddressChange = function(value) {
|
||||||
|
var addr;
|
||||||
|
console.log('[send.js.391:value:]', value); //TODO
|
||||||
|
|
||||||
|
$scope.error = $scope.success = null;
|
||||||
|
if (!value) return '';
|
||||||
|
|
||||||
|
if (value.indexOf('bitcoin:') === 0) {
|
||||||
|
return $scope.setFromUri(value);
|
||||||
|
} else if (/^https?:\/\//.test(value)) {
|
||||||
|
return $scope.setFromPayPro(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.openAddressBook = function() {
|
$scope.openAddressBook = function() {
|
||||||
var modalInstance = $modal.open({
|
var modalInstance = $modal.open({
|
||||||
templateUrl: 'views/modals/address-book.html',
|
templateUrl: 'views/modals/address-book.html',
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="text" id="address" name="address" ng-disabled="loading || isPayUri"
|
<input type="text" id="address" name="address" ng-disabled="loading || lockAddress"
|
||||||
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" valid-address required>
|
placeholder="{{'Bitcoin address'|translate}}" ng-model="address" valid-address required>
|
||||||
<i class="fi-address-book"></i>
|
<i class="fi-address-book"></i>
|
||||||
<div ng-hide="showScanner || disableScanner">
|
<div ng-hide="showScanner || disableScanner">
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
<div class="small-9 columns">
|
<div class="small-9 columns">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="number" id="amount"
|
<input type="number" id="amount"
|
||||||
ng-disabled="loading || isPayUri.fixedAmount"
|
ng-disabled="loading || lockAmount"
|
||||||
name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount"
|
name="amount" placeholder="{{'Amount'|translate}}" ng-model="amount"
|
||||||
ng-minlength="0.00000001" ng-maxlength="10000000000" valid-amount required
|
ng-minlength="0.00000001" ng-maxlength="10000000000" valid-amount required
|
||||||
autocomplete="off">
|
autocomplete="off">
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
<div class="small-9 columns">
|
<div class="small-9 columns">
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<input type="number" id="alternative"
|
<input type="number" id="alternative"
|
||||||
ng-disabled="loading || !isRateAvailable ||isPayUri"
|
ng-disabled="loading || !isRateAvailable || lockAmount"
|
||||||
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" requiredautocomplete="off">
|
name="alternative" placeholder="{{'Amount'|translate}}" ng-model="alternative" requiredautocomplete="off">
|
||||||
<i class="icon-usd"></i>
|
<i class="icon-usd"></i>
|
||||||
</div>
|
</div>
|
||||||
|
@ -173,10 +173,10 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-6 medium-6 small-6 columns text-left">
|
<div class="large-6 medium-6 small-6 columns text-left">
|
||||||
<a class="button tiny secondary m0" title="Address book" ng-hide="!!$root.merchant || isPayUri" ng-click="openAddressBook()">
|
<a class="button tiny secondary m0" title="Address book" ng-hide="!!$root.merchant || lockAddress" ng-click="openAddressBook()">
|
||||||
<i class="fi-address-book"></i> Address book
|
<i class="fi-address-book"></i> Address book
|
||||||
</a>
|
</a>
|
||||||
<a ng-click="cancelSend(sendForm)" class="button warning m0" ng-show="!!$root.merchant || isPayUri">
|
<a ng-click="cancelSend(sendForm)" class="button warning m0" ng-show="!!$root.merchant || lockAddress">
|
||||||
Cancel
|
Cancel
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue