Skip to content

Commit

Permalink
wallet-rpc: get input paths when creating batch
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Sep 23, 2022
1 parent 1ada5b4 commit 4e9c7fc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/wallet/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2490,6 +2490,8 @@ class RPC extends RPCBase {

async createBatch(args, help) {
const [actions, options] = this._validateBatch(args, help, 'createbatch');
options.paths = true;

const wallet = this.wallet;
const mtx = await wallet.createBatch(actions, options);

Expand All @@ -2504,7 +2506,7 @@ class RPC extends RPCBase {

const valid = new Validator(args);
const check = valid.array(0);
const options = valid.obj(1);
const options = valid.obj(1, {});
const actions = [];

for (const action of check) {
Expand Down
22 changes: 22 additions & 0 deletions test/wallet-rpc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,28 @@ describe('Wallet RPC Methods', function() {
await nclient.execute('generatetoaddress', [100, addr]);
});

it('should have paths when creating batch', async () => {
const json = await wclient.execute(
'createbatch',
[
[['NONE', addr, 1]]
]
);

assert(json.inputs[0].path);
});

it('should not have paths when sending batch', async () => {
const json = await wclient.execute(
'sendbatch',
[
[['NONE', addr, 1]]
]
);

assert(!json.inputs[0].path);
});

it('should not send invalid batch: OPEN arguments', async () => {
await assert.rejects(
wclient.execute(
Expand Down

0 comments on commit 4e9c7fc

Please sign in to comment.