Browse Source

use mktx_for_open_channel in commands module. fix indentation

patch-4
ThomasV 4 years ago
parent
commit
018f09f2af
  1. 19
      electrum/commands.py
  2. 7
      electrum/lnworker.py
  3. 16
      electrum/wallet.py

19
electrum/commands.py

@ -54,7 +54,6 @@ from .address_synchronizer import TX_HEIGHT_LOCAL
from .mnemonic import Mnemonic
from .lnutil import SENT, RECEIVED
from .lnutil import LnFeatures
from .lnutil import ln_dummy_address
from .lnpeer import channel_id_from_funding_tx
from .plugin import run_hook
from .version import ELECTRUM_VERSION
@ -996,13 +995,17 @@ class Commands:
async def open_channel(self, connection_string, amount, push_amount=0, password=None, wallet: Abstract_Wallet = None):
funding_sat = satoshis(amount)
push_sat = satoshis(push_amount)
dummy_output = PartialTxOutput.from_address_and_value(ln_dummy_address(), funding_sat)
funding_tx = wallet.mktx(outputs = [dummy_output], rbf=False, sign=False, nonlocal_only=True)
chan, funding_tx = await wallet.lnworker._open_channel_coroutine(connect_str=connection_string,
funding_tx=funding_tx,
funding_sat=funding_sat,
push_sat=push_sat,
password=password)
coins = wallet.get_spendable_coins(None)
funding_tx = wallet.lnworker.mktx_for_open_channel(
coins=coins,
funding_sat=funding_sat,
fee_est=None)
chan, funding_tx = await wallet.lnworker._open_channel_coroutine(
connect_str=connection_string,
funding_tx=funding_tx,
funding_sat=funding_sat,
push_sat=push_sat,
password=password)
return chan.funding_outpoint.to_str()
@command('')

7
electrum/lnworker.py

@ -984,8 +984,11 @@ class LNWallet(LNWorker):
self.remove_channel(chan.channel_id)
raise
def mktx_for_open_channel(self, *, coins: Sequence[PartialTxInput], funding_sat: int,
fee_est=None) -> PartialTransaction:
def mktx_for_open_channel(
self, *,
coins: Sequence[PartialTxInput],
funding_sat: int,
fee_est=None) -> PartialTransaction:
dummy_address = ln_dummy_address()
outputs = [PartialTxOutput.from_address_and_value(dummy_address, funding_sat)]
tx = self.wallet.make_unsigned_transaction(

16
electrum/wallet.py

@ -1330,13 +1330,17 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
run_hook('make_unsigned_transaction', self, tx)
return tx
def mktx(self, *, outputs: List[PartialTxOutput], password=None, fee=None, change_addr=None,
domain=None, rbf=False, nonlocal_only=False, tx_version=None, sign=True) -> PartialTransaction:
def mktx(self, *,
outputs: List[PartialTxOutput],
password=None, fee=None, change_addr=None,
domain=None, rbf=False, nonlocal_only=False,
tx_version=None, sign=True) -> PartialTransaction:
coins = self.get_spendable_coins(domain, nonlocal_only=nonlocal_only)
tx = self.make_unsigned_transaction(coins=coins,
outputs=outputs,
fee=fee,
change_addr=change_addr)
tx = self.make_unsigned_transaction(
coins=coins,
outputs=outputs,
fee=fee,
change_addr=change_addr)
tx.set_rbf(rbf)
if tx_version is not None:
tx.version = tx_version

Loading…
Cancel
Save