Merge branch 'master' into nymkappa/bugfix/channel-map-rendering
This commit is contained in:
		
						commit
						73285ae776
					
				| @ -1,6 +1,5 @@ | |||||||
| import { CpfpInfo, TransactionExtended, TransactionStripped } from '../mempool.interfaces'; | import { CpfpInfo, TransactionExtended, TransactionStripped } from '../mempool.interfaces'; | ||||||
| import config from '../config'; | import config from '../config'; | ||||||
| import { convertChannelId } from './lightning/clightning/clightning-convert'; |  | ||||||
| export class Common { | export class Common { | ||||||
|   static nativeAssetId = config.MEMPOOL.NETWORK === 'liquidtestnet' ? |   static nativeAssetId = config.MEMPOOL.NETWORK === 'liquidtestnet' ? | ||||||
|     '144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49' |     '144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49' | ||||||
| @ -193,16 +192,20 @@ export class Common { | |||||||
|     date.setUTCMilliseconds(0); |     date.setUTCMilliseconds(0); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   static channelShortIdToIntegerId(id: string): string { |   static channelShortIdToIntegerId(channelId: string): string { | ||||||
|     if (config.LIGHTNING.BACKEND === 'lnd') { |     if (channelId.indexOf('x') === -1) { // Already an integer id
 | ||||||
|       return id; |       return channelId; | ||||||
|     } |     } | ||||||
|     return convertChannelId(id); |     if (channelId.indexOf('/') !== -1) { // Topology import
 | ||||||
|  |       channelId = channelId.slice(0, -2); | ||||||
|  |     } | ||||||
|  |     const s = channelId.split('x').map(part => BigInt(part)); | ||||||
|  |     return ((s[0] << 40n) | (s[1] << 16n) | s[2]).toString(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /** Decodes a channel id returned by lnd as uint64 to a short channel id */ |   /** Decodes a channel id returned by lnd as uint64 to a short channel id */ | ||||||
|   static channelIntegerIdToShortId(id: string): string { |   static channelIntegerIdToShortId(id: string): string { | ||||||
|     if (config.LIGHTNING.BACKEND === 'cln') { |     if (id.indexOf('x') !== -1) { // Already a short id
 | ||||||
|       return id; |       return id; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -448,7 +448,7 @@ class ChannelsApi { | |||||||
|       const result = await DB.query<ResultSetHeader>(` |       const result = await DB.query<ResultSetHeader>(` | ||||||
|         UPDATE channels |         UPDATE channels | ||||||
|         SET status = 0 |         SET status = 0 | ||||||
|         WHERE short_id NOT IN ( |         WHERE id NOT IN ( | ||||||
|           ${graphChannelsIds.map(id => `"${id}"`).join(',')} |           ${graphChannelsIds.map(id => `"${id}"`).join(',')} | ||||||
|         ) |         ) | ||||||
|         AND status != 2 |         AND status != 2 | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { ILightningApi } from '../lightning-api.interface'; | import { ILightningApi } from '../lightning-api.interface'; | ||||||
| import FundingTxFetcher from '../../../tasks/lightning/sync-tasks/funding-tx-fetcher'; | import FundingTxFetcher from '../../../tasks/lightning/sync-tasks/funding-tx-fetcher'; | ||||||
| import logger from '../../../logger'; | import logger from '../../../logger'; | ||||||
|  | import { Common } from '../../common'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Convert a clightning "listnode" entry to a lnd node entry |  * Convert a clightning "listnode" entry to a lnd node entry | ||||||
| @ -70,14 +71,6 @@ export async function convertAndmergeBidirectionalChannels(clChannels: any[]): P | |||||||
|   return consolidatedChannelList; |   return consolidatedChannelList; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function convertChannelId(channelId): string { |  | ||||||
|   if (channelId.indexOf('/') !== -1) { |  | ||||||
|     channelId = channelId.slice(0, -2); |  | ||||||
|   } |  | ||||||
|   const s = channelId.split('x').map(part => BigInt(part)); |  | ||||||
|   return ((s[0] << 40n) | (s[1] << 16n) | s[2]).toString(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /** | /** | ||||||
|  * Convert two clightning "getchannels" entries into a full a lnd "describegraph.edges" format |  * Convert two clightning "getchannels" entries into a full a lnd "describegraph.edges" format | ||||||
|  * In this case, clightning knows the channel policy for both nodes |  * In this case, clightning knows the channel policy for both nodes | ||||||
| @ -90,7 +83,7 @@ async function buildFullChannel(clChannelA: any, clChannelB: any): Promise<ILigh | |||||||
|   const outputIdx = parts[2]; |   const outputIdx = parts[2]; | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     channel_id: clChannelA.short_channel_id, |     channel_id: Common.channelShortIdToIntegerId(clChannelA.short_channel_id), | ||||||
|     capacity: clChannelA.satoshis, |     capacity: clChannelA.satoshis, | ||||||
|     last_update: lastUpdate, |     last_update: lastUpdate, | ||||||
|     node1_policy: convertPolicy(clChannelA), |     node1_policy: convertPolicy(clChannelA), | ||||||
| @ -111,7 +104,7 @@ async function buildIncompleteChannel(clChannel: any): Promise<ILightningApi.Cha | |||||||
|   const outputIdx = parts[2]; |   const outputIdx = parts[2]; | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     channel_id: clChannel.short_channel_id, |     channel_id: Common.channelShortIdToIntegerId(clChannel.short_channel_id), | ||||||
|     capacity: clChannel.satoshis, |     capacity: clChannel.satoshis, | ||||||
|     last_update: clChannel.last_update ?? 0, |     last_update: clChannel.last_update ?? 0, | ||||||
|     node1_policy: convertPolicy(clChannel), |     node1_policy: convertPolicy(clChannel), | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user