diff --git a/bitcart/coins/__init__.py b/bitcart/coins/__init__.py index 6b24848..0f11878 100644 --- a/bitcart/coins/__init__.py +++ b/bitcart/coins/__init__.py @@ -1,6 +1,7 @@ from .bch import BCH from .bnb import BNB from .btc import BTC +from .btclnd import BTCLND from .eth import ETH from .grs import GRS from .ltc import LTC @@ -11,6 +12,7 @@ COINS = { "BTC": BTC, + "BTCLND": BTCLND, "BCH": BCH, "XMR": XMR, "ETH": ETH, diff --git a/bitcart/coins/btc.py b/bitcart/coins/btc.py index b4a7e9f..68466ea 100644 --- a/bitcart/coins/btc.py +++ b/bitcart/coins/btc.py @@ -453,7 +453,7 @@ async def validate_key(self, key: str, *args: Any, **kwargs: Any) -> bool: ### Lightning apis ### @lightning - async def open_channel(self, node_id: str, amount: AmountType) -> str: + async def open_channel(self, node_id: str, amount: AmountType, private: bool = False) -> str: """Open lightning channel Open channel with node, returns string of format @@ -463,6 +463,7 @@ async def open_channel(self, node_id: str, amount: AmountType) -> str: self (BTC): self node_id (str): id of node to open channel with amount (AmountType): amount to open channel + private (bool): if True, open an unannounced (private) channel Returns: str: string of format txid:output_index diff --git a/bitcart/coins/btclnd.py b/bitcart/coins/btclnd.py new file mode 100644 index 0000000..1a0fac8 --- /dev/null +++ b/bitcart/coins/btclnd.py @@ -0,0 +1,31 @@ +"""BitcoinLND SDK coin class. + +Provides the same interface as BTC but connects to the BTCLND daemon +(LND-backed) instead of Electrum. +""" + +from .btc import BTC + + +class BTCLND(BTC): + coin_name = "BTCLND" + friendly_name = "Bitcoin (LND)" + display_symbol = "BTC" # Show "BTC" to customers on checkout, not "BTCLND" + xpub_name = "Seed" + RPC_URL = "http://localhost:5012" + RPC_USER = "electrum" + RPC_PASS = "electrumz" # noqa + # LND only supports hot wallets (seed-based), not watch-only + hot_wallet_only = True + # Lightning is always enabled with LND + lightning_default = True + # LND supports Tor hybrid mode + supports_tor = True + supports_zero_conf = True + # Rate rules: define fixed SATS conversion (1 BTC = 100,000,000 SATS) + # Uses BTCLND prefix (internal currency name) matching how the rate engine looks up rules + rate_rules = "BTCLND_SATS = 100000000\nBTCLND_BTC = 1" + + async def open_channel(self, node_id: str, amount, private: bool = False) -> str: + """Open lightning channel with announced/unannounced support.""" + return await self.server.open_channel(node_id, amount, private=private)