mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
encapsulate funding_address_for_channel
This commit is contained in:
parent
037290a9a8
commit
67174b9814
2 changed files with 9 additions and 6 deletions
|
@ -4,6 +4,7 @@ import binascii
|
|||
import json
|
||||
from .util import bfh, PrintError
|
||||
from .bitcoin import Hash
|
||||
from .bitcoin import redeem_script_to_address
|
||||
from .crypto import sha256
|
||||
from . import ecc
|
||||
from .lnutil import Outpoint, ChannelConfig, LocalState, RemoteState, Keypair, OnlyPubkeyKeypair, ChannelConstraints, RevocationStore
|
||||
|
@ -12,6 +13,7 @@ from .lnutil import secret_to_pubkey, derive_privkey, derive_pubkey, derive_blin
|
|||
from .lnutil import sign_and_get_sig_string
|
||||
from .lnutil import make_htlc_tx_with_open_channel, make_commitment, make_received_htlc, make_offered_htlc
|
||||
from .lnutil import HTLC_TIMEOUT_WEIGHT, HTLC_SUCCESS_WEIGHT
|
||||
from .lnutil import funding_output_script
|
||||
from contextlib import contextmanager
|
||||
|
||||
SettleHtlc = namedtuple("SettleHtlc", ["htlc_id"])
|
||||
|
@ -141,6 +143,10 @@ class HTLCStateMachine(PrintError):
|
|||
|
||||
self.state = 'DISCONNECTED'
|
||||
|
||||
def get_funding_addres(self):
|
||||
script = funding_output_script(self.local_config, self.remote_config)
|
||||
return redeem_script_to_address('p2wsh', script)
|
||||
|
||||
def add_htlc(self, htlc):
|
||||
"""
|
||||
AddHTLC adds an HTLC to the state machine's local update log. This method
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import threading
|
||||
|
||||
from .util import PrintError, bh2u, bfh, NoDynamicFeeEstimates
|
||||
from .lnutil import (funding_output_script, extract_ctn_from_tx, derive_privkey,
|
||||
from .lnutil import (extract_ctn_from_tx, derive_privkey,
|
||||
get_per_commitment_secret_from_seed, derive_pubkey,
|
||||
make_commitment_output_to_remote_address,
|
||||
RevocationStore, UnableToDeriveSecret)
|
||||
|
@ -29,7 +29,7 @@ class LNWatcher(PrintError):
|
|||
return response['params'], response['result']
|
||||
|
||||
def watch_channel(self, chan, callback):
|
||||
funding_address = funding_address_for_channel(chan)
|
||||
funding_address = chan.get_funding_address()
|
||||
self.watched_channels[funding_address] = chan, callback
|
||||
self.network.subscribe_to_addresses([funding_address], self.on_address_status)
|
||||
|
||||
|
@ -51,9 +51,6 @@ class LNWatcher(PrintError):
|
|||
callback(chan, result)
|
||||
|
||||
|
||||
def funding_address_for_channel(chan):
|
||||
script = funding_output_script(chan.local_config, chan.remote_config)
|
||||
return redeem_script_to_address('p2wsh', script)
|
||||
|
||||
|
||||
class LNChanCloseHandler(PrintError):
|
||||
|
@ -66,7 +63,7 @@ class LNChanCloseHandler(PrintError):
|
|||
self.wallet = wallet
|
||||
self.chan = chan
|
||||
self.lock = threading.Lock()
|
||||
self.funding_address = funding_address_for_channel(chan)
|
||||
self.funding_address = chan.get_funding_address()
|
||||
self.watched_addresses = set()
|
||||
network.register_callback(self.on_network_update, ['updated'])
|
||||
self.watch_address(self.funding_address)
|
||||
|
|
Loading…
Add table
Reference in a new issue