submarine_swaps: describe event-flow for both swap direction in docstr

So that I don't have to figure out every time.
This commit is contained in:
SomberNight 2020-10-22 17:22:35 +02:00
parent 21e46fb147
commit 08f70420e3
No known key found for this signature in database
GPG key ID: B33B5F232C6271E9

View file

@ -218,7 +218,13 @@ class SwapManager(Logger):
async def normal_swap(self, lightning_amount: int, expected_onchain_amount: int,
password, *, tx: PartialTransaction = None) -> str:
"""send on-chain BTC, receive on Lightning"""
"""send on-chain BTC, receive on Lightning
- User generates an LN invoice with RHASH, and knows preimage.
- User creates on-chain output locked to RHASH.
- Server pays LN invoice. User reveals preimage.
- Server spends the on-chain output using preimage.
"""
assert self.network
assert self.lnwatcher
privkey = os.urandom(32)
@ -296,7 +302,15 @@ class SwapManager(Logger):
return tx.txid()
async def reverse_swap(self, amount_sat: int, expected_amount: int) -> bool:
"""send on Lightning, receive on-chain"""
"""send on Lightning, receive on-chain
- User generates preimage, RHASH. Sends RHASH to server.
- Server creates an LN invoice for RHASH.
- User pays LN invoice - except server needs to hold the HTLC as preimage is unknown.
- Server creates on-chain output locked to RHASH.
- User spends on-chain output, revealing preimage.
- Server fulfills HTLC using preimage.
"""
assert self.network
assert self.lnwatcher
privkey = os.urandom(32)