mirror of
https://github.com/Ride-The-Lightning/RTL.git
synced 2026-08-13 12:33:07 +02:00
msatoshi migration without backward compatibility
msatoshi migration without backward compatibility
This commit is contained in:
parent
40173091e9
commit
1fcad6306f
85 changed files with 1679 additions and 1304 deletions
|
|
@ -17,8 +17,9 @@ export const listPeerChannels = (req, res, next) => {
|
|||
channel.alias = channel.peer_id.substring(0, 20);
|
||||
}
|
||||
const local = channel.to_us_msat || 0;
|
||||
const remote = (channel.total_msat - channel.to_us_msat) || 0;
|
||||
const remote = (channel.total_msat - local) || 0;
|
||||
const total = channel.total_msat || 0;
|
||||
channel.to_them_msat = remote;
|
||||
channel.balancedness = (total === 0) ? 1 : (1 - Math.abs((local - remote) / total)).toFixed(3);
|
||||
return channel;
|
||||
});
|
||||
|
|
@ -35,20 +36,16 @@ export const listChannels = (req, res, next) => {
|
|||
if (options.error) {
|
||||
return res.status(options.statusCode).json({ message: options.message, error: options.error });
|
||||
}
|
||||
if (common.isVersionCompatible(req.session.selectedNode.api_version, '0.10.2')) {
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listPeerChannels';
|
||||
}
|
||||
else {
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listChannels';
|
||||
}
|
||||
options.url = req.session.selectedNode.ln_server_url + '/v1/channel/listPeerChannels';
|
||||
request(options).then((body) => {
|
||||
body?.map((channel) => {
|
||||
if (!channel.alias || channel.alias === '') {
|
||||
channel.alias = channel.id.substring(0, 20);
|
||||
}
|
||||
const local = (channel.msatoshi_to_us) ? channel.msatoshi_to_us : (channel.to_us_msat || 0);
|
||||
const remote = (channel.msatoshi_to_them) ? channel.msatoshi_to_them : ((channel.total_msat - channel.to_us_msat) || 0);
|
||||
const total = channel.msatoshi_total ? channel.msatoshi_total : (channel.total_msat || 0);
|
||||
const local = channel.to_us_msat || 0;
|
||||
const remote = (channel.total_msat - local) || 0;
|
||||
const total = channel.total_msat || 0;
|
||||
channel.to_them_msat = remote;
|
||||
channel.balancedness = (total === 0) ? 1 : (1 - Math.abs((local - remote) / total)).toFixed(3);
|
||||
return channel;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ function paymentReducer(accumulator, currentPayment) {
|
|||
}
|
||||
function summaryReducer(accumulator, mpp) {
|
||||
if (mpp.status === 'complete') {
|
||||
accumulator.msatoshi = accumulator.msatoshi + mpp.msatoshi;
|
||||
accumulator.msatoshi_sent = accumulator.msatoshi_sent + mpp.msatoshi_sent;
|
||||
accumulator.amount_msat = accumulator.amount_msat + mpp.amount_msat;
|
||||
accumulator.amount_sent_msat = accumulator.amount_sent_msat + mpp.amount_sent_msat;
|
||||
accumulator.status = mpp.status;
|
||||
}
|
||||
if (mpp.bolt11) {
|
||||
|
|
@ -47,10 +47,10 @@ function groupBy(payments) {
|
|||
delete temp.partid;
|
||||
}
|
||||
else {
|
||||
const paySummary = curr?.reduce(summaryReducer, { msatoshi: 0, msatoshi_sent: 0, status: (curr[0] && curr[0].status) ? curr[0].status : 'failed' });
|
||||
const paySummary = curr?.reduce(summaryReducer, { amount_msat: 0, amount_sent_msat: 0, status: (curr[0] && curr[0].status) ? curr[0].status : 'failed' });
|
||||
temp = {
|
||||
is_group: true, is_expanded: false, total_parts: (curr.length ? curr.length : 0), status: paySummary.status, payment_hash: curr[0].payment_hash,
|
||||
destination: curr[0].destination, msatoshi: paySummary.msatoshi, msatoshi_sent: paySummary.msatoshi_sent, created_at: curr[0].created_at,
|
||||
destination: curr[0].destination, amount_msat: paySummary.amount_msat, amount_sent_msat: paySummary.amount_sent_msat, created_at: curr[0].created_at,
|
||||
mpps: curr
|
||||
};
|
||||
if (paySummary.bolt11) {
|
||||
|
|
|
|||
|
|
@ -72,17 +72,12 @@ export class CLWebSocketClient {
|
|||
this.wsServer.sendEventsToAllLNClients(msgStr, clWsClt.selectedNode);
|
||||
};
|
||||
clWsClt.webSocketClient.onerror = (err) => {
|
||||
if (clWsClt.selectedNode.api_version === '' || !clWsClt.selectedNode.api_version || this.common.isVersionCompatible(clWsClt.selectedNode.api_version, '0.6.0')) {
|
||||
this.logger.log({ selectedNode: clWsClt.selectedNode, level: 'ERROR', fileName: 'CLWebSocket', msg: 'Web socket error', error: err });
|
||||
const errStr = ((typeof err === 'object' && err.message) ? JSON.stringify({ error: err.message }) : (typeof err === 'object') ? JSON.stringify({ error: err }) : ('{ "error": ' + err + ' }'));
|
||||
this.wsServer.sendErrorToAllLNClients(errStr, clWsClt.selectedNode);
|
||||
clWsClt.webSocketClient.close();
|
||||
if (clWsClt.reConnect) {
|
||||
this.reconnet(clWsClt);
|
||||
}
|
||||
}
|
||||
else {
|
||||
clWsClt.reConnect = false;
|
||||
this.logger.log({ selectedNode: clWsClt.selectedNode, level: 'ERROR', fileName: 'CLWebSocket', msg: 'Web socket error', error: err });
|
||||
const errStr = ((typeof err === 'object' && err.message) ? JSON.stringify({ error: err.message }) : (typeof err === 'object') ? JSON.stringify({ error: err }) : ('{ "error": ' + err + ' }'));
|
||||
this.wsServer.sendErrorToAllLNClients(errStr, clWsClt.selectedNode);
|
||||
clWsClt.webSocketClient.close();
|
||||
if (clWsClt.reConnect) {
|
||||
this.reconnet(clWsClt);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -194,19 +194,19 @@ export const circularRebalance = (req, res, next) => {
|
|||
return res.status(201).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: invoice, paymentHash: paymentHash, paymentDetails: payToRouteCallRes, paymentStatus: payStatus });
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Channel Rebalance From Sent Info Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: invoice, paymentHash: paymentHash, paymentDetails: payToRouteCallRes, paymentStatus: { message: err.message, error: err.error } });
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: invoice, paymentHash: paymentHash, paymentDetails: payToRouteCallRes, paymentStatus: err.error });
|
||||
});
|
||||
}, 3000);
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Channel Rebalance From Send Payment To Route Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: invoice, paymentHash: paymentHash, paymentDetails: {}, paymentStatus: { message: err.message, error: err.error } });
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: invoice, paymentHash: paymentHash, paymentDetails: {}, paymentStatus: err.error });
|
||||
});
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Channel Rebalance From Find Routes Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: (foundExistingInvoice.serialized || ''), paymentHash: '', paymentDetails: {}, paymentStatus: { message: err.message, error: err.error } });
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: !!foundExistingInvoice, invoice: (foundExistingInvoice.serialized || ''), paymentHash: '', paymentDetails: {}, paymentStatus: err.error });
|
||||
});
|
||||
}).catch((errRes) => {
|
||||
const err = common.handleError(errRes, 'Channels', 'Channel Rebalance From List Pending Invoices Error', req.session.selectedNode);
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: false, invoice: '', paymentHash: '', paymentDetails: {}, paymentStatus: { message: err.message, error: err.error } });
|
||||
return res.status(err.statusCode).json({ flgReusingInvoice: false, invoice: '', paymentHash: '', paymentDetails: {}, paymentStatus: err.error });
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue