aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-10-10 18:47:11 +0000
committerAdam Soltys <[email protected]>2022-10-10 18:47:11 +0000
commit78394a6b57d7686b23024607e4282e8bd6516759 (patch)
tree823f6fbcc9fbb193c1c49c1b4d80c903c9c4854d
parent5154c74ddb9b70759343400e0122e8905b68ef15 (diff)
downloadcoinos-server-78394a6b57d7686b23024607e4282e8bd6516759.tar.gz
coinos-server-78394a6b57d7686b23024607e4282e8bd6516759.zip
fix liquid send
-rw-r--r--routes/invoices.js32
-rw-r--r--routes/liquid/send.js8
2 files changed, 24 insertions, 16 deletions
diff --git a/routes/invoices.js b/routes/invoices.js
index 512679db..3a7f16b5 100644
--- a/routes/invoices.js
+++ b/routes/invoices.js
@@ -13,13 +13,13 @@ app.get("/invoice", async (req, res, next) => {
try {
const invoice = await db.Invoice.findOne({
where: {
- uuid: req.query.uuid
+ uuid: req.query.uuid,
},
include: {
model: db.User,
as: "user",
- attributes: ["username", "currency"]
- }
+ attributes: ["username", "currency"],
+ },
});
res.send(invoice);
@@ -38,7 +38,7 @@ app.get("/invoice/:text", async (req, res, next) => {
: text.startsWith("ln")
? { text }
: {
- [Op.or]: [{ unconfidential: text }, { address: text }]
+ [Op.or]: [{ unconfidential: text }, { address: text }],
};
const invoice = await db.Invoice.findOne({
@@ -46,8 +46,8 @@ app.get("/invoice/:text", async (req, res, next) => {
include: {
model: db.User,
as: "user",
- attributes: ["username", "currency"]
- }
+ attributes: ["username", "currency"],
+ },
});
res.send(invoice);
@@ -71,12 +71,12 @@ app.post("/invoice", optionalAuth, async (req, res, next) => {
else {
user = await db.User.findOne({
where: {
- username: user.username
+ username: user.username,
},
include: {
model: db.Account,
- as: "account"
- }
+ as: "account",
+ },
});
}
if (!user) throw new Error("user not provided");
@@ -111,7 +111,7 @@ app.post("/invoice", optionalAuth, async (req, res, next) => {
rate,
tip,
unconfidential,
- user_id: user.id
+ user_id: user.id,
};
if (network === "lightning") {
@@ -121,8 +121,16 @@ app.post("/invoice", optionalAuth, async (req, res, next) => {
}
if (liquidAddress) {
- l("conversion request for", liquidAddress, invoice.text);
- store.convert[invoice.text] = { address: liquidAddress, tx };
+ if (network === "lightning") {
+ l("conversion request for", liquidAddress, invoice.text);
+ store.convert[invoice.text] = { address: liquidAddress, tx };
+ } else if (network === "liquid") {
+ l("conversion request for", liquidAddress, invoice.unconfidential);
+ store.convert[invoice.unconfidential] = { address: liquidAddress, tx };
+ } else {
+ l("conversion request for", liquidAddress, invoice.address);
+ store.convert[invoice.address] = { address: liquidAddress, tx };
+ }
}
l(
diff --git a/routes/liquid/send.js b/routes/liquid/send.js
index 2fa7a22a..d7a7c7b4 100644
--- a/routes/liquid/send.js
+++ b/routes/liquid/send.js
@@ -44,16 +44,16 @@ export const sendLiquid = async ({ asset, amount, user, address, memo, tx, limit
let {
asset,
value,
- scriptPubKey: { type, addresses }
+ scriptPubKey
} = vout[i];
- if (type === "fee") fee = toSats(value);
+ if (scriptPubKey.type === "fee") fee = toSats(value);
else {
if (!totals[asset]) totals[asset] = change[asset] = 0;
totals[asset] += toSats(value);
- if (addresses) {
- if (await isChange(addresses[0])) {
+ if (scriptPubKey.address) {
+ if (await isChange(scriptPubKey.address)) {
change[asset] += toSats(value);
}
}