Skip to content

Commit

Permalink
work around missing fields/policy
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Otto committed Jan 6, 2019
1 parent 0f1296d commit 74ac83d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions route_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,34 @@ def update_expiry(self, hops, total_time_lock):

policy = self.lnd.get_policy(hop_out_channel_id, hop.pub_key)

time_lock_delta = policy.time_lock_delta
time_lock_delta = self.get_time_lock_delta(policy)
total_time_lock += time_lock_delta
hop_out_channel_id = hop.chan_id
return total_time_lock

def get_fee_msat(self, amount_msat, channel_id, source_pubkey):
policy = self.lnd.get_policy(channel_id, source_pubkey)
fee_base_msat = self.get_fee_base_msat(policy)
fee_rate_milli_msat = int(policy.fee_rate_milli_msat)
fee_rate_milli_msat = self.get_fee_rate_msat(policy)
return fee_base_msat + fee_rate_milli_msat * amount_msat // 1000000

@staticmethod
def get_time_lock_delta(policy):
# sometimes that field seems not to be set -- interpret it as 0
if hasattr(policy, "time_lock_delta"):
return policy.time_lock_delta
return int(0)

@staticmethod
def get_fee_base_msat(policy):
# sometimes that field seems not to be set -- interpret it as 0
if hasattr(policy, "fee_base_msat"):
return int(policy.fee_base_msat)
return int(0)

@staticmethod
def get_fee_rate_msat(policy):
# sometimes that field seems not to be set -- interpret it as 0
if hasattr(policy, "fee_rate_milli_msat"):
return int(policy.fee_rate_milli_msat)
return int(0)

0 comments on commit 74ac83d

Please sign in to comment.