Skip to content

Commit

Permalink
accept alias for hc and display it on get-info.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Jul 22, 2022
1 parent a2c48fc commit aa8d4da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/Commands.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object Commands {
RemoteNodeInfo(
PublicKey(ByteVector.fromValidHex(params.pubkey)),
NodeAddress.fromParts(host = params.host, port = params.port),
name.getOrElse("unnamed")
params.label.getOrElse("unnamed")
)
).toEither
) match {
Expand Down Expand Up @@ -744,7 +744,11 @@ object Commands {
// @formatter:off
(("id" -> commits.map(_.channelId.toHex)) ~~
("short_channel_id" -> scid) ~~
("label" -> commits.map(_.remoteInfo.alias)) ~~
("label" -> commits.flatMap(_.remoteInfo
.alias.pipe(alias =>
if (alias == "unnamed") None else Some(alias)
)
)) ~~
("peer" ->
(("pubkey" -> commits.map(_.remoteInfo.nodeId.toString)) ~~
("our_pubkey" -> commits.map(_.remoteInfo.nodeSpecificPubKey.toString)) ~~
Expand Down
10 changes: 7 additions & 3 deletions src/main/scala/Handler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ case class UnknownCommand(method: String) extends Command
case class ShowError(err: String) extends Command
case class Ping() extends Command
case class GetInfo() extends Command
case class RequestHostedChannel(pubkey: String, host: String, port: Int)
extends Command
case class RequestHostedChannel(
pubkey: String,
host: String,
port: Int,
label: Option[String]
) extends Command
case class RemoveHostedChannel(channelId: String) extends Command
case class CreateInvoice(
description: Option[String],
Expand Down Expand Up @@ -156,7 +160,7 @@ object SprayConverters extends DefaultJsonProtocol {
implicit val convertGetInfo: JsonFormat[GetInfo] =
jsonFormat0(GetInfo.apply)
implicit val convertRequestHostedChannel: JsonFormat[RequestHostedChannel] =
jsonFormat3(RequestHostedChannel.apply)
jsonFormat4(RequestHostedChannel.apply)
implicit val convertRemoveHostedChannel: JsonFormat[RemoveHostedChannel] =
jsonFormat1(RemoveHostedChannel.apply)
implicit val convertCreateInvoice: JsonFormat[CreateInvoice] =
Expand Down

0 comments on commit aa8d4da

Please sign in to comment.