From e8e96707e5d08b72a4056393915ec8f3c1ab4c42 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Fri, 27 Oct 2023 09:34:20 -0700 Subject: [PATCH] Fix estimate minning fee on testnet --- api/lightning/lnd.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/api/lightning/lnd.py b/api/lightning/lnd.py index a4f84d78b..4b7bd9447 100644 --- a/api/lightning/lnd.py +++ b/api/lightning/lnd.py @@ -71,6 +71,8 @@ def metadata_callback(context, callback): 5: "Insufficient local balance.", } + is_testnet = lightningstub.GetInfo(lnrpc.GetInfoRequest()).testnet + @classmethod def get_version(cls): try: @@ -92,12 +94,17 @@ def decode_payreq(cls, invoice): def estimate_fee(cls, amount_sats, target_conf=2, min_confs=1): """Returns estimated fee for onchain payouts""" + if cls.is_testnet: + dummy_address = "tb1qehyqhruxwl2p5pt52k6nxj4v8wwc3f3pg7377x" + else: + dummy_address = "bc1qgxwaqe4m9mypd7ltww53yv3lyxhcfnhzzvy5j3" + # We assume segwit. Use hardcoded address as shortcut so there is no need of user inputs yet. request = lnrpc.EstimateFeeRequest( - AddrToAmount={"bc1qgxwaqe4m9mypd7ltww53yv3lyxhcfnhzzvy5j3": amount_sats}, + AddrToAmount={dummy_address: amount_sats}, target_conf=target_conf, min_confs=min_confs, - spend_unconfirmed=False, + spend_unconfirmed=True, ) response = cls.lightningstub.EstimateFee(request)