paypro: try to find existing tx proposals.
This commit is contained in:
parent
5105fd4229
commit
62fe6ce628
2 changed files with 26 additions and 2 deletions
|
|
@ -88,8 +88,31 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
var uri = address.indexOf('bitcoin:') === 0
|
||||
&& copay.HDPath.parseBitcoinURI(address);
|
||||
if (uri && uri.merchant) {
|
||||
w.createTx(uri.merchant, commentText, done);
|
||||
if (uri.merchant) {
|
||||
var existing;
|
||||
|
||||
Object.keys(w.txProposals.txps).forEach(function(ntxid, i, obj) {
|
||||
var txp = w.txProposals.txps[ntxid];
|
||||
if (!txp) return;
|
||||
var total = typeof txp.merchant.total !== 'string'
|
||||
? txp.merchant.total.toString(10)
|
||||
: txp.merchant.total;
|
||||
if (txp.merchant.request_url === uri.merchant && total === amount) {
|
||||
existing = txp;
|
||||
obj.length = 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (existing) {
|
||||
var tx = existing.builder.build();
|
||||
if (!tx.isComplete()) {
|
||||
$scope.sign(existing.getID());
|
||||
} else {
|
||||
done(existing.getID(), existing.merchant.pr.ca);
|
||||
}
|
||||
} else {
|
||||
w.createTx(uri.merchant, commentText, done);
|
||||
}
|
||||
} else {
|
||||
w.createTx(address, amount, commentText, done);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -976,6 +976,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
|||
signature: sig,
|
||||
ca: ca,
|
||||
},
|
||||
request_url: options.uri || options.url,
|
||||
total: bignum('0').toString(10)
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue