aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/buildliquidtx.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/buildliquidtx.js b/lib/buildliquidtx.js
index d9b14d13..aafaf049 100644
--- a/lib/buildliquidtx.js
+++ b/lib/buildliquidtx.js
@@ -2,7 +2,7 @@ const axios = require("axios");
const liquid = require("liquidjs-lib");
const coinselect = require("coinselect");
const split = require("coinselect/split");
-const api = prod ? "https://blockstream.info/api" : "http://localhost:3002";
+const api = prod ? "https://blockstream.info/liquid/api" : "http://localhost:3002";
const SATS = 100000000;
const network = prod ? liquid.networks["liquid"] : liquid.networks["regtest"];
@@ -14,9 +14,10 @@ module.exports = async ({ address, asset, amount, feeRate, user }) => {
if (!feerate) feerate = 0.00002;
feeRate = feerate * SATS;
}
- feeRate = Math.round(feeRate / 1000);
+ feeRate = Math.round(feeRate / 100);
if (asset !== btc) feeRate = 0;
+
const payments = await db.Payment.findAll({
where: {
received: true,
@@ -49,7 +50,6 @@ module.exports = async ({ address, asset, amount, feeRate, user }) => {
];
let { inputs, outputs, fee } = coinselect(utxos, targets, feeRate);
-
if (!inputs || !outputs) {
l.info(
"utxos",
@@ -57,8 +57,10 @@ module.exports = async ({ address, asset, amount, feeRate, user }) => {
feeRate,
utxos.map((u) => u.value),
inputs,
- outputs
+ outputs,
+ fee
);
+
throw new Error(
"Couldn't find inputs for transaction, check your balance/fee"
);
@@ -88,17 +90,16 @@ module.exports = async ({ address, asset, amount, feeRate, user }) => {
psbt = psbt.addInput({
hash: txid,
index: vout,
- nonWitnessUtxo: Buffer.from(await lq.getRawTransaction(txid), "hex"),
+ nonWitnessUtxo: Buffer.from((await lq.getTransaction(txid)).hex, "hex"),
});
}
if (asset !== btc) {
- l.info("feeInput", feeInput);
psbt.addInput({
hash: feeInput.txid,
index: feeInput.vout,
nonWitnessUtxo: Buffer.from(
- await lq.getRawTransaction(feeInput.txid),
+ (await lq.getTransaction(feeInput.txid).hex),
"hex"
),
});