1
0

backups: restore from closing tx, sweep to_remote

* add a method for backups to sweep to_remote
* to_remote sweeping needs the payment_basepoint's private key
  to sign the sweep transaction
* we restore the private key from our funding multisig pubkey
  (pubished with the closing transaction) and a static payment key secret
This commit is contained in:
bitromortac
2021-09-15 09:47:58 +02:00
committed by ThomasV
parent f746e2cc6b
commit 3a3f5059b4
3 changed files with 89 additions and 9 deletions

View File

@@ -56,9 +56,10 @@ from .lnutil import (Outpoint, LocalConfig, RemoteConfig, Keypair, OnlyPubkeyKey
ShortChannelID, map_htlcs_to_ctx_output_idxs,
fee_for_htlc_output, offered_htlc_trim_threshold_sat,
received_htlc_trim_threshold_sat, make_commitment_output_to_remote_address, FIXED_ANCHOR_SAT,
ChannelType, LNProtocolWarning)
ChannelType, LNProtocolWarning, ctx_has_anchors)
from .lnsweep import create_sweeptxs_for_our_ctx, create_sweeptxs_for_their_ctx
from .lnsweep import create_sweeptx_for_their_revoked_htlc, SweepInfo
from .lnsweep import create_sweeptx_their_backup_ctx
from .lnhtlc import HTLCManager
from .lnmsg import encode_msg, decode_msg
from .address_synchronizer import TX_HEIGHT_LOCAL
@@ -594,14 +595,19 @@ class ChannelBackup(AbstractChannel):
return True
def create_sweeptxs_for_their_ctx(self, ctx):
return {}
return create_sweeptx_their_backup_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
def create_sweeptxs_for_our_ctx(self, ctx):
if self.is_imported:
return create_sweeptxs_for_our_ctx(chan=self, ctx=ctx, sweep_address=self.get_sweep_address())
else:
# backup from op_return
return {}
return
def maybe_sweep_revoked_htlc(self, ctx: Transaction, htlc_tx: Transaction) -> Optional[SweepInfo]:
return None
def extract_preimage_from_htlc_txin(self, txin: TxInput) -> None:
return None
def get_funding_address(self):
return self.cb.funding_address