From dd23e97da99fd963b6ac38320c3b1c5235771c03 Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Mon, 6 Nov 2023 16:39:54 -0500 Subject: [PATCH 1/3] mod: update to lnd v0.17.1-beta.rc1 --- go.mod | 5 ++--- go.sum | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 59d4728..aa8bdfa 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/btcsuite/btcd/btcutil/psbt v1.1.8 github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f - github.com/btcsuite/btcwallet v0.16.10-0.20230804184612-07be54bc22cf + github.com/btcsuite/btcwallet v0.16.10-0.20231017144732-e3ff37491e9c github.com/btcsuite/btcwallet/wtxmgr v1.5.0 - github.com/lightningnetwork/lnd v0.17.0-beta + github.com/lightningnetwork/lnd v0.17.1-beta.rc1 github.com/lightningnetwork/lnd/kvdb v1.4.4 github.com/stretchr/testify v1.8.2 google.golang.org/grpc v1.56.3 @@ -136,7 +136,6 @@ require ( golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 // indirect golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect diff --git a/go.sum b/go.sum index 10d7b79..f57bebb 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtyd github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f h1:bAs4lUbRJpnnkd9VhRV3jjAVU7DJVjMaK+IsvSeZvFo= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcwallet v0.16.10-0.20230804184612-07be54bc22cf h1:iZrvu/dynDPUcLJFkKiN9wnS4EdjwZSJS1H33Rx/a1Y= -github.com/btcsuite/btcwallet v0.16.10-0.20230804184612-07be54bc22cf/go.mod h1:qUPTONX2GVX7ERHvgh352/WySsfYlrkL4729qX9o9cA= +github.com/btcsuite/btcwallet v0.16.10-0.20231017144732-e3ff37491e9c h1:+7tbYEUj0TYYIvuvE9YP+x5dU3FT/8J6Qh8d5YvQwrE= +github.com/btcsuite/btcwallet v0.16.10-0.20231017144732-e3ff37491e9c/go.mod h1:WSKhOJWUmUOHKCKEzdt+jWAHFAE/t4RqVbCwL2pEdiU= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2 h1:etuLgGEojecsDOYTII8rYiGHjGyV5xTqsXi+ZQ715UU= github.com/btcsuite/btcwallet/wallet/txauthor v1.3.2/go.mod h1:Zpk/LOb2sKqwP2lmHjaZT9AdaKsHPSbNLm2Uql5IQ/0= github.com/btcsuite/btcwallet/wallet/txrules v1.2.0 h1:BtEN5Empw62/RVnZ0VcJaVtVlBijnLlJY+dwjAye2Bg= @@ -397,8 +397,8 @@ github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display h1:pRdza2wl github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f h1:Pua7+5TcFEJXIIZ1I2YAUapmbcttmLj4TTi786bIi3s= github.com/lightningnetwork/lightning-onion v1.2.1-0.20230823005744-06182b1d7d2f/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI= -github.com/lightningnetwork/lnd v0.17.0-beta h1:Vzl2W3ClIDdffuQD5IaZwyP7CKR/CbXxWqws72Cq51g= -github.com/lightningnetwork/lnd v0.17.0-beta/go.mod h1:8w27nArqZ1P7U6FP9U78GlaTLNm7u9GhV5Edv1C1yRU= +github.com/lightningnetwork/lnd v0.17.1-beta.rc1 h1:O90nWe8yYZztT4jVFO6M012N9tabwW8uOOIQnQPYrWg= +github.com/lightningnetwork/lnd v0.17.1-beta.rc1/go.mod h1:LvdKf2VlM1gFphEqjyYnRaWdCrEhy31NNSHvONJENmU= github.com/lightningnetwork/lnd/clock v1.0.1/go.mod h1:KnQudQ6w0IAMZi1SgvecLZQZ43ra2vpDNj7H/aasemg= github.com/lightningnetwork/lnd/clock v1.1.1 h1:OfR3/zcJd2RhH0RU+zX/77c0ZiOnIMsDIBjgjWdZgA0= github.com/lightningnetwork/lnd/clock v1.1.1/go.mod h1:mGnAhPyjYZQJmebS7aevElXKTFDuO+uNFFfMXK1W8xQ= @@ -717,7 +717,6 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From b93f98a5704bc17260a7afb2c4dadd352f330e91 Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Mon, 6 Nov 2023 17:10:47 -0500 Subject: [PATCH 2/3] chainkit: add GetBlockHeader to ChainKit --- chainkit_client.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/chainkit_client.go b/chainkit_client.go index 4ce4931..3351ddb 100644 --- a/chainkit_client.go +++ b/chainkit_client.go @@ -18,6 +18,11 @@ type ChainKitClient interface { GetBlock(ctx context.Context, hash chainhash.Hash) (*wire.MsgBlock, error) + // GetBlockHeader returns a block header given the corresponding block + // hash. + GetBlockHeader(ctx context.Context, + hash chainhash.Hash) (*wire.BlockHeader, error) + // GetBestBlock returns the latest block hash and current height of the // valid most-work chain. GetBestBlock(ctx context.Context) (chainhash.Hash, int32, error) @@ -77,6 +82,33 @@ func (s *chainKitClient) GetBlock(ctxParent context.Context, return msgBlock, nil } +// GetBlockHeader returns a block header given the corresponding block hash. +func (s *chainKitClient) GetBlockHeader(ctxParent context.Context, + hash chainhash.Hash) (*wire.BlockHeader, error) { + + ctx, cancel := context.WithTimeout(ctxParent, s.timeout) + defer cancel() + + macaroonAuth := s.chainMac.WithMacaroonAuth(ctx) + req := &chainrpc.GetBlockHeaderRequest{ + BlockHash: hash[:], + } + resp, err := s.client.GetBlockHeader(macaroonAuth, req) + if err != nil { + return nil, err + } + + // Convert raw block header bytes into wire.BlockHeader. + blockHeader := &wire.BlockHeader{} + blockReader := bytes.NewReader(resp.RawBlockHeader) + err = blockHeader.Deserialize(blockReader) + if err != nil { + return nil, err + } + + return blockHeader, nil +} + // GetBestBlock returns the block hash and current height from the valid // most-work chain. func (s *chainKitClient) GetBestBlock(ctxParent context.Context) (chainhash.Hash, From 47505749bf64f6e8718f4c1eceb47579d053f969 Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Thu, 9 Nov 2023 12:39:20 -0500 Subject: [PATCH 3/3] testdata: add chainkit permissions --- testdata/permissions.json | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/testdata/permissions.json b/testdata/permissions.json index c739302..c439617 100644 --- a/testdata/permissions.json +++ b/testdata/permissions.json @@ -40,6 +40,38 @@ } ] }, + "/chainrpc.ChainKit/GetBlock": { + "permissions": [ + { + "entity": "onchain", + "action": "read" + } + ] + }, + "/chainrpc.ChainKit/GetBlockHeader": { + "permissions": [ + { + "entity": "onchain", + "action": "read" + } + ] + }, + "/chainrpc.ChainKit/GetBestBlock": { + "permissions": [ + { + "entity": "onchain", + "action": "read" + } + ] + }, + "/chainrpc.ChainKit/GetBlockHash": { + "permissions": [ + { + "entity": "onchain", + "action": "read" + } + ] + }, "/chainrpc.ChainNotifier/RegisterBlockEpochNtfn": { "permissions": [ { @@ -520,7 +552,7 @@ } ] }, - "/lnrpc.Lightning/SendCustomMessage": { + "/lnrpc.Lightning/SendCustomMessage": { "permissions": [ { "entity": "peers", @@ -584,7 +616,7 @@ } ] }, - "/lnrpc.Lightning/SubscribeCustomMessages": { + "/lnrpc.Lightning/SubscribeCustomMessages": { "permissions": [ { "entity": "peers",