Skip to content

Commit

Permalink
Handle Invalid Transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Sep 28, 2022
1 parent a538a39 commit 2c25613
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions index.js
Expand Up @@ -34,13 +34,19 @@ app.post('/api/mine', (req, res) => {
app.post('/api/transact', (req, res) => {
const { amount, recipient } = req.body;

const transaction = wallet.createTransaction({ recipient, amount });
let transaction;

try {
wallet.createTransaction({ recipient, amount });
} catch(error) {
return res.status(400).json({ type: 'error', message: error.message });
}

transactionPool.setTransaction(transaction);

console.log('transactionPool', transactionPool);

res.json({ transaction });
res.json({ type: 'success', transaction });
});

const syncChains = () => {
Expand Down

0 comments on commit 2c25613

Please sign in to comment.