Merge pull request #664 from pinheadmz/patch-9
Wallet: better error for send() if no outputs given
This commit is contained in:
commit
07f55479eb
@ -1244,7 +1244,7 @@ class Wallet extends EventEmitter {
|
||||
const mtx = new MTX();
|
||||
|
||||
assert(Array.isArray(outputs), 'Outputs must be an array.');
|
||||
assert(outputs.length > 0, 'No outputs available.');
|
||||
assert(outputs.length > 0, 'At least one output required.');
|
||||
|
||||
// Add the outputs
|
||||
for (const obj of outputs) {
|
||||
|
||||
@ -18,6 +18,7 @@ const Input = require('../lib/primitives/input');
|
||||
const Outpoint = require('../lib/primitives/outpoint');
|
||||
const Script = require('../lib/script/script');
|
||||
const HD = require('../lib/hd');
|
||||
const Wallet = require('../lib/wallet/wallet');
|
||||
|
||||
const KEY1 = 'xprv9s21ZrQH143K3Aj6xQBymM31Zb4BVc7wxqfUhMZrzewdDVCt'
|
||||
+ 'qUP9iWfcHgJofs25xbaUpCps9GDXj83NiWvQCAkWQhVj5J4CorfnpKX94AZ';
|
||||
@ -1642,6 +1643,21 @@ describe('Wallet', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw error with missing outputs', async () => {
|
||||
const wallet = new Wallet({});
|
||||
|
||||
let err = null;
|
||||
|
||||
try {
|
||||
await wallet.send({outputs: []});
|
||||
} catch (e) {
|
||||
err = e;
|
||||
}
|
||||
|
||||
assert(err);
|
||||
assert.equal(err.message, 'At least one output required.');
|
||||
});
|
||||
|
||||
it('should cleanup', async () => {
|
||||
consensus.COINBASE_MATURITY = 100;
|
||||
// await wdb.close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user