refactor: remove unused code

This commit is contained in:
tecnovert
2025-10-02 23:21:30 +02:00
parent c27ea87e9f
commit 4e152d5a2b
15 changed files with 54 additions and 1898 deletions

View File

@@ -22,6 +22,8 @@ import threading
import time
import unittest
from coincurve.keys import PrivateKey
import basicswap.config as cfg
from basicswap.basicswap import (
BasicSwap,
@@ -40,9 +42,6 @@ from basicswap.basicswap_util import (
from basicswap.util.address import (
toWIF,
)
from basicswap.contrib.key import (
ECKey,
)
from basicswap.http_server import (
HttpThread,
)
@@ -291,10 +290,9 @@ class Test(unittest.TestCase):
def setUpClass(cls):
super(Test, cls).setUpClass()
eckey = ECKey()
eckey.generate()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, eckey.get_bytes())
cls.network_pubkey = eckey.get_pubkey().get_bytes().hex()
k = PrivateKey()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, k.secret)
cls.network_pubkey = k.public_key.format().hex()
if os.path.isdir(cfg.TEST_DATADIRS):
logging.info("Removing " + cfg.TEST_DATADIRS)

View File

@@ -17,6 +17,8 @@ import time
import traceback
import unittest
from coincurve.keys import PrivateKey
import basicswap.config as cfg
from basicswap.basicswap import (
BasicSwap,
@@ -33,9 +35,6 @@ from basicswap.util.address import (
from basicswap.rpc import (
callrpc,
)
from basicswap.contrib.key import (
ECKey,
)
from basicswap.http_server import (
HttpThread,
)
@@ -312,10 +311,9 @@ class Test(unittest.TestCase):
)
logging.info("Preparing swap clients.")
eckey = ECKey()
eckey.generate()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, eckey.get_bytes())
cls.network_pubkey = eckey.get_pubkey().get_bytes().hex()
k = PrivateKey()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, k.secret)
cls.network_pubkey = k.public_key.format().hex()
for i in range(NUM_NODES):
prepare_swapclient_dir(TEST_DIR, i, cls.network_key, cls.network_pubkey)

View File

@@ -22,6 +22,8 @@ import threading
import time
import unittest
from coincurve.keys import PrivateKey
import basicswap.config as cfg
from basicswap.basicswap import (
BasicSwap,
@@ -40,9 +42,6 @@ from basicswap.basicswap_util import (
from basicswap.util.address import (
toWIF,
)
from basicswap.contrib.key import (
ECKey,
)
from basicswap.http_server import (
HttpThread,
)
@@ -296,10 +295,9 @@ class Test(unittest.TestCase):
def setUpClass(cls):
super(Test, cls).setUpClass()
eckey = ECKey()
eckey.generate()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, eckey.get_bytes())
cls.network_pubkey = eckey.get_pubkey().get_bytes().hex()
k = PrivateKey()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, k.secret)
cls.network_pubkey = k.public_key.format().hex()
if os.path.isdir(cfg.TEST_DATADIRS):
logging.info("Removing " + cfg.TEST_DATADIRS)

View File

@@ -13,9 +13,6 @@ import secrets
import threading
import unittest
import basicswap.contrib.ed25519_fast as edf
import basicswap.ed25519_fast_util as edu
from coincurve.ed25519 import ed25519_get_pubkey
from coincurve.ecdsaotves import (
ecdsaotves_enc_sign,
@@ -27,7 +24,7 @@ from coincurve.keys import PrivateKey
from basicswap.contrib.mnemonic import Mnemonic
from basicswap.db import create_db_, DBMethods, KnownIdentity
from basicswap.util import i2b, h2b
from basicswap.util import h2b
from basicswap.util.address import decodeAddress
from basicswap.util.crypto import ripemd160, hash160, blake256
from basicswap.util.extkey import ExtKeyPair
@@ -191,12 +188,13 @@ class Test(unittest.TestCase):
assert "Too many decimal places" in str(e)
def test_ed25519(self):
privkey = edu.get_secret()
pubkey = edu.encodepoint(edf.scalarmult_B(privkey))
privkey_bytes = i2b(privkey)
pubkey_test = ed25519_get_pubkey(privkey_bytes)
assert pubkey == pubkey_test
privkey = bytes.fromhex(
"0b4c6e34c21b910f92c7985a8093de526f5f8677a112a8c672d1098139b70e0f"
)
pubkey = ed25519_get_pubkey(privkey)
assert pubkey == bytes.fromhex(
"5c26c518fb698e91a5858c33e9075488c55c235f391162fe9e6cbd4f694f80aa"
)
def test_ecdsa_otves(self):
coin_settings = {"rpcport": 0, "rpcauth": "none"}
@@ -591,15 +589,15 @@ class Test(unittest.TestCase):
assert decode_varint(b) == (i, expect_length)
def test_base58(self):
kv = edu.get_secret()
Kv = edu.encodepoint(edf.scalarmult_B(kv))
ks = edu.get_secret()
Ks = edu.encodepoint(edf.scalarmult_B(ks))
k = bytes.fromhex(
"0b4c6e34c21b910f92c7985a8093de526f5f8677a112a8c672d1098139b70e0f"
)
K = ed25519_get_pubkey(k)
addr = xmr_encode_address(Kv, Ks)
addr = xmr_encode_address(K, K)
assert addr.startswith("4")
addr = xmr_encode_address(Kv, Ks, 4146)
addr = xmr_encode_address(K, K, 4146)
assert addr.startswith("Wo")
def test_blake256(self):

View File

@@ -20,6 +20,8 @@ import unittest
from copy import deepcopy
from coincurve.keys import PrivateKey
import basicswap.config as cfg
from basicswap.db import (
Concepts,
@@ -48,9 +50,6 @@ from basicswap.rpc_xmr import (
from basicswap.interface.xmr import (
XMR_COIN,
)
from basicswap.contrib.key import (
ECKey,
)
from basicswap.http_server import (
HttpThread,
)
@@ -342,9 +341,8 @@ class BaseTest(unittest.TestCase):
@classmethod
def getRandomPubkey(cls):
eckey = ECKey()
eckey.generate()
return eckey.get_pubkey().get_bytes()
k = PrivateKey()
return k.public_key.format()
@classmethod
def setUpClass(cls):
@@ -652,10 +650,9 @@ class BaseTest(unittest.TestCase):
logging.info("Preparing swap clients.")
if not cls.restore_instance:
eckey = ECKey()
eckey.generate()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, eckey.get_bytes())
cls.network_pubkey = eckey.get_pubkey().get_bytes().hex()
k = PrivateKey()
cls.network_key = toWIF(PREFIX_SECRET_KEY_REGTEST, k.secret)
cls.network_pubkey = k.public_key.format().hex()
for i in range(NUM_NODES):
start_nodes = set()