feeadjuster: improve setchannelfee deprecation detection

This commit is contained in:
Michael Schmoock
2022-04-27 12:13:42 +02:00
parent 4b3ff33576
commit be688b0920

View File

@@ -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 "