diff options
| author | Adam Soltys <[email protected]> | 2020-08-17 01:07:35 -0400 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-08-17 01:07:35 -0400 |
| commit | 38b69d34f0f1d58565b4144035a1b9956f2cc87b (patch) | |
| tree | c9dc1bca9fb17269ba8715caadf44f8f999bddf2 /lib | |
| parent | f70e48a69ccbd0f67220f25bcb65f098d537ec5f (diff) | |
| download | coinos-server-38b69d34f0f1d58565b4144035a1b9956f2cc87b.tar.gz coinos-server-38b69d34f0f1d58565b4144035a1b9956f2cc87b.zip | |
liquid tx fixes for prod
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/buildliquidtx.js | 15 |
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" ), }); |
