Browse Source

lnbase: use small buffer when reading, support new_channel without payment in online test, send channel_reserve_satoshis

dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
Janus 7 years ago
committed by ThomasV
parent
commit
4fdf1b9b84
  1. 5
      lib/lnbase.py
  2. 6
      lib/tests/test_lnbase_online.py

5
lib/lnbase.py

@ -625,7 +625,7 @@ class Peer(PrintError):
rn_l, rk_l = self.rn()
rn_m, rk_m = self.rn()
while True:
s = await self.reader.read(2**10)
s = await self.reader.read(1)
if not s:
raise Exception('connection closed')
self.read_buffer += s
@ -851,7 +851,8 @@ class Peer(PrintError):
delayed_payment_basepoint=local_config.delayed_basepoint.pubkey,
first_per_commitment_point=per_commitment_point_first,
to_self_delay=local_config.to_self_delay,
max_htlc_value_in_flight_msat=local_config.max_htlc_value_in_flight_msat
max_htlc_value_in_flight_msat=local_config.max_htlc_value_in_flight_msat,
channel_reserve_satoshis=10
)
self.send_message(msg)
try:

6
lib/tests/test_lnbase_online.py

@ -136,14 +136,14 @@ if __name__ == "__main__":
payment_hash = addr.paymenthash
pubkey = addr.pubkey.serialize()
amt = int(addr.amount * COIN)
advanced_channel = await peer.pay(wallet, openchannel, amt, payment_hash, pubkey, addr.min_final_cltv_expiry)
openchannel = await peer.pay(wallet, openchannel, amt, payment_hash, pubkey, addr.min_final_cltv_expiry)
elif "get_paid" in sys.argv[1]:
expected_received_sat = 200000
pay_req = lnencode(LnAddr(RHASH, amount=1/Decimal(COIN)*expected_received_sat, tags=[('d', 'one cup of coffee')]), peer.privkey[:32])
print("payment request", pay_req)
advanced_channel = await peer.receive_commitment_revoke_ack(openchannel, expected_received_sat, payment_preimage)
openchannel = await peer.receive_commitment_revoke_ack(openchannel, expected_received_sat, payment_preimage)
dumped = serialize_channels([advanced_channel])
dumped = serialize_channels([openchannel])
wallet.storage.put("channels", dumped)
wallet.storage.write()
fut = asyncio.run_coroutine_threadsafe(async_test(), network.asyncio_loop)

Loading…
Cancel
Save