mirror of
https://github.com/mempool/mempool.git
synced 2026-08-13 12:33:11 +02:00
Merge pull request #6157 from mempool/mononaut/fix-ln-split-bug
fix ln undefined .split error
This commit is contained in:
commit
dfe9b5d4e5
8 changed files with 34 additions and 9 deletions
|
|
@ -241,7 +241,7 @@ export class Common {
|
|||
return true;
|
||||
}
|
||||
// scriptsig-not-pushonly
|
||||
if (vin.scriptsig_asm) {
|
||||
if (vin.scriptsig_asm?.length) {
|
||||
for (const op of vin.scriptsig_asm.split(' ')) {
|
||||
if (opcodes[op] && opcodes[op] > opcodes['OP_16']) {
|
||||
return true;
|
||||
|
|
@ -508,7 +508,7 @@ export class Common {
|
|||
}
|
||||
|
||||
static setLegacySighashFlags(flags: bigint, scriptsig_asm: string): bigint {
|
||||
for (const item of scriptsig_asm.split(' ')) {
|
||||
for (const item of scriptsig_asm?.split(' ') ?? []) {
|
||||
// skip op_codes
|
||||
if (item.startsWith('OP_')) {
|
||||
continue;
|
||||
|
|
@ -933,6 +933,13 @@ export class Common {
|
|||
}
|
||||
|
||||
static findSocketNetwork(addr: string): {network: string | null, url: string} {
|
||||
if (!addr?.length) {
|
||||
return {
|
||||
network: null,
|
||||
url: ''
|
||||
};
|
||||
}
|
||||
|
||||
let network: string | null = null;
|
||||
let url: string = addr;
|
||||
|
||||
|
|
@ -940,7 +947,7 @@ export class Common {
|
|||
url = addr.split('://')[1];
|
||||
}
|
||||
|
||||
if (!url) {
|
||||
if (!url?.length) {
|
||||
return {
|
||||
network: null,
|
||||
url: addr,
|
||||
|
|
@ -966,7 +973,15 @@ export class Common {
|
|||
};
|
||||
}
|
||||
} else if (addr.indexOf('ipv6') !== -1 || (config.LIGHTNING.BACKEND === 'lnd' && url.indexOf(']:'))) {
|
||||
url = url.split('[')[1].split(']')[0];
|
||||
const parts = url.split('[');
|
||||
if (parts.length < 2) {
|
||||
return {
|
||||
network: null,
|
||||
url: addr,
|
||||
};
|
||||
} else {
|
||||
url = parts[1].split(']')[0];
|
||||
}
|
||||
const ipv = isIP(url);
|
||||
if (ipv === 6) {
|
||||
const parts = addr.split(':');
|
||||
|
|
|
|||
|
|
@ -580,6 +580,9 @@ class ChannelsApi {
|
|||
* Save or update a channel present in the graph
|
||||
*/
|
||||
public async $saveChannel(channel: ILightningApi.Channel, status = 1): Promise<void> {
|
||||
if (!channel.chan_point?.length) {
|
||||
return;
|
||||
}
|
||||
const [ txid, vout ] = channel.chan_point.split(':');
|
||||
|
||||
const policy1: Partial<ILightningApi.RoutingPolicy> = channel.node1_policy || {};
|
||||
|
|
|
|||
|
|
@ -354,7 +354,7 @@ class NodesRoutes {
|
|||
return;
|
||||
}
|
||||
|
||||
const nodes = await nodesApi.$getNodesPerISP(req.params.isp);
|
||||
const nodes = await nodesApi.$getNodesPerISP(req.params.isp || '');
|
||||
res.header('Pragma', 'public');
|
||||
res.header('Cache-control', 'public');
|
||||
res.setHeader('Expires', new Date(Date.now() + 1000 * 60).toUTCString());
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ class TransactionUtils {
|
|||
return;
|
||||
}
|
||||
|
||||
if (vin.prevout.scriptpubkey_type === 'p2sh') {
|
||||
if (vin.prevout.scriptpubkey_type === 'p2sh' && vin.scriptsig_asm?.length) {
|
||||
const redeemScript = vin.scriptsig_asm.split(' ').reverse()[0];
|
||||
vin.inner_redeemscript_asm = this.convertScriptSigAsm(redeemScript);
|
||||
if (vin.witness && vin.witness.length > 2) {
|
||||
|
|
|
|||
|
|
@ -74,11 +74,15 @@ class FundingTxFetcher {
|
|||
public async $fetchChannelOpenTx(channelId: string): Promise<{timestamp: number, txid: string, value: number} | null> {
|
||||
channelId = Common.channelIntegerIdToShortId(channelId);
|
||||
|
||||
if (!channelId?.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (this.fundingTxCache[channelId]) {
|
||||
return this.fundingTxCache[channelId];
|
||||
}
|
||||
|
||||
const parts = channelId.split('x');
|
||||
const parts = channelId?.split('x') ?? [];
|
||||
if (parts.length < 3) {
|
||||
logger.debug(`Channel ID ${channelId} does not seem valid, should contains at least 3 parts separated by 'x'`, logger.tags.ln);
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export async function $lookupNodeLocation(): Promise<void> {
|
|||
} catch (e) { }
|
||||
|
||||
for (const node of nodes) {
|
||||
const sockets: string[] = node.sockets.split(',');
|
||||
const sockets: string[] = node.sockets?.split(',') ?? [];
|
||||
for (const socket of sockets) {
|
||||
const ip = socket.substring(0, socket.lastIndexOf(':')).replace('[', '').replace(']', '');
|
||||
const hasClearnet = [4, 6].includes(net.isIP(ip));
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ class LightningStatsImporter {
|
|||
|
||||
for (const channel of networkGraph.edges) {
|
||||
const short_id = Common.channelIntegerIdToShortId(channel.channel_id);
|
||||
if (!short_id?.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const tx = await fundingTxFetcher.$fetchChannelOpenTx(short_id);
|
||||
if (!tx) {
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ export { opcodes };
|
|||
|
||||
/** extracts m and n from a multisig script (asm), returns nothing if it is not a multisig script */
|
||||
export function parseMultisigScript(script: string): void | { m: number, n: number } {
|
||||
if (!script) {
|
||||
if (!script?.length) {
|
||||
return;
|
||||
}
|
||||
const ops = script.split(' ');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue