2019-08-14 06:44:27 +02:00
|
|
|
package lbrycrd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/btcsuite/btcd/btcec"
|
2019-10-10 05:07:33 +02:00
|
|
|
"github.com/lbryio/lbry.go/v2/extras/errors"
|
2019-08-14 06:44:27 +02:00
|
|
|
c "github.com/lbryio/lbryschema.go/claim"
|
|
|
|
pb "github.com/lbryio/types/v2/go"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewChannel() (*c.ClaimHelper, *btcec.PrivateKey, error) {
|
|
|
|
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 {
|
|
|
|
return nil, nil, errors.Err(err)
|
|
|
|
}
|
|
|
|
pubkeyBytes, err := c.PublicKeyToDER(privateKey.PubKey())
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, errors.Err(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
helper := c.ClaimHelper{Claim: pbClaim}
|
|
|
|
helper.Version = c.NoSig
|
|
|
|
helper.GetChannel().PublicKey = pubkeyBytes
|
|
|
|
helper.Tags = []string{}
|
|
|
|
coverSrc := new(pb.Source)
|
|
|
|
helper.GetChannel().Cover = coverSrc
|
|
|
|
helper.Languages = []*pb.Language{}
|
|
|
|
thumbnailSrc := new(pb.Source)
|
|
|
|
helper.Thumbnail = thumbnailSrc
|
|
|
|
helper.Locations = []*pb.Location{}
|
|
|
|
|
|
|
|
return &helper, privateKey, nil
|
|
|
|
}
|