Skip to content

Commit

Permalink
Keep submit raw tx option
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-dc committed Nov 13, 2018
1 parent b17a3eb commit bd83242
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
38 changes: 34 additions & 4 deletions routes/tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ router.get('/pending', function(req, res, next) {
});


router.get('/submit', function(req, res, next) {
res.render('tx_submit', { });
});

router.get('/submit', function(req, res, next) {
res.render('tx_submit', { });
});


router.post('/submit', function(req, res, next) {
Expand Down Expand Up @@ -81,7 +82,36 @@ router.post('/submit', function(req, res, next) {
}
});
});


router.get('/submit_raw', function(req, res, next) {
res.render('tx_submit_raw', { });
});

router.post('/submit_raw', function(req, res, next) {
if (!req.body.txHex) {
return res.render('tx_submit_raw', { message: "No transaction data specified!"});
}

var config = req.app.get('config');
var web3 = new Web3();

web3.setProvider(config.provider);

async.waterfall([
function(callback) {
web3.eth.sendRawTransaction(req.body.txHex, function(err, result) {
callback(err, result);
});
}
], function(err, hash) {
if (err) {
res.render('tx_submit_raw', { message: "Error submitting transaction: " + err });
} else {
res.render('tx_submit_raw', { message: "Transaction submitted. Hash: " + hash });
}
});
});

router.get('/:tx', function(req, res, next) {

var config = req.app.get('config');
Expand Down
12 changes: 7 additions & 5 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ html(lang="en")
ul.dropdown-menu
li
a(href='/explorer/tx/submit') Submit Tx
li
a(href='/explorer/tx/submit_raw') Submit Raw Tx
// hide verify links
// li
// a(href='/explorer/contract/verify') Verify Contract
// li
// a(href='/explorer/signature/verify') Verify Signature
//li
// a(href='/explorer/contract/verify') Verify Contract
//li
// a(href='/explorer/signature/verify') Verify Signature
form.navbar-form.navbar-right(action="/explorer/search", method="POST")
.form-group
input.form-control#search(type='text', placeholder='Block / Tx / Account', name='search')
Expand Down
11 changes: 11 additions & 0 deletions views/tx_submit_raw.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends layout

block content
h3 Submit raw transaction
form(action="/tx/submit_raw", method="post")
.form-group
label(for="txHex") Signed Transaction Hex
textarea.form-control#txHex(rows=15, name="txHex", placeholder="0x...")
button.btn.btn-default.pull-right(type="submit") Submit
if message
p #{message}

0 comments on commit bd83242

Please sign in to comment.