electrum

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

commit d6f62d4e7f3e703f584ad8b8fac6fe5468c487ce
parent 04ec7e9968e80abddf073be07608a49b3a9d9382
Author: Janus <ysangkok@gmail.com>
Date:   Mon, 22 Oct 2018 21:03:55 +0200

follow-up redeeming of local outgoing htlc outputs, fix tests

Diffstat:
Melectrum/lnwatcher.py | 20+++++++-------------
Melectrum/tests/test_lnutil.py | 2+-
2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py @@ -163,7 +163,6 @@ class LNWatcher(PrintError): # check if any response applies keep_watching_this = False local_height = self.network.get_local_height() - txs_to_add = [] for e_tx in list(encumbered_sweep_txns): conflicts = self.addr_sync.get_conflicting_transactions(e_tx.tx.txid(), e_tx.tx, include_self=True) conflict_mined_status = self.get_deepest_tx_mined_status_for_txids(conflicts) @@ -177,16 +176,17 @@ class LNWatcher(PrintError): if local_height > e_tx.cltv_expiry: self.print_error('CLTV ({} > {}) fulfilled'.format(local_height, e_tx.cltv_expiry)) else: - self.print_error('waiting for CLTV ({} > {}) for funding outpoint {} and tx {}' - .format(local_height, e_tx.cltv_expiry, funding_outpoint, prev_tx.txid())) + self.print_error('waiting for {}: CLTV ({} > {}), funding outpoint {} and tx {}' + .format(e_tx.name, local_height, e_tx.cltv_expiry, funding_outpoint[:8], prev_tx.txid()[:8])) broadcast = False if e_tx.csv_delay: if num_conf < e_tx.csv_delay: - self.print_error('waiting for CSV ({} >= {}) for funding outpoint {} and tx {}' - .format(num_conf, e_tx.csv_delay, funding_outpoint, prev_tx.txid())) + self.print_error('waiting for {}: CSV ({} >= {}), funding outpoint {} and tx {}' + .format(e_tx.name, num_conf, e_tx.csv_delay, funding_outpoint[:8], prev_tx.txid()[:8])) broadcast = False if broadcast: - await self.broadcast_or_log(e_tx) + if not await self.broadcast_or_log(e_tx): + self.print_error(f'encumbered tx: {str(e_tx)}, prev_txid: {prev_txid}') else: # not mined or in mempool keep_watching_this |= await self.inspect_tx_candidate(funding_outpoint, e_tx.tx) @@ -200,19 +200,13 @@ class LNWatcher(PrintError): self.print_error(f'broadcast: {e_tx.name}: failure: {repr(e)}') else: self.print_error(f'broadcast: {e_tx.name}: success. txid: {txid}') - return True - return False @with_watchtower def add_sweep_tx(self, funding_outpoint: str, prev_txid: str, sweeptx): encumbered_sweeptx = EncumberedTransaction.from_json(sweeptx) with self.lock: - tx_set = self.sweepstore[funding_outpoint][prev_txid] - if encumbered_sweeptx in tx_set: - return False - tx_set.add(encumbered_sweeptx) + self.sweepstore[funding_outpoint][prev_txid].add(encumbered_sweeptx) self.write_to_disk() - return True def get_tx_mined_status(self, txid: str): if not txid: diff --git a/electrum/tests/test_lnutil.py b/electrum/tests/test_lnutil.py @@ -542,7 +542,7 @@ class TestLNUtil(unittest.TestCase): our_commit_tx)) def htlc_tx(self, htlc, htlc_output_index, amount_msat, htlc_payment_preimage, remote_htlc_sig, success, cltv_timeout, local_feerate_per_kw, our_commit_tx): - our_htlc_tx_output = make_htlc_tx_output( + _script, our_htlc_tx_output = make_htlc_tx_output( amount_msat=amount_msat, local_feerate=local_feerate_per_kw, revocationpubkey=local_revocation_pubkey,