electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 08f70420e348adb9b3a0e297c7fdd9380a1161d7
parent 21e46fb14796076afca148fcd6cc8ada11a7d17a
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 22 Oct 2020 17:22:35 +0200

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

So that I don't have to figure out every time.

Diffstat:
Melectrum/submarine_swaps.py | 18++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/electrum/submarine_swaps.py b/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)