paypro: more merchant data storage. createTx and sendTx work.
This commit is contained in:
parent
d7ec908701
commit
b0dc3fc24d
2 changed files with 40 additions and 8 deletions
|
|
@ -61,10 +61,14 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
w.createTx(address, amount, commentText, function(ntxid) {
|
function done(ntxid, ca) {
|
||||||
if (w.isShared()) {
|
if (w.isShared()) {
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
var message = 'The transaction proposal has been created';
|
var message = 'The transaction proposal has been created';
|
||||||
|
if (ca) {
|
||||||
|
message += '.\nThis payment protocol transaction
|
||||||
|
+ 'has been verified through ' + ca;
|
||||||
|
}
|
||||||
notification.success('Success!', message);
|
notification.success('Success!', message);
|
||||||
$scope.loadTxs();
|
$scope.loadTxs();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -80,7 +84,13 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$rootScope.pendingPayment = null;
|
$rootScope.pendingPayment = null;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (~address.indexOf('://')) {
|
||||||
|
w.createTx(address, commentText, done);
|
||||||
|
} else {
|
||||||
|
w.createTx(address, amount, commentText, done);
|
||||||
|
}
|
||||||
|
|
||||||
// reset fields
|
// reset fields
|
||||||
$scope.address = $scope.amount = $scope.commentText = null;
|
$scope.address = $scope.amount = $scope.commentText = null;
|
||||||
|
|
|
||||||
|
|
@ -815,7 +815,10 @@ Wallet.prototype.receivePaymentRequest = function(tx, options, pr, cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!trusted.length) {
|
if (!trusted.length) {
|
||||||
return cb(new Error('Not a trusted certificate.'));
|
var G = typeof window !== 'undefined' ? window : global;
|
||||||
|
if (!G.SSL_UNTRUSTED) {
|
||||||
|
return cb(new Error('Not a trusted certificate.'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify Signature
|
// Verify Signature
|
||||||
|
|
@ -849,7 +852,11 @@ Wallet.prototype.receivePaymentRequest = function(tx, options, pr, cb) {
|
||||||
outputs: outputs.map(function(output) {
|
outputs: outputs.map(function(output) {
|
||||||
return {
|
return {
|
||||||
amount: output.get('amount'),
|
amount: output.get('amount'),
|
||||||
script: output.get('script').toString('hex')
|
script: {
|
||||||
|
offset: output.get('script').offset,
|
||||||
|
limit: output.get('script').limit,
|
||||||
|
buffer: output.get('script').buffer.toString('hex')
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
time: time,
|
time: time,
|
||||||
|
|
@ -877,7 +884,7 @@ Wallet.prototype.receivePaymentRequest = function(tx, options, pr, cb) {
|
||||||
self.log('The server sent you a message:');
|
self.log('The server sent you a message:');
|
||||||
self.log(memo);
|
self.log(memo);
|
||||||
|
|
||||||
return cb(ntxid);
|
return cb(ntxid, ca);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1021,8 +1028,14 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
}
|
}
|
||||||
|
|
||||||
merchantData.pr.pd.outputs.forEach(function(output, i) {
|
merchantData.pr.pd.outputs.forEach(function(output, i) {
|
||||||
var amount = output.get ? output.get('amount') : output.amount;
|
var amount = output.get
|
||||||
var script = output.get ? output.get('script') : new Buffer(output.script, 'hex');
|
? output.get('amount')
|
||||||
|
: output.amount;
|
||||||
|
|
||||||
|
var script = output.get
|
||||||
|
? output.get('script')
|
||||||
|
: new Buffer(output.script, 'hex');
|
||||||
|
|
||||||
var v = new Buffer(8);
|
var v = new Buffer(8);
|
||||||
v[0] = (amount.low >> 0) & 0xff;
|
v[0] = (amount.low >> 0) & 0xff;
|
||||||
v[1] = (amount.low >> 8) & 0xff;
|
v[1] = (amount.low >> 8) & 0xff;
|
||||||
|
|
@ -1032,7 +1045,9 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
v[5] = (amount.high >> 8) & 0xff;
|
v[5] = (amount.high >> 8) & 0xff;
|
||||||
v[6] = (amount.high >> 16) & 0xff;
|
v[6] = (amount.high >> 16) & 0xff;
|
||||||
v[7] = (amount.high >> 24) & 0xff;
|
v[7] = (amount.high >> 24) & 0xff;
|
||||||
|
|
||||||
var s = script.buffer.slice(script.offset, script.limit);
|
var s = script.buffer.slice(script.offset, script.limit);
|
||||||
|
|
||||||
b.tx.outs[i].v = v;
|
b.tx.outs[i].v = v;
|
||||||
b.tx.outs[i].s = s;
|
b.tx.outs[i].s = s;
|
||||||
});
|
});
|
||||||
|
|
@ -1176,12 +1191,19 @@ Wallet.prototype.getUnspent = function(cb) {
|
||||||
Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb) {
|
Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
if (typeof comment === 'undefined') {
|
if (typeof amountSatStr === 'function') {
|
||||||
var cb = amountSatStr;
|
var cb = amountSatStr;
|
||||||
var merchant = toAddress;
|
var merchant = toAddress;
|
||||||
return this.createPaymentTx({ uri: merchant }, cb);
|
return this.createPaymentTx({ uri: merchant }, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof comment === 'function') {
|
||||||
|
var cb = comment;
|
||||||
|
var merchant = toAddress;
|
||||||
|
var comment = amountSatStr;
|
||||||
|
return this.createPaymentTx({ uri: merchant, memo: comment }, cb);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof opts === 'function') {
|
if (typeof opts === 'function') {
|
||||||
cb = opts;
|
cb = opts;
|
||||||
opts = {};
|
opts = {};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue