From 383897c42ec2587a863e1b4a3ccad1a0f4046fe3 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 19 Oct 2018 21:01:32 +0200 Subject: [PATCH] lnbase: when opening channel, test if we have enough balance first and make sure we don't try to create the funding txn from local UTXOs --- electrum/lnbase.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/electrum/lnbase.py b/electrum/lnbase.py index 6b61b1265..326a7f023 100644 --- a/electrum/lnbase.py +++ b/electrum/lnbase.py @@ -394,6 +394,10 @@ class Peer(PrintError): @log_exceptions async def channel_establishment_flow(self, password, funding_sat, push_msat, temp_channel_id): + wallet = self.lnworker.wallet + # dry run creating funding tx to see if we even have enough funds + funding_tx_test = wallet.mktx([TxOutput(bitcoin.TYPE_ADDRESS, wallet.dummy_address(), funding_sat)], + password, self.lnworker.config, nonlocal_only=True) await self.initialized feerate = self.current_feerate_per_kw() local_config, per_commitment_secret_seed = self.make_local_config(funding_sat, push_msat, LOCAL) @@ -454,7 +458,7 @@ class Peer(PrintError): redeem_script = funding_output_script(local_config, remote_config) funding_address = bitcoin.redeem_script_to_address('p2wsh', redeem_script) funding_output = TxOutput(bitcoin.TYPE_ADDRESS, funding_address, funding_sat) - funding_tx = self.lnworker.wallet.mktx([funding_output], password, self.lnworker.config) + funding_tx = wallet.mktx([funding_output], password, self.lnworker.config, nonlocal_only=True) funding_txid = funding_tx.txid() funding_index = funding_tx.outputs().index(funding_output) # remote commitment transaction