paypro: cleanup a lot of old code and comments. minor fixes.
This commit is contained in:
parent
d9c72392bd
commit
3b550d853f
3 changed files with 9 additions and 35 deletions
|
|
@ -75,7 +75,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
+ ' has been verified through ' + ca + '.';
|
+ ' has been verified through ' + ca + '.';
|
||||||
}
|
}
|
||||||
if (merchantData) {
|
if (merchantData) {
|
||||||
message += '\nFor merchant: ' + merchantData.pr.payment_url;
|
message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
|
||||||
}
|
}
|
||||||
notification.success('Success!', message);
|
notification.success('Success!', message);
|
||||||
$scope.loadTxs();
|
$scope.loadTxs();
|
||||||
|
|
@ -93,7 +93,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
+ ' has been verified through ' + ca + '.';
|
+ ' has been verified through ' + ca + '.';
|
||||||
}
|
}
|
||||||
if (merchantData) {
|
if (merchantData) {
|
||||||
message += '\nFor merchant: ' + merchantData.pr.payment_url;
|
message += '\nFor merchant: ' + merchantData.pr.pd.payment_url;
|
||||||
}
|
}
|
||||||
notification.success('Transaction broadcast', message);
|
notification.success('Transaction broadcast', message);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@ angular.module('copayApp.directives')
|
||||||
var validator = function(value) {
|
var validator = function(value) {
|
||||||
var uri = copay.HDPath.parseBitcoinURI(value);
|
var uri = copay.HDPath.parseBitcoinURI(value);
|
||||||
|
|
||||||
window._rootScope = scope;
|
|
||||||
|
|
||||||
// Is this a payment protocol URI (BIP-72)?
|
// Is this a payment protocol URI (BIP-72)?
|
||||||
if (uri && uri.merchant) {
|
if (uri && uri.merchant) {
|
||||||
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
||||||
|
|
@ -46,9 +44,6 @@ angular.module('copayApp.directives')
|
||||||
// XXX There needs to be a better way to do this:
|
// XXX There needs to be a better way to do this:
|
||||||
total = +total / config.unitToSatoshi;
|
total = +total / config.unitToSatoshi;
|
||||||
|
|
||||||
var sendForm = angular.element(
|
|
||||||
document.getElementsByName('sendForm')[0]);
|
|
||||||
|
|
||||||
var address = angular.element(
|
var address = angular.element(
|
||||||
document.querySelector('input#address'));
|
document.querySelector('input#address'));
|
||||||
|
|
||||||
|
|
@ -81,12 +76,10 @@ angular.module('copayApp.directives')
|
||||||
sendall.attr('class', sendall.attr('class') + ' hidden');
|
sendall.attr('class', sendall.attr('class') + ' hidden');
|
||||||
|
|
||||||
// Reset all the changes from the payment protocol weirdness.
|
// Reset all the changes from the payment protocol weirdness.
|
||||||
// XXX use ng-change attr instead
|
|
||||||
//address.attr('ng-change', 'ppChange()');
|
//address.attr('ng-change', 'ppChange()');
|
||||||
//scope.ppChange = scope.ppChange || function() {
|
//scope.ppChange = scope.ppChange || function() {
|
||||||
//address.on('change', function(ev) {
|
//address.on('change', function(ev) {
|
||||||
scope.$on('change', function(ev) {
|
scope.$watch('address', function(newValue, oldValue) {
|
||||||
//scope.$watch('address', function(newValue, oldValue) {
|
|
||||||
var val = address.val();
|
var val = address.val();
|
||||||
var uri = copay.HDPath.parseBitcoinURI(val || '');
|
var uri = copay.HDPath.parseBitcoinURI(val || '');
|
||||||
if (!uri || !uri.merchant) {
|
if (!uri || !uri.merchant) {
|
||||||
|
|
@ -111,7 +104,6 @@ angular.module('copayApp.directives')
|
||||||
// TODO: Check paymentRequest expiration,
|
// TODO: Check paymentRequest expiration,
|
||||||
// delete if beyond expiration date.
|
// delete if beyond expiration date.
|
||||||
//};
|
//};
|
||||||
//});
|
|
||||||
});
|
});
|
||||||
//scope.$apply(); // scope.$digest();
|
//scope.$apply(); // scope.$digest();
|
||||||
|
|
||||||
|
|
@ -120,9 +112,11 @@ angular.module('copayApp.directives')
|
||||||
scope.sendForm.$valid = true;
|
scope.sendForm.$valid = true;
|
||||||
scope.sendForm.$invalid = false;
|
scope.sendForm.$invalid = false;
|
||||||
scope.sendForm.$pristine = true;
|
scope.sendForm.$pristine = true;
|
||||||
|
|
||||||
scope.sendForm.address.$valid = true;
|
scope.sendForm.address.$valid = true;
|
||||||
scope.sendForm.address.$invalid = false;
|
scope.sendForm.address.$invalid = false;
|
||||||
scope.sendForm.address.$pristine = true;
|
scope.sendForm.address.$pristine = true;
|
||||||
|
|
||||||
scope.sendForm.amount.$valid = true;
|
scope.sendForm.amount.$valid = true;
|
||||||
scope.sendForm.amount.$invalid = false;
|
scope.sendForm.amount.$invalid = false;
|
||||||
scope.sendForm.amount.$pristine = true;
|
scope.sendForm.amount.$pristine = true;
|
||||||
|
|
|
||||||
|
|
@ -803,7 +803,7 @@ Wallet.prototype.createPaymentTx = function(options, cb) {
|
||||||
'Accept': PayPro.PAYMENT_REQUEST_CONTENT_TYPE
|
'Accept': PayPro.PAYMENT_REQUEST_CONTENT_TYPE
|
||||||
+ ', ' + PayPro.PAYMENT_ACK_CONTENT_TYPE,
|
+ ', ' + PayPro.PAYMENT_ACK_CONTENT_TYPE,
|
||||||
'Content-Type': 'application/octet-stream'
|
'Content-Type': 'application/octet-stream'
|
||||||
// XHR does not allow these:
|
// XHR does not allow this:
|
||||||
// 'Content-Length': 0
|
// 'Content-Length': 0
|
||||||
},
|
},
|
||||||
responseType: 'arraybuffer'
|
responseType: 'arraybuffer'
|
||||||
|
|
@ -856,7 +856,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
||||||
var certs = PayPro.X509Certificates.decode(pki_data);
|
var certs = PayPro.X509Certificates.decode(pki_data);
|
||||||
certs = certs.certificate;
|
certs = certs.certificate;
|
||||||
|
|
||||||
// XXX Temporary fix for tests
|
// Fix for older versions of bitcore
|
||||||
if (!PayPro.RootCerts) {
|
if (!PayPro.RootCerts) {
|
||||||
PayPro.RootCerts = {
|
PayPro.RootCerts = {
|
||||||
getTrusted: function() {}
|
getTrusted: function() {}
|
||||||
|
|
@ -869,10 +869,6 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
||||||
return PayPro.RootCerts.getTrusted(pem);
|
return PayPro.RootCerts.getTrusted(pem);
|
||||||
}).filter(Boolean);
|
}).filter(Boolean);
|
||||||
|
|
||||||
// if (!trusted.length) {
|
|
||||||
// return cb(new Error('Not a trusted certificate.'));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Verify Signature
|
// Verify Signature
|
||||||
var verified = pr.verify();
|
var verified = pr.verify();
|
||||||
|
|
||||||
|
|
@ -1018,21 +1014,9 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
|
|
||||||
pay = pay.serialize();
|
pay = pay.serialize();
|
||||||
|
|
||||||
this.log(pay);
|
this.log('Sending Payment Message:');
|
||||||
this.log(pay.toString('hex'));
|
this.log(pay.toString('hex'));
|
||||||
|
|
||||||
// https://www.google.com/search?q=angular+%24http+ArrayBuffer+in+body
|
|
||||||
// https://github.com/feross/buffer/blob/master/index.js
|
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays
|
|
||||||
|
|
||||||
// var view = new Uint8Array(new ArrayBuffer(pay.length));
|
|
||||||
// Buffer._augment(view);
|
|
||||||
// pay = pay.copy(view);
|
|
||||||
|
|
||||||
// var view = new Uint8Array(new ArrayBuffer(pay.length));
|
|
||||||
// view.set(Array.prototype.slice.call(pay), 0);
|
|
||||||
// pay = view;
|
|
||||||
|
|
||||||
var buf = new ArrayBuffer(pay.length);
|
var buf = new ArrayBuffer(pay.length);
|
||||||
var view = new Uint8Array(buf);
|
var view = new Uint8Array(buf);
|
||||||
for (var i = 0; i < pay.length; i++) {
|
for (var i = 0; i < pay.length; i++) {
|
||||||
|
|
@ -1051,11 +1035,7 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
// 'Content-Length': (pay.byteLength || pay.length) + '',
|
// 'Content-Length': (pay.byteLength || pay.length) + '',
|
||||||
// 'Content-Transfer-Encoding': 'binary'
|
// 'Content-Transfer-Encoding': 'binary'
|
||||||
},
|
},
|
||||||
// data: pay,
|
data: buf, // Technically how this should be done via XHR.
|
||||||
// data: pay,
|
|
||||||
// data: view,
|
|
||||||
data: buf, // Technically how this should be done.
|
|
||||||
// requestType: 'arraybuffer',
|
|
||||||
responseType: 'arraybuffer'
|
responseType: 'arraybuffer'
|
||||||
})
|
})
|
||||||
.success(function(data, status, headers, config) {
|
.success(function(data, status, headers, config) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue