Merge pull request #7689 from guggero/housekeeping

Housekeeping (fix small issues, take over stale contributor PRs)
This commit is contained in:
Oliver Gugger authored and GitHub committed 2023-06-13 17:42:53 +02:00
commit cf1f44ab10
45 files changed
+406 -328

No files matched your search

+4 -4
View File
@@ -269,7 +269,7 @@ func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispat
}
// GetBlock returns a block given the corresponding block hash.
func (s *Server) GetBlock(ctx context.Context,
func (s *Server) GetBlock(_ context.Context,
in *GetBlockRequest) (*GetBlockResponse, error) {
// We'll start by reconstructing the RPC request into what the
@@ -295,8 +295,8 @@ func (s *Server) GetBlock(ctx context.Context,
// GetBestBlock returns the latest block hash and current height of the valid
// most-work chain.
func (s *Server) GetBestBlock(ctx context.Context,
req *GetBestBlockRequest) (*GetBestBlockResponse, error) {
func (s *Server) GetBestBlock(_ context.Context,
_ *GetBestBlockRequest) (*GetBestBlockResponse, error) {
blockHash, blockHeight, err := s.cfg.Chain.GetBestBlock()
if err != nil {
@@ -311,7 +311,7 @@ func (s *Server) GetBestBlock(ctx context.Context,
// GetBlockHash returns the hash of the block in the best blockchain
// at the given height.
func (s *Server) GetBlockHash(ctx context.Context,
func (s *Server) GetBlockHash(_ context.Context,
req *GetBlockHashRequest) (*GetBlockHashResponse, error) {
blockHash, err := s.cfg.Chain.GetBlockHash(req.BlockHeight)
+9 -2
View File
@@ -292,12 +292,19 @@ func AddInvoice(ctx context.Context, cfg *AddInvoiceConfig,
// If specified, add a fallback address to the payment request.
if len(invoice.FallbackAddr) > 0 {
addr, err := btcutil.DecodeAddress(invoice.FallbackAddr,
cfg.ChainParams)
addr, err := btcutil.DecodeAddress(
invoice.FallbackAddr, cfg.ChainParams,
)
if err != nil {
return nil, nil, fmt.Errorf("invalid fallback "+
"address: %v", err)
}
if !addr.IsForNet(cfg.ChainParams) {
return nil, nil, fmt.Errorf("fallback address is not "+
"for %s", cfg.ChainParams.Name)
}
options = append(options, zpay32.FallbackAddr(addr))
}
+4 -2
View File
@@ -101,8 +101,10 @@ service Lightning {
rpc SignMessage (SignMessageRequest) returns (SignMessageResponse);
/* lncli: `verifymessage`
VerifyMessage verifies a signature over a msg. The signature must be
zbase32 encoded and signed by an active node in the resident node's
VerifyMessage verifies a signature over a message and recovers the signer's
public key. The signature is only deemed valid if the recovered public key
corresponds to a node key in the public Lightning network. The signature
must be zbase32 encoded and signed by an active node in the resident node's
channel database. In addition to returning the validity of the signature,
VerifyMessage also returns the recovered pubkey from the signature.
*/
+1 -1
View File
@@ -2740,7 +2740,7 @@
},
"/v1/verifymessage": {
"post": {
"summary": "lncli: `verifymessage`\nVerifyMessage verifies a signature over a msg. The signature must be\nzbase32 encoded and signed by an active node in the resident node's\nchannel database. In addition to returning the validity of the signature,\nVerifyMessage also returns the recovered pubkey from the signature.",
"summary": "lncli: `verifymessage`\nVerifyMessage verifies a signature over a message and recovers the signer's\npublic key. The signature is only deemed valid if the recovered public key\ncorresponds to a node key in the public Lightning network. The signature\nmust be zbase32 encoded and signed by an active node in the resident node's\nchannel database. In addition to returning the validity of the signature,\nVerifyMessage also returns the recovered pubkey from the signature.",
"operationId": "Lightning_VerifyMessage",
"responses": {
"200": {
+8 -4
View File
@@ -73,8 +73,10 @@ type LightningClient interface {
// only the message digest and signature are needed for verification.
SignMessage(ctx context.Context, in *SignMessageRequest, opts ...grpc.CallOption) (*SignMessageResponse, error)
// lncli: `verifymessage`
// VerifyMessage verifies a signature over a msg. The signature must be
// zbase32 encoded and signed by an active node in the resident node's
// VerifyMessage verifies a signature over a message and recovers the signer's
// public key. The signature is only deemed valid if the recovered public key
// corresponds to a node key in the public Lightning network. The signature
// must be zbase32 encoded and signed by an active node in the resident node's
// channel database. In addition to returning the validity of the signature,
// VerifyMessage also returns the recovered pubkey from the signature.
VerifyMessage(ctx context.Context, in *VerifyMessageRequest, opts ...grpc.CallOption) (*VerifyMessageResponse, error)
@@ -1375,8 +1377,10 @@ type LightningServer interface {
// only the message digest and signature are needed for verification.
SignMessage(context.Context, *SignMessageRequest) (*SignMessageResponse, error)
// lncli: `verifymessage`
// VerifyMessage verifies a signature over a msg. The signature must be
// zbase32 encoded and signed by an active node in the resident node's
// VerifyMessage verifies a signature over a message and recovers the signer's
// public key. The signature is only deemed valid if the recovered public key
// corresponds to a node key in the public Lightning network. The signature
// must be zbase32 encoded and signed by an active node in the resident node's
// channel database. In addition to returning the validity of the signature,
// VerifyMessage also returns the recovered pubkey from the signature.
VerifyMessage(context.Context, *VerifyMessageRequest) (*VerifyMessageResponse, error)
+1 -1
View File
@@ -123,7 +123,7 @@ func (s *Server) SendToRoute(ctx context.Context,
// QueryProbability returns the current success probability estimate for a
// given node pair and amount.
func (s *Server) QueryProbability(ctx context.Context,
func (s *Server) QueryProbability(_ context.Context,
req *QueryProbabilityRequest) (*QueryProbabilityResponse, error) {
fromNode, err := route.NewVertexFromBytes(req.FromNode)
+3 -1
View File
@@ -2246,7 +2246,9 @@ type Transaction struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The raw serialized transaction.
// The raw serialized transaction. Despite the field name, this does need to be
// specified in raw bytes (or base64 encoded when using REST) and not in hex.
// To not break existing software, the field can't simply be renamed.
TxHex []byte `protobuf:"bytes,1,opt,name=tx_hex,json=txHex,proto3" json:"tx_hex,omitempty"`
// An optional label to save with the transaction. Limited to 500 characters.
Label string `protobuf:"bytes,2,opt,name=label,proto3" json:"label,omitempty"`
+3 -1
View File
@@ -712,7 +712,9 @@ message ImportTapscriptResponse {
message Transaction {
/*
The raw serialized transaction.
The raw serialized transaction. Despite the field name, this does need to be
specified in raw bytes (or base64 encoded when using REST) and not in hex.
To not break existing software, the field can't simply be renamed.
*/
bytes tx_hex = 1;
+1 -1
View File
@@ -1893,7 +1893,7 @@
"tx_hex": {
"type": "string",
"format": "byte",
"description": "The raw serialized transaction."
"description": "The raw serialized transaction. Despite the field name, this does need to be\nspecified in raw bytes (or base64 encoded when using REST) and not in hex.\nTo not break existing software, the field can't simply be renamed."
},
"label": {
"type": "string",
+8 -2
View File
@@ -1104,6 +1104,12 @@ func (w *WalletKit) FundPsbt(_ context.Context,
"%s for network %s: %v", addrStr,
w.cfg.ChainParams.Name, err)
}
if !addr.IsForNet(w.cfg.ChainParams) {
return nil, fmt.Errorf("address is not for %s",
w.cfg.ChainParams.Name)
}
pkScript, err := txscript.PayToAddrScript(addr)
if err != nil {
return nil, fmt.Errorf("error getting pk "+
@@ -1692,7 +1698,7 @@ const msgSignaturePrefix = "Bitcoin Signed Message:\n"
// SignMessageWithAddr signs a message with the private key of the provided
// address. The address needs to belong to the lnd wallet.
func (w *WalletKit) SignMessageWithAddr(ctx context.Context,
func (w *WalletKit) SignMessageWithAddr(_ context.Context,
req *SignMessageWithAddrRequest) (*SignMessageWithAddrResponse, error) {
addr, err := btcutil.DecodeAddress(req.Addr, w.cfg.ChainParams)
@@ -1757,7 +1763,7 @@ func (w *WalletKit) SignMessageWithAddr(ctx context.Context,
// provided address. There is no dependence on the private key of the address
// therefore also external addresses are allowed to verify signatures.
// Supported address types are P2PKH, P2WKH, NP2WKH, P2TR.
func (w *WalletKit) VerifyMessageWithAddr(ctx context.Context,
func (w *WalletKit) VerifyMessageWithAddr(_ context.Context,
req *VerifyMessageWithAddrRequest) (*VerifyMessageWithAddrResponse,
error) {
+9 -4
View File
@@ -144,24 +144,29 @@ func (r *ServerShell) CreateSubServer(configRegistry lnrpc.SubServerConfigDispat
return subServer, macPermissions, nil
}
// AddTower adds a new watchtower reachable at the given address and considers
// it for new sessions. If the watchtower already exists, then any new addresses
// included will be considered when dialing it for session negotiations and
// backups.
// GetInfo returns information about the Lightning node that this Handler
// instance represents. This information includes the node's public key, a list
// of network addresses that the tower is listening on, and a list of URIs that
// the node is reachable at.
func (c *Handler) GetInfo(ctx context.Context,
req *GetInfoRequest) (*GetInfoResponse, error) {
// Check if the node is active.
if err := c.isActive(); err != nil {
return nil, err
}
// Retrieve the node's public key.
pubkey := c.cfg.Tower.PubKey().SerializeCompressed()
// Retrieve a list of network addresses that the tower is listening on.
var listeners []string
for _, addr := range c.cfg.Tower.ListeningAddrs() {
listeners = append(listeners, addr.String())
}
// Retrieve a list of external IP addresses that the node is reachable
// at.
var uris []string
for _, addr := range c.cfg.Tower.ExternalIPs() {
uris = append(uris, fmt.Sprintf("%x@%v", pubkey, addr))