1
0

Swaps over Nostr

- Separation between SwapManager and its transport:
   Legacy transpport uses http, Nostr uses websockets
 - The transport uses a context to open/close connections.
   This context is not async, because it needs to be called
   from the GUI
 - Swapserver fees values are initialized to None instead
   of 0, so that any attempt to use them before the swap
   manager is initialized will raise an exception.
 - Remove swapserver fees disk caching (swap_pairs file)
 - Regtests use http transport
 - Android uses http transport (until QML is ready)
This commit is contained in:
ThomasV
2024-10-10 12:30:27 +02:00
parent 7fdf1e0669
commit 60f13a977e
15 changed files with 549 additions and 211 deletions

View File

@@ -15,7 +15,7 @@ if TYPE_CHECKING:
from electrum.wallet import Abstract_Wallet
class SwapServer(Logger, EventListener):
class HttpSwapServer(Logger, EventListener):
"""
public API:
- getpairs
@@ -57,7 +57,7 @@ class SwapServer(Logger, EventListener):
async def get_pairs(self, r):
sm = self.sm
sm.init_pairs()
sm.server_update_pairs()
pairs = {
"info": [],
"warnings": [],

View File

@@ -29,7 +29,7 @@ from typing import TYPE_CHECKING
from electrum.plugin import BasePlugin, hook
from .server import SwapServer
from .server import HttpSwapServer
if TYPE_CHECKING:
from electrum.simple_config import SimpleConfig
@@ -49,12 +49,6 @@ class SwapServerPlugin(BasePlugin):
# we use the first wallet loaded
if self.server is not None:
return
if self.config.NETWORK_OFFLINE:
return
self.server = SwapServer(self.config, wallet)
sm = wallet.lnworker.swap_manager
for coro in [
self.server.run(),
]:
asyncio.run_coroutine_threadsafe(daemon.taskgroup.spawn(coro), daemon.asyncio_loop)
sm.is_server = True
sm.http_server = HttpSwapServer(self.config, wallet)