Skip to content

Commit

Permalink
Update http.js
Browse files Browse the repository at this point in the history
This adds http handlers for the createclaim/sendclaim rpc methods.

This was made for shakestation so I could select which wallet to create/send claims from without having to rpc selectwallet which could potentially break other scripts that may have been running at the same time.
  • Loading branch information
eskimo authored Jul 18, 2023
1 parent 81bddcd commit 9faf3ef
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/wallet/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,38 @@ class HTTP extends Server {

return res.json(200, json);
});

// Create Claim
this.get('/wallet/:id/createclaim/:name', async (req, res) => {
const valid = Validator.fromRequest(req);
const name = valid.str('name');

enforce(name, 'Must pass name.');
enforce(rules.verifyName(name), 'Must pass valid name.');

const claim = await req.wallet.createClaim(name);
return res.json(200, {
name: claim.name,
target: claim.target,
value: claim.value,
size: claim.size,
fee: claim.fee,
address: claim.address.toString(this.network),
txt: claim.txt
});
});

// Send Claim
this.post('/wallet/:id/sendclaim/:name', async (req, res) => {
const valid = Validator.fromRequest(req);
const name = valid.str('name');

enforce(name, 'Must pass name.');
enforce(rules.verifyName(name), 'Must pass valid name.');

const claim = await req.wallet.sendClaim(name);
return res.json(200, claim.getJSON(this.network));
});
}

/**
Expand Down

0 comments on commit 9faf3ef

Please sign in to comment.