Browse Source

new error for address network mismatch

activeAddress
Ivan Socolsky 10 years ago
parent
commit
90dfc17ab5
  1. 1
      lib/errors/errordefinitions.js
  2. 4
      lib/server.js
  3. 2
      test/integration/server.js

1
lib/errors/errordefinitions.js

@ -11,6 +11,7 @@ var errors = {
COPAYER_REGISTERED: 'Copayer ID already registered on server',
COPAYER_VOTED: 'Copayer already voted on this transaction proposal',
DUST_AMOUNT: 'Amount below dust threshold',
INCORRECT_ADDRESS_NETWORK: 'Incorrect address network',
INSUFFICIENT_FUNDS: 'Insufficient funds',
INSUFFICIENT_FUNDS_FOR_FEE: 'Insufficient funds for fee',
INVALID_ADDRESS: 'Invalid address',

4
lib/server.js

@ -1009,11 +1009,11 @@ WalletService.prototype.createTx = function(opts, cb) {
try {
toAddress = new Bitcore.Address(output.toAddress);
} catch (ex) {
cb(new ClientError(Errors.codes.INVALID_ADDRESS, 'Invalid address'));
cb(Errors.INVALID_ADDRESS);
return false;
}
if (toAddress.network != wallet.getNetworkName()) {
cb(new ClientError(Errors.codes.INVALID_ADDRESS, 'Incorrect address network'));
cb(Errors.INCORRECT_ADDRESS_NETWORK);
return false;
}
if (!_.isNumber(output.amount) || _.isNaN(output.amount) || output.amount <= 0) {

2
test/integration/server.js

@ -1779,7 +1779,7 @@ describe('Wallet service', function() {
server.createTx(txOpts, function(err, tx) {
should.not.exist(tx);
should.exist(err);
err.code.should.equal('INVALID_ADDRESS');
err.code.should.equal('INCORRECT_ADDRESS_NETWORK');
err.message.should.equal('Incorrect address network');
done();
});

Loading…
Cancel
Save