Skip to content

Commit

Permalink
Fix estimate minning fee on testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Oct 27, 2023
1 parent 951b0ab commit e8e9670
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions api/lightning/lnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit e8e9670

Please sign in to comment.