Browse Source

.

activeAddress
Ivan Socolsky 10 years ago
parent
commit
4fcbadddf7
  1. 2
      lib/model/txproposal.js
  2. 4
      lib/server.js
  3. 6
      lib/storage.js
  4. 10
      test/integration.js

2
lib/model/txproposal.js

@ -1,5 +1,7 @@
'use strict';
var _ = require('lodash');
var TxProposalAction = require('./txproposalaction');
function TxProposal(opts) {

4
lib/server.js

@ -255,7 +255,7 @@ CopayServer.prototype.createTx = function (opts, cb) {
self._getUtxos({ walletId: wallet.id }, function (err, utxos) {
if (err) return cb(err);
var txp = new TxProposal({
creatorId: opts.copayerId,
toAddress: opts.toAddress,
@ -267,7 +267,7 @@ CopayServer.prototype.createTx = function (opts, cb) {
});
txp.rawTx = self._createRawTx(txp);
self.storage.storeTx(txp, function (err) {
self.storage.storeTx(wallet.id, txp, function (err) {
if (err) return cb(err);
return cb(null, txp);

6
lib/storage.js

@ -28,7 +28,7 @@ Storage.prototype.fetchWallet = function (id, cb) {
};
Storage.prototype.fetchTx = function (walletId, txProposalId, cb) {
this.db.get('wallet-' + walletId + '-tx-' + txProposalId, function (err, data) {
this.db.get('wallet-' + walletId + '-txp-' + txProposalId, function (err, data) {
if (err) {
if (err.notFound) return cb();
return cb(err);
@ -45,8 +45,8 @@ Storage.prototype.storeAddress = function (walletId, address, cb) {
this.db.put('wallet-' + walletId + '-address-' + address.address, address, cb);
};
Storage.prototype.storeTx = function (walletId, tx, cb) {
this.db.put('wallet-' + walletId + '-tx-' + tx.txProposalId, tx, cb);
Storage.prototype.storeTx = function (walletId, txp, cb) {
this.db.put('wallet-' + walletId + '-txp-' + txp.txProposalId, txp, cb);
};
Storage.prototype.fetchAddresses = function (walletId, cb) {

10
test/integration.js

@ -398,11 +398,13 @@ describe('Copay server', function() {
});
});
it.skip('should create tx', function (done) {
it('should create tx', function (done) {
var bc = sinon.stub();
bc.getUnspentUtxos = sinon.stub().yields(null, ['utxo1', 'utxo2']);
bc.getUnspentUtxos = sinon.stub().callsArgWith(1, null, ['utxo1', 'utxo2']);
server._getBlockExplorer = sinon.stub().returns(bc);
server._createRawTx = sinon.stub().returns('raw');
var txOpts = {
copayerId: '1',
walletId: '123',
@ -415,7 +417,9 @@ describe('Copay server', function() {
server.createTx(txOpts, function (err, tx) {
should.not.exist(err);
tx.should.exist;
tx.raw.should.exist;
tx.rawTx.should.equal('raw');
tx.isAccepted().should.equal.false;
tx.isRejected().should.equal.false;
done();
});
});

Loading…
Cancel
Save