commit 04ec7e9968e80abddf073be07608a49b3a9d9382
parent 1f97a9753ec14e568b179874d874f46af70b85d4
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 22 Oct 2018 20:39:44 +0200
lnutil.make_funding_input: don't return payment pubkeys
order depends on who is initiator anyway
Diffstat:
2 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/electrum/lnchan.py b/electrum/lnchan.py
@@ -159,7 +159,8 @@ class Channel(PrintError):
def get_state(self):
return self._state
- def check_can_pay(self, amount_msat):
+ def check_can_pay(self, amount_msat: int) -> None:
+ # FIXME channel reserve
if self.get_state() != 'OPEN':
raise PaymentFailure('Channel not open')
if self.available_to_spend(LOCAL) < amount_msat:
@@ -168,6 +169,8 @@ class Channel(PrintError):
raise PaymentFailure('Too many HTLCs already in channel')
if htlcsum(self.htlcs(LOCAL, only_pending=True)) + amount_msat > self.config[REMOTE].max_htlc_value_in_flight_msat:
raise PaymentFailure('HTLC value sum would exceed max allowed: {} msat'.format(self.config[REMOTE].max_htlc_value_in_flight_msat))
+ if amount_msat <= 0: # FIXME htlc_minimum_msat
+ raise PaymentFailure(f'HTLC value too small: {amount_msat} msat')
def can_pay(self, amount_msat):
try:
@@ -722,8 +725,6 @@ class Channel(PrintError):
closing_tx = make_closing_tx(self.config[LOCAL].multisig_key.pubkey,
self.config[REMOTE].multisig_key.pubkey,
- self.config[LOCAL].payment_basepoint.pubkey,
- self.config[REMOTE].payment_basepoint.pubkey,
# TODO hardcoded we_are_initiator:
True, *self.funding_outpoint, self.constraints.capacity,
outputs)
diff --git a/electrum/lnutil.py b/electrum/lnutil.py
@@ -320,10 +320,8 @@ def make_htlc_tx_with_open_channel(chan, pcp, for_us, we_receive, commit, htlc):
return script, htlc_tx
def make_funding_input(local_funding_pubkey: bytes, remote_funding_pubkey: bytes,
- payment_basepoint: bytes, remote_payment_basepoint: bytes,
funding_pos: int, funding_txid: bytes, funding_sat: int):
pubkeys = sorted([bh2u(local_funding_pubkey), bh2u(remote_funding_pubkey)])
- payments = [payment_basepoint, remote_payment_basepoint]
# commitment tx input
c_input = {
'type': 'p2wsh',
@@ -335,7 +333,7 @@ def make_funding_input(local_funding_pubkey: bytes, remote_funding_pubkey: bytes
'value': funding_sat,
'coinbase': False,
}
- return c_input, payments
+ return c_input
class HTLCOwner(IntFlag):
LOCAL = 1
@@ -374,16 +372,15 @@ def calc_onchain_fees(num_htlcs, feerate, for_us, we_are_initiator):
return {LOCAL: fee if we_pay_fee else 0, REMOTE: fee if not we_pay_fee else 0}
def make_commitment(ctn, local_funding_pubkey, remote_funding_pubkey,
- remote_payment_pubkey, payment_basepoint,
- remote_payment_basepoint, revocation_pubkey,
+ remote_payment_pubkey, funder_payment_basepoint,
+ fundee_payment_basepoint, revocation_pubkey,
delayed_pubkey, to_self_delay, funding_txid,
funding_pos, funding_sat, local_amount, remote_amount,
dust_limit_sat, fees_per_participant,
htlcs):
- c_input, payments = make_funding_input(local_funding_pubkey, remote_funding_pubkey,
- payment_basepoint, remote_payment_basepoint, funding_pos,
- funding_txid, funding_sat)
- obs = get_obscured_ctn(ctn, *payments)
+ c_input = make_funding_input(local_funding_pubkey, remote_funding_pubkey,
+ funding_pos, funding_txid, funding_sat)
+ obs = get_obscured_ctn(ctn, funder_payment_basepoint, fundee_payment_basepoint)
locktime = (0x20 << 24) + (obs & 0xffffff)
sequence = (0x80 << 24) + (obs >> 24)
c_input['sequence'] = sequence
@@ -529,11 +526,9 @@ def get_compressed_pubkey_from_bech32(bech32_pubkey: str) -> bytes:
def make_closing_tx(local_funding_pubkey: bytes, remote_funding_pubkey: bytes,
- payment_basepoint: bytes, remote_payment_basepoint: bytes,
funding_txid: bytes, funding_pos: int, funding_sat: int, outputs: List[TxOutput]):
- c_input, payments = make_funding_input(local_funding_pubkey, remote_funding_pubkey,
- payment_basepoint, remote_payment_basepoint, funding_pos,
- funding_txid, funding_sat)
+ c_input = make_funding_input(local_funding_pubkey, remote_funding_pubkey,
+ funding_pos, funding_txid, funding_sat)
c_input['sequence'] = 0xFFFF_FFFF
tx = Transaction.from_io([c_input], outputs, locktime=0, version=2)
return tx