-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_init_.py
58 lines (43 loc) · 1.73 KB
/
_init_.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import json
import asyncio
from electrum.plugin import BasePlugin, hook
from electrum.i18n import _
from electrum.gui.qt.util import EnterButton, WindowModalDialog
from electrum.wallet import Wallet
from .coinjoin import CoinJoinManager
from .coinjoin_config import CoinJoinConfig
fullname = 'firebolt-electrum'
description = _("P2P Coinjoin by ZK Proof")
available_for = ['qt']
class P2PCoinJoinPlugin(BasePlugin):
def __init__(self, parent, config, name):
BasePlugin.__init__(self, parent, config, name)
self.coinjoin_manager = CoinJoinManager()
@hook
def load_wallet(self, wallet: Wallet, window):
button = EnterButton(_("P2P CoinJoin"), lambda: self.start_coinjoin(window, wallet))
window.buttons.add(button)
def start_coinjoin(self, window, wallet: Wallet):
d = WindowModalDialog(window, _("P2P CoinJoin"))
d.setMinimumWidth(500)
vbox = d.layout()
# UI elements for CoinJoin configuration
vbox.addWidget(EnterButton(_("Start CoinJoin"), lambda: self.run_coinjoin(d, wallet)))
d.exec_()
def run_coinjoin(self, dialog, wallet: Wallet):
dialog.show_message(_("Starting CoinJoin..."))
# Example call to the CoinJoin manager with asyncio
loop = asyncio.get_event_loop()
result = loop.run_until_complete(self.coinjoin_manager.initiate_coinjoin(wallet))
if result:
dialog.show_message(_("CoinJoin complete!"))
else:
dialog.show_error(_("CoinJoin failed."))
def tests(self):
pass
self.P2PCoinJoinPlugin.load_wallet(wallet, window)
self.start_coinjoin(window, wallet)
self.run_coinjoin(d, wallet)
self.tests()
self.stop_coinjoin()