lnwire: converge discovery part of messages with specification
Change the name of fields of messages which are belong to the discovery subsystem in a such way so they were the same with the names that are defined in the specification.
This commit is contained in:
parent
54b3541707
commit
c3b2854428
@ -344,7 +344,7 @@ func (d *Discovery) networkHandler() {
|
|||||||
func(p *channeldb.ChannelEdgePolicy) error {
|
func(p *channeldb.ChannelEdgePolicy) error {
|
||||||
c := &lnwire.ChannelUpdateAnnouncement{
|
c := &lnwire.ChannelUpdateAnnouncement{
|
||||||
Signature: d.fakeSig,
|
Signature: d.fakeSig,
|
||||||
ChannelID: lnwire.NewChanIDFromInt(p.ChannelID),
|
ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID),
|
||||||
Timestamp: uint32(p.LastUpdate.Unix()),
|
Timestamp: uint32(p.LastUpdate.Unix()),
|
||||||
Flags: p.Flags,
|
Flags: p.Flags,
|
||||||
TimeLockDelta: p.TimeLockDelta,
|
TimeLockDelta: p.TimeLockDelta,
|
||||||
@ -403,7 +403,7 @@ func (d *Discovery) networkHandler() {
|
|||||||
// may want to batch this request to be broadcast to immediate peers during the
|
// may want to batch this request to be broadcast to immediate peers during the
|
||||||
// next announcement epoch.
|
// next announcement epoch.
|
||||||
func (d *Discovery) processNetworkAnnouncement(aMsg *networkMsg) bool {
|
func (d *Discovery) processNetworkAnnouncement(aMsg *networkMsg) bool {
|
||||||
isPremature := func(chanID *lnwire.ChannelID) bool {
|
isPremature := func(chanID *lnwire.ShortChannelID) bool {
|
||||||
return chanID.BlockHeight > d.bestHeight
|
return chanID.BlockHeight > d.bestHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,11 +438,11 @@ func (d *Discovery) processNetworkAnnouncement(aMsg *networkMsg) bool {
|
|||||||
// If the advertised inclusionary block is beyond our knowledge
|
// If the advertised inclusionary block is beyond our knowledge
|
||||||
// of the chain tip, then we'll put the announcement in limbo
|
// of the chain tip, then we'll put the announcement in limbo
|
||||||
// to be fully verified once we advance forward in the chain.
|
// to be fully verified once we advance forward in the chain.
|
||||||
if isPremature(&msg.ChannelID) {
|
if isPremature(&msg.ShortChannelID) {
|
||||||
blockHeight := msg.ChannelID.BlockHeight
|
blockHeight := msg.ShortChannelID.BlockHeight
|
||||||
log.Infof("Announcement for chan_id=(%v), is "+
|
log.Infof("Announcement for chan_id=(%v), is "+
|
||||||
"premature: advertises height %v, only height "+
|
"premature: advertises height %v, only height "+
|
||||||
"%v is known", msg.ChannelID, msg.ChannelID.BlockHeight,
|
"%v is known", msg.ShortChannelID, msg.ShortChannelID.BlockHeight,
|
||||||
d.bestHeight)
|
d.bestHeight)
|
||||||
|
|
||||||
d.prematureAnnouncements[blockHeight] = append(
|
d.prematureAnnouncements[blockHeight] = append(
|
||||||
@ -458,18 +458,18 @@ func (d *Discovery) processNetworkAnnouncement(aMsg *networkMsg) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proof = &channeldb.ChannelAuthProof{
|
proof = &channeldb.ChannelAuthProof{
|
||||||
NodeSig1: msg.FirstNodeSig,
|
NodeSig1: msg.NodeSig1,
|
||||||
NodeSig2: msg.SecondNodeSig,
|
NodeSig2: msg.NodeSig2,
|
||||||
BitcoinSig1: msg.FirstBitcoinSig,
|
BitcoinSig1: msg.BitcoinSig1,
|
||||||
BitcoinSig2: msg.SecondBitcoinSig,
|
BitcoinSig2: msg.BitcoinSig2,
|
||||||
}
|
}
|
||||||
|
|
||||||
edge := &channeldb.ChannelEdgeInfo{
|
edge := &channeldb.ChannelEdgeInfo{
|
||||||
ChannelID: msg.ChannelID.ToUint64(),
|
ChannelID: msg.ShortChannelID.ToUint64(),
|
||||||
NodeKey1: msg.FirstNodeID,
|
NodeKey1: msg.NodeID1,
|
||||||
NodeKey2: msg.SecondNodeID,
|
NodeKey2: msg.NodeID2,
|
||||||
BitcoinKey1: msg.FirstBitcoinKey,
|
BitcoinKey1: msg.BitcoinKey1,
|
||||||
BitcoinKey2: msg.SecondBitcoinKey,
|
BitcoinKey2: msg.BitcoinKey2,
|
||||||
AuthProof: proof,
|
AuthProof: proof,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,13 +487,13 @@ func (d *Discovery) processNetworkAnnouncement(aMsg *networkMsg) bool {
|
|||||||
// that the directional information for an already known channel has
|
// that the directional information for an already known channel has
|
||||||
// been updated.
|
// been updated.
|
||||||
case *lnwire.ChannelUpdateAnnouncement:
|
case *lnwire.ChannelUpdateAnnouncement:
|
||||||
chanID := msg.ChannelID.ToUint64()
|
chanID := msg.ShortChannelID.ToUint64()
|
||||||
|
|
||||||
// If the advertised inclusionary block is beyond our knowledge
|
// If the advertised inclusionary block is beyond our knowledge
|
||||||
// of the chain tip, then we'll put the announcement in limbo
|
// of the chain tip, then we'll put the announcement in limbo
|
||||||
// to be fully verified once we advance forward in the chain.
|
// to be fully verified once we advance forward in the chain.
|
||||||
if isPremature(&msg.ChannelID) {
|
if isPremature(&msg.ShortChannelID) {
|
||||||
blockHeight := msg.ChannelID.BlockHeight
|
blockHeight := msg.ShortChannelID.BlockHeight
|
||||||
log.Infof("Update announcement for chan_id=(%v), is "+
|
log.Infof("Update announcement for chan_id=(%v), is "+
|
||||||
"premature: advertises height %v, only height "+
|
"premature: advertises height %v, only height "+
|
||||||
"%v is known", chanID, blockHeight,
|
"%v is known", chanID, blockHeight,
|
||||||
@ -578,7 +578,7 @@ func (d *Discovery) synchronize(syncReq *syncRequest) error {
|
|||||||
if err := d.cfg.Router.ForEachChannel(func(chanInfo *channeldb.ChannelEdgeInfo,
|
if err := d.cfg.Router.ForEachChannel(func(chanInfo *channeldb.ChannelEdgeInfo,
|
||||||
e1, e2 *channeldb.ChannelEdgePolicy) error {
|
e1, e2 *channeldb.ChannelEdgePolicy) error {
|
||||||
|
|
||||||
chanID := lnwire.NewChanIDFromInt(chanInfo.ChannelID)
|
chanID := lnwire.NewShortChanIDFromInt(chanInfo.ChannelID)
|
||||||
|
|
||||||
// First, using the parameters of the channel, along with the
|
// First, using the parameters of the channel, along with the
|
||||||
// channel authentication proof, we'll create re-create the
|
// channel authentication proof, we'll create re-create the
|
||||||
@ -586,15 +586,15 @@ func (d *Discovery) synchronize(syncReq *syncRequest) error {
|
|||||||
// TODO(andrew.shvv) skip if proof is nil
|
// TODO(andrew.shvv) skip if proof is nil
|
||||||
authProof := chanInfo.AuthProof
|
authProof := chanInfo.AuthProof
|
||||||
chanAnn := &lnwire.ChannelAnnouncement{
|
chanAnn := &lnwire.ChannelAnnouncement{
|
||||||
FirstNodeSig: authProof.NodeSig1,
|
NodeSig1: authProof.NodeSig1,
|
||||||
SecondNodeSig: authProof.NodeSig2,
|
NodeSig2: authProof.NodeSig2,
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
FirstBitcoinSig: authProof.BitcoinSig1,
|
BitcoinSig1: authProof.BitcoinSig1,
|
||||||
SecondBitcoinSig: authProof.BitcoinSig2,
|
BitcoinSig2: authProof.BitcoinSig2,
|
||||||
FirstNodeID: chanInfo.NodeKey1,
|
NodeID1: chanInfo.NodeKey1,
|
||||||
SecondNodeID: chanInfo.NodeKey2,
|
NodeID2: chanInfo.NodeKey2,
|
||||||
FirstBitcoinKey: chanInfo.BitcoinKey1,
|
BitcoinKey1: chanInfo.BitcoinKey1,
|
||||||
SecondBitcoinKey: chanInfo.BitcoinKey2,
|
BitcoinKey2: chanInfo.BitcoinKey2,
|
||||||
}
|
}
|
||||||
announceMessages = append(announceMessages, chanAnn)
|
announceMessages = append(announceMessages, chanAnn)
|
||||||
|
|
||||||
@ -604,7 +604,7 @@ func (d *Discovery) synchronize(syncReq *syncRequest) error {
|
|||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
announceMessages = append(announceMessages, &lnwire.ChannelUpdateAnnouncement{
|
announceMessages = append(announceMessages, &lnwire.ChannelUpdateAnnouncement{
|
||||||
Signature: d.fakeSig,
|
Signature: d.fakeSig,
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
Timestamp: uint32(e1.LastUpdate.Unix()),
|
Timestamp: uint32(e1.LastUpdate.Unix()),
|
||||||
Flags: 0,
|
Flags: 0,
|
||||||
TimeLockDelta: e1.TimeLockDelta,
|
TimeLockDelta: e1.TimeLockDelta,
|
||||||
@ -616,7 +616,7 @@ func (d *Discovery) synchronize(syncReq *syncRequest) error {
|
|||||||
if e2 != nil {
|
if e2 != nil {
|
||||||
announceMessages = append(announceMessages, &lnwire.ChannelUpdateAnnouncement{
|
announceMessages = append(announceMessages, &lnwire.ChannelUpdateAnnouncement{
|
||||||
Signature: d.fakeSig,
|
Signature: d.fakeSig,
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
Timestamp: uint32(e2.LastUpdate.Unix()),
|
Timestamp: uint32(e2.LastUpdate.Unix()),
|
||||||
Flags: 1,
|
Flags: 1,
|
||||||
TimeLockDelta: e2.TimeLockDelta,
|
TimeLockDelta: e2.TimeLockDelta,
|
||||||
|
@ -175,7 +175,7 @@ func createNodeAnnouncement() (*lnwire.NodeAnnouncement,
|
|||||||
func createUpdateAnnouncement(blockHeight uint32) *lnwire.ChannelUpdateAnnouncement {
|
func createUpdateAnnouncement(blockHeight uint32) *lnwire.ChannelUpdateAnnouncement {
|
||||||
return &lnwire.ChannelUpdateAnnouncement{
|
return &lnwire.ChannelUpdateAnnouncement{
|
||||||
Signature: testSig,
|
Signature: testSig,
|
||||||
ChannelID: lnwire.ChannelID{
|
ShortChannelID: lnwire.ShortChannelID{
|
||||||
BlockHeight: blockHeight,
|
BlockHeight: blockHeight,
|
||||||
},
|
},
|
||||||
Timestamp: uint32(prand.Int31()),
|
Timestamp: uint32(prand.Int31()),
|
||||||
@ -188,14 +188,14 @@ func createUpdateAnnouncement(blockHeight uint32) *lnwire.ChannelUpdateAnnouncem
|
|||||||
|
|
||||||
func createChannelAnnouncement(blockHeight uint32) *lnwire.ChannelAnnouncement {
|
func createChannelAnnouncement(blockHeight uint32) *lnwire.ChannelAnnouncement {
|
||||||
// Our fake channel will be "confirmed" at height 101.
|
// Our fake channel will be "confirmed" at height 101.
|
||||||
chanID := lnwire.ChannelID{
|
chanID := lnwire.ShortChannelID{
|
||||||
BlockHeight: blockHeight,
|
BlockHeight: blockHeight,
|
||||||
TxIndex: 0,
|
TxIndex: 0,
|
||||||
TxPosition: 0,
|
TxPosition: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &lnwire.ChannelAnnouncement{
|
return &lnwire.ChannelAnnouncement{
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -954,7 +954,7 @@ func (f *fundingManager) waitForFundingConfirmation(
|
|||||||
// construct the compact chainID which is used on the network to unique
|
// construct the compact chainID which is used on the network to unique
|
||||||
// identify channels.
|
// identify channels.
|
||||||
// TODO(roasbeef): remove after spec change, no more chanID's!!!
|
// TODO(roasbeef): remove after spec change, no more chanID's!!!
|
||||||
chanID := lnwire.ChannelID{
|
chanID := lnwire.ShortChannelID{
|
||||||
BlockHeight: confDetails.BlockHeight,
|
BlockHeight: confDetails.BlockHeight,
|
||||||
TxIndex: confDetails.TxIndex,
|
TxIndex: confDetails.TxIndex,
|
||||||
TxPosition: uint16(fundingPoint.Index),
|
TxPosition: uint16(fundingPoint.Index),
|
||||||
@ -1025,14 +1025,14 @@ type chanAnnouncement struct {
|
|||||||
// authenticated only by us and contains our directional routing policy for the
|
// authenticated only by us and contains our directional routing policy for the
|
||||||
// channel.
|
// channel.
|
||||||
func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
||||||
channel *lnwallet.LightningChannel, chanID lnwire.ChannelID,
|
channel *lnwallet.LightningChannel, chanID lnwire.ShortChannelID,
|
||||||
localProof, remoteProof *channelProof) *chanAnnouncement {
|
localProof, remoteProof *channelProof) *chanAnnouncement {
|
||||||
|
|
||||||
// The unconditional section of the announcement is the ChannelID
|
// The unconditional section of the announcement is the ChannelID
|
||||||
// itself which compactly encodes the location of the funding output
|
// itself which compactly encodes the location of the funding output
|
||||||
// within the blockchain.
|
// within the blockchain.
|
||||||
chanAnn := &lnwire.ChannelAnnouncement{
|
chanAnn := &lnwire.ChannelAnnouncement{
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The chanFlags field indicates which directed edge of the channel is
|
// The chanFlags field indicates which directed edge of the channel is
|
||||||
@ -1048,27 +1048,27 @@ func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
|||||||
selfBytes := localIdentity.SerializeCompressed()
|
selfBytes := localIdentity.SerializeCompressed()
|
||||||
remoteBytes := remotePub.SerializeCompressed()
|
remoteBytes := remotePub.SerializeCompressed()
|
||||||
if bytes.Compare(selfBytes, remoteBytes) == -1 {
|
if bytes.Compare(selfBytes, remoteBytes) == -1 {
|
||||||
chanAnn.FirstNodeID = localIdentity
|
chanAnn.NodeID1 = localIdentity
|
||||||
chanAnn.SecondNodeID = remotePub
|
chanAnn.NodeID2 = remotePub
|
||||||
chanAnn.FirstNodeSig = localProof.nodeSig
|
chanAnn.NodeSig1 = localProof.nodeSig
|
||||||
chanAnn.SecondNodeSig = remoteProof.nodeSig
|
chanAnn.NodeSig2 = remoteProof.nodeSig
|
||||||
chanAnn.FirstBitcoinSig = localProof.nodeSig
|
chanAnn.BitcoinSig1 = localProof.nodeSig
|
||||||
chanAnn.SecondBitcoinSig = remoteProof.nodeSig
|
chanAnn.BitcoinSig2 = remoteProof.nodeSig
|
||||||
chanAnn.FirstBitcoinKey = channel.LocalFundingKey
|
chanAnn.BitcoinKey1 = channel.LocalFundingKey
|
||||||
chanAnn.SecondBitcoinKey = channel.RemoteFundingKey
|
chanAnn.BitcoinKey2 = channel.RemoteFundingKey
|
||||||
|
|
||||||
// If we're the first node then update the chanFlags to
|
// If we're the first node then update the chanFlags to
|
||||||
// indicate the "direction" of the update.
|
// indicate the "direction" of the update.
|
||||||
chanFlags = 0
|
chanFlags = 0
|
||||||
} else {
|
} else {
|
||||||
chanAnn.FirstNodeID = remotePub
|
chanAnn.NodeID1 = remotePub
|
||||||
chanAnn.SecondNodeID = localIdentity
|
chanAnn.NodeID2 = localIdentity
|
||||||
chanAnn.FirstNodeSig = remoteProof.nodeSig
|
chanAnn.NodeSig1 = remoteProof.nodeSig
|
||||||
chanAnn.SecondNodeSig = localProof.nodeSig
|
chanAnn.NodeSig2 = localProof.nodeSig
|
||||||
chanAnn.FirstBitcoinSig = remoteProof.nodeSig
|
chanAnn.BitcoinSig1 = remoteProof.nodeSig
|
||||||
chanAnn.SecondBitcoinSig = localProof.nodeSig
|
chanAnn.BitcoinSig2 = localProof.nodeSig
|
||||||
chanAnn.FirstBitcoinKey = channel.RemoteFundingKey
|
chanAnn.BitcoinKey1 = channel.RemoteFundingKey
|
||||||
chanAnn.SecondBitcoinKey = channel.LocalFundingKey
|
chanAnn.BitcoinKey2 = channel.LocalFundingKey
|
||||||
|
|
||||||
// If we're the second node then update the chanFlags to
|
// If we're the second node then update the chanFlags to
|
||||||
// indicate the "direction" of the update.
|
// indicate the "direction" of the update.
|
||||||
@ -1078,7 +1078,7 @@ func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
|||||||
// TODO(roasbeef): add real sig, populate proper FeeSchema
|
// TODO(roasbeef): add real sig, populate proper FeeSchema
|
||||||
chanUpdateAnn := &lnwire.ChannelUpdateAnnouncement{
|
chanUpdateAnn := &lnwire.ChannelUpdateAnnouncement{
|
||||||
Signature: localProof.nodeSig,
|
Signature: localProof.nodeSig,
|
||||||
ChannelID: chanID,
|
ShortChannelID: chanID,
|
||||||
Timestamp: uint32(time.Now().Unix()),
|
Timestamp: uint32(time.Now().Unix()),
|
||||||
Flags: chanFlags,
|
Flags: chanFlags,
|
||||||
TimeLockDelta: 1,
|
TimeLockDelta: 1,
|
||||||
@ -1099,7 +1099,7 @@ func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
|||||||
// announcements are then send to the channel router to handle broadcasting to
|
// announcements are then send to the channel router to handle broadcasting to
|
||||||
// the network during its next trickle.
|
// the network during its next trickle.
|
||||||
func (f *fundingManager) announceChannel(idKey, remoteIDKey *btcec.PublicKey,
|
func (f *fundingManager) announceChannel(idKey, remoteIDKey *btcec.PublicKey,
|
||||||
channel *lnwallet.LightningChannel, chanID lnwire.ChannelID, localProof,
|
channel *lnwallet.LightningChannel, chanID lnwire.ShortChannelID, localProof,
|
||||||
remoteProof *channelProof) {
|
remoteProof *channelProof) {
|
||||||
|
|
||||||
// TODO(roasbeef): need a Signer.SignMessage method to finalize
|
// TODO(roasbeef): need a Signer.SignMessage method to finalize
|
||||||
|
@ -23,7 +23,7 @@ type AnnounceSignatures struct {
|
|||||||
// as the block height, the next 3 bytes indicating the transaction
|
// as the block height, the next 3 bytes indicating the transaction
|
||||||
// index within the block, and the least significant two bytes
|
// index within the block, and the least significant two bytes
|
||||||
// indicating the output index which pays to the channel.
|
// indicating the output index which pays to the channel.
|
||||||
ShortChannelID ChannelID
|
ShortChannelID ShortChannelID
|
||||||
|
|
||||||
// NodeSignature is the signature which contains the signed announce
|
// NodeSignature is the signature which contains the signed announce
|
||||||
// channel message, by this signature we proof that we posses of the
|
// channel message, by this signature we proof that we posses of the
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func TestAnnounceSignatureEncodeDecode(t *testing.T) {
|
func TestAnnounceSignatureEncodeDecode(t *testing.T) {
|
||||||
ac := &AnnounceSignatures{
|
ac := &AnnounceSignatures{
|
||||||
ChannelID: *outpoint1,
|
ChannelID: *outpoint1,
|
||||||
ShortChannelID: NewChanIDFromInt(1),
|
ShortChannelID: NewShortChanIDFromInt(1),
|
||||||
NodeSignature: someSig,
|
NodeSignature: someSig,
|
||||||
BitcoinSignature: someSig,
|
BitcoinSignature: someSig,
|
||||||
}
|
}
|
||||||
|
@ -15,28 +15,28 @@ type ChannelAnnouncement struct {
|
|||||||
// references between node's channel and node. Requiring both nodes
|
// references between node's channel and node. Requiring both nodes
|
||||||
// to sign indicates they are both willing to route other payments via
|
// to sign indicates they are both willing to route other payments via
|
||||||
// this node.
|
// this node.
|
||||||
FirstNodeSig *btcec.Signature
|
NodeSig1 *btcec.Signature
|
||||||
SecondNodeSig *btcec.Signature
|
NodeSig2 *btcec.Signature
|
||||||
|
|
||||||
// ChannelID is the unique description of the funding transaction.
|
|
||||||
ChannelID ChannelID
|
|
||||||
|
|
||||||
// This signatures are used by nodes in order to create cross
|
// This signatures are used by nodes in order to create cross
|
||||||
// references between node's channel and node. Requiring the bitcoin
|
// references between node's channel and node. Requiring the bitcoin
|
||||||
// signatures proves they control the channel.
|
// signatures proves they control the channel.
|
||||||
FirstBitcoinSig *btcec.Signature
|
BitcoinSig1 *btcec.Signature
|
||||||
SecondBitcoinSig *btcec.Signature
|
BitcoinSig2 *btcec.Signature
|
||||||
|
|
||||||
|
// ShortChannelID is the unique description of the funding transaction.
|
||||||
|
ShortChannelID ShortChannelID
|
||||||
|
|
||||||
// The public keys of the two nodes who are operating the channel, such
|
// The public keys of the two nodes who are operating the channel, such
|
||||||
// that is FirstNodeID the numerically-lesser of the two DER encoded
|
// that is NodeID1 the numerically-lesser than NodeID2 (ascending
|
||||||
// keys (ascending numerical order).
|
// numerical order).
|
||||||
FirstNodeID *btcec.PublicKey
|
NodeID1 *btcec.PublicKey
|
||||||
SecondNodeID *btcec.PublicKey
|
NodeID2 *btcec.PublicKey
|
||||||
|
|
||||||
// Public keys which corresponds to the keys which was declared in
|
// Public keys which corresponds to the keys which was declared in
|
||||||
// multisig funding transaction output.
|
// multisig funding transaction output.
|
||||||
FirstBitcoinKey *btcec.PublicKey
|
BitcoinKey1 *btcec.PublicKey
|
||||||
SecondBitcoinKey *btcec.PublicKey
|
BitcoinKey2 *btcec.PublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
// A compile time check to ensure ChannelAnnouncement implements the
|
// A compile time check to ensure ChannelAnnouncement implements the
|
||||||
@ -57,15 +57,15 @@ func (a *ChannelAnnouncement) Validate() error {
|
|||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&a.FirstNodeSig,
|
&a.NodeSig1,
|
||||||
&a.SecondNodeSig,
|
&a.NodeSig2,
|
||||||
&a.ChannelID,
|
&a.ShortChannelID,
|
||||||
&a.FirstBitcoinSig,
|
&a.BitcoinSig1,
|
||||||
&a.SecondBitcoinSig,
|
&a.BitcoinSig2,
|
||||||
&a.FirstNodeID,
|
&a.NodeID1,
|
||||||
&a.SecondNodeID,
|
&a.NodeID2,
|
||||||
&a.FirstBitcoinKey,
|
&a.BitcoinKey1,
|
||||||
&a.SecondBitcoinKey,
|
&a.BitcoinKey2,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,15 +75,15 @@ func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
|
|||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
|
func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
a.FirstNodeSig,
|
a.NodeSig1,
|
||||||
a.SecondNodeSig,
|
a.NodeSig2,
|
||||||
a.ChannelID,
|
a.ShortChannelID,
|
||||||
a.FirstBitcoinSig,
|
a.BitcoinSig1,
|
||||||
a.SecondBitcoinSig,
|
a.BitcoinSig2,
|
||||||
a.FirstNodeID,
|
a.NodeID1,
|
||||||
a.SecondNodeID,
|
a.NodeID2,
|
||||||
a.FirstBitcoinKey,
|
a.BitcoinKey1,
|
||||||
a.SecondBitcoinKey,
|
a.BitcoinKey2,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *ChannelAnnouncement) Command() uint32 {
|
func (a *ChannelAnnouncement) Command() uint32 {
|
||||||
return CmdChannelAnnoucmentMessage
|
return CmdChannelAnnouncement
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxPayloadLength returns the maximum allowed payload size for this message
|
// MaxPayloadLength returns the maximum allowed payload size for this message
|
||||||
@ -102,31 +102,31 @@ func (a *ChannelAnnouncement) Command() uint32 {
|
|||||||
func (a *ChannelAnnouncement) MaxPayloadLength(pver uint32) uint32 {
|
func (a *ChannelAnnouncement) MaxPayloadLength(pver uint32) uint32 {
|
||||||
var length uint32
|
var length uint32
|
||||||
|
|
||||||
// FirstNodeSig - 64 bytes
|
// NodeSig1 - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
// SecondNodeSig - 64 bytes
|
// NodeSig2 - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
// ChannelID - 8 bytes
|
// ShortChannelID - 8 bytes
|
||||||
length += 8
|
length += 8
|
||||||
|
|
||||||
// FirstBitcoinSig - 64 bytes
|
// BitcoinSig1 - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
// SecondBitcoinSig - 64 bytes
|
// BitcoinSig2 - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
// FirstNodeID - 33 bytes
|
// NodeID1 - 33 bytes
|
||||||
length += 33
|
length += 33
|
||||||
|
|
||||||
// SecondNodeID - 33 bytes
|
// NodeID2 - 33 bytes
|
||||||
length += 33
|
length += 33
|
||||||
|
|
||||||
// FirstBitcoinKey - 33 bytes
|
// BitcoinKey1 - 33 bytes
|
||||||
length += 33
|
length += 33
|
||||||
|
|
||||||
// SecondBitcoinKey - 33 bytes
|
// BitcoinKey2 - 33 bytes
|
||||||
length += 33
|
length += 33
|
||||||
|
|
||||||
return length
|
return length
|
||||||
@ -138,13 +138,11 @@ func (a *ChannelAnnouncement) DataToSign() ([]byte, error) {
|
|||||||
// We should not include the signatures itself.
|
// We should not include the signatures itself.
|
||||||
var w bytes.Buffer
|
var w bytes.Buffer
|
||||||
err := writeElements(&w,
|
err := writeElements(&w,
|
||||||
a.ChannelID,
|
a.ShortChannelID,
|
||||||
a.FirstBitcoinSig,
|
a.NodeID1,
|
||||||
a.SecondBitcoinSig,
|
a.NodeID2,
|
||||||
a.FirstNodeID,
|
a.BitcoinKey1,
|
||||||
a.SecondNodeID,
|
a.BitcoinKey2,
|
||||||
a.FirstBitcoinKey,
|
|
||||||
a.SecondBitcoinKey,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -11,15 +11,15 @@ import (
|
|||||||
|
|
||||||
func TestChannelAnnoucementEncodeDecode(t *testing.T) {
|
func TestChannelAnnoucementEncodeDecode(t *testing.T) {
|
||||||
ca := &ChannelAnnouncement{
|
ca := &ChannelAnnouncement{
|
||||||
FirstNodeSig: someSig,
|
NodeSig1: someSig,
|
||||||
SecondNodeSig: someSig,
|
NodeSig2: someSig,
|
||||||
ChannelID: someChannelID,
|
ShortChannelID: someChannelID,
|
||||||
FirstBitcoinSig: someSig,
|
BitcoinSig1: someSig,
|
||||||
SecondBitcoinSig: someSig,
|
BitcoinSig2: someSig,
|
||||||
FirstNodeID: pubKey,
|
NodeID1: pubKey,
|
||||||
SecondNodeID: pubKey,
|
NodeID2: pubKey,
|
||||||
FirstBitcoinKey: pubKey,
|
BitcoinKey1: pubKey,
|
||||||
SecondBitcoinKey: pubKey,
|
BitcoinKey2: pubKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next encode the CA message into an empty bytes buffer.
|
// Next encode the CA message into an empty bytes buffer.
|
||||||
@ -65,23 +65,23 @@ func TestChannelAnnoucementValidation(t *testing.T) {
|
|||||||
secondBitcoinSig, _ := secondBitcoinPrivKey.Sign(hash)
|
secondBitcoinSig, _ := secondBitcoinPrivKey.Sign(hash)
|
||||||
|
|
||||||
ca := &ChannelAnnouncement{
|
ca := &ChannelAnnouncement{
|
||||||
ChannelID: someChannelID,
|
ShortChannelID: someChannelID,
|
||||||
FirstBitcoinSig: firstBitcoinSig,
|
BitcoinSig1: firstBitcoinSig,
|
||||||
SecondBitcoinSig: secondBitcoinSig,
|
BitcoinSig2: secondBitcoinSig,
|
||||||
FirstNodeID: firstNodePubKey,
|
NodeID1: firstNodePubKey,
|
||||||
SecondNodeID: secondNodePubKey,
|
NodeID2: secondNodePubKey,
|
||||||
FirstBitcoinKey: firstBitcoinPubKey,
|
BitcoinKey1: firstBitcoinPubKey,
|
||||||
SecondBitcoinKey: secondBitcoinPubKey,
|
BitcoinKey2: secondBitcoinPubKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
dataToSign, _ := ca.DataToSign()
|
dataToSign, _ := ca.DataToSign()
|
||||||
hash = chainhash.DoubleHashB(dataToSign)
|
hash = chainhash.DoubleHashB(dataToSign)
|
||||||
|
|
||||||
firstNodeSign, _ := firstNodePrivKey.Sign(hash)
|
firstNodeSign, _ := firstNodePrivKey.Sign(hash)
|
||||||
ca.FirstNodeSig = firstNodeSign
|
ca.NodeSig1 = firstNodeSign
|
||||||
|
|
||||||
secondNodeSign, _ := secondNodePrivKey.Sign(hash)
|
secondNodeSign, _ := secondNodePrivKey.Sign(hash)
|
||||||
ca.SecondNodeSig = secondNodeSign
|
ca.NodeSig2 = secondNodeSign
|
||||||
|
|
||||||
if err := ca.Validate(); err != nil {
|
if err := ca.Validate(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package lnwire
|
package lnwire
|
||||||
|
|
||||||
// ChannelID represent the set of data which is needed to retrieve all
|
// ShortChannelID represent the set of data which is needed to retrieve all
|
||||||
// necessary data to validate the channel existence.
|
// necessary data to validate the channel existence.
|
||||||
type ChannelID struct {
|
type ShortChannelID struct {
|
||||||
// BlockHeight is the height of the block where funding transaction
|
// BlockHeight is the height of the block where funding transaction
|
||||||
// located.
|
// located.
|
||||||
//
|
//
|
||||||
@ -18,21 +18,21 @@ type ChannelID struct {
|
|||||||
TxPosition uint16
|
TxPosition uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewChanIDFromInt returns a new ChannelID which is the decoded version of the
|
// NewShortChanIDFromInt returns a new ShortChannelID which is the decoded
|
||||||
// compact channel ID encoded within the uint64. The format of the compact
|
// version of the compact channel ID encoded within the uint64. The format of
|
||||||
// channel ID is as follows: 3 bytes for the block height, 3 bytes for the
|
// the compact channel ID is as follows: 3 bytes for the block height, 3 bytes
|
||||||
// transaction index, and 2 bytes for the output index.
|
// for the transaction index, and 2 bytes for the output index.
|
||||||
func NewChanIDFromInt(chanID uint64) ChannelID {
|
func NewShortChanIDFromInt(chanID uint64) ShortChannelID {
|
||||||
return ChannelID{
|
return ShortChannelID{
|
||||||
BlockHeight: uint32(chanID >> 40),
|
BlockHeight: uint32(chanID >> 40),
|
||||||
TxIndex: uint32(chanID>>16) & 0xFFFFFF,
|
TxIndex: uint32(chanID>>16) & 0xFFFFFF,
|
||||||
TxPosition: uint16(chanID),
|
TxPosition: uint16(chanID),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToUint64 converts the ChannelID into a compact format encoded within a
|
// ToUint64 converts the ShortChannelID into a compact format encoded within a
|
||||||
// uint64 (8 bytes).
|
// uint64 (8 bytes).
|
||||||
func (c *ChannelID) ToUint64() uint64 {
|
func (c *ShortChannelID) ToUint64() uint64 {
|
||||||
// TODO(roasbeef): explicit error on overflow?
|
// TODO(roasbeef): explicit error on overflow?
|
||||||
return ((uint64(c.BlockHeight) << 40) | (uint64(c.TxIndex) << 16) |
|
return ((uint64(c.BlockHeight) << 40) | (uint64(c.TxIndex) << 16) |
|
||||||
(uint64(c.TxPosition)))
|
(uint64(c.TxPosition)))
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestChannelIDEncoding(t *testing.T) {
|
func TestChannelIDEncoding(t *testing.T) {
|
||||||
var testCases = []ChannelID{
|
var testCases = []ShortChannelID{
|
||||||
{
|
{
|
||||||
BlockHeight: (1 << 24) - 1,
|
BlockHeight: (1 << 24) - 1,
|
||||||
TxIndex: (1 << 24) - 1,
|
TxIndex: (1 << 24) - 1,
|
||||||
@ -29,7 +29,7 @@ func TestChannelIDEncoding(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
chanInt := testCase.ToUint64()
|
chanInt := testCase.ToUint64()
|
||||||
|
|
||||||
newChanID := NewChanIDFromInt(chanInt)
|
newChanID := NewShortChanIDFromInt(chanInt)
|
||||||
|
|
||||||
if !reflect.DeepEqual(testCase, newChanID) {
|
if !reflect.DeepEqual(testCase, newChanID) {
|
||||||
t.Fatalf("chan ID's don't match: expected %v got %v",
|
t.Fatalf("chan ID's don't match: expected %v got %v",
|
||||||
|
@ -17,8 +17,8 @@ type ChannelUpdateAnnouncement struct {
|
|||||||
// ownership of node id.
|
// ownership of node id.
|
||||||
Signature *btcec.Signature
|
Signature *btcec.Signature
|
||||||
|
|
||||||
// ChannelID is the unique description of the funding transaction.
|
// ShortChannelID is the unique description of the funding transaction.
|
||||||
ChannelID ChannelID
|
ShortChannelID ShortChannelID
|
||||||
|
|
||||||
// Timestamp allows ordering in the case of multiple announcements.
|
// Timestamp allows ordering in the case of multiple announcements.
|
||||||
// We should ignore the message if timestamp is not greater than
|
// We should ignore the message if timestamp is not greater than
|
||||||
@ -74,7 +74,7 @@ func (a *ChannelUpdateAnnouncement) Validate() error {
|
|||||||
func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||||
return readElements(r,
|
return readElements(r,
|
||||||
&a.Signature,
|
&a.Signature,
|
||||||
&a.ChannelID,
|
&a.ShortChannelID,
|
||||||
&a.Timestamp,
|
&a.Timestamp,
|
||||||
&a.Flags,
|
&a.Flags,
|
||||||
&a.TimeLockDelta,
|
&a.TimeLockDelta,
|
||||||
@ -91,7 +91,7 @@ func (a *ChannelUpdateAnnouncement) Decode(r io.Reader, pver uint32) error {
|
|||||||
func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
|
func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||||
return writeElements(w,
|
return writeElements(w,
|
||||||
a.Signature,
|
a.Signature,
|
||||||
a.ChannelID,
|
a.ShortChannelID,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.Flags,
|
a.Flags,
|
||||||
a.TimeLockDelta,
|
a.TimeLockDelta,
|
||||||
@ -106,7 +106,7 @@ func (a *ChannelUpdateAnnouncement) Encode(w io.Writer, pver uint32) error {
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *ChannelUpdateAnnouncement) Command() uint32 {
|
func (a *ChannelUpdateAnnouncement) Command() uint32 {
|
||||||
return CmdChannelUpdateAnnoucmentMessage
|
return CmdChannelUpdateAnnouncement
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxPayloadLength returns the maximum allowed payload size for this message
|
// MaxPayloadLength returns the maximum allowed payload size for this message
|
||||||
@ -119,7 +119,7 @@ func (a *ChannelUpdateAnnouncement) MaxPayloadLength(pver uint32) uint32 {
|
|||||||
// Signature - 64 bytes
|
// Signature - 64 bytes
|
||||||
length += 64
|
length += 64
|
||||||
|
|
||||||
// ChannelID - 8 bytes
|
// ShortChannelID - 8 bytes
|
||||||
length += 8
|
length += 8
|
||||||
|
|
||||||
// Timestamp - 4 bytes
|
// Timestamp - 4 bytes
|
||||||
@ -150,7 +150,7 @@ func (a *ChannelUpdateAnnouncement) DataToSign() ([]byte, error) {
|
|||||||
// We should not include the signatures itself.
|
// We should not include the signatures itself.
|
||||||
var w bytes.Buffer
|
var w bytes.Buffer
|
||||||
err := writeElements(&w,
|
err := writeElements(&w,
|
||||||
a.ChannelID,
|
a.ShortChannelID,
|
||||||
a.Timestamp,
|
a.Timestamp,
|
||||||
a.Flags,
|
a.Flags,
|
||||||
a.TimeLockDelta,
|
a.TimeLockDelta,
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) {
|
func TestChannelUpdateAnnouncementEncodeDecode(t *testing.T) {
|
||||||
cua := &ChannelUpdateAnnouncement{
|
cua := &ChannelUpdateAnnouncement{
|
||||||
Signature: someSig,
|
Signature: someSig,
|
||||||
ChannelID: someChannelID,
|
ShortChannelID: someChannelID,
|
||||||
Timestamp: maxUint32,
|
Timestamp: maxUint32,
|
||||||
Flags: maxUint16,
|
Flags: maxUint16,
|
||||||
TimeLockDelta: maxUint16,
|
TimeLockDelta: maxUint16,
|
||||||
|
@ -21,7 +21,7 @@ type FundingLocked struct {
|
|||||||
|
|
||||||
// ChannelId serves to uniquely identify the channel created by the
|
// ChannelId serves to uniquely identify the channel created by the
|
||||||
// current channel funding workflow.
|
// current channel funding workflow.
|
||||||
ChannelID ChannelID
|
ChannelID ShortChannelID
|
||||||
|
|
||||||
// NextPerCommitmentPoint is the secret that can be used to revoke
|
// NextPerCommitmentPoint is the secret that can be used to revoke
|
||||||
// the next commitment transaction for the channel.
|
// the next commitment transaction for the channel.
|
||||||
@ -30,7 +30,7 @@ type FundingLocked struct {
|
|||||||
|
|
||||||
// NewFundingLocked creates a new FundingLocked message, populating it with
|
// NewFundingLocked creates a new FundingLocked message, populating it with
|
||||||
// the necessary IDs and revocation secret..
|
// the necessary IDs and revocation secret..
|
||||||
func NewFundingLocked(op wire.OutPoint, cid ChannelID,
|
func NewFundingLocked(op wire.OutPoint, cid ShortChannelID,
|
||||||
npcp *btcec.PublicKey) *FundingLocked {
|
npcp *btcec.PublicKey) *FundingLocked {
|
||||||
return &FundingLocked{
|
return &FundingLocked{
|
||||||
ChannelOutpoint: op,
|
ChannelOutpoint: op,
|
||||||
|
@ -270,7 +270,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case ChannelID:
|
case ShortChannelID:
|
||||||
// Check that field fit in 3 bytes and write the blockHeight
|
// Check that field fit in 3 bytes and write the blockHeight
|
||||||
if e.BlockHeight > ((1 << 24) - 1) {
|
if e.BlockHeight > ((1 << 24) - 1) {
|
||||||
return errors.New("block height should fit in 3 bytes")
|
return errors.New("block height should fit in 3 bytes")
|
||||||
@ -596,7 +596,7 @@ func readElement(r io.Reader, element interface{}) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case *ChannelID:
|
case *ShortChannelID:
|
||||||
var blockHeight [4]byte
|
var blockHeight [4]byte
|
||||||
if _, err = io.ReadFull(r, blockHeight[1:]); err != nil {
|
if _, err = io.ReadFull(r, blockHeight[1:]); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -612,7 +612,7 @@ func readElement(r io.Reader, element interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
*e = ChannelID{
|
*e = ShortChannelID{
|
||||||
BlockHeight: binary.BigEndian.Uint32(blockHeight[:]),
|
BlockHeight: binary.BigEndian.Uint32(blockHeight[:]),
|
||||||
TxIndex: binary.BigEndian.Uint32(txIndex[:]),
|
TxIndex: binary.BigEndian.Uint32(txIndex[:]),
|
||||||
TxPosition: binary.BigEndian.Uint16(txPosition[:]),
|
TxPosition: binary.BigEndian.Uint16(txPosition[:]),
|
||||||
|
@ -64,7 +64,7 @@ var (
|
|||||||
maxUint24 uint32 = (1 << 24) - 1
|
maxUint24 uint32 = (1 << 24) - 1
|
||||||
maxUint16 uint16 = (1 << 16) - 1
|
maxUint16 uint16 = (1 << 16) - 1
|
||||||
|
|
||||||
someChannelID = ChannelID{
|
someChannelID = ShortChannelID{
|
||||||
BlockHeight: maxUint24,
|
BlockHeight: maxUint24,
|
||||||
TxIndex: maxUint24,
|
TxIndex: maxUint24,
|
||||||
TxPosition: maxUint16,
|
TxPosition: maxUint16,
|
||||||
|
@ -52,9 +52,9 @@ const (
|
|||||||
CmdErrorGeneric = uint32(4000)
|
CmdErrorGeneric = uint32(4000)
|
||||||
|
|
||||||
// Commands for discovery service.
|
// Commands for discovery service.
|
||||||
CmdChannelAnnoucmentMessage = uint32(5000)
|
CmdChannelAnnouncement = uint32(5000)
|
||||||
CmdChannelUpdateAnnoucmentMessage = uint32(5010)
|
CmdChannelUpdateAnnouncement = uint32(5010)
|
||||||
CmdNodeAnnoucmentMessage = uint32(5020)
|
CmdNodeAnnouncement = uint32(5020)
|
||||||
CmdAnnounceSignatures = uint32(5030)
|
CmdAnnounceSignatures = uint32(5030)
|
||||||
|
|
||||||
// Commands for connection keep-alive.
|
// Commands for connection keep-alive.
|
||||||
@ -121,11 +121,11 @@ func makeEmptyMessage(command uint32) (Message, error) {
|
|||||||
msg = &RevokeAndAck{}
|
msg = &RevokeAndAck{}
|
||||||
case CmdErrorGeneric:
|
case CmdErrorGeneric:
|
||||||
msg = &ErrorGeneric{}
|
msg = &ErrorGeneric{}
|
||||||
case CmdChannelAnnoucmentMessage:
|
case CmdChannelAnnouncement:
|
||||||
msg = &ChannelAnnouncement{}
|
msg = &ChannelAnnouncement{}
|
||||||
case CmdChannelUpdateAnnoucmentMessage:
|
case CmdChannelUpdateAnnouncement:
|
||||||
msg = &ChannelUpdateAnnouncement{}
|
msg = &ChannelUpdateAnnouncement{}
|
||||||
case CmdNodeAnnoucmentMessage:
|
case CmdNodeAnnouncement:
|
||||||
msg = &NodeAnnouncement{}
|
msg = &NodeAnnouncement{}
|
||||||
case CmdPing:
|
case CmdPing:
|
||||||
msg = &Ping{}
|
msg = &Ping{}
|
||||||
|
@ -154,7 +154,7 @@ func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *NodeAnnouncement) Command() uint32 {
|
func (a *NodeAnnouncement) Command() uint32 {
|
||||||
return CmdNodeAnnoucmentMessage
|
return CmdNodeAnnouncement
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxPayloadLength returns the maximum allowed payload size for this message
|
// MaxPayloadLength returns the maximum allowed payload size for this message
|
||||||
|
8
peer.go
8
peer.go
@ -536,10 +536,10 @@ func (p *peer) logWireMessage(msg lnwire.Message, read bool) {
|
|||||||
case *lnwire.NodeAnnouncement:
|
case *lnwire.NodeAnnouncement:
|
||||||
m.NodeID.Curve = nil
|
m.NodeID.Curve = nil
|
||||||
case *lnwire.ChannelAnnouncement:
|
case *lnwire.ChannelAnnouncement:
|
||||||
m.FirstNodeID.Curve = nil
|
m.NodeID1.Curve = nil
|
||||||
m.SecondNodeID.Curve = nil
|
m.NodeID2.Curve = nil
|
||||||
m.FirstBitcoinKey.Curve = nil
|
m.BitcoinKey1.Curve = nil
|
||||||
m.SecondBitcoinKey.Curve = nil
|
m.BitcoinKey2.Curve = nil
|
||||||
case *lnwire.SingleFundingComplete:
|
case *lnwire.SingleFundingComplete:
|
||||||
m.RevocationKey.Curve = nil
|
m.RevocationKey.Curve = nil
|
||||||
case *lnwire.SingleFundingRequest:
|
case *lnwire.SingleFundingRequest:
|
||||||
|
@ -75,7 +75,7 @@ func createTestNode() (*channeldb.LightningNode, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func randEdgePolicy(chanID lnwire.ChannelID,
|
func randEdgePolicy(chanID lnwire.ShortChannelID,
|
||||||
node *channeldb.LightningNode) *channeldb.ChannelEdgePolicy {
|
node *channeldb.LightningNode) *channeldb.ChannelEdgePolicy {
|
||||||
|
|
||||||
return &channeldb.ChannelEdgePolicy{
|
return &channeldb.ChannelEdgePolicy{
|
||||||
@ -90,7 +90,7 @@ func randEdgePolicy(chanID lnwire.ChannelID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func randChannelEdge(ctx *testCtx, chanValue btcutil.Amount,
|
func randChannelEdge(ctx *testCtx, chanValue btcutil.Amount,
|
||||||
fundingHeight uint32) (*wire.MsgTx, wire.OutPoint, lnwire.ChannelID) {
|
fundingHeight uint32) (*wire.MsgTx, wire.OutPoint, lnwire.ShortChannelID) {
|
||||||
|
|
||||||
fundingTx := wire.NewMsgTx(2)
|
fundingTx := wire.NewMsgTx(2)
|
||||||
fundingTx.TxOut = append(fundingTx.TxOut, &wire.TxOut{
|
fundingTx.TxOut = append(fundingTx.TxOut, &wire.TxOut{
|
||||||
@ -105,7 +105,7 @@ func randChannelEdge(ctx *testCtx, chanValue btcutil.Amount,
|
|||||||
ctx.chain.addUtxo(chanUtxo, chanValue)
|
ctx.chain.addUtxo(chanUtxo, chanValue)
|
||||||
|
|
||||||
// Our fake channel will be "confirmed" at height 101.
|
// Our fake channel will be "confirmed" at height 101.
|
||||||
chanID := lnwire.ChannelID{
|
chanID := lnwire.ShortChannelID{
|
||||||
BlockHeight: fundingHeight,
|
BlockHeight: fundingHeight,
|
||||||
TxIndex: 0,
|
TxIndex: 0,
|
||||||
TxPosition: 0,
|
TxPosition: 0,
|
||||||
|
@ -547,7 +547,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
// Before we can add the channel to the channel graph, we need
|
// Before we can add the channel to the channel graph, we need
|
||||||
// to obtain the full funding outpoint that's encoded within
|
// to obtain the full funding outpoint that's encoded within
|
||||||
// the channel ID.
|
// the channel ID.
|
||||||
channelID := lnwire.NewChanIDFromInt(msg.ChannelID)
|
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||||
fundingPoint, err := r.fetchChanPoint(&channelID)
|
fundingPoint, err := r.fetchChanPoint(&channelID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("unable to fetch chan point for "+
|
return errors.Errorf("unable to fetch chan point for "+
|
||||||
@ -580,7 +580,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
fundingPoint, msg.ChannelID)
|
fundingPoint, msg.ChannelID)
|
||||||
|
|
||||||
case *channeldb.ChannelEdgePolicy:
|
case *channeldb.ChannelEdgePolicy:
|
||||||
channelID := lnwire.NewChanIDFromInt(msg.ChannelID)
|
channelID := lnwire.NewShortChanIDFromInt(msg.ChannelID)
|
||||||
edge1Timestamp, edge2Timestamp, _, err := r.cfg.Graph.HasChannelEdge(msg.ChannelID)
|
edge1Timestamp, edge2Timestamp, _, err := r.cfg.Graph.HasChannelEdge(msg.ChannelID)
|
||||||
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
if err != nil && err != channeldb.ErrGraphNoEdgesFound {
|
||||||
return errors.Errorf("unable to check for edge "+
|
return errors.Errorf("unable to check for edge "+
|
||||||
@ -658,7 +658,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
|
|||||||
|
|
||||||
// fetchChanPoint retrieves the original outpoint which is encoded within the
|
// fetchChanPoint retrieves the original outpoint which is encoded within the
|
||||||
// channelID.
|
// channelID.
|
||||||
func (r *ChannelRouter) fetchChanPoint(chanID *lnwire.ChannelID) (*wire.OutPoint, error) {
|
func (r *ChannelRouter) fetchChanPoint(chanID *lnwire.ShortChannelID) (*wire.OutPoint, error) {
|
||||||
// First fetch the block hash by the block number encoded, then use
|
// First fetch the block hash by the block number encoded, then use
|
||||||
// that hash to fetch the block itself.
|
// that hash to fetch the block itself.
|
||||||
blockNum := int64(chanID.BlockHeight)
|
blockNum := int64(chanID.BlockHeight)
|
||||||
|
Loading…
Reference in New Issue
Block a user