Lightning Service Provider (LSP) Specification
The BLGV LSP follows industry standards while providing enhanced services for enterprise Lightning Network integration.
โก LSP Overviewโ
Service Categoriesโ
- Channel Management: Automated channel opening and liquidity provision
- Payment Routing: Optimized payment path finding and forwarding
- Liquidity Services: Just-in-time liquidity for payments
- Node Management: Hosted Lightning node services
BLGV LSP Featuresโ
interface LSPService {
channelOpening: ChannelOpeningService;
liquidityProvision: LiquidityService;
paymentRouting: RoutingService;
nodeHosting: HostedNodeService;
monitoring: MonitoringService;
}
๐ง Channel Opening Serviceโ
Automated Channel Creationโ
interface ChannelRequest {
clientPubkey: string;
channelSize: number;
pushAmount?: number;
feeRate?: number;
isPrivate?: boolean;
}
class LSPChannelService {
async openChannel(request: ChannelRequest): Promise<ChannelResponse> {
// Validate client requirements
const validation = await this.validateChannelRequest(request);
if (!validation.valid) {
throw new Error(validation.error);
}
// Open channel with appropriate parameters
const channel = await this.lightning.openChannel({
nodePubkey: request.clientPubkey,
localFundingAmount: request.channelSize,
pushSat: request.pushAmount || 0,
private: request.isPrivate || false,
satPerByte: request.feeRate || this.getOptimalFeeRate()
});
return {
channelId: channel.channelId,
fundingTxid: channel.fundingTxid,
capacity: request.channelSize,
status: 'pending',
estimatedConfirmation: this.estimateConfirmationTime(request.feeRate)
};
}
}
๐ง Liquidity Servicesโ
Just-in-Time Liquidityโ
interface LiquidityRequest {
amount: number;
duration: number; // milliseconds
maxFeeRate: number; // ppm
}
class JITLiquidityService {
async provideLiquidity(request: LiquidityRequest): Promise<LiquidityResponse> {
// Check available liquidity
const availableLiquidity = await this.getAvailableLiquidity();
if (availableLiquidity < request.amount) {
// Request liquidity from other LSPs or exchanges
await this.requestExternalLiquidity(request.amount);
}
// Allocate liquidity for specified duration
const allocation = await this.allocateLiquidity({
amount: request.amount,
duration: request.duration,
reservationId: this.generateReservationId()
});
return {
allocated: true,
reservationId: allocation.reservationId,
expiresAt: Date.now() + request.duration,
feeRate: this.calculateLiquidityFee(request)
};
}
}
๐๏ธ Node Hosting Servicesโ
Hosted Lightning Nodesโ
interface HostedNodeConfig {
alias: string;
color: string;
features: NodeFeatures;
channels: ChannelConfig[];
autopilot: AutopilotConfig;
}
class HostedNodeService {
async createHostedNode(config: HostedNodeConfig): Promise<HostedNode> {
// Create isolated Lightning node instance
const nodeInstance = await this.nodeOrchestrator.createNode({
alias: config.alias,
color: config.color,
features: config.features
});
// Configure initial channels
for (const channelConfig of config.channels) {
await this.openInitialChannel(nodeInstance, channelConfig);
}
// Enable autopilot if requested
if (config.autopilot.enabled) {
await this.enableAutopilot(nodeInstance, config.autopilot);
}
return {
nodeId: nodeInstance.nodeId,
pubkey: nodeInstance.pubkey,
endpoint: `https://lsp.blgvbtc.com/nodes/${nodeInstance.nodeId}`,
macaroon: await this.generateClientMacaroon(nodeInstance),
tlsCert: nodeInstance.tlsCert
};
}
}
๐ Monitoring & Analyticsโ
Real-time Node Monitoringโ
interface NodeMetrics {
channelCount: number;
totalCapacity: number;
routingRevenue: number;
successRate: number;
uptime: number;
forwardingEvents: ForwardingEvent[];
}
class LSPMonitoringService {
async getNodeMetrics(nodeId: string): Promise<NodeMetrics> {
const node = await this.getHostedNode(nodeId);
const channels = await node.listChannels();
const payments = await node.listPayments();
const forwards = await node.getForwardingHistory();
return {
channelCount: channels.length,
totalCapacity: channels.reduce((sum, ch) => sum + ch.capacity, 0),
routingRevenue: forwards.reduce((sum, fwd) => sum + fwd.fee, 0),
successRate: this.calculateSuccessRate(payments),
uptime: await this.calculateUptime(node),
forwardingEvents: forwards
};
}
}
๐ Authentication & Securityโ
LSP API Authenticationโ
interface LSPCredentials {
apiKey: string;
signature: string;
timestamp: number;
nonce: string;
}
class LSPAuthService {
async authenticateRequest(credentials: LSPCredentials): Promise<boolean> {
// Verify timestamp is recent (within 5 minutes)
const now = Date.now();
if (Math.abs(now - credentials.timestamp) > 300000) {
return false;
}
// Verify signature
const message = `${credentials.timestamp}${credentials.nonce}`;
const expectedSignature = this.generateHMAC(message, credentials.apiKey);
return credentials.signature === expectedSignature;
}
}
๐ฐ Fee Structureโ
LSP Pricing Modelโ
interface LSPFees {
channelOpening: {
baseFee: number; // Fixed fee per channel
capacityFee: number; // Fee per satoshi capacity
};
liquidity: {
reservationFee: number; // Fee for liquidity reservation
utilizationFee: number; // Fee based on actual usage
};
routing: {
baseFee: number; // Base routing fee
feeRate: number; // Fee rate per payment
};
hosting: {
monthlyFee: number; // Monthly hosting fee
transactionFee: number; // Per-transaction fee
};
}
const blgvLSPFees: LSPFees = {
channelOpening: {
baseFee: 1000, // 1000 sats base fee
capacityFee: 0.001 // 0.1% of capacity
},
liquidity: {
reservationFee: 100, // 100 sats per reservation
utilizationFee: 500 // 500 ppm utilization
},
routing: {
baseFee: 1000, // 1000 msat base fee
feeRate: 100 // 100 ppm
},
hosting: {
monthlyFee: 50000, // 50k sats per month
transactionFee: 100 // 100 sats per transaction
}
};
๐ Integration Examplesโ
Mobile Wallet Integrationโ
import { LSPClient } from '@blgv/lsp-client';
const lspClient = new LSPClient({
endpoint: 'https://lsp.blgvbtc.com',
apiKey: 'your-api-key'
});
// Request channel for mobile wallet
const channelRequest = await lspClient.requestChannel({
clientPubkey: mobileWallet.pubkey,
channelSize: 1000000, // 0.01 BTC
pushAmount: 100000 // 0.001 BTC pushed to client
});
// Monitor channel status
const channelStatus = await lspClient.getChannelStatus(channelRequest.channelId);
Exchange Integrationโ
// Request just-in-time liquidity for large payment
const liquidityRequest = await lspClient.requestLiquidity({
amount: 10000000, // 0.1 BTC
duration: 3600000, // 1 hour
maxFeeRate: 1000 // 1000 ppm max fee
});
// Execute payment with reserved liquidity
const payment = await lspClient.sendPayment({
invoice: lightningInvoice,
reservationId: liquidityRequest.reservationId
});
Need help? Check our Lightning LSP Platform or Lightning Protocol documentation.