paypro: support user amount decision on 0-value-server-outputs.
This commit is contained in:
parent
f20836a24c
commit
d87697dfed
3 changed files with 39 additions and 1 deletions
|
|
@ -62,6 +62,13 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
var w = $rootScope.wallet;
|
||||
|
||||
function done(ntxid, merchantData) {
|
||||
if (merchantData && +merchantData.total === 0) {
|
||||
var txp = w.txProposals.txps[ntxid];
|
||||
txp.builder.tx.outs[0].v = bitcore.Bignum(amount + '', 10).toBuffer({
|
||||
endian: 'little',
|
||||
size: 1
|
||||
});
|
||||
}
|
||||
if (w.isShared()) {
|
||||
$scope.loading = false;
|
||||
var message = 'The transaction proposal has been created';
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ angular.module('copayApp.directives')
|
|||
var amount = angular.element(
|
||||
document.querySelector('input#amount'));
|
||||
amount.val(total);
|
||||
amount.attr('disabled', true);
|
||||
if (+merchantData.total !== 0) {
|
||||
amount.attr('disabled', true);
|
||||
}
|
||||
|
||||
var sendto = angular.element(document
|
||||
.querySelector('div.send-note > p[ng-class]:first-of-type'));
|
||||
|
|
|
|||
|
|
@ -1261,6 +1261,31 @@ Wallet.prototype.verifyPaymentRequest = function(ntxid) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Figure out whether the user is supposed
|
||||
// to decide the value of the outputs.
|
||||
var undecided = false;
|
||||
var total = bignum('0', 10);
|
||||
for (var i = 0; i < outputs.length; i++) {
|
||||
var output = outputs[i];
|
||||
var amount = output.get('amount');
|
||||
var v = new Buffer(8);
|
||||
v[0] = (amount.high >> 24) & 0xff;
|
||||
v[1] = (amount.high >> 16) & 0xff;
|
||||
v[2] = (amount.high >> 8) & 0xff;
|
||||
v[3] = (amount.high >> 0) & 0xff;
|
||||
v[4] = (amount.low >> 24) & 0xff;
|
||||
v[5] = (amount.low >> 16) & 0xff;
|
||||
v[6] = (amount.low >> 8) & 0xff;
|
||||
v[7] = (amount.low >> 0) & 0xff;
|
||||
total = total.add(bignum.fromBuffer(v, {
|
||||
endian: 'little',
|
||||
size: 1
|
||||
}));
|
||||
}
|
||||
if (+total.toString(10) === 0) {
|
||||
undecided = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < outputs.length; i++) {
|
||||
var output = outputs[i];
|
||||
|
||||
|
|
@ -1299,6 +1324,10 @@ Wallet.prototype.verifyPaymentRequest = function(ntxid) {
|
|||
// var es = bitcore.Address.fromScriptPubKey(new bitcore.Script(es), network)[0];
|
||||
// var as = bitcore.Address.fromScriptPubKey(new bitcore.Script(tx.outs[i].s), network)[0];
|
||||
|
||||
if (undecided) {
|
||||
av = ev = new Buffer([0]);
|
||||
}
|
||||
|
||||
// Make sure the tx's output script and values match the payment request's.
|
||||
if (av.toString('hex') !== ev.toString('hex')
|
||||
|| as.toString('hex') !== es.toString('hex')) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue