paypro: prepare for txp refactor. will stay reverted until #1001 is merged.
This commit is contained in:
parent
d87697dfed
commit
3ade672561
3 changed files with 16 additions and 19 deletions
|
|
@ -63,7 +63,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
|
|
||||||
function done(ntxid, merchantData) {
|
function done(ntxid, merchantData) {
|
||||||
if (merchantData && +merchantData.total === 0) {
|
if (merchantData && +merchantData.total === 0) {
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
txp.builder.tx.outs[0].v = bitcore.Bignum(amount + '', 10).toBuffer({
|
txp.builder.tx.outs[0].v = bitcore.Bignum(amount + '', 10).toBuffer({
|
||||||
endian: 'little',
|
endian: 'little',
|
||||||
size: 1
|
size: 1
|
||||||
|
|
|
||||||
|
|
@ -965,7 +965,7 @@ Wallet.prototype.sendPaymentTx = function(ntxid, options, cb) {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
var txp = this.txProposals.txps[ntxid];
|
var txp = this.txProposals.get(ntxid);
|
||||||
if (!txp) return;
|
if (!txp) return;
|
||||||
|
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
|
|
@ -1178,10 +1178,8 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
|
|
||||||
b = b.setHashToScriptMap(pkr.getRedeemScriptMap(inputChainPaths));
|
b = b.setHashToScriptMap(pkr.getRedeemScriptMap(inputChainPaths));
|
||||||
|
|
||||||
if (priv) {
|
var keys = priv.getForPaths(inputChainPaths);
|
||||||
var keys = priv.getForPaths(inputChainPaths);
|
var signed = b.sign(keys);
|
||||||
var signed = b.sign(keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.fetch) return;
|
if (options.fetch) return;
|
||||||
|
|
||||||
|
|
@ -1193,15 +1191,16 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
var myId = this.getMyCopayerId();
|
var myId = this.getMyCopayerId();
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
var me = {};
|
|
||||||
|
|
||||||
var tx = b.build();
|
var tx = b.build();
|
||||||
if (priv && tx.countInputSignatures(0)) me[myId] = now;
|
if (!tx.countInputSignatures(0))
|
||||||
|
throw new Error('Could not sign generated tx');
|
||||||
|
|
||||||
|
var me = {};
|
||||||
|
me[myId] = now;
|
||||||
var meSeen = {};
|
var meSeen = {};
|
||||||
if (priv) meSeen[myId] = now;
|
if (priv) meSeen[myId] = now;
|
||||||
|
|
||||||
var data = {
|
var ntxid = this.txProposals.add(new TxProposal({
|
||||||
inputChainPaths: inputChainPaths,
|
inputChainPaths: inputChainPaths,
|
||||||
signedBy: me,
|
signedBy: me,
|
||||||
seenBy: meSeen,
|
seenBy: meSeen,
|
||||||
|
|
@ -1210,9 +1209,7 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent)
|
||||||
builder: b,
|
builder: b,
|
||||||
comment: options.memo,
|
comment: options.memo,
|
||||||
merchant: merchantData
|
merchant: merchantData
|
||||||
};
|
}));
|
||||||
|
|
||||||
var ntxid = this.txProposals.add(data);
|
|
||||||
return ntxid;
|
return ntxid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1224,7 +1221,7 @@ Wallet.prototype.verifyPaymentRequest = function(ntxid) {
|
||||||
if (!ntxid) return false;
|
if (!ntxid) return false;
|
||||||
|
|
||||||
var txp = typeof ntxid !== 'object'
|
var txp = typeof ntxid !== 'object'
|
||||||
? this.txProposals.txps[ntxid]
|
? this.txProposals.get(ntxid)
|
||||||
: ntxid;
|
: ntxid;
|
||||||
|
|
||||||
// If we're not a payment protocol proposal, ignore.
|
// If we're not a payment protocol proposal, ignore.
|
||||||
|
|
|
||||||
|
|
@ -782,7 +782,7 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
merchantData.raw = pr.serialize().toString('hex');
|
merchantData.raw = pr.serialize().toString('hex');
|
||||||
|
|
||||||
var myId = w.getMyCopayerId();
|
var myId = w.getMyCopayerId();
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
should.exist(txp);
|
should.exist(txp);
|
||||||
should.exist(txp.signedBy[myId]);
|
should.exist(txp.signedBy[myId]);
|
||||||
should.not.exist(txp.rejectedBy[myId]);
|
should.not.exist(txp.rejectedBy[myId]);
|
||||||
|
|
@ -809,7 +809,7 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
amount.low = 2;
|
amount.low = 2;
|
||||||
|
|
||||||
var myId = w.getMyCopayerId();
|
var myId = w.getMyCopayerId();
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
should.exist(txp);
|
should.exist(txp);
|
||||||
should.exist(txp.signedBy[myId]);
|
should.exist(txp.signedBy[myId]);
|
||||||
should.not.exist(txp.rejectedBy[myId]);
|
should.not.exist(txp.rejectedBy[myId]);
|
||||||
|
|
@ -830,12 +830,12 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
should.exist(merchantData);
|
should.exist(merchantData);
|
||||||
|
|
||||||
// Tamper with payment request in its abstract form:
|
// Tamper with payment request in its abstract form:
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
var tx = txp.builder.tx || txp.builder.build();
|
var tx = txp.builder.tx || txp.builder.build();
|
||||||
tx.outs[0].v = new Buffer([2, 0, 0, 0, 0, 0, 0, 0]);
|
tx.outs[0].v = new Buffer([2, 0, 0, 0, 0, 0, 0, 0]);
|
||||||
|
|
||||||
var myId = w.getMyCopayerId();
|
var myId = w.getMyCopayerId();
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
should.exist(txp);
|
should.exist(txp);
|
||||||
should.exist(txp.signedBy[myId]);
|
should.exist(txp.signedBy[myId]);
|
||||||
should.not.exist(txp.rejectedBy[myId]);
|
should.not.exist(txp.rejectedBy[myId]);
|
||||||
|
|
@ -856,7 +856,7 @@ describe('PayPro (in Wallet) model', function() {
|
||||||
should.exist(merchantData);
|
should.exist(merchantData);
|
||||||
|
|
||||||
var myId = w.getMyCopayerId();
|
var myId = w.getMyCopayerId();
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.get(ntxid);
|
||||||
should.exist(txp);
|
should.exist(txp);
|
||||||
should.exist(txp.signedBy[myId]);
|
should.exist(txp.signedBy[myId]);
|
||||||
should.not.exist(txp.rejectedBy[myId]);
|
should.not.exist(txp.rejectedBy[myId]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue