electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 1a7b06b69092fb4955e4cd91f99224b1c1eb6f70
parent 646881f437ee651e464a4e391b186e3be30394f4
Author: Janus <ysangkok@gmail.com>
Date:   Tue,  2 Oct 2018 17:13:45 +0200

lnhtlc: multiply weight by feerate before rounding

This resolves the error formerly manifested as:
Traceback (most recent call last):
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/packages/jsonrpclib/SimpleJSONRPCServer.py", line 376, in _dispatch
    return func(*params)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/daemon.py", line 292, in run_cmdline
    result = func(*args, **kwargs)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/commands.py", line 87, in func_wrapper
    return func(*args, **kwargs)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/commands.py", line 697, in lnpay
    return f.result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnbase.py", line 887, in pay
    sig_64, htlc_sigs = chan.sign_next_commitment()
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnhtlc.py", line 281, in sign_next_commitment
    htlc_tx = make_htlc_tx_with_open_channel(self, *args)
  File "/home/janus/Skrivebord/lightning-rfc/tools/electrum/electrum/lnutil.py", line 262, in make_htlc_tx_with_open_channel
    commit.txid(), commit.htlc_output_indices[original_htlc_output_index],
KeyError: 0

Diffstat:
Melectrum/lnhtlc.py | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/electrum/lnhtlc.py b/electrum/lnhtlc.py @@ -509,8 +509,9 @@ class HTLCStateMachine(PrintError): feerate = self.pending_feerate(subject) conf = self.remote_config if subject == REMOTE else self.local_config weight = HTLC_SUCCESS_WEIGHT if subject != htlc_initiator else HTLC_TIMEOUT_WEIGHT - return filter(lambda htlc: htlc.amount_msat // 1000 - weight * (feerate // 1000) >= conf.dust_limit_sat, - self.htlcs_in_local if htlc_initiator == LOCAL else self.htlcs_in_remote) + htlcs = self.htlcs_in_local if htlc_initiator == LOCAL else self.htlcs_in_remote + fee_for_htlc = lambda htlc: htlc.amount_msat // 1000 - (weight * feerate // 1000) + return filter(lambda htlc: fee_for_htlc(htlc) >= conf.dust_limit_sat, htlcs) @property def pending_remote_commitment(self):