UpdateNodeAnnouncement
lncli: peers updatenodeannouncement UpdateNodeAnnouncement allows the caller to update the node parameters and broadcasts a new version of the node announcement to its peers.
Source: peersrpc/peers.proto
gRPC
rpc UpdateNodeAnnouncement (NodeAnnouncementUpdateRequest) returns (NodeAnnouncementUpdateResponse);
REST
HTTP Method | Path |
---|---|
POST | /v2/peers/nodeannouncement |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:10009'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
const TLS_PATH = 'LND_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync(['lightning.proto', 'peersrpc/peers.proto'], loaderOptions);
const peersrpc = grpc.loadPackageDefinition(packageDefinition).peersrpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new peersrpc.Peers(GRPC_HOST, creds);
let request = {
feature_updates: <UpdateFeatureAction>,
color: <string>,
alias: <string>,
address_updates: <UpdateAddressAction>,
};
client.updateNodeAnnouncement(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "ops": <Op>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the peersrpc/peers.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import peers_pb2 as peersrpc, peers_pb2_grpc as peersstub
GRPC_HOST = 'localhost:10009'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = peersstub.PeersStub(channel)
request = peersrpc.NodeAnnouncementUpdateRequest(
feature_updates=<UpdateFeatureAction>,
color=<string>,
alias=<string>,
address_updates=<UpdateAddressAction>,
)
response = stub.UpdateNodeAnnouncement(request)
print(response)
# {
# "ops": <Op>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8080'
const MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
let requestBody = {
feature_updates: <array>, // <UpdateFeatureAction>
color: <string>, // <string>
alias: <string>, // <string>
address_updates: <array>, // <UpdateAddressAction>
};
let options = {
url: `https://${REST_HOST}/v2/peers/nodeannouncement`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
},
form: JSON.stringify(requestBody),
}
request.post(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "ops": <array>, // <Op>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8080'
MACAROON_PATH = 'LND_DIR/data/chain/bitcoin/regtest/admin.macaroon'
TLS_PATH = 'LND_DIR/tls.cert'
url = f'https://{REST_HOST}/v2/peers/nodeannouncement'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
data = {
'feature_updates': <UpdateFeatureAction>,
'color': <string>,
'alias': <string>,
'address_updates': <UpdateAddressAction>,
}
r = requests.post(url, headers=headers, data=json.dumps(data), verify=TLS_PATH)
print(r.json())
# {
# "ops": <Op>,
# }
# There is no CLI command for this RPC
Messages
peersrpc.NodeAnnouncementUpdateRequest
Source: peersrpc/peers.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
feature_updates | UpdateFeatureAction[] | array | body |
color | string | string | body |
alias | string | string | body |
address_updates | UpdateAddressAction[] | array | body |
peersrpc.NodeAnnouncementUpdateResponse
Source: peersrpc/peers.proto
Field | gRPC Type | REST Type |
---|---|---|
ops | Op[] | array |
Nested Messages
peersrpc.UpdateFeatureAction
Field | gRPC Type | REST Type |
---|---|---|
action | UpdateAction | string |
feature_bit | FeatureBit | string |
peersrpc.UpdateAddressAction
Field | gRPC Type | REST Type |
---|---|---|
action | UpdateAction | string |
address | string | string |
lnrpc.Op
Field | gRPC Type | REST Type |
---|---|---|
entity | string | string |
actions | string[] | array |
Enums
peersrpc.UpdateAction
Name | Number |
---|---|
ADD | 0 |
REMOVE | 1 |
lnrpc.FeatureBit
Name | Number |
---|---|
DATALOSS_PROTECT_REQ | 0 |
DATALOSS_PROTECT_OPT | 1 |
INITIAL_ROUING_SYNC | 3 |
UPFRONT_SHUTDOWN_SCRIPT_REQ | 4 |
UPFRONT_SHUTDOWN_SCRIPT_OPT | 5 |
GOSSIP_QUERIES_REQ | 6 |
GOSSIP_QUERIES_OPT | 7 |
TLV_ONION_REQ | 8 |
TLV_ONION_OPT | 9 |
EXT_GOSSIP_QUERIES_REQ | 10 |
EXT_GOSSIP_QUERIES_OPT | 11 |
STATIC_REMOTE_KEY_REQ | 12 |
STATIC_REMOTE_KEY_OPT | 13 |
PAYMENT_ADDR_REQ | 14 |
PAYMENT_ADDR_OPT | 15 |
MPP_REQ | 16 |
MPP_OPT | 17 |
WUMBO_CHANNELS_REQ | 18 |
WUMBO_CHANNELS_OPT | 19 |
ANCHORS_REQ | 20 |
ANCHORS_OPT | 21 |
ANCHORS_ZERO_FEE_HTLC_REQ | 22 |
ANCHORS_ZERO_FEE_HTLC_OPT | 23 |
AMP_REQ | 30 |
AMP_OPT | 31 |