From be688b0920ba9593c755e1f11a461f04b17b23d7 Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Wed, 27 Apr 2022 12:13:42 +0200 Subject: [PATCH] feeadjuster: improve setchannelfee deprecation detection --- feeadjuster/feeadjuster.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/feeadjuster/feeadjuster.py b/feeadjuster/feeadjuster.py index 8a6b213..8738b92 100755 --- a/feeadjuster/feeadjuster.py +++ b/feeadjuster/feeadjuster.py @@ -113,10 +113,7 @@ def setchannelfee(plugin: Plugin, scid: str, base: int, ppm: int): if fees is None or base == fees['base'] and ppm == fees['ppm']: return False try: - if plugin.rpcfeemethod == 'setchannel': - plugin.rpc.setchannel(scid, base, ppm) # new method - else: - plugin.rpc.setchannelfee(scid, base, ppm) # deprecated + plugin.rpc.setchannel(scid, base, ppm) return True except RpcError as e: plugin.log(f"Could not adjust fees for channel {scid}: '{e}'", level="error") @@ -303,10 +300,10 @@ def init(options: dict, configuration: dict, plugin: Plugin, **kwargs): and "destination" in c["command"]]) == 1: plugin.listchannels_by_dst = True - # detect if server supports new 'setchannel' command over setchannelfee - plugin.rpcfeemethod = 'setchannelfee' - if len([c for c in rpchelp if c["command"].startswith("setchannel ")]) == 1: - plugin.rpcfeemethod = 'setchannel' + # Detect if server supports new 'setchannel' command over setchannelfee. + # If not, make plugin.rpc.setchannel a 'symlink' to setchannelfee + if len([c for c in rpchelp if c["command"].startswith("setchannel ")]) == 0: + plugin.rpc.setchannel = plugin.rpc.setchannelfee plugin.log(f"Plugin feeadjuster initialized " f"({plugin.adj_basefee} base / {plugin.adj_ppmfee} ppm) with an "