chanrestore: return error instead of nil if failed derivation

This commit fixes a bug in the openChannelShell function where,
instead of properly returning an error when failing to derive
the shachain root's private key, nil was returned instead. This
would lead to a panic as the channel shell was then referenced
further down in the callstack. An error is now properly returned.
This commit is contained in:
nsa 2019-06-30 12:42:36 -04:00
parent 6a4179e224
commit 9804caca6d

View File

@ -41,7 +41,7 @@ func (c *chanDBRestorer) openChannelShell(backup chanbackup.Single) (
// shachain...
privKey, err := c.secretKeys.DerivePrivKey(backup.ShaChainRootDesc)
if err != nil {
return nil, nil
return nil, fmt.Errorf("unable to derive shachain root key: %v", err)
}
revRoot, err := chainhash.NewHash(privKey.Serialize())
if err != nil {