mirror of https://github.com/BTCPrivate/copay.git
commit
1519ed73c5
|
@ -255,7 +255,9 @@ TxProposal.prototype.setSent = function(sentTxid) {
|
|||
this.sentTs = Date.now();
|
||||
};
|
||||
|
||||
|
||||
TxProposal.prototype.getSent = function() {
|
||||
return this.sentTs;
|
||||
}
|
||||
|
||||
TxProposal.prototype._allSignatures = function() {
|
||||
var ret = {};
|
||||
|
|
|
@ -405,9 +405,11 @@ Wallet.prototype._onTxProposal = function(senderId, data) {
|
|||
if (tx.isComplete()) {
|
||||
this._checkSentTx(m.ntxid, function(ret) {
|
||||
if (ret) {
|
||||
m.txp.setSent(m.ntxid);
|
||||
self.emit('txProposalsUpdated');
|
||||
self.store();
|
||||
if (!m.txp.getSent()) {
|
||||
m.txp.setSent(m.ntxid);
|
||||
self.emit('txProposalsUpdated');
|
||||
self.store();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -100,17 +100,17 @@ angular.module('copayApp.services')
|
|||
$rootScope.$digest();
|
||||
});
|
||||
|
||||
w.on('txProposalsUpdated', function(dontDigest) {
|
||||
var updateTxsAndBalance = _.debounce(function() {
|
||||
root.updateTxs();
|
||||
// give sometime to the tx to propagate.
|
||||
$timeout(function() {
|
||||
root.updateBalance(function() {
|
||||
if (!dontDigest) {
|
||||
$rootScope.$digest();
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
root.updateBalance(function() {
|
||||
$rootScope.$digest();
|
||||
})
|
||||
}, 3000);
|
||||
|
||||
w.on('txProposalsUpdated', function(dontDigest) {
|
||||
updateTxsAndBalance();
|
||||
});
|
||||
|
||||
w.on('txProposalEvent', function(e) {
|
||||
|
||||
var user = w.publicKeyRing.nicknameForCopayer(e.cId);
|
||||
|
|
|
@ -112,7 +112,11 @@ describe('TxProposal', function() {
|
|||
});
|
||||
it('sets force opts', function() {
|
||||
var b = new FakeBuilder();
|
||||
b.opts={juan:1, pepe:1, fee:1000};
|
||||
b.opts = {
|
||||
juan: 1,
|
||||
pepe: 1,
|
||||
fee: 1000
|
||||
};
|
||||
var txp;
|
||||
var o = {
|
||||
creator: 1,
|
||||
|
@ -121,9 +125,16 @@ describe('TxProposal', function() {
|
|||
inputChainPaths: ['m/1'],
|
||||
};
|
||||
(function() {
|
||||
txp = TxProposal.fromObj(o,{pepe:100});
|
||||
txp = TxProposal.fromObj(o, {
|
||||
pepe: 100
|
||||
});
|
||||
}).should.throw('Invalid tx proposal: no ins');
|
||||
o.builderObj.opts.should.deep.equal({juan:1, pepe:100, feeSat:undefined, fee:undefined});
|
||||
o.builderObj.opts.should.deep.equal({
|
||||
juan: 1,
|
||||
pepe: 100,
|
||||
feeSat: undefined,
|
||||
fee: undefined
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -131,13 +142,36 @@ describe('TxProposal', function() {
|
|||
describe('#setSent', function() {
|
||||
it('should set txid and timestamp', function() {
|
||||
var now = Date.now();
|
||||
var txp = dummyProposal;
|
||||
var txp = new TxProposal({
|
||||
creator: 1,
|
||||
createdTs: 1,
|
||||
builder: new FakeBuilder(),
|
||||
inputChainPaths: ['m/1'],
|
||||
});
|
||||
txp.setSent('3a42');
|
||||
txp.sentTs.should.gte(now);
|
||||
txp.sentTxid.should.equal('3a42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSent', function() {
|
||||
it('should get sent timestamp', function() {
|
||||
var now = Date.now();
|
||||
var txp = new TxProposal({
|
||||
creator: 1,
|
||||
createdTs: 1,
|
||||
builder: new FakeBuilder(),
|
||||
inputChainPaths: ['m/1'],
|
||||
});
|
||||
|
||||
var sentTs = txp.getSent();
|
||||
should.not.exist(sentTs);
|
||||
|
||||
txp.setSent('3a42');
|
||||
sentTs = txp.getSent();
|
||||
sentTs.should.gte(now);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Signature verification', function() {
|
||||
var validScriptSig = new bitcore.Script(FakeBuilder.VALID_SCRIPTSIG_BUF);
|
||||
|
|
|
@ -1564,6 +1564,7 @@ describe('Wallet model', function() {
|
|||
var txp = {
|
||||
getSeen: sinon.stub().returns(true),
|
||||
setCopayers: sinon.stub().returns(['new copayer']),
|
||||
getSent: sinon.stub().returns(false),
|
||||
setSent: sinon.spy(),
|
||||
builder: {
|
||||
build: sinon.stub().returns({
|
||||
|
@ -1595,6 +1596,7 @@ describe('Wallet model', function() {
|
|||
var txp = {
|
||||
getSeen: sinon.stub().returns(true),
|
||||
setCopayers: sinon.stub().returns(['new copayer']),
|
||||
getSent: sinon.stub().returns(false),
|
||||
setSent: sinon.spy(),
|
||||
builder: {
|
||||
build: sinon.stub().returns({
|
||||
|
@ -1618,6 +1620,38 @@ describe('Wallet model', function() {
|
|||
done();
|
||||
});
|
||||
|
||||
it('should not overwrite sent info', function(done) {
|
||||
var data = {
|
||||
txProposal: {
|
||||
dummy: 1,
|
||||
},
|
||||
};
|
||||
var txp = {
|
||||
getSeen: sinon.stub().returns(true),
|
||||
setCopayers: sinon.stub().returns(['new copayer']),
|
||||
getSent: sinon.stub().returns(true),
|
||||
setSent: sinon.spy(),
|
||||
builder: {
|
||||
build: sinon.stub().returns({
|
||||
isComplete: sinon.stub().returns(true),
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
w.txProposals.merge = sinon.stub().returns({
|
||||
ntxid: 1,
|
||||
txp: txp,
|
||||
new: false,
|
||||
hasChanged: false,
|
||||
});
|
||||
w._checkSentTx = sinon.stub().yields(true);
|
||||
|
||||
w._onTxProposal('senderID', data);
|
||||
txp.setSent.called.should.be.false;
|
||||
w.sendTxProposal.called.should.be.false;
|
||||
done();
|
||||
});
|
||||
|
||||
it('should resend when not complete only if changed', function(done) {
|
||||
var data = {
|
||||
txProposal: {
|
||||
|
|
Loading…
Reference in New Issue