diff options
| author | Adam Soltys <[email protected]> | 2020-04-03 15:13:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-04-03 15:13:41 -0700 |
| commit | f324b72f007a72d25976a066f1f201b75990993f (patch) | |
| tree | e1bf48fc01610ce635b7dc04a5b5c451216238ea /routes/bitcoin | |
| parent | 8d15c4e724a65347a999f31486f72bdbd9d38812 (diff) | |
| download | coinos-server-f324b72f007a72d25976a066f1f201b75990993f.tar.gz coinos-server-f324b72f007a72d25976a066f1f201b75990993f.zip | |
return fee rate with estimate
Diffstat (limited to 'routes/bitcoin')
| -rw-r--r-- | routes/bitcoin/fee.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/routes/bitcoin/fee.js b/routes/bitcoin/fee.js index 259f2329..a2c63660 100644 --- a/routes/bitcoin/fee.js +++ b/routes/bitcoin/fee.js @@ -14,10 +14,13 @@ module.exports = async (req, res) => { subtractFeeFromOutputs: amount === user.balance ? [0] : [] } - if (feeRate) params["feeRate"] = (parseInt(feeRate) / SATS * 1000).toFixed(8); + if (feeRate) params["feeRate"] = (feeRate / SATS * 1000).toFixed(8); tx = await bc.fundRawTransaction(tx, params); - res.send({ tx }); + let decoded = await bc.decodeRawTransaction(tx.hex); + /* TODO: figure out why this 0.8 multiplier seems necessary */ + feeRate = (tx.fee * SATS / decoded.vsize) * 1000 * 0.80145; + res.send({ feeRate, tx }); } catch (e) { l.error("bitcoin fee estimation error", e); return res.status(500).send(e.message); |
