Skip to content

Commit

Permalink
Mint: Talk to LND via gRPC (#595)
Browse files Browse the repository at this point in the history
* protos + lnd_grpc.py + __init__ +  status method

* `create_invoice`

* `pay_invoice`, `pay_partial_invoice` and router pb2

* `get_invoice_status`

* channel keep-alive options

* Update lnd_grpc.py

* `get_payment_status` + make format

* `get_payment_quote` and `paid_invoices_stream`. This was suspiciously easy...

* download_and_build script modified to fix the imports on generated code

* pyproject with new dependencies

* update poetry.lock

* fixed errors in `pay_partial_invoice`

* update .env.example

* make format

* enable regtest

* update .env.example

* suggested fixes

* suggested changes pt.2

* Update cashu/core/settings.py

Co-authored-by: callebtc <[email protected]>

---------

Co-authored-by: callebtc <[email protected]>
  • Loading branch information
lollerfirst and callebtc authored Jul 29, 2024
1 parent 4d0d25f commit d388508
Show file tree
Hide file tree
Showing 19 changed files with 25,240 additions and 98 deletions.
24 changes: 19 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,31 @@ MINT_DATABASE=data/mint
# MINT_DATABASE=postgres://cashu:cashu@localhost:5432/cashu

# Funding source backends
# Supported: FakeWallet, LndRestWallet, CLNRestWallet, BlinkWallet, LNbitsWallet, StrikeWallet, CoreLightningRestWallet (deprecated)
# Set one funding source backend for each unit
# Supported: FakeWallet, LndRestWallet, LndRPCWallet, CLNRestWallet, BlinkWallet, LNbitsWallet, StrikeWallet, CoreLightningRestWallet (deprecated)

MINT_BACKEND_BOLT11_SAT=FakeWallet
# Only works if a usd derivation path is set
# MINT_BACKEND_BOLT11_SAT=FakeWallet
# MINT_BACKEND_BOLT11_USD=FakeWallet
# MINT_BACKEND_BOLT11_EUR=FakeWallet

# for use with LNbitsWallet
MINT_LNBITS_ENDPOINT=https://legend.lnbits.com
MINT_LNBITS_KEY=yourkeyasdasdasd
# Funding source settings

# Use with LndRPCWallet
MINT_LND_RPC_ENDPOINT=localhost:10009
MINT_LND_RPC_CERT="/path/to/tls.cert"
MINT_LND_RPC_MACAROON="/path/to/admin.macaroon"

# Use with LndRestWallet
MINT_LND_REST_ENDPOINT=https://127.0.0.1:8086
MINT_LND_REST_CERT="/home/lnd/.lnd/tls.cert"
MINT_LND_REST_MACAROON="/home/lnd/.lnd/data/chain/bitcoin/regtest/admin.macaroon"
MINT_LND_REST_CERT_VERIFY=True

# Use with LND
# This setting enables MPP support for Partial multi-path payments (NUT-15)
MINT_LND_ENABLE_MPP=TRUE

# Use with CLNRestWallet
MINT_CLNREST_URL=https://localhost:3010
MINT_CLNREST_CERT="./clightning-2/regtest/ca.pem"
Expand All @@ -86,6 +96,10 @@ MINT_CORELIGHTNING_REST_URL=https://localhost:3001
MINT_CORELIGHTNING_REST_MACAROON="./clightning-rest/access.macaroon"
MINT_CORELIGHTNING_REST_CERT="./clightning-2-rest/certificate.pem"

# Use with LNbitsWallet
MINT_LNBITS_ENDPOINT=https://legend.lnbits.com
MINT_LNBITS_KEY=yourkeyasdasdasd

# Use with BlinkWallet
MINT_BLINK_KEY=blink_abcdefgh

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python-version: ["3.10"]
poetry-version: ["1.7.1"]
backend-wallet-class:
["LndRestWallet", "CLNRestWallet", "CoreLightningRestWallet", "LNbitsWallet"]
["LndRPCWallet", "LndRestWallet", "CLNRestWallet", "CoreLightningRestWallet", "LNbitsWallet"]
mint-database: ["./test_data/test_mint", "postgres://cashu:cashu@localhost:5432/cashu"]
# mint-database: ["./test_data/test_mint"]
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/regtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,18 @@ jobs:
MINT_TEST_DATABASE: ${{ inputs.mint-database }}
TOR: false
MINT_BACKEND_BOLT11_SAT: ${{ inputs.backend-wallet-class }}
# LNbits wallet
MINT_LNBITS_ENDPOINT: http://localhost:5001
MINT_LNBITS_KEY: d08a3313322a4514af75d488bcc27eee
# LndRestWallet
MINT_LND_REST_ENDPOINT: https://localhost:8081/
MINT_LND_REST_CERT: ./regtest/data/lnd-3/tls.cert
MINT_LND_REST_MACAROON: ./regtest/data/lnd-3/data/chain/bitcoin/regtest/admin.macaroon
# LndRPCWallet
MINT_LND_RPC_ENDPOINT: localhost:10009
MINT_LND_RPC_CERT: ./regtest/data/lnd-3/tls.cert
MINT_LND_RPC_MACAROON: ./regtest/data/lnd-3/data/chain/bitcoin/regtest/admin.macaroon

MINT_LND_ENABLE_MPP: true
# LND_GRPC_ENDPOINT: localhost
# LND_GRPC_PORT: 10009
Expand Down
5 changes: 5 additions & 0 deletions cashu/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ class LndRestFundingSource(MintSettings):
mint_lnd_rest_invoice_macaroon: Optional[str] = Field(default=None)
mint_lnd_enable_mpp: bool = Field(default=False)

class LndRPCFundingSource(MintSettings):
mint_lnd_rpc_endpoint: Optional[str] = Field(default=None)
mint_lnd_rpc_cert: Optional[str] = Field(default=None)
mint_lnd_rpc_macaroon: Optional[str] = Field(default=None)

class CLNRestFundingSource(MintSettings):
mint_clnrest_url: Optional[str] = Field(default=None)
Expand All @@ -217,6 +221,7 @@ class CoreLightningRestFundingSource(MintSettings):

class Settings(
EnvSettings,
LndRPCFundingSource,
LndRestFundingSource,
CoreLightningRestFundingSource,
CLNRestFundingSource,
Expand Down
1 change: 1 addition & 0 deletions cashu/lightning/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .corelightningrest import CoreLightningRestWallet # noqa: F401
from .fake import FakeWallet # noqa: F401
from .lnbits import LNbitsWallet # noqa: F401
from .lnd_grpc.lnd_grpc import LndRPCWallet # noqa: F401
from .lndrest import LndRestWallet # noqa: F401
from .strike import StrikeWallet # noqa: F401

Expand Down
Loading

0 comments on commit d388508

Please sign in to comment.