aboutsummaryrefslogtreecommitdiffstats
path: root/routes/liquid/send.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-05-21 14:05:02 -0400
committerAdam Soltys <[email protected]>2021-05-21 14:05:02 -0400
commit3ce9c73b1d4a281fe1475206d49c4f436e0b992e (patch)
tree8e8324d74761f164d9615a068a0f4f840506e642 /routes/liquid/send.js
parent37412d24f5c7b0c6d316ce240ef29cd4ccd2ca6d (diff)
downloadcoinos-server-3ce9c73b1d4a281fe1475206d49c4f436e0b992e.tar.gz
coinos-server-3ce9c73b1d4a281fe1475206d49c4f436e0b992e.zip
persist liquid conversion requests
Diffstat (limited to 'routes/liquid/send.js')
-rw-r--r--routes/liquid/send.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/routes/liquid/send.js b/routes/liquid/send.js
index b80471b0..55041845 100644
--- a/routes/liquid/send.js
+++ b/routes/liquid/send.js
@@ -1,7 +1,19 @@
const btc = config.liquid.btcasset;
const lcad = config.liquid.cadasset;
-sendLiquid = async ({ user, address, memo, tx, limit }) => {
+sendLiquid = async ({ asset, amount, user, address, memo, tx, limit }) => {
+ l.info("sending liquid", amount, user, address);
+ if (!tx) {
+ ({ tx } = await liquidTx({
+ address,
+ asset,
+ amount,
+ feeRate: 100,
+ replaceable: false,
+ user
+ }));
+ }
+
const isChange = async address =>
(await lq.getAddressInfo(address)).ismine &&
!Object.keys(addresses).includes(address);
@@ -126,6 +138,8 @@ sendLiquid = async ({ user, address, memo, tx, limit }) => {
let signed = await lq.signRawTransactionWithWallet(blinded);
let txid = await lq.sendRawTransaction(signed.hex);
+ l.info("sent liquid tx", txid, address);
+
let main;
for (let i = 0; i < assets.length; i++) {
p = payments[i];
@@ -150,12 +164,7 @@ module.exports = ah(async (req, res) => {
let { user } = req;
try {
- let { address, feeRate, memo, tx } = req.body;
-
- if (!tx) {
- ({ tx } = await liquidTx({ ...req.body, user }));
- }
- res.send(await sendLiquid({ user, address, memo, tx }));
+ res.send(await sendLiquid({...req.body, user }));
} catch (e) {
l.error("problem sending liquid", user.username, e.message);
return res.status(500).send(e);