aboutsummaryrefslogtreecommitdiffstats
path: root/routes/liquid/fee.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-08 16:29:14 -0700
committerAdam Soltys <[email protected]>2022-09-08 16:29:14 -0700
commitbe27adba90c2c52ccbfac5885d70e5b37753fc58 (patch)
tree3ea8a2e1700112782d3bd16517fff4a875d38756 /routes/liquid/fee.js
parentd89458ebef267c7dc2290100ecb05b7d0891c224 (diff)
parentc60ad34877c44760263a9e93e99aa425ad0fdd99 (diff)
downloadcoinos-server-be27adba90c2c52ccbfac5885d70e5b37753fc58.tar.gz
coinos-server-be27adba90c2c52ccbfac5885d70e5b37753fc58.zip
Merge branch 'prod'
Diffstat (limited to 'routes/liquid/fee.js')
-rw-r--r--routes/liquid/fee.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/routes/liquid/fee.js b/routes/liquid/fee.js
index 34ee2553..4ec29455 100644
--- a/routes/liquid/fee.js
+++ b/routes/liquid/fee.js
@@ -1,9 +1,10 @@
+import db from "$db";
import { emit } from "$lib/sockets";
import buildTx from "$lib/buildliquidtx";
+import { err, l } from "$lib/logging";
-liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
+export const liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
let tx, fee;
- let node = lq;
if (user.account.pubkey) {
let psbt = await buildTx({
@@ -27,7 +28,7 @@ liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
});
if (invoice) {
- let { ismine } = await node.getAddressInfo(address);
+ let { ismine } = await lq.getAddressInfo(address);
if (ismine) {
emit(user.username, "to", invoice.user);
return;
@@ -35,7 +36,7 @@ liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
}
if (config.liquid.walletpass)
- await node.walletPassphrase(config.liquid.walletpass, 300);
+ await lq.walletPassphrase(config.liquid.walletpass, 300);
amount = parseInt(amount);
@@ -46,9 +47,9 @@ liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
let value = (amount / SATS).toFixed(8);
if (feeRate) params.feeRate = (feeRate / SATS).toFixed(8);
- let info = await node.getAddressInfo(address);
+ let info = await lq.getAddressInfo(address);
- tx = await node.createRawTransaction(
+ tx = await lq.createRawTransaction(
[],
[
{
@@ -62,12 +63,12 @@ liquidTx = async ({ address, asset, amount, feeRate, replaceable, user }) => {
l("funding tx for fee estimate", tx);
- tx = await node.fundRawTransaction(tx, params);
+ tx = await lq.fundRawTransaction(tx, params);
- let blinded = await node.blindRawTransaction(tx.hex);
- let signed = await node.signRawTransactionWithWallet(blinded);
+ let blinded = await lq.blindRawTransaction(tx.hex);
+ let signed = await lq.signRawTransactionWithWallet(blinded);
- decoded = await node.decodeRawTransaction(signed.hex);
+ let decoded = await lq.decodeRawTransaction(signed.hex);
feeRate = Math.round((tx.fee * SATS * 1000) / decoded.vsize);
l("estimated", asset, feeRate);