aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-01-31 15:14:13 -0800
committerAdam Soltys <[email protected]>2024-01-31 15:14:13 -0800
commit77ee281bbd518758030b60f122eeb65def4cd17d (patch)
tree546869ab9f1fd17c6f8682eb06763ad6837b3e71 /doc
parent1e91f135e8f7164ee4eb9dffc3bfca94cc2e87ec (diff)
downloadcoinos-ui-77ee281bbd518758030b60f122eeb65def4cd17d.tar.gz
coinos-ui-77ee281bbd518758030b60f122eeb65def4cd17d.zip
pass options param with invoice buttons
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions
='/coinos-server.git/blame/routes/liquid/broadcast.js?h=conversions&id=d03dad4d85ccd107068719c4b68cbd6a255864f6'>^
7ab3036c ^
d01159ce ^




7ab3036c ^
d01159ce ^





7ab3036c ^
60ffe18e ^
7ab3036c ^

d1cc66d1 ^
8a82c694 ^
7ab3036c ^
3161dd7e ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
                               
                                    




                                                        
















                                                 
                                             






                                    
 




                                                    
 





                                                        
            
                     

               
                                                      
                                  
   
  
import store from "$lib/store";
export default async (req, res) => {
  try {
    const { user } = req;
    let hash = await lq.sendRawTransaction(req.body.tx);

    if (user) {
      await db.transaction(async transaction => {
        let account = await db.Account.findOne({
          where: {
            id: user.account_id
          },
          lock: transaction.LOCK.UPDATE,
          transaction
        });

        let payment = await db.Payment.create(
          {
            ...req.body.payment,
            hash,
            amount: -req.body.payment.amount,
            tip: 0,
            account_id: account.id,
            user_id: user.id,
            rate: store.rates[user.currency],
            currency: user.currency,
            confirmed: true,
            received: false,
            network: "liquid"
          },
          { transaction }
        );

        await account.increment(
          { balance: payment.amount - payment.fee },
          { transaction }
        );
        await account.reload({ transaction });

        payment = payment.get({ plain: true });
        payment.account = account.get({ plain: true });
        emit(user.username, "payment", payment);
        emit(user.username, "account", payment.account);
        res.send(payment);
      });
    } else {
      res.send(hash);
    }
  } catch (e) {
    err("problem broadcasting liquid transaction", e);
    res.code(500).send(e.message);
  }
};