This commit is contained in:
hatim boufnichel 2024-04-24 19:04:44 +02:00
parent 72097354a2
commit 0ccc08371f
2 changed files with 10 additions and 5 deletions

View file

@ -211,9 +211,11 @@ export default class {
}) })
} }
async NewAddress(addressType: Types.AddressType): Promise<NewAddressResponse> { async NewAddress(addressType: Types.AddressType, skipHealthCheck = false): Promise<NewAddressResponse> {
this.log("generating new address") this.log("generating new address")
await this.Health() if (!skipHealthCheck) {
await this.Health()
}
let lndAddressType: AddressType let lndAddressType: AddressType
switch (addressType) { switch (addressType) {
case Types.AddressType.NESTED_PUBKEY_HASH: case Types.AddressType.NESTED_PUBKEY_HASH:
@ -356,7 +358,6 @@ export default class {
} }
async OpenChannel(destination: string, closeAddress: string, fundingAmount: number, pushSats: number) { async OpenChannel(destination: string, closeAddress: string, fundingAmount: number, pushSats: number) {
await this.Health()
const abortController = new AbortController() const abortController = new AbortController()
const req = OpenChannelReq(destination, closeAddress, fundingAmount, pushSats) const req = OpenChannelReq(destination, closeAddress, fundingAmount, pushSats)
const stream = this.lightning.openChannel(req, { abort: abortController.signal }) const stream = this.lightning.openChannel(req, { abort: abortController.signal })

View file

@ -9,7 +9,7 @@ export const setupNetwork = async () => {
const core = new Core(settings) const core = new Core(settings)
await core.Init() await core.Init()
const { alice, bob, carol, dave } = await initLndInstances(settings) const { alice, bob, carol, dave } = await initLndInstances(settings)
/*const aliceAddr = await alice.NewAddress(AddressType.WITNESS_PUBKEY_HASH) /*const aliceAddr = await alice.NewAddress(AddressType.WITNESS_PUBKEY_HASH, true)
const bobAddr = await bob.NewAddress(AddressType.WITNESS_PUBKEY_HASH) const bobAddr = await bob.NewAddress(AddressType.WITNESS_PUBKEY_HASH)
const carolAddr = await carol.NewAddress(AddressType.WITNESS_PUBKEY_HASH) const carolAddr = await carol.NewAddress(AddressType.WITNESS_PUBKEY_HASH)
const daveAddr = await dave.NewAddress(AddressType.WITNESS_PUBKEY_HASH) const daveAddr = await dave.NewAddress(AddressType.WITNESS_PUBKEY_HASH)
@ -19,7 +19,11 @@ export const setupNetwork = async () => {
await core.SendToAddress(daveAddr.address, 10) await core.SendToAddress(daveAddr.address, 10)
await core.Mine(6)*/ await core.Mine(6)*/
const alicePub = await alice.GetInfo() const alicePub = await alice.GetInfo()
console.log({ alicePub }) const [pubkey, host] = alicePub.uris[0].split('@')
await alice.ConnectPeer(pubkey, host)
console.log(await alice.GetInfo())
const aliceAddr = await alice.NewAddress(AddressType.WITNESS_PUBKEY_HASH, true)
console.log({ aliceAddr })
} }
const initLndInstances = async (settings: TestSettings) => { const initLndInstances = async (settings: TestSettings) => {