Add peers rpc to lnd (#4403)

This commit is contained in:
benthecarman 2022-06-18 18:42:08 -05:00 committed by GitHub
parent 7f43ef98ad
commit 04802ae239
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 120 additions and 1 deletions

View file

@ -17,11 +17,13 @@ Compile / scalacOptions ++= Seq(
"-Wconf:cat=deprecation:site=walletrpc\\..*:silent",
"-Wconf:cat=deprecation:site=routerrpc\\..*:silent",
"-Wconf:cat=deprecation:site=invoicesrpc\\..*:silent",
"-Wconf:cat=deprecation:site=peersrpc\\..*:silent",
"-Wconf:cat=unused-imports:site=lnrpc:silent",
"-Wconf:cat=unused-imports:site=signrpc:silent",
"-Wconf:cat=unused-imports:site=walletrpc:silent",
"-Wconf:cat=unused-imports:site=routerrpc:silent",
"-Wconf:cat=unused-imports:site=invoicesrpc:silent"
"-Wconf:cat=unused-imports:site=invoicesrpc:silent",
"-Wconf:cat=unused-imports:site=peersrpc:silent"
)
TaskKeys.downloadLnd := {

View file

@ -0,0 +1,115 @@
syntax = "proto3";
import "lightning.proto";
package peersrpc;
option go_package = "github.com/lightningnetwork/lnd/lnrpc/peersrpc";
import "scalapb/scalapb.proto";
option (scalapb.options) = {
import: "org.bitcoins.lnd.rpc.LndUtils._"
scope: PACKAGE
field_transformations : [
{
when : {
type: TYPE_UINT64
}
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt64' }}
},
{
when : {
type: TYPE_UINT32
}
set : {[scalapb.field] {type : 'org.bitcoins.core.number.UInt32' }}
}
]
};
// Peers is a service that can be used to get information and interact
// with the other nodes of the newtwork.
service Peers {
/* lncli: peers updatenodeannouncement
UpdateNodeAnnouncement allows the caller to update the node parameters
and broadcasts a new version of the node announcement to its peers.
*/
rpc UpdateNodeAnnouncement (NodeAnnouncementUpdateRequest)
returns (NodeAnnouncementUpdateResponse);
}
// UpdateAction is used to determine the kind of action we are referring to.
enum UpdateAction {
// ADD indicates this is an "insertion" kind of action.
ADD = 0;
// REMOVE indicates this is a "deletion" kind of action.
REMOVE = 1;
}
enum FeatureSet {
/*
SET_INIT identifies features that should be sent in an Init message to
a remote peer.
*/
SET_INIT = 0;
/*
SET_LEGACY_GLOBAL identifies features that should be set in the legacy
GlobalFeatures field of an Init message, which maintains backwards
compatibility with nodes that haven't implemented flat features.
*/
SET_LEGACY_GLOBAL = 1;
/*
SET_NODE_ANN identifies features that should be advertised on node
announcements.
*/
SET_NODE_ANN = 2;
/*
SET_INVOICE identifies features that should be advertised on invoices
generated by the daemon.
*/
SET_INVOICE = 3;
/*
SET_INVOICE_AMP identifies the features that should be advertised on
AMP invoices generated by the daemon.
*/
SET_INVOICE_AMP = 4;
}
message UpdateAddressAction {
// Determines the kind of action.
UpdateAction action = 1;
// The address used to apply the update action.
string address = 2;
}
message UpdateFeatureAction {
// Determines the kind of action.
UpdateAction action = 1;
// The feature bit used to apply the update action.
lnrpc.FeatureBit feature_bit = 2;
}
message NodeAnnouncementUpdateRequest {
// Set of changes for the features that the node supports.
repeated UpdateFeatureAction feature_updates = 1;
// Color is the node's color in hex code format.
string color = 2;
// Alias or nick name of the node.
string alias = 3;
// Set of changes for the node's known addresses.
repeated UpdateAddressAction address_updates = 4;
}
message NodeAnnouncementUpdateResponse {
repeated lnrpc.Op ops = 1;
}

View file

@ -37,6 +37,7 @@ import org.bitcoins.lnd.rpc.LndRpcClient._
import org.bitcoins.lnd.rpc.LndUtils._
import org.bitcoins.lnd.rpc.config._
import org.bitcoins.lnd.rpc.internal._
import peersrpc.PeersClient
import routerrpc._
import scodec.bits._
import signrpc._
@ -145,6 +146,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
lazy val signer: SignerClient = SignerClient(clientSettings)
lazy val router: RouterClient = RouterClient(clientSettings)
lazy val invoices: InvoicesClient = InvoicesClient(clientSettings)
lazy val peersClient: PeersClient = PeersClient(clientSettings)
lazy val stateClient: StateClient = StateClient(clientSettings)
def genSeed(): Future[GenSeedResponse] = {