mirror of https://github.com/lukechilds/Agama.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
786 B
26 lines
786 B
7 years ago
|
module.exports = (shepherd) => {
|
||
|
shepherd.get('/electrum/estimatefee', (req, res, next) => {
|
||
|
const ecl = new shepherd.electrumJSCore(shepherd.electrumServers[req.query.network].port, shepherd.electrumServers[req.query.network].address, shepherd.electrumServers[req.query.network].proto); // tcp or tls
|
||
|
|
||
|
ecl.connect();
|
||
|
ecl.blockchainEstimatefee(req.query.blocks)
|
||
|
.then((json) => {
|
||
|
ecl.close();
|
||
|
shepherd.log('electrum estimatefee ==>', true);
|
||
|
|
||
|
const successObj = {
|
||
|
msg: 'success',
|
||
|
result: json,
|
||
|
};
|
||
|
|
||
|
res.end(JSON.stringify(successObj));
|
||
|
});
|
||
|
});
|
||
|
|
||
|
shepherd.estimateTxSize = (numVins, numOuts) => {
|
||
|
// in x 180 + out x 34 + 10 plus or minus in
|
||
|
return numVins * 180 + numOuts * 34 + 11;
|
||
|
}
|
||
|
|
||
|
return shepherd;
|
||
|
};
|