Browse Source

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

So that I don't have to figure out every time.
patch-4
SomberNight 4 years ago
parent
commit
08f70420e3
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 18
      electrum/submarine_swaps.py

18
electrum/submarine_swaps.py

@ -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)

Loading…
Cancel
Save