diff options
| author | Adam Soltys <[email protected]> | 2022-09-08 16:29:14 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-08 16:29:14 -0700 |
| commit | be27adba90c2c52ccbfac5885d70e5b37753fc58 (patch) | |
| tree | 3ea8a2e1700112782d3bd16517fff4a875d38756 /routes/liquid | |
| parent | d89458ebef267c7dc2290100ecb05b7d0891c224 (diff) | |
| parent | c60ad34877c44760263a9e93e99aa425ad0fdd99 (diff) | |
| download | coinos-server-be27adba90c2c52ccbfac5885d70e5b37753fc58.tar.gz coinos-server-be27adba90c2c52ccbfac5885d70e5b37753fc58.zip | |
Merge branch 'prod'
Diffstat (limited to 'routes/liquid')
| -rw-r--r-- | routes/liquid/fee.js | 21 | ||||
| -rw-r--r-- | routes/liquid/index.js | 4 | ||||
| -rw-r--r-- | routes/liquid/send.js | 10 |
3 files changed, 20 insertions, 15 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); 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); |
