UpdateChanStatus
UpdateChanStatus attempts to manually set the state of a channel (enabled, disabled, or auto). A manual "disable" request will cause the channel to stay disabled until a subsequent manual request of either "enable" or "auto".
Source: routerrpc/router.proto
gRPC
rpc UpdateChanStatus (UpdateChanStatusRequest) returns (UpdateChanStatusResponse);
REST
HTTP Method | Path |
---|---|
POST | /v2/router/updatechanstatus |
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', 'routerrpc/router.proto'], loaderOptions);
const routerrpc = grpc.loadPackageDefinition(packageDefinition).routerrpc;
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 routerrpc.Router(GRPC_HOST, creds);
let request = {
chan_point: <ChannelPoint>,
action: <ChanStatusAction>,
};
client.updateChanStatus(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the routerrpc/router.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import router_pb2 as routerrpc, router_pb2_grpc as routerstub
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 = routerstub.RouterStub(channel)
request = routerrpc.UpdateChanStatusRequest(
chan_point=<ChannelPoint>,
action=<ChanStatusAction>,
)
response = stub.UpdateChanStatus(request)
print(response)
# {
# }
- 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 = {
chan_point: <object>, // <ChannelPoint>
action: <string>, // <ChanStatusAction>
};
let options = {
url: `https://${REST_HOST}/v2/router/updatechanstatus`,
// 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:
// {
// }
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/router/updatechanstatus'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
data = {
'chan_point': <ChannelPoint>,
'action': <ChanStatusAction>,
}
r = requests.post(url, headers=headers, data=json.dumps(data), verify=TLS_PATH)
print(r.json())
# {
# }
$ lncli updatechanstatus --help
NAME:
lncli updatechanstatus - Set the status of an existing channel on the network.
USAGE:
lncli updatechanstatus [command options] funding_txid [output_index] action
CATEGORY:
Channels
DESCRIPTION:
Set the status of an existing channel on the network. The actions can
be "enable", "disable", or "auto". If the action changes the status, a
message will be broadcast over the network.
Note that enabling / disabling a channel using this command ONLY affects
what's advertised over the network. For example, disabling a channel
using this command does not close it.
If a channel is manually disabled, automatic / background requests to
re-enable the channel will be ignored. However, if a channel is
manually enabled, automatic / background requests to disable the
channel will succeed (such requests are usually made on channel close
or when the peer is down).
The "auto" action restores automatic channel state management. Per
the behavior described above, it's only needed to undo the effect of
a prior "disable" action, and will be a no-op otherwise.
OPTIONS:
--funding_txid value the txid of the channel's funding transaction
--output_index value the output index for the funding output of the funding transaction (default: 0)
--chan_point value the channel whose status should be updated. Takes the form of: txid:output_index
--action value the action to take: must be one of "enable", "disable", or "auto"
Messages
routerrpc.UpdateChanStatusRequest
Source: routerrpc/router.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
chan_point | ChannelPoint | object | body |
action | ChanStatusAction | string | body |
routerrpc.UpdateChanStatusResponse
Source: routerrpc/router.proto
note
This response has no parameters.
Nested Messages
lnrpc.ChannelPoint
Field | gRPC Type | REST Type |
---|---|---|
funding_txid_bytes | bytes | string |
funding_txid_str | string | string |
output_index | uint32 | integer |
Enums
routerrpc.ChanStatusAction
Name | Number |
---|---|
ENABLE | 0 |
DISABLE | 1 |
AUTO | 2 |