unlock on reconnect
This commit is contained in:
parent
1623777c1f
commit
89154933b9
5 changed files with 12 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ import { Utils } from '../helpers/utilsWrapper.js';
|
|||
import { TxPointSettings } from '../storage/tlv/stateBundler.js';
|
||||
import { WalletKitClient } from '../../../proto/lnd/walletkit.client.js';
|
||||
const DeadLineMetadata = (deadline = 10 * 1000) => ({ deadline: Date.now() + deadline })
|
||||
const deadLndRetrySeconds = 5
|
||||
const deadLndRetrySeconds = 20
|
||||
type TxActionOptions = { useProvider: boolean, from: 'user' | 'system' }
|
||||
export default class {
|
||||
lightning: LightningClient
|
||||
|
|
@ -43,9 +43,11 @@ export default class {
|
|||
outgoingOpsLocked = false
|
||||
liquidProvider: LiquidityProvider
|
||||
utils: Utils
|
||||
constructor(settings: LndSettings, liquidProvider: LiquidityProvider, utils: Utils, addressPaidCb: AddressPaidCb, invoicePaidCb: InvoicePaidCb, newBlockCb: NewBlockCb, htlcCb: HtlcCb, channelEventCb: ChannelEventCb) {
|
||||
unlockLnd: () => Promise<void>
|
||||
constructor(settings: LndSettings, liquidProvider: LiquidityProvider, unlockLnd: () => Promise<any>, utils: Utils, addressPaidCb: AddressPaidCb, invoicePaidCb: InvoicePaidCb, newBlockCb: NewBlockCb, htlcCb: HtlcCb, channelEventCb: ChannelEventCb) {
|
||||
this.settings = settings
|
||||
this.utils = utils
|
||||
this.unlockLnd = unlockLnd
|
||||
this.addressPaidCb = addressPaidCb
|
||||
this.invoicePaidCb = invoicePaidCb
|
||||
this.newBlockCb = newBlockCb
|
||||
|
|
@ -168,7 +170,7 @@ export default class {
|
|||
this.log("LND is dead, will try to reconnect in", deadLndRetrySeconds, "seconds")
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
await this.Health()
|
||||
await this.unlockLnd()
|
||||
this.log("LND is back online")
|
||||
clearInterval(interval)
|
||||
await this.Warmup()
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ export default class {
|
|||
const updateProviderBalance = (b: number) => this.storage.liquidityStorage.IncrementTrackedProviderBalance('lnPub', settings.liquiditySettings.liquidityProviderPub, b)
|
||||
this.liquidityProvider = new LiquidityProvider(settings.liquiditySettings.liquidityProviderPub, this.utils, this.invoicePaidCb, updateProviderBalance)
|
||||
this.rugPullTracker = new RugPullTracker(this.storage, this.liquidityProvider)
|
||||
this.lnd = new LND(settings.lndSettings, this.liquidityProvider, this.utils, this.addressPaidCb, this.invoicePaidCb, this.newBlockCb, this.htlcCb, this.channelEventCb)
|
||||
this.lnd = new LND(settings.lndSettings, this.liquidityProvider, () => this.unlocker.Unlock(), this.utils, this.addressPaidCb, this.invoicePaidCb, this.newBlockCb, this.htlcCb, this.channelEventCb)
|
||||
this.liquidityManager = new LiquidityManager(this.settings.liquiditySettings, this.storage, this.utils, this.liquidityProvider, this.lnd, this.rugPullTracker)
|
||||
this.metricsManager = new MetricsManager(this.storage, this.lnd)
|
||||
|
||||
|
|
|
|||
|
|
@ -301,12 +301,12 @@ export class Unlocker {
|
|||
|
||||
GetWalletPassword = () => {
|
||||
const path = this.settings.walletPasswordPath
|
||||
let password = Buffer.alloc(0)
|
||||
let password: Buffer | null = null
|
||||
try {
|
||||
password = fs.readFileSync(path)
|
||||
} catch {
|
||||
}
|
||||
if (password.length === 0) {
|
||||
if (!password || password.length === 0) {
|
||||
this.log("no wallet password configured, using wallet secret")
|
||||
const secret = this.GetWalletSecret(false)
|
||||
if (secret === "") {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ export const setupNetwork = async (): Promise<ChainTools> => {
|
|||
await core.InitAddress()
|
||||
await core.Mine(1)
|
||||
const setupUtils = new Utils({ dataDir: settings.storageSettings.dataDir, allowResetMetricsStorages: settings.allowResetMetricsStorages })
|
||||
const alice = new LND(settings.lndSettings, new LiquidityProvider("", setupUtils, async () => { }, async () => { }), setupUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
const bob = new LND({ ...settings.lndSettings, mainNode: settings.lndSettings.otherNode }, new LiquidityProvider("", setupUtils, async () => { }, async () => { }), setupUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
const alice = new LND(settings.lndSettings, new LiquidityProvider("", setupUtils, async () => { }, async () => { }), async () => { }, setupUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
const bob = new LND({ ...settings.lndSettings, mainNode: settings.lndSettings.otherNode }, new LiquidityProvider("", setupUtils, async () => { }, async () => { }), async () => { }, setupUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
await tryUntil<void>(async i => {
|
||||
const peers = await alice.ListPeers()
|
||||
if (peers.peers.length > 0) {
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ export const SetupTest = async (d: Describe, chainTools: ChainTools): Promise<Te
|
|||
await externalAccessToMainLnd.Warmup() */
|
||||
|
||||
const otherLndSetting = { ...settings.lndSettings, mainNode: settings.lndSettings.otherNode }
|
||||
const externalAccessToOtherLnd = new LND(otherLndSetting, new LiquidityProvider("", extermnalUtils, async () => { }, async () => { }), extermnalUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
const externalAccessToOtherLnd = new LND(otherLndSetting, new LiquidityProvider("", extermnalUtils, async () => { }, async () => { }), async () => { }, extermnalUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
await externalAccessToOtherLnd.Warmup()
|
||||
|
||||
const thirdLndSetting = { ...settings.lndSettings, mainNode: settings.lndSettings.thirdNode }
|
||||
const externalAccessToThirdLnd = new LND(thirdLndSetting, new LiquidityProvider("", extermnalUtils, async () => { }, async () => { }), extermnalUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
const externalAccessToThirdLnd = new LND(thirdLndSetting, new LiquidityProvider("", extermnalUtils, async () => { }, async () => { }), async () => { }, extermnalUtils, async () => { }, async () => { }, () => { }, () => { }, () => { })
|
||||
await externalAccessToThirdLnd.Warmup()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue