diff options
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/bitcoin/fee.js | 7 | ||||
| -rw-r--r-- | routes/bitcoin/send.js | 5 | ||||
| -rw-r--r-- | routes/lightning/send.js | 4 | ||||
| -rw-r--r-- | routes/liquid/fee.js | 21 | ||||
| -rw-r--r-- | routes/liquid/index.js | 4 | ||||
| -rw-r--r-- | routes/liquid/send.js | 10 | ||||
| -rw-r--r-- | routes/lnurl.js | 1 | ||||
| -rw-r--r-- | routes/payments.js | 3 |
8 files changed, 37 insertions, 18 deletions
diff --git a/routes/bitcoin/fee.js b/routes/bitcoin/fee.js index af622ca5..fb67c08e 100644 --- a/routes/bitcoin/fee.js +++ b/routes/bitcoin/fee.js @@ -1,5 +1,10 @@ +import config from "$config"; +import db from "$db"; +import bc from "$lib/bitcoin"; +import { err } from "$lib/logging"; import { emit } from "$lib/sockets"; import buildTx from "$lib/buildtx"; +import { SATS } from "$lib/utils"; export default async (req, res) => { let { user } = req; @@ -57,7 +62,7 @@ export default async (req, res) => { await bc.walletPassphrase(config.bitcoin.walletpass, 300); let signed = await bc.signRawTransactionWithWallet(tx.hex); - decoded = await bc.decodeRawTransaction(signed.hex); + let decoded = await bc.decodeRawTransaction(signed.hex); feeRate = Math.round((tx.fee * SATS * 1000) / decoded.vsize); res.send({ feeRate, tx }); diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js index 51d702fd..bde3ce00 100644 --- a/routes/bitcoin/send.js +++ b/routes/bitcoin/send.js @@ -1,6 +1,11 @@ +import bc from "$lib/bitcoin"; +import { emit } from "$lib/sockets"; +import db from "$db"; import { toSats } from "$lib/utils"; import store from "$lib/store"; import config from "$config"; +import { l, warn, err } from "$lib/logging"; + const btc = config.liquid.btcasset; import { computeConversionFee, diff --git a/routes/lightning/send.js b/routes/lightning/send.js index c5de7ece..ba88aaf6 100644 --- a/routes/lightning/send.js +++ b/routes/lightning/send.js @@ -1,3 +1,6 @@ +import { err } from "$lib/logging"; +import send from "$lib/send"; + export default async (req, res) => { let { amount, route, memo, payreq } = req.body; let { user } = req; @@ -5,6 +8,7 @@ export default async (req, res) => { try { res.send(await send(amount, memo, payreq, user)); } catch (e) { + console.log(e) err( "problem sending lightning payment", user.username, 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); diff --git a/routes/liquid/index.js b/routes/liquid/index.js index 6da18363..b75cf23e 100644 --- a/routes/liquid/index.js +++ b/routes/liquid/index.js @@ -2,12 +2,10 @@ import broadcast from "./broadcast"; import generate from "./generate"; // import fee from "./fee"; import send from "./send"; -// import taxi from "./taxi"; export default { broadcast, generate, - // fee, +// fee, send, - // taxi }; diff --git a/routes/liquid/send.js b/routes/liquid/send.js index 5297de1c..8c94d976 100644 --- a/routes/liquid/send.js +++ b/routes/liquid/send.js @@ -1,15 +1,21 @@ +import db from "$db"; +import lq from "$lib/liquid"; import { toSats } from "$lib/utils"; import { emit } from "$lib/sockets"; import store from "$lib/store"; import config from "$config"; -const btc = config.liquid.btcasset; -const lcad = config.liquid.cadasset; +import { l, warn, err } from "$lib/logging"; +// import { liquidTx } from "$routes/liquid/fee"; // import { Transaction } from 'liquidjs-lib'; + import { computeConversionFee, conversionFeeReceiver } from "./conversionFee.js"; +const btc = config.liquid.btcasset; +const lcad = config.liquid.cadasset; + export const sendLiquid = async ({ asset, amount, user, address, memo, tx, limit }) => { try { l("sending liquid", amount, address); diff --git a/routes/lnurl.js b/routes/lnurl.js index 2749262d..a0d2a6d0 100644 --- a/routes/lnurl.js +++ b/routes/lnurl.js @@ -27,6 +27,7 @@ const recipients = persist("data/recipients.json"); const lnurlPayments = persist("data/payments.json"); const withdrawals = persist("data/withdrawals.json"); +console.log("creating lnurl") export const lnurlServer = lnurl.createServer(config.lnurl); app.get("/url", async (req, res, next) => { diff --git a/routes/payments.js b/routes/payments.js index a9313520..1f9a94ec 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -87,8 +87,7 @@ setTimeout(async () => { app.post("/liquid/broadcast", optionalAuth, lqRoutes.broadcast); app.get("/liquid/generate", auth, lqRoutes.generate); // app.post("/liquid/fee", auth, lqRoutes.fee); -app.post("/liquid/send", auth, lqRoutes.send); -// app.post("/taxi", auth, lqRoutes.taxi); +// app.post("/liquid/send", auth, lqRoutes.send); setTimeout(async () => { try { |
