|
|
@ -137,7 +137,7 @@ helpers.toSatoshi = function(btc) { |
|
|
|
helpers.stubUtxos = function(server, wallet, amounts, cb) { |
|
|
|
var amounts = [].concat(amounts); |
|
|
|
|
|
|
|
async.map(_.range(1, Math.ceil(amounts.length / 2) + 1), function(i, next) { |
|
|
|
async.mapSeries(_.range(1, Math.ceil(amounts.length / 2) + 1), function(i, next) { |
|
|
|
server.createAddress({}, function(err, address) { |
|
|
|
next(err, address); |
|
|
|
}); |
|
|
@ -184,7 +184,7 @@ helpers.stubAddressActivity = function(activeAddresses) { |
|
|
|
|
|
|
|
helpers.clientSign = WalletUtils.signTxp; |
|
|
|
|
|
|
|
helpers.createProposalOpts = function(toAddress, amount, message, signingKey, feePerKb) { |
|
|
|
helpers.createProposalOptsLegacy = function(toAddress, amount, message, signingKey, feePerKb) { |
|
|
|
var opts = { |
|
|
|
toAddress: toAddress, |
|
|
|
amount: helpers.toSatoshi(amount), |
|
|
@ -193,7 +193,8 @@ helpers.createProposalOpts = function(toAddress, amount, message, signingKey, fe |
|
|
|
}; |
|
|
|
if (feePerKb) opts.feePerKb = feePerKb; |
|
|
|
|
|
|
|
var hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount, opts.message); |
|
|
|
var hash = WalletUtils.getProposalHash(toAddress, opts.amount, message); |
|
|
|
|
|
|
|
try { |
|
|
|
opts.proposalSignature = WalletUtils.signMessage(hash, signingKey); |
|
|
|
} catch (ex) {} |
|
|
@ -201,27 +202,41 @@ helpers.createProposalOpts = function(toAddress, amount, message, signingKey, fe |
|
|
|
return opts; |
|
|
|
}; |
|
|
|
|
|
|
|
helpers.createProposalOptsByType = function(type, outputs, message, signingKey, feePerKb) { |
|
|
|
helpers.createSimpleProposalOpts = function(toAddress, amount, message, signingKey, feePerKb) { |
|
|
|
var outputs = [{ |
|
|
|
toAddress: toAddress, |
|
|
|
amount: amount, |
|
|
|
}]; |
|
|
|
return helpers.createProposalOpts(Model.TxProposal.Types.SIMPLE, outputs, message, signingKey, feePerKb); |
|
|
|
}; |
|
|
|
|
|
|
|
helpers.createProposalOpts = function(type, outputs, message, signingKey, feePerKb) { |
|
|
|
_.each(outputs, function(output) { |
|
|
|
output.amount = helpers.toSatoshi(output.amount); |
|
|
|
}); |
|
|
|
var opts = { |
|
|
|
type: type, |
|
|
|
message: message, |
|
|
|
proposalSignature: null, |
|
|
|
}; |
|
|
|
if (type == Model.TxProposal.Types.MULTIPLEOUTPUTS) { |
|
|
|
opts.outputs = []; |
|
|
|
_.each(outputs, function(o) { |
|
|
|
opts.outputs.push(o); |
|
|
|
o.amount = helpers.toSatoshi(o.amount); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
opts.toAddress = outputs[0].toAddress; |
|
|
|
opts.amount = helpers.toSatoshi(outputs[0].amount); |
|
|
|
} |
|
|
|
if (feePerKb) opts.feePerKb = feePerKb; |
|
|
|
|
|
|
|
var txp = Model.TxProposal.create(opts); |
|
|
|
var proposalHeader = txp.getHeader(); |
|
|
|
var hash = WalletUtils.getProposalHash.apply(WalletUtils, proposalHeader); |
|
|
|
switch (type) { |
|
|
|
case Model.TxProposal.Types.SIMPLE: |
|
|
|
opts.toAddress = outputs[0].toAddress; |
|
|
|
opts.amount = outputs[0].amount; |
|
|
|
break; |
|
|
|
case Model.TxProposal.Types.MULTIPLEOUTPUTS: |
|
|
|
opts.outputs = outputs; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
var header = { |
|
|
|
outputs: outputs, |
|
|
|
message: opts.message, |
|
|
|
payProUrl: opts.payProUrl |
|
|
|
}; |
|
|
|
var hash = WalletUtils.getProposalHash(header); |
|
|
|
|
|
|
|
try { |
|
|
|
opts.proposalSignature = WalletUtils.signMessage(hash, signingKey); |
|
|
@ -335,7 +350,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should notify copayers a new tx proposal has been created', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1, 1], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
setTimeout(function() { |
|
|
@ -362,7 +377,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should notify copayers a new outgoing tx has been created', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1, 1], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
|
|
|
|
var txpId; |
|
|
|
async.waterfall([ |
|
|
@ -415,7 +430,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should notify copayers a tx has been finally rejected', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, 1, function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
|
|
|
|
var txpId; |
|
|
|
async.waterfall([ |
|
|
@ -541,7 +556,7 @@ describe('Wallet service', function() { |
|
|
|
}, |
|
|
|
}, function(err) { |
|
|
|
helpers.stubUtxos(server, wallet, 1, function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.8, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
setTimeout(function() { |
|
|
@ -1275,7 +1290,7 @@ describe('Wallet service', function() { |
|
|
|
server.joinWallet(copayerOpts, function(err, result) { |
|
|
|
should.not.exist(err); |
|
|
|
helpers.getAuthServer(result.copayerId, function(server, wallet) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[0].privKey); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[0].privKey); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
|
should.exist(err); |
|
|
@ -1300,7 +1315,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should create a tx', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1335,9 +1350,20 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should create a tx with legacy signature', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOptsLegacy('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should create a tx using the uxtos with minimum amount first', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200, 300], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 150, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 150, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1359,7 +1385,7 @@ describe('Wallet service', function() { |
|
|
|
blockchainExplorer.getUnspentUtxos = sinon.stub().callsArgWith(1, 'dummy error'); |
|
|
|
server.createAddress({}, function(err, address) { |
|
|
|
should.not.exist(err); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('BLOCKCHAINERROR'); |
|
|
@ -1370,7 +1396,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx with invalid proposal signature', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, 'dummy'); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, 'dummy'); |
|
|
|
|
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
@ -1383,7 +1409,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx with proposal signed by another copayer', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[1].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[1].privKey_1H_0); |
|
|
|
|
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
@ -1396,11 +1422,11 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx for invalid address', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('invalid address', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('invalid address', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
|
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
|
should.exist(err); |
|
|
|
should.not.exist(tx); |
|
|
|
// may fail due to Non-base58 character, or Checksum mismatch, or other
|
|
|
|
done(); |
|
|
|
}); |
|
|
@ -1409,7 +1435,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx for address of different network', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('myE38JHdxmQcTJGP1ZiX4BiGhDxMJDvLJD', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('myE38JHdxmQcTJGP1ZiX4BiGhDxMJDvLJD', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
|
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
@ -1422,7 +1448,7 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
|
|
|
|
it('should fail to create tx for invalid amount', function(done) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(tx); |
|
|
|
should.exist(err); |
|
|
@ -1433,7 +1459,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx when insufficient funds', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 120, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 120, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
@ -1454,7 +1480,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx when insufficient funds for fee', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, 0.048222, function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.048200, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.048200, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
@ -1466,7 +1492,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should scale fees according to tx size', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1, 1, 1, 1], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 3.5, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 3.5, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
tx.getBitcoreTx()._estimateSize().should.be.within(1001, 1999); |
|
|
@ -1478,11 +1504,11 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should be possible to use a smaller fee', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, 1, function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('INSUFFICIENTFUNDS'); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.99995, null, TestData.copayers[0].privKey_1H_0, 5000); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
tx.fee.should.equal(5000); |
|
|
@ -1502,7 +1528,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx for dust amount', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [1], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.00000001, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.00000001, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('DUSTAMOUNT'); |
|
|
@ -1518,7 +1544,7 @@ describe('Wallet service', function() { |
|
|
|
var change = 0.00000001; |
|
|
|
var amount = 1 - fee - change; |
|
|
|
|
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('DUSTAMOUNT'); |
|
|
@ -1530,14 +1556,14 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail with different error for insufficient funds and locked funds', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [10, 10], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 11, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 11, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
server.getBalance({}, function(err, balance) { |
|
|
|
should.not.exist(err); |
|
|
|
balance.totalAmount.should.equal(helpers.toSatoshi(20)); |
|
|
|
balance.lockedAmount.should.equal(helpers.toSatoshi(20)); |
|
|
|
txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('LOCKEDFUNDS'); |
|
|
@ -1554,7 +1580,7 @@ describe('Wallet service', function() { |
|
|
|
var fee = Bitcore.Transaction.FEE_PER_KB / 1e8; |
|
|
|
var amount = 1 - fee; |
|
|
|
|
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1573,7 +1599,7 @@ describe('Wallet service', function() { |
|
|
|
name: 'dummy', |
|
|
|
message: 'dummy exception' |
|
|
|
}); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 2, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 2, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.message.should.equal('dummy exception'); |
|
|
@ -1585,11 +1611,11 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should create tx when there is a pending tx and enough UTXOs', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [10.1, 10.2, 10.3], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 12, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 12, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
|
var txOpts2 = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts2 = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts2, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1610,11 +1636,11 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx when there is a pending tx and not enough UTXOs', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [10.1, 10.2, 10.3], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 12, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 12, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
|
var txOpts2 = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 24, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts2 = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 24, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts2, function(err, tx) { |
|
|
|
err.code.should.equal('LOCKEDFUNDS'); |
|
|
|
should.not.exist(tx); |
|
|
@ -1640,7 +1666,7 @@ describe('Wallet service', function() { |
|
|
|
should.not.exist(err); |
|
|
|
balance.totalAmount.should.equal(helpers.toSatoshi(N * 100)); |
|
|
|
balance.lockedAmount.should.equal(helpers.toSatoshi(0)); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
async.map(_.range(N), function(i, cb) { |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
cb(err, tx); |
|
|
@ -1664,11 +1690,16 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should create tx for type multiple_outputs', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var outputs = [ |
|
|
|
{ toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount: 75, message: 'message #1' }, |
|
|
|
{ toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount: 75, message: 'message #2' } |
|
|
|
]; |
|
|
|
var txOpts = helpers.createProposalOptsByType(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var outputs = [{ |
|
|
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', |
|
|
|
amount: 75, |
|
|
|
message: 'message #1' |
|
|
|
}, { |
|
|
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', |
|
|
|
amount: 75, |
|
|
|
message: 'message #2' |
|
|
|
}]; |
|
|
|
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1677,16 +1708,20 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should fail to create tx for type multiple_outputs with invalid output argument', function(done) { |
|
|
|
it('should fail to create tx for type multiple_outputs with missing output argument', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var outputs = [ |
|
|
|
{ toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount: 80, message: 'message #1', foo: 'bar' }, |
|
|
|
{ toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', amount: 90, message: 'message #2' } |
|
|
|
]; |
|
|
|
var txOpts = helpers.createProposalOptsByType(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var outputs = [{ |
|
|
|
amount: 80, |
|
|
|
message: 'message #1', |
|
|
|
}, { |
|
|
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', |
|
|
|
amount: 90, |
|
|
|
message: 'message #2' |
|
|
|
}]; |
|
|
|
var txOpts = helpers.createProposalOpts(Model.TxProposal.Types.MULTIPLEOUTPUTS, outputs, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.message.should.contain('Invalid outputs argument'); |
|
|
|
err.message.should.contain('outputs argument missing'); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1694,7 +1729,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to create tx for unsupported proposal type', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
txOpts.type = 'bogus'; |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
@ -1712,7 +1747,7 @@ describe('Wallet service', function() { |
|
|
|
balance.lockedAmount.should.equal(0); |
|
|
|
balance.totalKbToSendMax.should.equal(3); |
|
|
|
var max = (balance.totalAmount - balance.lockedAmount) - (balance.totalKbToSendMax * 10000); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1729,7 +1764,7 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
it('should be able to send max non-locked amount', function(done) { |
|
|
|
helpers.stubUtxos(server, wallet, _.range(1, 10, 0), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 3.5, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 3.5, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
server.getBalance({}, function(err, balance) { |
|
|
@ -1738,7 +1773,7 @@ describe('Wallet service', function() { |
|
|
|
balance.lockedAmount.should.equal(helpers.toSatoshi(4)); |
|
|
|
balance.totalKbToSendMax.should.equal(2); |
|
|
|
var max = (balance.totalAmount - balance.lockedAmount) - (balance.totalKbToSendMax * 2000); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0, 2000); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', max / 1e8, null, TestData.copayers[0].privKey_1H_0, 2000); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1774,7 +1809,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
function(next) { |
|
|
|
async.each(_.range(3), function(i, next) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
server.rejectTx({ |
|
|
@ -1787,7 +1822,7 @@ describe('Wallet service', function() { |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
// Allow a 4th tx
|
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
server.rejectTx({ |
|
|
|
txProposalId: tx.id, |
|
|
@ -1797,7 +1832,7 @@ describe('Wallet service', function() { |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
// Do not allow before backoff time
|
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.exist(err); |
|
|
|
err.code.should.equal('NOTALLOWEDTOCREATETX'); |
|
|
@ -1806,7 +1841,7 @@ describe('Wallet service', function() { |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
var clock = sinon.useFakeTimers(Date.now() + (WalletService.backoffTimeMinutes + 2) * 60 * 1000, 'Date'); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
clock.restore(); |
|
|
|
server.rejectTx({ |
|
|
@ -1818,7 +1853,7 @@ describe('Wallet service', function() { |
|
|
|
function(next) { |
|
|
|
// Do not allow a 5th tx before backoff time
|
|
|
|
var clock = sinon.useFakeTimers(Date.now() + (WalletService.backoffTimeMinutes + 2) * 60 * 1000 + 1, 'Date'); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
clock.restore(); |
|
|
|
should.exist(err); |
|
|
@ -1841,7 +1876,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, _.range(1, 9), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -1931,7 +1966,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, _.range(1, 9), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
@ -2136,7 +2171,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, [10, 10], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(txp); |
|
|
@ -2195,7 +2230,7 @@ describe('Wallet service', function() { |
|
|
|
|
|
|
|
it('should fail to brodcast a not yet accepted tx', function(done) { |
|
|
|
helpers.stubBroadcast('999'); |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some other message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some other message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(txp); |
|
|
@ -2288,7 +2323,7 @@ describe('Wallet service', function() { |
|
|
|
}); |
|
|
|
|
|
|
|
it('other copayers should see pending proposal created by one copayer', function(done) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(txp); |
|
|
@ -2309,7 +2344,7 @@ describe('Wallet service', function() { |
|
|
|
async.waterfall([ |
|
|
|
|
|
|
|
function(next) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
txpId = txp.id; |
|
|
|
should.not.exist(err); |
|
|
@ -2397,7 +2432,7 @@ describe('Wallet service', function() { |
|
|
|
async.waterfall([ |
|
|
|
|
|
|
|
function(next) { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 10, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
txpId = txp.id; |
|
|
|
should.not.exist(err); |
|
|
@ -2479,7 +2514,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, 10, function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 9, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, txp) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(txp); |
|
|
@ -2535,11 +2570,12 @@ describe('Wallet service', function() { |
|
|
|
helpers.createAndJoinWallet(1, 1, function(s, w) { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, _.range(10), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
helpers.stubUtxos(server, wallet, _.range(1, 11), function() { |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.1, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
async.eachSeries(_.range(10), function(i, next) { |
|
|
|
clock.tick(10 * 1000); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
next(); |
|
|
|
}); |
|
|
|
}, function(err) { |
|
|
@ -2560,7 +2596,7 @@ describe('Wallet service', function() { |
|
|
|
}, function(err, txps) { |
|
|
|
should.not.exist(err); |
|
|
|
var times = _.pluck(txps, 'createdOn'); |
|
|
|
times.should.deep.equal([90, 80, 70, 60]); |
|
|
|
times.should.deep.equal([100, 90, 80, 70, 60]); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2583,7 +2619,7 @@ describe('Wallet service', function() { |
|
|
|
}, function(err, txps) { |
|
|
|
should.not.exist(err); |
|
|
|
var times = _.pluck(txps, 'createdOn'); |
|
|
|
times.should.deep.equal([90, 80, 70, 60]); |
|
|
|
times.should.deep.equal([100, 90, 80, 70]); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2592,7 +2628,7 @@ describe('Wallet service', function() { |
|
|
|
server.getTxs({}, function(err, txps) { |
|
|
|
should.not.exist(err); |
|
|
|
var times = _.pluck(txps, 'createdOn'); |
|
|
|
times.should.deep.equal([90, 80, 70, 60, 50, 40, 30, 20, 10]); |
|
|
|
times.should.deep.equal([100, 90, 80, 70, 60, 50, 40, 30, 20, 10]); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -2620,7 +2656,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, _.range(4), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.01, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.01, null, TestData.copayers[0].privKey_1H_0); |
|
|
|
async.eachSeries(_.range(3), function(i, next) { |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
@ -2832,7 +2868,7 @@ describe('Wallet service', function() { |
|
|
|
wallet2 = w; |
|
|
|
|
|
|
|
helpers.stubUtxos(server2, wallet2, _.range(1, 3), function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.1, 'some message', TestData.copayers[1].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 0.1, 'some message', TestData.copayers[1].privKey_1H_0); |
|
|
|
async.eachSeries(_.range(2), function(i, next) { |
|
|
|
server2.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
@ -2898,7 +2934,7 @@ describe('Wallet service', function() { |
|
|
|
server = s; |
|
|
|
wallet = w; |
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function() { |
|
|
|
var txOpts = helpers.createProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts('18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
server.getPendingTxs({}, function(err, txs) { |
|
|
|
txp = txs[0]; |
|
|
@ -3210,7 +3246,7 @@ describe('Wallet service', function() { |
|
|
|
server._normalizeTxHistory = sinon.stub().returnsArg(0); |
|
|
|
|
|
|
|
helpers.stubUtxos(server, wallet, [100, 200], function(utxos) { |
|
|
|
var txOpts = helpers.createProposalOpts(mainAddresses[0].address, 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
var txOpts = helpers.createSimpleProposalOpts(mainAddresses[0].address, 80, 'some message', TestData.copayers[0].privKey_1H_0); |
|
|
|
server.createTx(txOpts, function(err, tx) { |
|
|
|
should.not.exist(err); |
|
|
|
should.exist(tx); |
|
|
|