Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor commitments, new payment basepoint #7509

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7926219
prepare a channel to have anchors
bitromortac Sep 13, 2021
6426e3a
add static payment key
bitromortac Sep 22, 2021
a3cd1fd
lnutil: update ctx fee calculation for anchors
bitromortac Sep 13, 2021
85c6a83
lnchannel+lnutil: change htlc output, send new sig
bitromortac Sep 13, 2021
7816110
lnutil+lnchannel: add anchors, adapt to_remote
bitromortac Sep 13, 2021
3500246
tests: add anchor commitment test vectors from rfc
bitromortac Sep 13, 2021
81d7556
lnsweep: update sweeps to_remote and htlcs
bitromortac Sep 13, 2021
8a7ea74
lnwatcher: renaming and comments for clarity
bitromortac Sep 13, 2021
63d0a6a
lnwatcher: fix early cltv-locked claiming
bitromortac Sep 13, 2021
f456024
lnwatcher: add field for onchain htlc settlement control
bitromortac Sep 13, 2021
b88585b
backups: restore from closing tx, sweep to_remote
bitromortac Sep 15, 2021
1d89e4e
qt: add anchor channel icon
bitromortac Oct 11, 2021
205d6cb
enable anchor outputs via config option
bitromortac Sep 13, 2021
6326817
unit tests: test anchors in lnpeer and lnchannel
bitromortac Sep 13, 2021
cfb4a10
regtest: adapt to anchor channels
bitromortac Sep 15, 2021
421f32d
anchors: switch to zero-fee-htlcs
bitromortac Oct 15, 2021
3f9c530
tests: tests for both anchors and old ctx types
bitromortac Nov 8, 2021
f9210b4
sweep: rename sweep creation functions and reorder
bitromortac Nov 12, 2021
f4ebe6e
htlctx: deal with possible peer htlctx batching
bitromortac Nov 15, 2021
5cb97c0
watchtower: only send first-stage HTLC justice txs
bitromortac Nov 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions electrum/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ def load_wallet(self, path, password, *, manual_upgrades=True) -> Optional[Abstr
return
wallet = Wallet(db, storage, config=self.config)
wallet.start_network(self.network)
if wallet.lnworker:
wallet.lnworker.maybe_enable_anchors_store_password(password)
self._wallets[path] = wallet
return wallet

Expand Down
Binary file added electrum/gui/icons/anchor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion electrum/gui/kivy/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ def on_start(self):
util.register_callback(self.on_channel_db, ['channel_db'])
util.register_callback(self.set_num_peers, ['gossip_peers'])
util.register_callback(self.set_unknown_channels, ['unknown_channels'])

if self.network and self.electrum_config.get('auto_connect') is None:
self.popup_dialog("first_screen")
# load_wallet_on_start will be called later, after initial network setup is completed
Expand Down Expand Up @@ -690,6 +690,8 @@ def on_wizard_success(self, storage, db, password):
self.logger.info(f'use single password: {self._use_single_password}')
wallet = Wallet(db, storage, config=self.electrum_config)
wallet.start_network(self.daemon.network)
if wallet.lnworker:
wallet.lnworker.maybe_enable_anchors_store_password(password)
self.daemon.add_wallet(wallet)
self.load_wallet(wallet)

Expand Down
4 changes: 3 additions & 1 deletion electrum/gui/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def start_new_window(self, path, uri, *, app_is_starting=False) -> Optional[Elec
def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wallet]:
wizard = InstallWizard(self.config, self.app, self.plugins, gui_object=self)
try:
path, storage = wizard.select_storage(path, self.daemon.get_wallet)
path, storage, password = wizard.select_storage(path, self.daemon.get_wallet)
# storage is None if file does not exist
if storage is None:
wizard.path = path # needed by trustedcoin plugin
Expand All @@ -372,6 +372,8 @@ def _start_wizard_to_select_or_create_wallet(self, path) -> Optional[Abstract_Wa
if storage is None or db.get_action():
return
wallet = Wallet(db, storage, config=self.config)
if wallet.lnworker:
wallet.lnworker.maybe_enable_anchors_store_password(password)
wallet.start_network(self.daemon.network)
self.daemon.add_wallet(wallet)
return wallet
Expand Down
9 changes: 9 additions & 0 deletions electrum/gui/qt/channels_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,13 @@ def icon(self) -> QIcon:
return read_QIcon("nocloud")


class ChanFeatAnchors(ChannelFeature):
def tooltip(self) -> str:
return _("This channel uses anchor outputs.")
def icon(self) -> QIcon:
return read_QIcon("anchor")


class ChannelFeatureIcons:
ICON_SIZE = QSize(16, 16)

Expand All @@ -548,6 +555,8 @@ def from_channel(cls, chan: AbstractChannel) -> 'ChannelFeatureIcons':
feats.append(ChanFeatTrampoline())
if not chan.has_onchain_backup():
feats.append(ChanFeatNoOnchainBackup())
if chan.has_anchors():
feats.append(ChanFeatAnchors())
return ChannelFeatureIcons(feats)

def paint(self, painter: QPainter, rect: QRect) -> None:
Expand Down
11 changes: 6 additions & 5 deletions electrum/gui/qt/installwizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def __init__(self, config: 'SimpleConfig', app: QApplication, plugins: 'Plugins'
self.raise_()
self.refresh_gui() # Need for QT on MacOSX. Lame.

def select_storage(self, path, get_wallet_from_daemon) -> Tuple[str, Optional[WalletStorage]]:
def select_storage(self, path, get_wallet_from_daemon) -> Tuple[str, Optional[WalletStorage], Optional[str]]:

vbox = QVBoxLayout()
hbox = QHBoxLayout()
Expand Down Expand Up @@ -302,8 +302,9 @@ def on_filename(filename):
get_new_wallet_name(wallet_folder)))
name_e.textChanged.connect(on_filename)
name_e.setText(os.path.basename(path))
password = None

def run_user_interaction_loop():
def run_user_interaction_loop() -> Optional[str]:
while True:
if self.loop.exec_() != 2: # 2 = next
raise UserCancelled()
Expand All @@ -320,7 +321,7 @@ def run_user_interaction_loop():
password = pw_e.text()
try:
temp_storage.decrypt(password)
break
return password
except InvalidPassword as e:
self.show_message(title=_('Error'), msg=str(e))
continue
Expand Down Expand Up @@ -351,14 +352,14 @@ def run_user_interaction_loop():
raise Exception('Unexpected encryption version')

try:
run_user_interaction_loop()
password = run_user_interaction_loop()
finally:
try:
pw_e.clear()
except RuntimeError: # wrapped C/C++ object has been deleted.
pass # happens when decrypting with hw device

return temp_storage.path, (temp_storage if temp_storage.file_exists() else None)
return temp_storage.path, (temp_storage if temp_storage.file_exists() else None), password

def run_upgrades(self, storage: WalletStorage, db: 'WalletDB') -> None:
path = storage.path
Expand Down
Loading