Browse Source

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
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 6 years ago
committed by ThomasV
parent
commit
c577df8489
  1. 6
      electrum/lnbase.py

6
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

Loading…
Cancel
Save