-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the EncodedNodeId interface that can be either a public key or a pair channel id, direction that's more compact. This is used as introduction node for blinded routes. We also use EncodedNodeId for the next node to relay a message to. Which is not in the spec yet but is necessary for us since we have no way to resolve the compact node id to a public key ourselves. It requires a compatible peer that accepts this format.
- Loading branch information
1 parent
77003f9
commit 34e6834
Showing
8 changed files
with
98 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.acinq.lightning | ||
|
||
import fr.acinq.bitcoin.PublicKey | ||
import fr.acinq.bitcoin.io.Input | ||
import fr.acinq.bitcoin.io.Output | ||
import fr.acinq.lightning.wire.LightningCodecs | ||
|
||
sealed class EncodedNodeId { | ||
/** Nodes are usually identified by their public key. */ | ||
data class Plain(val publicKey: PublicKey) : EncodedNodeId() { | ||
override fun toString(): String = publicKey.toString() | ||
} | ||
|
||
/** For compactness, nodes may be identified by the shortChannelId of one of their public channels. */ | ||
data class ShortChannelIdDir(val isNode1: Boolean, val scid: ShortChannelId) : EncodedNodeId() { | ||
override fun toString(): String = if (isNode1) "<-$scid" else "$scid->" | ||
} | ||
|
||
companion object { | ||
operator fun invoke(publicKey: PublicKey): EncodedNodeId = Plain(publicKey) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters