From b87f47e52264f7b2b7e41bfac271a6f971bf9092 Mon Sep 17 00:00:00 2001 From: Nitesh Balusu <84944042+niteshbalusu11@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:47:35 -0500 Subject: [PATCH] set remote chan reserve to 360 sats Signed-off-by: Nitesh Balusu <84944042+niteshbalusu11@users.noreply.github.com> --- src/utils/lnd-api.ts | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/utils/lnd-api.ts b/src/utils/lnd-api.ts index cf655b8..121ef45 100644 --- a/src/utils/lnd-api.ts +++ b/src/utils/lnd-api.ts @@ -17,11 +17,23 @@ export async function getInfo(lightning: Client) { } export async function estimateFee(lightning: Client, amount: Long, targetConf: number) { - const estimateFeeRequest = lnrpc.EstimateFeeRequest.encode({ - AddrToAmount: { + let AddrToAmount: { [key: string]: Long } = {}; + const { network } = (await getInfo(lightning)).chains[0]; + + if (network === "regtest") { + AddrToAmount = { + bcrt1p5u7y9s9hf0xd2hmaqvdntvzgewcwpnu4c050ucjvg7z7kxdv2xgqurylz5: amount, + bcrt1p732hwvhc4scanstktkrnxmku8m8f40svw3u9qp2krqh0f7vjfhuskk25fd: Long.fromValue(10000), + }; + } else { + AddrToAmount = { bc1qwljx57mxh2pmh2hgwkhp6z4077s0g8q2s0hh8p: amount, bc1q0aptdcqgpwm63y3p0sl6g2qjdjc2keymdkxzum: Long.fromValue(10000), - }, + }; + } + + const estimateFeeRequest = lnrpc.EstimateFeeRequest.encode({ + AddrToAmount, targetConf, }).finish(); @@ -69,7 +81,10 @@ export async function openChannelSync( zeroConf: boolean, taprootChannel: boolean, ) { - const commitmentType = taprootChannel ? lnrpc.CommitmentType.SIMPLE_TAPROOT : lnrpc.CommitmentType.ANCHORS; + const commitmentType = taprootChannel + ? lnrpc.CommitmentType.SIMPLE_TAPROOT + : lnrpc.CommitmentType.ANCHORS; + const remoteChanReserveSat = Long.fromValue(360); const openChannelSyncRequest = lnrpc.OpenChannelRequest.encode({ nodePubkey: hexToUint8Array(pubkey), @@ -81,6 +96,7 @@ export async function openChannelSync( spendUnconfirmed, zeroConf, commitmentType, + remoteChanReserveSat, }).finish(); return await grpcMakeUnaryRequest(