Skip to content

Commit

Permalink
Add types for inbound_base_discount_mtokens and `inbound_rate_disco…
Browse files Browse the repository at this point in the history
…unt`
  • Loading branch information
bkiac committed May 9, 2024
1 parent f7fc549 commit 35c88d3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 79 deletions.
20 changes: 2 additions & 18 deletions lnd_methods/info/get_channel.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AuthenticatedLightningArgs,
AuthenticatedLightningMethod,
ChannelPolicy,
} from '../../typescript';

export type GetChannelArgs = AuthenticatedLightningArgs<{
Expand All @@ -13,24 +14,7 @@ export type GetChannelResult = {
capacity: number;
/** Standard Format Channel Id */
id: string;
policies: {
/** Base Fee Millitokens */
base_fee_mtokens?: string;
/** Locktime Delta */
cltv_delta?: number;
/** Fees Charged Per Million Millitokens */
fee_rate?: number;
/** Channel Is Disabled */
is_disabled?: boolean;
/** Maximum HTLC Millitokens Value */
max_htlc_mtokens?: string;
/** Minimum HTLC Millitokens Value */
min_htlc_mtokens?: string;
/** Node Public Key */
public_key: string;
/** Policy Last Updated At ISO 8601 Date */
updated_at?: string;
}[];
policies: ChannelPolicy[];
/** Transaction Id Hex */
transaction_id: string;
/** Transaction Output Index */
Expand Down
38 changes: 12 additions & 26 deletions lnd_methods/info/get_network_graph.d.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,29 @@
import {AuthenticatedLnd} from '../../lnd_grpc';
import {AuthenticatedLightningMethod} from '../../typescript';
import type {AuthenticatedLnd} from '../../lnd_grpc';
import type {
AuthenticatedLightningMethod,
ChannelPolicy,
} from '../../typescript';

export type GetNetworkGraphResult = {
channels: {
channels: Array<{
/** Channel Capacity Tokens */
capacity: number;
/** Standard Format Channel Id */
id: string;
policies: {
/** Base Fee Millitokens */
base_fee_mtokens?: string;
/** CLTV Height Delta */
cltv_delta?: number;
/** Fee Rate In Millitokens Per Million */
fee_rate?: number;
/** Edge is Disabled */
is_disabled?: boolean;
/** Maximum HTLC Millitokens */
max_htlc_mtokens?: string;
/** Minimum HTLC Millitokens */
min_htlc_mtokens?: string;
/** Public Key */
public_key: string;
/** Last Update Epoch ISO 8601 Date */
updated_at?: string;
}[];
policies: ChannelPolicy[];
/** Funding Transaction Id */
transaction_id: string;
/** Funding Transaction Output Index */
transaction_vout: number;
/** Last Update Epoch ISO 8601 Date */
updated_at?: string;
}[];
nodes: {
}>;
nodes: Array<{
/** Name */
alias: string;
/** Hex Encoded Color */
color: string;
features: {
features: Array<{
/** BOLT 09 Feature Bit */
bit: number;
/** Feature is Known */
Expand All @@ -46,14 +32,14 @@ export type GetNetworkGraphResult = {
is_required: boolean;
/** Feature Type */
type: string;
}[];
}>;
/** Node Public Key */
public_key: string;
/** Network Addresses and Ports */
sockets: string[];
/** Last Updated ISO 8601 Date */
updated_at: string;
}[];
}>;
};

/**
Expand Down
34 changes: 9 additions & 25 deletions lnd_methods/info/get_node.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
import type {
AuthenticatedLightningArgs,
AuthenticatedLightningMethod,
ChannelPolicy,
} from '../../typescript';

export type GetNodeArgs = AuthenticatedLightningArgs<{
Expand All @@ -17,39 +18,22 @@ export type GetNodeResult = {
capacity: number;
/** Known Node Channels */
channel_count: number;
channels?: {
channels?: Array<{
/** Maximum Tokens */
capacity: number;
/** Standard Format Channel Id */
id: string;
policies: {
/** Base Fee Millitokens */
base_fee_mtokens?: string;
/** Locktime Delta */
cltv_delta?: number;
/** Fees Charged Per Million Millitokens */
fee_rate?: number;
/** Channel Is Disabled */
is_disabled?: boolean;
/** Maximum HTLC Millitokens Value */
max_htlc_mtokens?: string;
/** Minimum HTLC Millitokens Value */
min_htlc_mtokens?: string;
/** Node Public Key */
public_key: string;
/** Policy Last Updated At ISO 8601 Date */
updated_at?: string;
}[];
policies: ChannelPolicy[];
/** Transaction Id Hex */
transaction_id: string;
/** Transaction Output Index */
transaction_vout: number;
/** Channel Last Updated At ISO 8601 Date */
updated_at?: string;
}[];
}>;
/** RGB Hex Color */
color: string;
features: {
features: Array<{
/** BOLT 09 Feature Bit */
bit: number;
/** Feature is Known */
Expand All @@ -58,13 +42,13 @@ export type GetNodeResult = {
is_required: boolean;
/** Feature Type */
type: string;
}[];
sockets: {
}>;
sockets: Array<{
/** Host and Port */
socket: string;
/** Socket Type */
type: string;
}[];
}>;
/** Last Known Update ISO 8601 Date */
updated_at?: string;
};
Expand Down
51 changes: 41 additions & 10 deletions typescript/shared.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export type LightningError<TError = {err: Error}> = TError extends undefined

export type LightningCallback<TResult = void, TErrorDetails = any> = (
error: LightningError<TErrorDetails> | undefined | null,
result: TResult extends void ? undefined : TResult
result: TResult extends void ? undefined : TResult,
) => void;

export type LightningMethod<
TArgs = EmptyObject,
TResult = void,
TErrorDetails = any
TErrorDetails = any,
> = {
(args: TArgs): Promise<TResult>;
(args: TArgs, callback: LightningCallback<TResult, TErrorDetails>): void;
Expand All @@ -34,21 +34,21 @@ export type LightningMethod<
export type AuthenticatedLightningMethod<
TArgs extends {lnd: AuthenticatedLnd} = {lnd: AuthenticatedLnd},
TResult = void,
TErrorDetails = any
TErrorDetails = any,
> = LightningMethod<TArgs, TResult, TErrorDetails>;

export type UnauthenticatedLightningMethod<
TArgs extends {lnd: UnauthenticatedLnd} = {lnd: UnauthenticatedLnd},
TResult = void,
TErrorDetails = any
TErrorDetails = any,
> = LightningMethod<TArgs, TResult, TErrorDetails>;

export type AuthenticatedLightningSubscription<
TArgs extends {lnd: AuthenticatedLnd} = {lnd: AuthenticatedLnd}
TArgs extends {lnd: AuthenticatedLnd} = {lnd: AuthenticatedLnd},
> = (args: TArgs) => events.EventEmitter;

export type UnauthenticatedLightningSubscription<
TArgs extends {lnd: UnauthenticatedLnd} = {lnd: UnauthenticatedLnd}
TArgs extends {lnd: UnauthenticatedLnd} = {lnd: UnauthenticatedLnd},
> = (args: TArgs) => events.EventEmitter;

type CommonStatus = 'IN_FLIGHT' | 'SUCCEEDED' | 'FAILED';
Expand Down Expand Up @@ -113,10 +113,41 @@ export type RouteNode = {
fee_rate?: number;
/** Forward Edge Public Key Hex */
public_key: string;
}
};

export type Route = RouteNode[];

export type Route = RouteNode[]
export type Routes = Route[];

export type Routes = Route[]
export type UtxoSelection = 'largest' | 'random';

export type UtxoSelection = "largest" | "random";
export interface ChannelPolicy {
/** Base Fee Millitokens */
base_fee_mtokens?: string;
/** Locktime Delta */
cltv_delta?: number;
/** Fees Charged Per Million Millitokens */
fee_rate?: number;
/**
* Source Based Base Fee Reduction String
*
* Not supported on LND 0.17.5 and below
*/
inbound_base_discount_mtokens?: string;
/**
* Source Based Per Million Rate Reduction Number
*
* Not supported on LND 0.17.5 and below
*/
inbound_rate_discount?: number;
/** Channel Is Disabled */
is_disabled?: boolean;
/** Maximum HTLC Millitokens Value */
max_htlc_mtokens?: string;
/** Minimum HTLC Millitokens Value */
min_htlc_mtokens?: string;
/** Node Public Key */
public_key: string;
/** Policy Last Updated At ISO 8601 Date */
updated_at?: string;
}

0 comments on commit 35c88d3

Please sign in to comment.