mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-04 21:05:11 +00:00
restrict lightning to p2wpkh wallets
This commit is contained in:
parent
2255b07157
commit
570167a2c4
4 changed files with 26 additions and 17 deletions
|
@ -31,7 +31,7 @@ Popup:
|
|||
value: app.wallet.wallet_type
|
||||
BoxLabel:
|
||||
text: _("Lightning:")
|
||||
value: _('Enabled') if app.wallet.has_lightning() else _('Disabled')
|
||||
value: (_('Enabled') if app.wallet.has_lightning() else _('Disabled')) if app.wallet.can_have_lightning() else _('Not available')
|
||||
BoxLabel:
|
||||
text: _("Balance") + ':'
|
||||
value: app.format_amount_and_units(root.confirmed + root.unconfirmed + root.unmatured)
|
||||
|
@ -90,6 +90,7 @@ Popup:
|
|||
Button:
|
||||
size_hint: 0.5, None
|
||||
height: '48dp'
|
||||
disabled: not app.wallet.can_have_lightning()
|
||||
text: _('Disable LN') if app.wallet.has_lightning() else _('Enable LN')
|
||||
on_release:
|
||||
root.dismiss()
|
||||
|
|
|
@ -2190,20 +2190,21 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||
ks_type = str(keystore_types[0]) if keystore_types else _('No keystore')
|
||||
grid.addWidget(QLabel(ks_type), 4, 1)
|
||||
# lightning
|
||||
if self.wallet.has_lightning():
|
||||
lightning_b = QPushButton(_('Disable'))
|
||||
lightning_b.clicked.connect(dialog.close)
|
||||
lightning_b.clicked.connect(self.disable_lightning)
|
||||
lightning_label = QLabel(_('Enabled'))
|
||||
lightning_b.setDisabled(bool(self.wallet.lnworker.channels))
|
||||
else:
|
||||
lightning_b = QPushButton(_('Enable'))
|
||||
lightning_b.clicked.connect(dialog.close)
|
||||
lightning_b.clicked.connect(self.enable_lightning)
|
||||
lightning_label = QLabel(_('Disabled'))
|
||||
grid.addWidget(QLabel(_('Lightning')), 5, 0)
|
||||
grid.addWidget(lightning_label, 5, 1)
|
||||
grid.addWidget(lightning_b, 5, 2)
|
||||
if self.wallet.can_have_lightning():
|
||||
if self.wallet.has_lightning():
|
||||
lightning_b = QPushButton(_('Disable'))
|
||||
lightning_b.clicked.connect(dialog.close)
|
||||
lightning_b.clicked.connect(self.disable_lightning)
|
||||
lightning_label = QLabel(_('Enabled'))
|
||||
lightning_b.setDisabled(bool(self.wallet.lnworker.channels))
|
||||
else:
|
||||
lightning_b = QPushButton(_('Enable'))
|
||||
lightning_b.clicked.connect(dialog.close)
|
||||
lightning_b.clicked.connect(self.enable_lightning)
|
||||
lightning_label = QLabel(_('Disabled'))
|
||||
grid.addWidget(QLabel(_('Lightning')), 5, 0)
|
||||
grid.addWidget(lightning_label, 5, 1)
|
||||
grid.addWidget(lightning_b, 5, 2)
|
||||
vbox.addLayout(grid)
|
||||
|
||||
if self.wallet.is_deterministic():
|
||||
|
|
|
@ -474,8 +474,10 @@ class Peer(Logger):
|
|||
initial_msat = push_msat
|
||||
|
||||
if self.is_static_remotekey():
|
||||
addr = self.lnworker.wallet.get_unused_address()
|
||||
static_key = self.lnworker.wallet.get_public_key(addr) # just a pubkey
|
||||
wallet = self.lnworker.wallet
|
||||
assert wallet.txin_type == 'p2wpkh'
|
||||
addr = wallet.get_unused_address()
|
||||
static_key = wallet.get_public_key(addr) # just a pubkey
|
||||
payment_basepoint = OnlyPubkeyKeypair(bfh(static_key))
|
||||
else:
|
||||
payment_basepoint = keypair_generator(LnKeyFamily.PAYMENT_BASE)
|
||||
|
|
|
@ -280,7 +280,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||
def has_lightning(self):
|
||||
return bool(self.lnworker)
|
||||
|
||||
def can_have_lightning(self):
|
||||
# we want static_remotekey to be a wallet address
|
||||
return self.txin_type == 'p2wpkh'
|
||||
|
||||
def init_lightning(self):
|
||||
assert self.can_have_lightning()
|
||||
if self.db.get('lightning_privkey2'):
|
||||
return
|
||||
# TODO derive this deterministically from wallet.keystore at keystore generation time
|
||||
|
|
Loading…
Add table
Reference in a new issue