funding: populate ChainHash in announcement messages, update signing

This commit updates the tail end of the funding workflow to properly
include the ChainHash field when crafting ChannelAnnouncements and the
initial ChannelUpdate messages. Additionally, we now properly generate
the proper signatures to match the changes to BOLT0007.
This commit is contained in:
Olaoluwa Osuntokun 2017-08-21 23:33:19 -07:00
parent 8f25a73332
commit 39ab177567
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 6 additions and 2 deletions

View File

@ -1577,11 +1577,15 @@ func (f *fundingManager) newChanAnnouncement(localPubKey, remotePubKey *btcec.Pu
shortChanID lnwire.ShortChannelID, shortChanID lnwire.ShortChannelID,
chanID lnwire.ChannelID) (*chanAnnouncement, error) { chanID lnwire.ChannelID) (*chanAnnouncement, error) {
chainHash := *f.cfg.Wallet.Cfg.NetParams.GenesisHash
// The unconditional section of the announcement is the ShortChannelID // The unconditional section of the announcement is the ShortChannelID
// 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{
ShortChannelID: shortChanID, ShortChannelID: shortChanID,
Features: lnwire.NewFeatureVector([]lnwire.Feature{}),
ChainHash: chainHash,
} }
// The chanFlags field indicates which directed edge of the channel is // The chanFlags field indicates which directed edge of the channel is
@ -1657,7 +1661,7 @@ func (f *fundingManager) newChanAnnouncement(localPubKey, remotePubKey *btcec.Pu
return nil, errors.Errorf("unable to generate node "+ return nil, errors.Errorf("unable to generate node "+
"signature for channel announcement: %v", err) "signature for channel announcement: %v", err)
} }
bitcoinSig, err := f.cfg.SignMessage(localFundingKey, selfBytes) bitcoinSig, err := f.cfg.SignMessage(localFundingKey, chanAnnMsg)
if err != nil { if err != nil {
return nil, errors.Errorf("unable to generate bitcoin "+ return nil, errors.Errorf("unable to generate bitcoin "+
"signature for node public key: %v", err) "signature for node public key: %v", err)
@ -1838,7 +1842,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
DustLimit: ourContribution.DustLimit, DustLimit: ourContribution.DustLimit,
MaxValueInFlight: ourContribution.MaxPendingAmount, MaxValueInFlight: ourContribution.MaxPendingAmount,
ChannelReserve: ourContribution.ChanReserve, ChannelReserve: ourContribution.ChanReserve,
HtlcMinimum: uint32(ourContribution.MinHTLC), HtlcMinimum: ourContribution.MinHTLC,
FeePerKiloWeight: uint32(feePerKw), FeePerKiloWeight: uint32(feePerKw),
CsvDelay: uint16(remoteCsvDelay), CsvDelay: uint16(remoteCsvDelay),
MaxAcceptedHTLCs: ourContribution.MaxAcceptedHtlcs, MaxAcceptedHTLCs: ourContribution.MaxAcceptedHtlcs,