2019-08-14 06:44:27 +02:00
|
|
|
package lbrycrd
|
|
|
|
|
|
|
|
import (
|
2021-10-06 20:00:59 +02:00
|
|
|
"github.com/lbryio/lbry.go/v3/schema/keys"
|
|
|
|
c "github.com/lbryio/lbry.go/v3/schema/stake"
|
|
|
|
|
|
|
|
"github.com/lbryio/lbcd/btcec"
|
2019-08-14 06:44:27 +02:00
|
|
|
pb "github.com/lbryio/types/v2/go"
|
2021-10-06 20:00:59 +02:00
|
|
|
|
|
|
|
"github.com/cockroachdb/errors"
|
2019-08-14 06:44:27 +02:00
|
|
|
)
|
|
|
|
|
2021-10-06 20:00:59 +02:00
|
|
|
func NewChannel() (*c.Helper, *btcec.PrivateKey, error) {
|
2019-08-14 06:44:27 +02:00
|
|
|
claimChannel := new(pb.Claim_Channel)
|
|
|
|
channel := new(pb.Channel)
|
|
|
|
claimChannel.Channel = channel
|
|
|
|
|
|
|
|
pbClaim := new(pb.Claim)
|
|
|
|
pbClaim.Type = claimChannel
|
|
|
|
|
|
|
|
privateKey, err := btcec.NewPrivateKey(btcec.S256())
|
|
|
|
if err != nil {
|
2021-10-06 20:00:59 +02:00
|
|
|
return nil, nil, errors.WithStack(err)
|
2019-08-14 06:44:27 +02:00
|
|
|
}
|
2020-10-28 06:36:49 +01:00
|
|
|
pubkeyBytes, err := keys.PublicKeyToDER(privateKey.PubKey())
|
2019-08-14 06:44:27 +02:00
|
|
|
if err != nil {
|
2021-10-06 20:00:59 +02:00
|
|
|
return nil, nil, errors.WithStack(err)
|
2019-08-14 06:44:27 +02:00
|
|
|
}
|
|
|
|
|
2021-10-06 20:00:59 +02:00
|
|
|
helper := c.Helper{Claim: pbClaim}
|
2019-08-14 06:44:27 +02:00
|
|
|
helper.Version = c.NoSig
|
2020-10-28 06:36:49 +01:00
|
|
|
helper.Claim.GetChannel().PublicKey = pubkeyBytes
|
|
|
|
helper.Claim.Tags = []string{}
|
2019-08-14 06:44:27 +02:00
|
|
|
coverSrc := new(pb.Source)
|
2020-10-28 06:36:49 +01:00
|
|
|
helper.Claim.GetChannel().Cover = coverSrc
|
|
|
|
helper.Claim.Languages = []*pb.Language{}
|
2019-08-14 06:44:27 +02:00
|
|
|
thumbnailSrc := new(pb.Source)
|
2020-10-28 06:36:49 +01:00
|
|
|
helper.Claim.Thumbnail = thumbnailSrc
|
|
|
|
helper.Claim.Locations = []*pb.Location{}
|
2019-08-14 06:44:27 +02:00
|
|
|
|
|
|
|
return &helper, privateKey, nil
|
|
|
|
}
|