Skip to content

Commit 2bf3fa0

Browse files
authored
Merge pull request #176 from Ride-The-Lightning/Release-v0.10.3
Release v0.10.3
2 parents 342dda4 + b5a44d6 commit 2bf3fa0

File tree

14 files changed

+305
-124
lines changed

14 files changed

+305
-124
lines changed

controllers/channel.js

Lines changed: 242 additions & 75 deletions
Large diffs are not rendered by default.

controllers/getBalance.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { isVersionCompatible } = require('../utils/utils');
12
//This controller houses the on-chain balance functions
23

34
//Function # 1
@@ -41,12 +42,14 @@ exports.getBalance = (req,res) => {
4142
var confBalance = 0;
4243
var unconfBalance = 0;
4344
var totalBalance = 0;
45+
const versionCompatible = global.version && isVersionCompatible(global.version, '23.02');
46+
4447
for (var i = 0; i < opArray.length; i++ )
4548
{
4649
if(opArray[i].status === 'confirmed')
47-
confBalance = confBalance + opArray[i].value;
50+
confBalance = confBalance + (versionCompatible ? (opArray[i].amount_msat/1000) : opArray[i].value);
4851
else if(opArray[i].status === 'unconfirmed')
49-
unconfBalance = unconfBalance + opArray[i].value;
52+
unconfBalance = unconfBalance + (versionCompatible ? (opArray[i].amount_msat/1000) : opArray[i].value);
5053
}
5154
totalBalance = confBalance + unconfBalance;
5255
const walBalance = {

controllers/getFees.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { isVersionCompatible } = require('../utils/utils');
12
//This controller houses all the fee functions
23

34
//Function # 1
@@ -28,11 +29,11 @@
2829
exports.getFees = (req,res) => {
2930
function connFailed(err) { throw err }
3031
ln.on('error', connFailed);
32+
const versionCompatible = global.version && isVersionCompatible(global.version, '23.02');
3133

3234
//Call the getinfo command
3335
ln.getinfo().then(data => {
34-
const feeData = {
35-
feeCollected: data.msatoshi_fees_collected};
36+
const feeData = { feeCollected: (versionCompatible ? data.fees_collected_msat : data.msatoshi_fees_collected) };
3637
global.logger.log('getFees success');
3738
res.status(200).json(feeData);
3839
}).catch(err => {

controllers/getinfo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ exports.getinfoRtl = (req,res) => {
113113
* type: string
114114
* description: msatoshi_fees_collected
115115
* fees_collected_msat:
116-
* type: string
116+
* type: number
117117
* description: fees_collected_msat
118118
* api_version:
119119
* type: string

controllers/invoice.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ exports.genInvoice = (req,res) => {
134134
* type: integer
135135
* description: msatoshi
136136
* amount_msat:
137-
* type: string
137+
* type: number
138138
* description: amount_msat
139139
* status:
140140
* type: string
@@ -146,7 +146,7 @@ exports.genInvoice = (req,res) => {
146146
* type: integer
147147
* description: msatoshi_received
148148
* amount_received_msat:
149-
* type: string
149+
* type: number
150150
* description: amount_received_msat
151151
* paid_at:
152152
* type: integer
@@ -335,7 +335,7 @@ exports.delInvoice = (req,res) => {
335335
* type: string
336336
* description: UNIX timestamp of when it will become / became unpayable
337337
* amount_msat:
338-
* type: string
338+
* type: number
339339
* description: the amount required to pay this invoice
340340
* bolt11:
341341
* type: string
@@ -347,7 +347,7 @@ exports.delInvoice = (req,res) => {
347347
* type: string
348348
* description: If status is "paid", unique incrementing index for this payment
349349
* amount_received_msat:
350-
* type: string
350+
* type: number
351351
* description: If status is "paid", the amount actually received
352352
* paid_at:
353353
* type: string
@@ -419,7 +419,7 @@ exports.waitInvoice = (req,res) => {
419419
* type: string
420420
* description: UNIX timestamp of when it will become / became unpayable
421421
* amount_msat:
422-
* type: string
422+
* type: number
423423
* description: the amount required to pay this invoice
424424
* bolt11:
425425
* type: string
@@ -431,7 +431,7 @@ exports.waitInvoice = (req,res) => {
431431
* type: string
432432
* description: If status is "paid", unique incrementing index for this payment
433433
* amount_received_msat:
434-
* type: string
434+
* type: number
435435
* description: If status is "paid", the amount actually received
436436
* paid_at:
437437
* type: string

controllers/listfunds.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* type: integer
3333
* description: value
3434
* amount_msat:
35-
* type: string
35+
* type: number
3636
* description: amount_msat
3737
* address:
3838
* type: string
@@ -63,13 +63,13 @@
6363
* type: integer
6464
* description: channel_sat
6565
* our_amount_msat:
66-
* type: string
66+
* type: number
6767
* description: our_amount_msat
6868
* channel_total_sat:
6969
* type: integer
7070
* description: channel_total_sat
7171
* amount_msat:
72-
* type: string
72+
* type: number
7373
* description: amount_msat
7474
* funding_txid:
7575
* type: string

controllers/localRemoteBal.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { isVersionCompatible } = require('../utils/utils');
12
//This controller houses the local-remote channel balance functions
23

34
//Function # 1
@@ -45,17 +46,19 @@ exports.localRemoteBal = (req,res) => {
4546
var remoteBalance = 0;
4647
var pendingBalance = 0;
4748
var inactiveBalance = 0;
49+
const versionCompatible = global.version && isVersionCompatible(global.version, '23.02');
50+
4851
for (var i = 0; i < chanArray.length; i++ )
4952
{
50-
if((chanArray[i].state === 'CHANNELD_NORMAL') && chanArray[i].connected === true){
51-
localBalance = localBalance + chanArray[i].channel_sat;
52-
remoteBalance = remoteBalance + (chanArray[i].channel_total_sat - chanArray[i].channel_sat);
53+
if((chanArray[i].state === 'CHANNELD_NORMAL') && chanArray[i].connected === true) {
54+
localBalance = localBalance + (versionCompatible ? (chanArray[i].our_amount_msat/1000) : chanArray[i].channel_sat);
55+
remoteBalance = remoteBalance + (versionCompatible ? (chanArray[i].amount_msat/1000) : (chanArray[i].channel_total_sat - chanArray[i].channel_sat));
5356
}
5457
else if((chanArray[i].state === 'CHANNELD_NORMAL') && chanArray[i].connected === false) {
55-
inactiveBalance = inactiveBalance + chanArray[i].channel_sat;
58+
inactiveBalance = inactiveBalance + (versionCompatible ? (chanArray[i].our_amount_msat/1000) : chanArray[i].channel_sat);
5659
}
5760
else if(chanArray[i].state === 'CHANNELD_AWAITING_LOCKIN') {
58-
pendingBalance = pendingBalance + chanArray[i].channel_sat;
61+
pendingBalance = pendingBalance + (versionCompatible ? (chanArray[i].our_amount_msat/1000) : chanArray[i].channel_sat);
5962
}
6063
}
6164
global.logger.log('localbalance -> ' + localBalance);

controllers/network.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var wsServer = require('../utils/webSocketServer');
4747
* type: integer
4848
* description: msatoshi
4949
* amount_msat:
50-
* type: string
50+
* type: number
5151
* description: amount_msat
5252
* delay:
5353
* type: integer
@@ -222,7 +222,7 @@ exports.listNode = (req,res) => {
222222
* type: integer
223223
* description: satoshis
224224
* amount_msat:
225-
* type: string
225+
* type: number
226226
* description: amount_msat
227227
* message_flags:
228228
* type: integer
@@ -246,10 +246,10 @@ exports.listNode = (req,res) => {
246246
* type: integer
247247
* description: delay
248248
* htlc_minimum_msat:
249-
* type: string
249+
* type: number
250250
* description: htlc_minimum_msat
251251
* htlc_maximum_msat:
252-
* type: string
252+
* type: number
253253
* description: htlc_maximum_msat
254254
* 500:
255255
* description: Server error
@@ -465,7 +465,7 @@ exports.estimateFees = (req,res) => {
465465
* type: object
466466
* properties:
467467
* lease_fee_base_msat:
468-
* type: string
468+
* type: number
469469
* description: lease_fee_base_msat
470470
* lease_fee_basis:
471471
* type: string
@@ -474,7 +474,7 @@ exports.estimateFees = (req,res) => {
474474
* type: string
475475
* description: funding_weight
476476
* channel_fee_max_base_msat:
477-
* type: string
477+
* type: number
478478
* description: channel_fee_max_base_msat
479479
* channel_fee_max_proportional_thousandths:
480480
* type: string

controllers/offers.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
1-
const isVersionCompatible = (currentVersion, checkVersion) => {
2-
if (currentVersion) {
3-
const versionsArr = currentVersion.trim()?.replace('v', '').split('-')[0].split('.') || [];
4-
const checkVersionsArr = checkVersion.split('.');
5-
return (+versionsArr[0] > +checkVersionsArr[0]) ||
6-
(+versionsArr[0] === +checkVersionsArr[0] && +versionsArr[1] > +checkVersionsArr[1]) ||
7-
(+versionsArr[0] === +checkVersionsArr[0] && +versionsArr[1] === +checkVersionsArr[1] && +versionsArr[2] >= +checkVersionsArr[2]);
8-
}
9-
return false;
10-
};
11-
12-
//This controller houses all the offers functions
1+
const { isVersionCompatible } = require('../utils/utils');
2+
//This controller houses all the offers functions
133

144
//Function # 1
155
//Invoke the 'offer' command to setup an offer
@@ -77,7 +67,7 @@ const isVersionCompatible = (currentVersion, checkVersion) => {
7767
* - in: body
7868
* name: single_use
7969
* description: Indicates that the offer is only valid once
80-
* type: boolean
70+
* type: string
8171
* security:
8272
* - MacaroonAuth: []
8373
* responses:

controllers/payments.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ var wsServer = require('../utils/webSocketServer');
8686
* type: integer
8787
* description: msatoshi
8888
* amount_msat:
89-
* type: string
89+
* type: number
9090
* description: amount_msat
9191
* msatoshi_sent:
9292
* type: integer
9393
* description: msatoshi_sent
9494
* amount_sent_msat:
95-
* type: string
95+
* type: number
9696
* description: amount_sent_msat
9797
* created_at:
9898
* type: integer
@@ -206,7 +206,7 @@ exports.payInvoice = (req,res) => {
206206
* type: string
207207
* description: preimage
208208
* amount_sent_msat:
209-
* type: string
209+
* type: number
210210
* description: amount_sent_msat
211211
* description: pays
212212
* 500:
@@ -284,13 +284,13 @@ exports.listPays = (req,res) => {
284284
* type: integer
285285
* description: msatoshi
286286
* amount_msat:
287-
* type: string
287+
* type: number
288288
* description: amount_msat
289289
* msatoshi_sent:
290290
* type: integer
291291
* description: msatoshi_sent
292292
* amount_sent_msat:
293-
* type: string
293+
* type: number
294294
* description: amount_sent_msat
295295
* created_at:
296296
* type: integer
@@ -509,13 +509,13 @@ exports.decodePay = (req,res) => {
509509
* type: integer
510510
* description: msatoshi
511511
* amount_msat:
512-
* type: string
512+
* type: number
513513
* description: amount_msat
514514
* msatoshi_sent:
515515
* type: integer
516516
* description: msatoshi_sent
517517
* amount_sent_msat:
518-
* type: string
518+
* type: number
519519
* description: amount_sent_msat
520520
* payment_preimage:
521521
* type: string
@@ -650,13 +650,13 @@ getMemoForPayment = (payment) => {
650650
* type: integer
651651
* description: msatoshi
652652
* amount_msat:
653-
* type: string
653+
* type: number
654654
* description: amount_msat
655655
* msatoshi_sent:
656656
* type: integer
657657
* description: msatoshi_sent
658658
* amount_sent_msat:
659-
* type: string
659+
* type: number
660660
* description: amount_sent_msat
661661
* created_at:
662662
* type: integer

0 commit comments

Comments
 (0)