mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
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
This commit is contained in:
parent
f1ea73a2c6
commit
80798061c3
1 changed files with 5 additions and 1 deletions
|
@ -394,6 +394,10 @@ class Peer(PrintError):
|
||||||
|
|
||||||
@log_exceptions
|
@log_exceptions
|
||||||
async def channel_establishment_flow(self, password, funding_sat, push_msat, temp_channel_id):
|
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
|
await self.initialized
|
||||||
feerate = self.current_feerate_per_kw()
|
feerate = self.current_feerate_per_kw()
|
||||||
local_config, per_commitment_secret_seed = self.make_local_config(funding_sat, push_msat, LOCAL)
|
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)
|
redeem_script = funding_output_script(local_config, remote_config)
|
||||||
funding_address = bitcoin.redeem_script_to_address('p2wsh', redeem_script)
|
funding_address = bitcoin.redeem_script_to_address('p2wsh', redeem_script)
|
||||||
funding_output = TxOutput(bitcoin.TYPE_ADDRESS, funding_address, funding_sat)
|
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_txid = funding_tx.txid()
|
||||||
funding_index = funding_tx.outputs().index(funding_output)
|
funding_index = funding_tx.outputs().index(funding_output)
|
||||||
# remote commitment transaction
|
# remote commitment transaction
|
||||||
|
|
Loading…
Add table
Reference in a new issue