diff options
| author | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
| commit | c0888fab024cc9f7c99812bfabf9d7774312dbf7 (patch) | |
| tree | cad95683af97432f6092a2c2bae10fbb7a588db5 /estimateBitcoinFee.js | |
| parent | bf2b51f0c2ae9b8f0f330dde6411e45fc0da8a25 (diff) | |
| download | coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.tar.gz coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.zip | |
refactor
Diffstat (limited to 'estimateBitcoinFee.js')
| -rw-r--r-- | estimateBitcoinFee.js | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/estimateBitcoinFee.js b/estimateBitcoinFee.js deleted file mode 100644 index b32a0dc6..00000000 --- a/estimateBitcoinFee.js +++ /dev/null @@ -1,30 +0,0 @@ -const config = require("./config"); - -const l = require("pino")(); -const SATS = 100000000; - -module.exports = (app, bc, db, emit) => async (req, res) => { - let { user } = req; - let { address, amount, feeRate } = req.body; - let tx, fee; - - try { - amount = parseInt(amount); - - tx = await bc.createRawTransaction([], { - [address]: (amount / SATS).toFixed(8) - }); - - let params = { - subtractFeeFromOutputs: amount === user.balance ? [0] : [] - } - - if (feeRate) params["feeRate"] = (parseInt(feeRate) / SATS * 1000).toFixed(8); - - tx = await bc.fundRawTransaction(tx, params); - res.send({ tx }); - } catch (e) { - l.error(e); - return res.status(500).send(e.message); - } -}; |
