mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 19:22:40 +01:00
netann: let SignChannelUpdate take ChannelUpdate interface
This commit is contained in:
parent
c4ad342405
commit
a5afcd21b7
@ -67,7 +67,7 @@ func ChanUpdSetTimestamp(bestBlockHeight uint32) ChannelUpdateModifier {
|
|||||||
//
|
//
|
||||||
// NOTE: This method modifies the given update.
|
// NOTE: This method modifies the given update.
|
||||||
func SignChannelUpdate(signer keychain.MessageSignerRing,
|
func SignChannelUpdate(signer keychain.MessageSignerRing,
|
||||||
keyLoc keychain.KeyLocator, update *lnwire.ChannelUpdate1,
|
keyLoc keychain.KeyLocator, update lnwire.ChannelUpdate,
|
||||||
mods ...ChannelUpdateModifier) error {
|
mods ...ChannelUpdateModifier) error {
|
||||||
|
|
||||||
// Apply the requested changes to the channel update.
|
// Apply the requested changes to the channel update.
|
||||||
@ -75,16 +75,45 @@ func SignChannelUpdate(signer keychain.MessageSignerRing,
|
|||||||
modifier(update)
|
modifier(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the DER-encoded ECDSA signature over the message digest.
|
switch upd := update.(type) {
|
||||||
sig, err := SignAnnouncement(signer, keyLoc, update)
|
case *lnwire.ChannelUpdate1:
|
||||||
if err != nil {
|
data, err := upd.DataToSign()
|
||||||
return err
|
if err != nil {
|
||||||
}
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Parse the DER-encoded signature into a fixed-size 64-byte array.
|
sig, err := signer.SignMessage(keyLoc, data, true)
|
||||||
update.Signature, err = lnwire.NewSigFromSignature(sig)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
}
|
||||||
|
|
||||||
|
// Parse the DER-encoded signature into a fixed-size 64-byte
|
||||||
|
// array.
|
||||||
|
upd.Signature, err = lnwire.NewSigFromSignature(sig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
case *lnwire.ChannelUpdate2:
|
||||||
|
data, err := upd.DataToSign()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sig, err := signer.SignMessageSchnorr(
|
||||||
|
keyLoc, data, false, nil, upd.DigestTag(),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
upd.Signature, err = lnwire.NewSigFromSignature(sig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unhandled implementation of "+
|
||||||
|
"ChannelUpdate: %T", update)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user