htlcswitch: eliminate HopID in favor of a [33]byte for compressed pub keys
This commit is contained in:
parent
ea57a94c2e
commit
4c7af9f16d
@ -14,7 +14,7 @@ import (
|
||||
// Currently, the payment hash is used to uniquely identify each circuit.
|
||||
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 {
|
||||
return hex.EncodeToString(k[:])
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package htlcswitch
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@ -83,15 +81,12 @@ type Peer interface {
|
||||
// SendMessage sends message to remote peer.
|
||||
SendMessage(lnwire.Message) error
|
||||
|
||||
// ID returns the lightning network peer id.
|
||||
ID() [sha256.Size]byte
|
||||
|
||||
// WipeChannel removes the passed channel from all indexes associated
|
||||
// with the peer.
|
||||
WipeChannel(*lnwallet.LightningChannel) error
|
||||
|
||||
// PubKey returns the peer public key.
|
||||
PubKey() []byte
|
||||
// PubKey returns the serialize public key of the source peer.
|
||||
PubKey() [33]byte
|
||||
|
||||
// Disconnect disconnects with peer if we have error which we can't
|
||||
// properly handle.
|
||||
|
@ -1,34 +1,21 @@
|
||||
package htlcswitch
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
|
||||
"github.com/btcsuite/golangcrypto/ripemd160"
|
||||
"github.com/go-errors/errors"
|
||||
"github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/routing"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"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
|
||||
// hop for a forwarded HTLC. The existnce of this field within the
|
||||
// ForwardingInfo struct enables the ability for HTLC to cross chain-boundaries
|
||||
// at will.
|
||||
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 (
|
||||
// BitcoinHop denotes that an HTLC is to be forwarded along the Bitcoin
|
||||
// link with the specified short channel ID.
|
||||
@ -39,9 +26,6 @@ const (
|
||||
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.
|
||||
func (c NetworkHop) String() string {
|
||||
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 (
|
||||
// exitHop is a special "hop" which denotes that an incoming HTLC is
|
||||
// meant to pay finally to the receiving node.
|
||||
|
Loading…
Reference in New Issue
Block a user