mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-12 14:42:38 +02:00
htlcswitch: eliminate HopID in favor of a [33]byte for compressed pub keys
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
|||||||
// Currently, the payment hash is used to uniquely identify each circuit.
|
// Currently, the payment hash is used to uniquely identify each circuit.
|
||||||
type circuitKey [sha256.Size]byte
|
type circuitKey [sha256.Size]byte
|
||||||
|
|
||||||
// String represent the circuit key in string format.
|
// String returns the string representation of the circuitKey.
|
||||||
func (k *circuitKey) String() string {
|
func (k *circuitKey) String() string {
|
||||||
return hex.EncodeToString(k[:])
|
return hex.EncodeToString(k[:])
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package htlcswitch
|
package htlcswitch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
|
||||||
|
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
@@ -83,15 +81,12 @@ type Peer interface {
|
|||||||
// SendMessage sends message to remote peer.
|
// SendMessage sends message to remote peer.
|
||||||
SendMessage(lnwire.Message) error
|
SendMessage(lnwire.Message) error
|
||||||
|
|
||||||
// ID returns the lightning network peer id.
|
|
||||||
ID() [sha256.Size]byte
|
|
||||||
|
|
||||||
// WipeChannel removes the passed channel from all indexes associated
|
// WipeChannel removes the passed channel from all indexes associated
|
||||||
// with the peer.
|
// with the peer.
|
||||||
WipeChannel(*lnwallet.LightningChannel) error
|
WipeChannel(*lnwallet.LightningChannel) error
|
||||||
|
|
||||||
// PubKey returns the peer public key.
|
// PubKey returns the serialize public key of the source peer.
|
||||||
PubKey() []byte
|
PubKey() [33]byte
|
||||||
|
|
||||||
// Disconnect disconnects with peer if we have error which we can't
|
// Disconnect disconnects with peer if we have error which we can't
|
||||||
// properly handle.
|
// properly handle.
|
||||||
|
@@ -1,34 +1,21 @@
|
|||||||
package htlcswitch
|
package htlcswitch
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/btcsuite/golangcrypto/ripemd160"
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lightning-onion"
|
"github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/routing"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/roasbeef/btcd/btcec"
|
|
||||||
"github.com/roasbeef/btcutil"
|
"github.com/roasbeef/btcutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
// HopID represents the id which is used by propagation subsystem in order to
|
|
||||||
// identify lightning network node.
|
|
||||||
// TODO(andrew.shvv) remove after switching to the using channel id.
|
|
||||||
type HopID [ripemd160.Size]byte
|
|
||||||
// NetworkHop indicates the blockchain network that is intended to be the next
|
// NetworkHop indicates the blockchain network that is intended to be the next
|
||||||
// hop for a forwarded HTLC. The existnce of this field within the
|
// hop for a forwarded HTLC. The existnce of this field within the
|
||||||
// ForwardingInfo struct enables the ability for HTLC to cross chain-boundaries
|
// ForwardingInfo struct enables the ability for HTLC to cross chain-boundaries
|
||||||
// at will.
|
// at will.
|
||||||
type NetworkHop uint8
|
type NetworkHop uint8
|
||||||
|
|
||||||
// NewHopID creates new instance of hop form node public key.
|
|
||||||
func NewHopID(pubKey []byte) HopID {
|
|
||||||
var routeID HopID
|
|
||||||
copy(routeID[:], btcutil.Hash160(pubKey))
|
|
||||||
return routeID
|
|
||||||
}
|
|
||||||
const (
|
const (
|
||||||
// BitcoinHop denotes that an HTLC is to be forwarded along the Bitcoin
|
// BitcoinHop denotes that an HTLC is to be forwarded along the Bitcoin
|
||||||
// link with the specified short channel ID.
|
// link with the specified short channel ID.
|
||||||
@@ -39,9 +26,6 @@ const (
|
|||||||
LitecoinHop
|
LitecoinHop
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns string representation of hop id.
|
|
||||||
func (h HopID) String() string {
|
|
||||||
return hex.EncodeToString(h[:])
|
|
||||||
// String returns the string representation of the target NetworkHop.
|
// String returns the string representation of the target NetworkHop.
|
||||||
func (c NetworkHop) String() string {
|
func (c NetworkHop) String() string {
|
||||||
switch c {
|
switch c {
|
||||||
@@ -54,9 +38,6 @@ func (c NetworkHop) String() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEqual checks does the two hop ids are equal.
|
|
||||||
func (h HopID) IsEqual(h2 HopID) bool {
|
|
||||||
return bytes.Equal(h[:], h2[:])
|
|
||||||
var (
|
var (
|
||||||
// exitHop is a special "hop" which denotes that an incoming HTLC is
|
// exitHop is a special "hop" which denotes that an incoming HTLC is
|
||||||
// meant to pay finally to the receiving node.
|
// meant to pay finally to the receiving node.
|
||||||
|
Reference in New Issue
Block a user