mirror of
https://github.com/aljazceru/breez-lnd.git
synced 2025-12-24 01:24:25 +01:00
lnrpc: expose network name in GetInfo
Previously only a testnet boolean was available which made it impossible to distinguish between regtest and mainnet.
This commit is contained in:
@@ -1669,6 +1669,11 @@ var getInfoCommand = cli.Command{
|
|||||||
Action: actionDecorator(getInfo),
|
Action: actionDecorator(getInfo),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type chain struct {
|
||||||
|
Chain string `json:"chain"`
|
||||||
|
Network string `json:"network"`
|
||||||
|
}
|
||||||
|
|
||||||
func getInfo(ctx *cli.Context) error {
|
func getInfo(ctx *cli.Context) error {
|
||||||
ctxb := context.Background()
|
ctxb := context.Background()
|
||||||
client, cleanUp := getClient(ctx)
|
client, cleanUp := getClient(ctx)
|
||||||
@@ -1680,6 +1685,14 @@ func getInfo(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chains := make([]chain, len(resp.Chains))
|
||||||
|
for i, c := range resp.Chains {
|
||||||
|
chains[i] = chain{
|
||||||
|
Chain: c.Chain,
|
||||||
|
Network: c.Network,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We print a struct that mimics the proto definition of GetInfoResponse
|
// We print a struct that mimics the proto definition of GetInfoResponse
|
||||||
// but has a better ordering for the same list of fields.
|
// but has a better ordering for the same list of fields.
|
||||||
printJSON(struct {
|
printJSON(struct {
|
||||||
@@ -1695,7 +1708,7 @@ func getInfo(ctx *cli.Context) error {
|
|||||||
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
|
BestHeaderTimestamp int64 `json:"best_header_timestamp"`
|
||||||
SyncedToChain bool `json:"synced_to_chain"`
|
SyncedToChain bool `json:"synced_to_chain"`
|
||||||
Testnet bool `json:"testnet"`
|
Testnet bool `json:"testnet"`
|
||||||
Chains []string `json:"chains"`
|
Chains []chain `json:"chains"`
|
||||||
Uris []string `json:"uris"`
|
Uris []string `json:"uris"`
|
||||||
}{
|
}{
|
||||||
Version: resp.Version,
|
Version: resp.Version,
|
||||||
@@ -1710,7 +1723,7 @@ func getInfo(ctx *cli.Context) error {
|
|||||||
BestHeaderTimestamp: resp.BestHeaderTimestamp,
|
BestHeaderTimestamp: resp.BestHeaderTimestamp,
|
||||||
SyncedToChain: resp.SyncedToChain,
|
SyncedToChain: resp.SyncedToChain,
|
||||||
Testnet: resp.Testnet,
|
Testnet: resp.Testnet,
|
||||||
Chains: resp.Chains,
|
Chains: chains,
|
||||||
Uris: resp.Uris,
|
Uris: resp.Uris,
|
||||||
})
|
})
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
1154
lnrpc/rpc.pb.go
1154
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@@ -1134,11 +1134,13 @@ message GetInfoResponse {
|
|||||||
/// Whether the wallet's view is synced to the main chain
|
/// Whether the wallet's view is synced to the main chain
|
||||||
bool synced_to_chain = 9 [json_name = "synced_to_chain"];
|
bool synced_to_chain = 9 [json_name = "synced_to_chain"];
|
||||||
|
|
||||||
/// Whether the current node is connected to testnet
|
/**
|
||||||
bool testnet = 10 [json_name = "testnet"];
|
Whether the current node is connected to testnet. This field is
|
||||||
|
deprecated and the network field should be used instead
|
||||||
|
**/
|
||||||
|
bool testnet = 10 [json_name = "testnet", deprecated = true];
|
||||||
|
|
||||||
/// A list of active chains the node is connected to
|
reserved 11;
|
||||||
repeated string chains = 11 [json_name = "chains"];
|
|
||||||
|
|
||||||
/// The URIs of the current node.
|
/// The URIs of the current node.
|
||||||
repeated string uris = 12 [json_name = "uris"];
|
repeated string uris = 12 [json_name = "uris"];
|
||||||
@@ -1151,6 +1153,17 @@ message GetInfoResponse {
|
|||||||
|
|
||||||
/// Number of inactive channels
|
/// Number of inactive channels
|
||||||
uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
|
uint32 num_inactive_channels = 15 [json_name = "num_inactive_channels"];
|
||||||
|
|
||||||
|
/// A list of active chains the node is connected to
|
||||||
|
repeated Chain chains = 16 [json_name = "chains"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message Chain {
|
||||||
|
/// The blockchain the node is on (eg bitcoin, litecoin)
|
||||||
|
string chain = 1 [json_name = "chain"];
|
||||||
|
|
||||||
|
/// The network the node is on (eg regtest, testnet, mainnet)
|
||||||
|
string network = 2 [json_name = "network"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message ConfirmationUpdate {
|
message ConfirmationUpdate {
|
||||||
|
|||||||
@@ -1284,6 +1284,17 @@
|
|||||||
"description": "- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)\n- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)",
|
"description": "- `p2wkh`: Pay to witness key hash (`WITNESS_PUBKEY_HASH` = 0)\n- `np2wkh`: Pay to nested witness key hash (`NESTED_PUBKEY_HASH` = 1)",
|
||||||
"title": "* \n`AddressType` has to be one of:"
|
"title": "* \n`AddressType` has to be one of:"
|
||||||
},
|
},
|
||||||
|
"lnrpcChain": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"chain": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"network": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"lnrpcChangePasswordRequest": {
|
"lnrpcChangePasswordRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -1859,14 +1870,7 @@
|
|||||||
"testnet": {
|
"testnet": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"format": "boolean",
|
"format": "boolean",
|
||||||
"title": "/ Whether the current node is connected to testnet"
|
"title": "* \nWhether the current node is connected to testnet. This field is \ndeprecated and the network field should be used instead"
|
||||||
},
|
|
||||||
"chains": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"title": "/ A list of active chains the node is connected to"
|
|
||||||
},
|
},
|
||||||
"uris": {
|
"uris": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
@@ -1888,6 +1892,13 @@
|
|||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "int64",
|
"format": "int64",
|
||||||
"title": "/ Number of inactive channels"
|
"title": "/ Number of inactive channels"
|
||||||
|
},
|
||||||
|
"chains": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/lnrpcChain"
|
||||||
|
},
|
||||||
|
"title": "/ A list of active chains the node is connected to"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1748,9 +1748,14 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
|||||||
"with current best block in the main chain: %v", err)
|
"with current best block in the main chain: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
activeChains := make([]string, registeredChains.NumActiveChains())
|
network := normalizeNetwork(activeNetParams.Name)
|
||||||
|
activeChains := make([]*lnrpc.Chain, registeredChains.NumActiveChains())
|
||||||
for i, chain := range registeredChains.ActiveChains() {
|
for i, chain := range registeredChains.ActiveChains() {
|
||||||
activeChains[i] = chain.String()
|
activeChains[i] = &lnrpc.Chain{
|
||||||
|
Chain: chain.String(),
|
||||||
|
Network: network,
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if external IP addresses were provided to lnd and use them
|
// Check if external IP addresses were provided to lnd and use them
|
||||||
|
|||||||
Reference in New Issue
Block a user