mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-06 01:18:17 +02:00
revocation: fix nil pointer panic in shachain constructor
This commit is contained in:
@@ -44,7 +44,7 @@ func NewHyperShaChain() *HyperShaChain {
|
|||||||
// NewHyperShaChainFromSeed...
|
// NewHyperShaChainFromSeed...
|
||||||
// * used to derive your own pre-images
|
// * used to derive your own pre-images
|
||||||
func NewHyperShaChainFromSeed(seed *[32]byte, deriveTo uint64) (*HyperShaChain, error) {
|
func NewHyperShaChainFromSeed(seed *[32]byte, deriveTo uint64) (*HyperShaChain, error) {
|
||||||
var shaSeed *[32]byte
|
var shaSeed [32]byte
|
||||||
|
|
||||||
// If no seed is specified, generate a new one.
|
// If no seed is specified, generate a new one.
|
||||||
if seed == nil {
|
if seed == nil {
|
||||||
@@ -52,13 +52,15 @@ func NewHyperShaChainFromSeed(seed *[32]byte, deriveTo uint64) (*HyperShaChain,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
shaSeed = *seed
|
||||||
}
|
}
|
||||||
|
|
||||||
// The last possible value in the chain is our starting index.
|
// The last possible value in the chain is our starting index.
|
||||||
start := uint64(maxIndex)
|
start := uint64(maxIndex)
|
||||||
stop := deriveTo
|
stop := deriveTo
|
||||||
|
|
||||||
curHash := derive(start, stop, *shaSeed)
|
curHash := derive(start, stop, shaSeed)
|
||||||
|
|
||||||
// TODO(roasbeef): from/to or static size?
|
// TODO(roasbeef): from/to or static size?
|
||||||
return &HyperShaChain{lastChainIndex: deriveTo, lastHash: curHash}, nil
|
return &HyperShaChain{lastChainIndex: deriveTo, lastHash: curHash}, nil
|
||||||
|
Reference in New Issue
Block a user