|
@ -20,7 +20,6 @@ import aiorpcx |
|
|
|
|
|
|
|
|
from .crypto import sha256, sha256d |
|
|
from .crypto import sha256, sha256d |
|
|
from . import bitcoin |
|
|
from . import bitcoin |
|
|
from .bip32 import BIP32Node |
|
|
|
|
|
from . import ecc |
|
|
from . import ecc |
|
|
from .ecc import sig_string_from_r_and_s, get_r_and_s_from_sig_string, der_sig_from_sig_string |
|
|
from .ecc import sig_string_from_r_and_s, get_r_and_s_from_sig_string, der_sig_from_sig_string |
|
|
from . import constants |
|
|
from . import constants |
|
@ -484,38 +483,32 @@ class Peer(Logger): |
|
|
return bool(self.features & LnFeatures.OPTION_STATIC_REMOTEKEY_OPT) |
|
|
return bool(self.features & LnFeatures.OPTION_STATIC_REMOTEKEY_OPT) |
|
|
|
|
|
|
|
|
def make_local_config(self, funding_sat: int, push_msat: int, initiator: HTLCOwner) -> LocalConfig: |
|
|
def make_local_config(self, funding_sat: int, push_msat: int, initiator: HTLCOwner) -> LocalConfig: |
|
|
# key derivation |
|
|
|
|
|
seed = os.urandom(32) |
|
|
|
|
|
node = BIP32Node.from_rootseed(seed, xtype='standard') |
|
|
|
|
|
keypair_generator = lambda family: generate_keypair(node, family) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
random_seed = os.urandom(32) |
|
|
if initiator == LOCAL: |
|
|
if initiator == LOCAL: |
|
|
initial_msat = funding_sat * 1000 - push_msat |
|
|
initial_msat = funding_sat * 1000 - push_msat |
|
|
else: |
|
|
else: |
|
|
initial_msat = push_msat |
|
|
initial_msat = push_msat |
|
|
|
|
|
|
|
|
if self.is_static_remotekey(): |
|
|
if self.is_static_remotekey(): |
|
|
|
|
|
# Note: in the future, if a CSV delay is added, |
|
|
|
|
|
# we will want to derive that key |
|
|
wallet = self.lnworker.wallet |
|
|
wallet = self.lnworker.wallet |
|
|
assert wallet.txin_type == 'p2wpkh' |
|
|
assert wallet.txin_type == 'p2wpkh' |
|
|
addr = wallet.get_unused_address() |
|
|
addr = wallet.get_unused_address() |
|
|
static_key = wallet.get_public_key(addr) # just a pubkey |
|
|
static_remotekey = bfh(wallet.get_public_key(addr)) |
|
|
payment_basepoint = OnlyPubkeyKeypair(bfh(static_key)) |
|
|
|
|
|
else: |
|
|
else: |
|
|
payment_basepoint = keypair_generator(LnKeyFamily.PAYMENT_BASE) |
|
|
static_remotekey = None |
|
|
|
|
|
|
|
|
local_config=LocalConfig( |
|
|
local_config = LocalConfig.from_seed( |
|
|
payment_basepoint=payment_basepoint, |
|
|
seed=random_seed, |
|
|
multisig_key=keypair_generator(LnKeyFamily.MULTISIG), |
|
|
static_remotekey=static_remotekey, |
|
|
htlc_basepoint=keypair_generator(LnKeyFamily.HTLC_BASE), |
|
|
|
|
|
delayed_basepoint=keypair_generator(LnKeyFamily.DELAY_BASE), |
|
|
|
|
|
revocation_basepoint=keypair_generator(LnKeyFamily.REVOCATION_BASE), |
|
|
|
|
|
to_self_delay=DEFAULT_TO_SELF_DELAY, |
|
|
to_self_delay=DEFAULT_TO_SELF_DELAY, |
|
|
dust_limit_sat=546, |
|
|
dust_limit_sat=546, |
|
|
max_htlc_value_in_flight_msat=funding_sat * 1000, |
|
|
max_htlc_value_in_flight_msat=funding_sat * 1000, |
|
|
max_accepted_htlcs=5, |
|
|
max_accepted_htlcs=5, |
|
|
initial_msat=initial_msat, |
|
|
initial_msat=initial_msat, |
|
|
reserve_sat=546, |
|
|
reserve_sat=546, |
|
|
per_commitment_secret_seed=keypair_generator(LnKeyFamily.REVOCATION_ROOT).privkey, |
|
|
|
|
|
funding_locked_received=False, |
|
|
funding_locked_received=False, |
|
|
was_announced=False, |
|
|
was_announced=False, |
|
|
current_commitment_signature=None, |
|
|
current_commitment_signature=None, |
|
|