aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-04-04 15:05:11 -0700
committerAdam Soltys <[email protected]>2020-04-04 15:15:36 -0700
commit3c83b64ca231170ff379541842dba11371a777d7 (patch)
treea31ab36d2d1af3cf266ee2b1403429d5a0da3f35
parent54714984ce540a6a2f9004325aed6524b117d0c6 (diff)
downloadcoinos-server-3c83b64ca231170ff379541842dba11371a777d7.tar.gz
coinos-server-3c83b64ca231170ff379541842dba11371a777d7.zip
fix liquid fee rate calculation
-rw-r--r--routes/liquid/fee.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/routes/liquid/fee.js b/routes/liquid/fee.js
index 54ecf5f8..9dbb7e0a 100644
--- a/routes/liquid/fee.js
+++ b/routes/liquid/fee.js
@@ -17,10 +17,14 @@ module.exports = async (req, res) => {
if (feeRate) params.feeRate = (feeRate / SATS).toFixed(8);
tx = await lq.fundRawTransaction(tx, params);
- let decoded = await lq.decodeRawTransaction(tx.hex);
- /* TODO: figure out why this multiplier seems necessary */
- feeRate = parseInt(tx.fee * SATS * 1000 / decoded.size);
- l.info(decoded.weight, decoded.size, decoded.vsize, params.feeRate * SATS, feeRate);
+
+ if (config.liquid.walletpass)
+ await lq.walletPassphrase(config.liquid.walletpass, 300);
+
+ let signed = (await lq.signRawTransactionWithWallet(tx.hex));
+ decoded = await lq.decodeRawTransaction(signed.hex);
+ feeRate = parseInt(tx.fee * SATS * 1000 / decoded.vsize);
+
res.send({ feeRate, tx });
} catch (e) {
l.error("error estimating liquid fee", e);