Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new RPCs introduced in lnd v0.18.4 #192

Merged
merged 11 commits into from
Sep 27, 2024
15 changes: 15 additions & 0 deletions chainkit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (

// ChainKitClient exposes chain functionality.
type ChainKitClient interface {
ServiceClient[chainrpc.ChainKitClient]

// GetBlock returns a block given the corresponding block hash.
GetBlock(ctx context.Context, hash chainhash.Hash) (*wire.MsgBlock,
error)
Expand Down Expand Up @@ -41,6 +43,10 @@ type chainKitClient struct {
wg sync.WaitGroup
}

// A compile time check to ensure that chainKitClient implements the
// ChainKitClient interface.
var _ ChainKitClient = (*chainKitClient)(nil)

func newChainKitClient(conn grpc.ClientConnInterface,
chainMac serializedMacaroon, timeout time.Duration) *chainKitClient {

Expand All @@ -55,6 +61,15 @@ func (s *chainKitClient) WaitForFinished() {
s.wg.Wait()
}

// RawClientWithMacAuth returns a context with the proper macaroon
// authentication, the default RPC timeout, and the raw client.
func (s *chainKitClient) RawClientWithMacAuth(
parentCtx context.Context) (context.Context, time.Duration,
chainrpc.ChainKitClient) {

return s.chainMac.WithMacaroonAuth(parentCtx), s.timeout, s.client
}

// GetBlock returns a block given the corresponding block hash.
func (s *chainKitClient) GetBlock(ctxParent context.Context,
hash chainhash.Hash) (*wire.MsgBlock, error) {
Expand Down
15 changes: 15 additions & 0 deletions chainnotifier_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ func WithReOrgChan(reOrgChan chan struct{}) NotifierOption {

// ChainNotifierClient exposes base lightning functionality.
type ChainNotifierClient interface {
ServiceClient[chainrpc.ChainNotifierClient]

RegisterBlockEpochNtfn(ctx context.Context) (
chan int32, chan error, error)

Expand All @@ -81,6 +83,10 @@ type chainNotifierClient struct {
wg sync.WaitGroup
}

// A compile time check to ensure that chainNotifierClient implements the
// ChainNotifierClient interface.
var _ ChainNotifierClient = (*chainNotifierClient)(nil)

func newChainNotifierClient(conn grpc.ClientConnInterface,
chainMac serializedMacaroon, timeout time.Duration) *chainNotifierClient {

Expand All @@ -95,6 +101,15 @@ func (s *chainNotifierClient) WaitForFinished() {
s.wg.Wait()
}

// RawClientWithMacAuth returns a context with the proper macaroon
// authentication, the default RPC timeout, and the raw client.
func (s *chainNotifierClient) RawClientWithMacAuth(
parentCtx context.Context) (context.Context, time.Duration,
chainrpc.ChainNotifierClient) {

return s.chainMac.WithMacaroonAuth(parentCtx), s.timeout, s.client
}

func (s *chainNotifierClient) RegisterSpendNtfn(ctx context.Context,
outpoint *wire.OutPoint, pkScript []byte, heightHint int32) (
chan *chainntnfs.SpendDetail, chan error, error) {
Expand Down
31 changes: 17 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/lightninglabs/lndclient

require (
github.com/btcsuite/btcd v0.24.2-beta.rc1.0.20240403021926-ae5533602c46
github.com/btcsuite/btcd v0.24.2-beta.rc1.0.20240625142744-cc26860b4026
github.com/btcsuite/btcd/btcec/v2 v2.3.3
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/btcutil/psbt v1.1.8
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
github.com/btcsuite/btcwallet v0.16.10-0.20240404104514-b2f31f9045fb
github.com/btcsuite/btcwallet v0.16.10-0.20240809133323-7d3434c65ae2
github.com/btcsuite/btcwallet/wtxmgr v1.5.3
github.com/lightningnetwork/lnd v0.18.0-beta.1
github.com/lightningnetwork/lnd/kvdb v1.4.8
github.com/lightningnetwork/lnd v0.18.0-beta.rc4.0.20240919095711-611852fd34b1
github.com/lightningnetwork/lnd/kvdb v1.4.10
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.59.0
gopkg.in/macaroon-bakery.v2 v2.0.1
Expand Down Expand Up @@ -76,9 +76,10 @@ require (
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgtype v1.14.0 // indirect
github.com/jackc/pgx/v4 v4.18.2 // indirect
github.com/jackc/pgx/v5 v5.3.1 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/jrick/logrotate v1.0.0 // indirect
github.com/jrick/logrotate v1.1.2 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/juju/clock v0.0.0-20220203021603-d9deb868a28a // indirect
github.com/juju/collections v0.0.0-20220203020748-febd7cad8a7a // indirect
Expand All @@ -89,18 +90,19 @@ require (
github.com/juju/utils/v3 v3.0.0-20220203023959-c3fbc78a33b0 // indirect
github.com/juju/version/v2 v2.0.0-20220204124744-fc9915e3d935 // indirect
github.com/kkdai/bstream v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf // indirect
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd // indirect
github.com/lightninglabs/neutrino/cache v1.1.2 // indirect
github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f // indirect
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb // indirect
github.com/lightningnetwork/lnd/clock v1.1.1 // indirect
github.com/lightningnetwork/lnd/fn v1.0.5 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.4 // indirect
github.com/lightningnetwork/lnd/fn v1.2.1 // indirect
github.com/lightningnetwork/lnd/healthcheck v1.2.5 // indirect
github.com/lightningnetwork/lnd/queue v1.1.1 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.2 // indirect
github.com/lightningnetwork/lnd/sqldb v1.0.4 // indirect
github.com/lightningnetwork/lnd/ticker v1.1.1 // indirect
github.com/lightningnetwork/lnd/tlv v1.2.3 // indirect
github.com/lightningnetwork/lnd/tlv v1.2.6 // indirect
github.com/lightningnetwork/lnd/tor v1.1.2 // indirect
github.com/ltcsuite/ltcd v0.0.0-20190101042124-f37f8bf35796 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand Down Expand Up @@ -156,7 +158,8 @@ require (
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand All @@ -174,7 +177,7 @@ require (
modernc.org/libc v1.49.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.29.8 // indirect
modernc.org/sqlite v1.29.10 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
Expand All @@ -184,6 +187,6 @@ require (
// allows us to specify that as an option.
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display

go 1.21.4
go 1.22.6

toolchain go1.22.2
toolchain go1.22.7
Loading
Loading