Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet: fix the return of POST /reveal and /redeem #532

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/wallet/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ class HTTP extends Server {

if (!name) {
const tx = await req.wallet.sendRevealAll();
return tx.getJSON(this.network);
return res.json(200, tx.getJSON(this.network));
}

const options = TransactionOptions.fromValidator(valid);
Expand Down Expand Up @@ -1105,7 +1105,7 @@ class HTTP extends Server {

if (!name) {
const tx = await req.wallet.sendRedeemAll();
return tx.getJSON(this.network);
return res.json(200, tx.getJSON(this.network));
}

const options = TransactionOptions.fromValidator(valid);
Expand Down
27 changes: 27 additions & 0 deletions test/wallet-http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,33 @@ describe('Wallet HTTP', function() {
assert.equal(reveals.length, 1);
});

it('should create all reveals', async () => {
await wallet.createOpen({
name: name
});

await mineBlocks(treeInterval + 1, cbAddress);

for (let i = 0; i < 3; i++) {
await wallet.createBid({
name: name,
bid: 1000,
lockup: 2000
});
}

await mineBlocks(biddingPeriod + 1, cbAddress);

const {info} = await nclient.execute('getnameinfo', [name]);
assert.equal(info.name, name);
assert.equal(info.state, 'REVEAL');

const json = await wallet.createReveal();

const reveals = json.outputs.filter(output => output.covenant.type === types.REVEAL);
assert.equal(reveals.length, 3);
});

it('should get all reveals (single player)', async () => {
await wallet.createOpen({
name: name
Expand Down