-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
184 lines (182 loc) · 5.25 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export const enum Network {
Bitcoin = 'Bitcoin',
Regtest = 'Regtest',
Signet = 'Signet',
Testnet = 'Testnet',
}
export const enum LogLevel {
Gossip = 'Gossip',
Trace = 'Trace',
Debug = 'Debug',
Warn = 'Warn',
Info = 'Info',
Error = 'Error',
}
export interface PeerDetails {
nodeId: string
address: string
isPersisted: boolean
isConnected: boolean
}
export interface ChannelId {
channelIdHex: Array<number>
}
export interface OutPoint {
txid: string
vout: number
}
export interface UserChannelId {
userChannelIdHex: string
}
export interface ChannelDetails {
channelId: ChannelId
counterpartyNodeId: string
fundingTxo?: OutPoint
channelValueSats: number
unspendablePunishmentReserve?: number
userChannelId: UserChannelId
feerateSatPer1000Weight: number
balanceMsat: number
outboundCapacityMsat: number
inboundCapacityMsat: number
confirmationsRequired?: number
confirmations?: number
isOutbound: boolean
isChannelReady: boolean
isUsable: boolean
isPublic: boolean
cltvExpiryDelta?: number
}
export interface PaymentPreimage {
field0: Array<number>
}
export interface PaymentSecret {
field0: Array<number>
}
export interface PaymentDetails {
hash: PaymentHash
preimage?: PaymentPreimage
secret?: PaymentSecret
amountMsat?: number
direction: PaymentDirection
status: PaymentStatus
}
export const enum PaymentStatus {
Pending = 'Pending',
Succeeded = 'Succeeded',
Failed = 'Failed',
}
export const enum PaymentDirection {
Inbound = 'Inbound',
Outbound = 'Outbound',
}
export interface PaymentHash {
field0: Array<number>
}
export interface Address {
addressHex: string
}
export interface Txid {
feild0: string
}
export interface PaymentSuccessful {
paymentHash: PaymentHash
}
export class ChannelConfig {
forwardingFeeProportionalMillionths: number
forwardingFeeBaseMsat: number
cltvExpiryDelta: number
maxDustHtlcExposure: number
forceCloseAvoidanceMaxFeeSatoshis: number
acceptUnderpayingHtlcs: boolean
constructor(
forwardingFeeProportionalMillionths: number,
forwardingFeeBaseMsat: number,
cltvExpiryDelta: number,
maxDustHtlcExposure: number,
forceCloseAvoidanceMaxFeeSatoshis: number,
acceptUnderpayingHtlcs: boolean,
)
}
export class ChannelPending {}
export class PaymentFailed {}
export class PaymentReceived {}
export class ChannelReady {}
export class ChannelClosed {}
export class NetAddress {
constructor(ipv4: string, port: number)
}
export class PublicKey {
constructor(nodeId: string)
}
export class Config {
constructor(
storageDirPath: string,
logDirPath: string | undefined | null,
network: Network,
listeningAddress: NetAddress,
defaultCltvExpiryDelta: number,
onchainWalletSyncIntervalSecs: number,
walletSyncIntervalSecs: number,
feeRateCacheUpdateIntervalSecs: number,
probingLiquidityLimitMultiplier: number,
logLevel: LogLevel,
)
}
export class Builder {
constructor()
static fromConfig(config: Config): Builder
setEntropySeedPath(seedPath: string): boolean
setEntropySeedBytes(seedBytes: Array<number>): boolean
setEntropyBip39Mnemonic(mnemonic: string, passphrase?: string | undefined | null): boolean
setEsploraServer(url: string): boolean
setGossipSourceP2P(): boolean
setGossipSourceRgs(rgsServerUrl: string): boolean
setStorageDirPath(storageDirPath: string): boolean
setNetwork(network: Network): boolean
setListeningAddress(listeningAddress: NetAddress): boolean
setLogLevel(level: LogLevel): boolean
build(): Node
}
export class Node {
start(): boolean
stop(): boolean
syncWallets(): boolean
nodeId(): string
listeningAddress(): string | null
newOnchainAddress(): Address
sendToOnchainAddress(address: Address, amountMsat: number): Txid
sendAllToOnchainAddress(address: Address): Txid
spendableOnchainBalanceSats(): bigint
totalOnchainBalanceSats(): bigint
connect(nodeId: PublicKey, address: NetAddress, persist: boolean): boolean
disconnect(counterpartyNodeId: PublicKey): boolean
connectOpenChannel(
nodeId: PublicKey,
address: NetAddress,
channelAmountSats: number,
pushToCounterpartyMsat: number | undefined | null,
channelConfig: ChannelConfig | undefined | null,
announceChannel: boolean,
): boolean
closeChannel(channelId: ChannelId, counterpartyNodeId: PublicKey): boolean
receivePayment(amountMsat: number, description: string, expirySecs: number): string
receiveVariableAmountPayment(description: string, expirySecs: number): string
sendPayment(invoice: string): PaymentHash
sendPaymentUsingAmount(invoice: string, amountMsat: number): PaymentHash
sendSpontaneousPayment(amountMsat: number, nodeId: PublicKey): PaymentHash
listPayments(): Array<PaymentDetails>
listPeers(): Array<PeerDetails>
listChannels(): Array<ChannelDetails>
payment(paymentHash: PaymentHash): PaymentDetails
removePayment(paymentHash: PaymentHash): boolean
signMessage(msg: Array<number>): string
verifySignature(msg: Array<number>, sig: string, pkey: PublicKey): boolean
updateChannelConfig(channelId: ChannelId, counterpartyNodeId: PublicKey, channelConfig: ChannelConfig): boolean
nextEvent(): Promise<string>
waitNextEvent(): Promise<string>
eventHandled(): Promise<string>
}