URI: 
       tadd get_channel_ctx to CLI, for testing breaches - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit e7218d798dd1c8556401b1f20d86f9e5474056b6
   DIR parent a6983441365d0150eb364d8d289e30ee5ebe6434
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 14 Mar 2019 18:31:41 +0100
       
       add get_channel_ctx to CLI, for testing breaches
       
       Diffstat:
         M electrum/commands.py                |       9 +++++++++
         M electrum/lnchannel.py               |       5 -----
         M electrum/tests/regtest/regtest.sh   |       5 +++--
       
       3 files changed, 12 insertions(+), 7 deletions(-)
       ---
   DIR diff --git a/electrum/commands.py b/electrum/commands.py
       t@@ -841,6 +841,15 @@ class Commands:
                coro = self.lnworker.force_close_channel(chan_id) if force else self.lnworker.close_channel(chan_id)
                return self.network.run_from_another_thread(coro)
        
       +    @command('wn')
       +    def get_channel_ctx(self, channel_point):
       +        """ return the current commitment transaction of a channel """
       +        txid, index = channel_point.split(':')
       +        chan_id, _ = channel_id_from_funding_tx(txid, int(index))
       +        chan = self.lnworker.channels[chan_id]
       +        tx = chan.force_close_tx()
       +        return tx.as_dict()
       +
        def eval_bool(x: str) -> bool:
            if x == 'false': return False
            if x == 'true': return True
   DIR diff --git a/electrum/lnchannel.py b/electrum/lnchannel.py
       t@@ -187,11 +187,6 @@ class Channel(PrintError):
                self.local_commitment = ctx
                if self.sweep_address is not None:
                    self.local_sweeptxs = create_sweeptxs_for_our_latest_ctx(self, self.local_commitment, self.sweep_address)
       -            initial = os.path.join(get_config().electrum_path(), 'initial_commitment_tx')
       -            tx = self.force_close_tx().serialize_to_network()
       -            if not os.path.exists(initial):
       -                with open(initial, 'w') as f:
       -                    f.write(tx)
        
            def set_remote_commitment(self):
                self.remote_commitment = self.current_commitment(REMOTE)
   DIR diff --git a/electrum/tests/regtest/regtest.sh b/electrum/tests/regtest/regtest.sh
       t@@ -71,13 +71,14 @@ fi
        
        if [[ $1 == "breach" ]]; then
            bob_node=$($bob nodeid)
       -    $alice open_channel $bob_node 0.15
       +    channel=$($alice open_channel $bob_node 0.15)
            sleep 3
       +    ctx=$($alice get_channel_ctx $channel | jq '.hex' | tr -d '"')
            bitcoin-cli generate 6 > /dev/null
            sleep 10
            request=$($bob addinvoice 0.01 "blah")
            $alice lnpay $request
       -    bitcoin-cli sendrawtransaction $(cat /tmp/alice/regtest/initial_commitment_tx)
       +    bitcoin-cli sendrawtransaction $ctx
            sleep 12
            bitcoin-cli generate 2 > /dev/null
            sleep 12