stake

package
v2.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoSig = version(byte(0))
	//Signature using ECDSA SECP256k1 key and SHA-256 hash.
	WithSig = version(byte(1))
	UNKNOWN = version(byte(2))
)
View Source
const SECP256k1 = "SECP256k1"

Variables

This section is empty.

Functions

func GetOutpointHash

func GetOutpointHash(txid string, vout uint32) (string, error)

Types

type Fee

type Fee struct {
	LBC *FeeInfo `json:"LBC,omitempty"`
	BTC *FeeInfo `json:"BTC,omitempty"`
	USD *FeeInfo `json:"USD,omitempty"`
}

Fee is the structure used for different currencies allowed for claims.

type FeeInfo

type FeeInfo struct {
	Amount  float32 `json:"amount"`  //Required
	Address string  `json:"address"` //Required
}

FeeInfo is the structure of fee information used by lbry.

type Signature

type Signature struct {
	btcec.Signature
}

func Sign

func Sign(privKey btcec.PrivateKey, channel StakeHelper, claim StakeHelper, k string) (*Signature, error)

func (*Signature) LBRYSDKEncode

func (s *Signature) LBRYSDKEncode() ([]byte, error)

type Sources

type Sources struct {
	LbrySDHash string `json:"lbry_sd_hash"` //Required
	BTIH       string `json:"btih"`         //Required
	URL        string `json:"url"`          //Required
}

Sources is the structure of Sources that can be used for a claim. Sources mainly include lbrysdhash but could be from elsewhere in the future.

type StakeHelper

type StakeHelper struct {
	Claim       *pb.Claim
	Support     *pb.Support
	LegacyClaim *legacy_pb.Claim
	ClaimID     []byte
	Version     version
	Signature   []byte
	Payload     []byte
}

func DecodeClaimBytes

func DecodeClaimBytes(serialized []byte, blockchainName string) (*StakeHelper, error)

DecodeClaimBytes take a byte array and tries to decode it to a protobuf claim or migrate it from either json v1,2,3 or pb v1

func DecodeClaimHex

func DecodeClaimHex(serialized string, blockchainName string) (*StakeHelper, error)

func DecodeClaimProtoBytes

func DecodeClaimProtoBytes(serialized []byte, blockchainName string) (*StakeHelper, error)

func DecodeSupportBytes

func DecodeSupportBytes(serialized []byte, blockchainName string) (*StakeHelper, error)

DecodeSupportBytes take a byte array and tries to decode it to a protobuf support

func DecodeSupportProtoBytes

func DecodeSupportProtoBytes(serialized []byte, blockchainName string) (*StakeHelper, error)

func (*StakeHelper) CompileValue

func (c *StakeHelper) CompileValue() ([]byte, error)

func (*StakeHelper) GetPublicKey

func (c *StakeHelper) GetPublicKey() (*btcec.PublicKey, error)

func (*StakeHelper) GetStream

func (c *StakeHelper) GetStream() *pb.Stream

func (*StakeHelper) IsClaim

func (c *StakeHelper) IsClaim() bool

func (*StakeHelper) IsSupport

func (c *StakeHelper) IsSupport() bool

func (*StakeHelper) LoadFromBytes

func (c *StakeHelper) LoadFromBytes(raw_claim []byte, blockchainName string) error

func (*StakeHelper) LoadFromHexString

func (c *StakeHelper) LoadFromHexString(claim_hex string, blockchainName string) error

func (*StakeHelper) LoadSupportFromBytes

func (c *StakeHelper) LoadSupportFromBytes(raw_claim []byte, blockchainName string) error

func (*StakeHelper) LoadSupportFromHexString

func (c *StakeHelper) LoadSupportFromHexString(claim_hex string, blockchainName string) error

func (*StakeHelper) RenderJSON

func (c *StakeHelper) RenderJSON() (string, error)

func (*StakeHelper) ValidateAddresses

func (c *StakeHelper) ValidateAddresses(blockchainName string) error

func (*StakeHelper) ValidateCertificate

func (c *StakeHelper) ValidateCertificate() error

func (*StakeHelper) ValidateClaimSignature

func (c *StakeHelper) ValidateClaimSignature(certificate *StakeHelper, k string, certificateId string, blockchainName string) (bool, error)

func (*StakeHelper) VerifyDigest

func (c *StakeHelper) VerifyDigest(certificate *StakeHelper, signature [64]byte, digest [32]byte) bool

type V1Claim

type V1Claim struct {
	Version     string  `json:"ver,omitempty"`
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content-type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
}

V1Claim is the first version of claim metadata used by lbry.

func (*V1Claim) Unmarshal

func (c *V1Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V1 claim from json. Main addition is to check the version.

type V2Claim

type V2Claim struct {
	Version     string  `json:"ver"`          //Required
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content-type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
	LicenseURL  *string `json:"license_url,omitempty"`
	NSFW        bool    `json:"nsfw"` //Required

}

V2Claim is the second version of claim metadata used by lbry.

func (*V2Claim) Unmarshal

func (c *V2Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V2 claim from json. Main addition is to check the version.

type V3Claim

type V3Claim struct {
	Version     string  `json:"ver"`          //Required
	Title       string  `json:"title"`        //Required
	Description string  `json:"description"`  //Required
	Author      string  `json:"author"`       //Required
	Language    string  `json:"language"`     //Required
	License     string  `json:"license"`      //Required
	Sources     Sources `json:"sources"`      //Required
	ContentType string  `json:"content_type"` //Required
	Thumbnail   *string `json:"thumbnail,omitempty"`
	Fee         *Fee    `json:"fee,omitempty"`
	Contact     *int    `json:"contact,omitempty"`
	PubKey      *string `json:"pubkey,omitempty"`
	LicenseURL  *string `json:"license_url,omitempty"`
	NSFW        bool    `json:"nsfw"` //Required
	Sig         *string `json:"sig"`
}

V3Claim is the third version of claim metadata used by lbry.

func (*V3Claim) Unmarshal

func (c *V3Claim) Unmarshal(value []byte) error

Unmarshal is an implementation to unmarshal the V3 claim from json. Main addition is to check the version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL