Merge pull request #560 from isocolsky/fix/args-check
change argument validation
This commit is contained in:
commit
4dc010cf0c
|
@ -1680,10 +1680,6 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb)
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
|
|
||||||
function(next) {
|
|
||||||
if (!checkRequired(opts, ['outputs'], next)) return;
|
|
||||||
next();
|
|
||||||
},
|
|
||||||
function(next) {
|
function(next) {
|
||||||
// feePerKb is required unless inputs & fee are specified
|
// feePerKb is required unless inputs & fee are specified
|
||||||
if (!_.isNumber(opts.feePerKb) && !(opts.inputs && _.isNumber(opts.fee)))
|
if (!_.isNumber(opts.feePerKb) && !(opts.inputs && _.isNumber(opts.fee)))
|
||||||
|
@ -1755,6 +1751,10 @@ WalletService.prototype._validateAndSanitizeTxOpts = function(wallet, opts, cb)
|
||||||
WalletService.prototype.createTx = function(opts, cb) {
|
WalletService.prototype.createTx = function(opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
if (!checkRequired(opts, ['outputs'], cb)) return;
|
||||||
|
|
||||||
function getChangeAddress(wallet, cb) {
|
function getChangeAddress(wallet, cb) {
|
||||||
if (wallet.singleAddress) {
|
if (wallet.singleAddress) {
|
||||||
self.storage.fetchAddresses(self.walletId, function(err, addresses) {
|
self.storage.fetchAddresses(self.walletId, function(err, addresses) {
|
||||||
|
|
|
@ -2294,6 +2294,21 @@ describe('Wallet service', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('should fail to create a tx without outputs param', function(done) {
|
||||||
|
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||||
|
var txOpts = {
|
||||||
|
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||||
|
amount: 0.8 * 1e8,
|
||||||
|
message: 'some message',
|
||||||
|
feePerKb: 123e2,
|
||||||
|
};
|
||||||
|
server.createTx(txOpts, function(err, tx) {
|
||||||
|
should.exist(err);
|
||||||
|
should.not.exist(tx);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
it('should be able to publish a temporary tx proposal', function(done) {
|
it('should be able to publish a temporary tx proposal', function(done) {
|
||||||
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||||
var txOpts = {
|
var txOpts = {
|
||||||
|
|
Loading…
Reference in New Issue