2018-09-27 04:02:46 +02:00
|
|
|
var request = require('request');
|
|
|
|
var options = require("../connect");
|
2018-10-10 02:08:05 +02:00
|
|
|
var common = require('../common');
|
2018-09-27 04:02:46 +02:00
|
|
|
|
|
|
|
exports.postTransactions = (req, res, next) => {
|
2018-10-10 02:08:05 +02:00
|
|
|
options.url = common.lnd_server_url + '/transactions';
|
2018-09-27 04:02:46 +02:00
|
|
|
options.form = JSON.stringify({
|
|
|
|
amount: req.body.amount,
|
|
|
|
addr: req.body.address,
|
|
|
|
sat_per_byte: req.body.fees,
|
|
|
|
target_conf: req.body.blocks
|
|
|
|
});
|
|
|
|
request.post(options, (error, response, body) => {
|
|
|
|
console.log('Transactions Post Response: ');
|
|
|
|
console.log(body);
|
|
|
|
if(undefined === body || body.error) {
|
|
|
|
res.status(500).json({
|
|
|
|
message: "Transactions post failed!",
|
2018-10-12 02:03:54 +02:00
|
|
|
error: (undefined === body) ? 'Error From Server!' : body.error
|
2018-09-27 04:02:46 +02:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
res.status(201).json(body);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|