ekzyis 7558655458 refactor: Structure code into different packages
I have put too much code into the same files.

Also, I put everything into the same package: main.

This package is only meant for executables.

Therefore, I have refactored my code to use multiple packages. These packages also guarantee separation of concerns since Golang doesn't allow cyclic imports.
2023-09-10 23:13:08 +02:00

22 lines
409 B
Go

package lnd
import (
"crypto/rand"
"io"
"github.com/lightningnetwork/lnd/lntypes"
)
func generateNewPreimage() (lntypes.Preimage, error) {
randomBytes := make([]byte, 32)
_, err := io.ReadFull(rand.Reader, randomBytes)
if err != nil {
return lntypes.Preimage{}, err
}
preimage, err := lntypes.MakePreimage(randomBytes)
if err != nil {
return lntypes.Preimage{}, err
}
return preimage, nil
}