client

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: ISC Imports: 27 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthDetailsVerify

func AuthDetailsVerify(a tkv1.AuthDetails, serverPublicKey string) error

AuthDetailsVerify verifies the action, signature, and receipt of the provided ticketvote v1 AuthDetails.

func CastVoteDetailsVerify

func CastVoteDetailsVerify(cvd tkv1.CastVoteDetails, serverPublicKey string) error

CastVoteDetailsVerify verifies the receipt of the provided ticketvote v1 CastVoteDetails.

func CensorshipRecordVerify

func CensorshipRecordVerify(r rcv1.Record, serverPubKey string) error

CensorshipRecordVerify verifies the censorship record of a records v1 Record.

func CommentTimestampVerify

func CommentTimestampVerify(ct cmv1.CommentTimestamp) error

CommentTimestampVerify verifies that all timestamps in the provided CommentTimestamp are valid.

func CommentTimestampsVerify

func CommentTimestampsVerify(tr cmv1.TimestampsReply) ([]uint32, error)

CommentTimestampsVerify verifies that all timestamps in a comments v1 TimestampsReply are valid. The IDs of comments that have not been anchored yet are returned.

func CommentVerify

func CommentVerify(c cmv1.Comment, serverPublicKey string) error

CommentVerify verifies the comment signature and receipt. If the comment has been deleted then the deletion signature and receipt will be verified.

func ProposalMetadataDecode

func ProposalMetadataDecode(files []rcv1.File) (*piv1.ProposalMetadata, error)

ProposalMetadataDecode decodes and returns the ProposalMetadata from the Provided record files. An error returned if a ProposalMetadata is not found.

func RecordTimestampVerify

func RecordTimestampVerify(t rcv1.Timestamp) error

RecordTimestampVerify verifies a records v1 API timestamp. This proves inclusion of the data in the merkle root that was timestamped onto the dcr blockchain.

func RecordTimestampsVerify

func RecordTimestampsVerify(tr rcv1.TimestampsReply) error

RecordTimestampsVerify verifies all timestamps in a records v1 API timestamps reply. This proves the inclusion of the data in the merkle root that was timestamped onto the dcr blockchain.

func RecordVerify

func RecordVerify(r rcv1.Record, serverPubKey string) error

RecordVerify verfifies the contents of a record. This includes verifying the censorship record, the user metadata, and any status changes that are present.

func StatusChangesDecode

func StatusChangesDecode(metadata []v1.MetadataStream) ([]v1.StatusChange, error)

StatusChangesDecode decodes and returns the status changes metadata stream from the provided metadata. An error IS NOT returned is status change metadata is not found.

func StatusChangesVerify

func StatusChangesVerify(sc []v1.StatusChange) error

StatusChanges verifies the signatures on all status change metadata.

func TicketVoteTimestampVerify

func TicketVoteTimestampVerify(t tkv1.Timestamp) error

TicketVoteTimestampVerify verifies that the provided ticketvote v1 Timestamp is valid.

func TicketVoteTimestampsVerify

func TicketVoteTimestampsVerify(tr tkv1.TimestampsReply) error

TicketVoteTimestampsVerify verifies that all timestamps in the ticketvote v1 TimestampsReply are valid.

func UserMetadataDecode

func UserMetadataDecode(ms []v1.MetadataStream) (*rcv1.UserMetadata, error)

UserMetadataDecode decodes and returns the UserMetadata from the provided metadata streams. An error is returned if a UserMetadata is not found.

func UserMetadataVerify

func UserMetadataVerify(um v1.UserMetadata, merkleRoot string) error

UserMetadataVerify verifies that the UserMetadata contains a valid user ID, a valid public key, and that this signature is a valid signature of the record merkle root.

func VoteDetailsVerify

func VoteDetailsVerify(vd tkv1.VoteDetails, serverPublicKey string) error

VoteDetailsVerify verifies the signature and receipt of the provided ticketvote v1 VoteDetails.

func VoteMetadataDecode

func VoteMetadataDecode(files []rcv1.File) (*piv1.VoteMetadata, error)

VoteMetadataDecode decodes and returns the VoteMetadata from the provided backend files. Nil is returned if a VoteMetadata is not found.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides a client for interacting with the politeiawww API.

func New

func New(host string, opts Opts) (*Client, error)

New returns a new politeiawww client.

func (*Client) CommentCount

func (c *Client) CommentCount(cc cmv1.Count) (*cmv1.CountReply, error)

CommentCount sends a comments v1 Count request to politeiawww.

func (*Client) CommentDel

func (c *Client) CommentDel(d cmv1.Del) (*cmv1.DelReply, error)

CommentDel sends a comments v1 Del request to politeiawww.

func (*Client) CommentNew

func (c *Client) CommentNew(n cmv1.New) (*cmv1.NewReply, error)

CommentNew sends a comments v1 New request to politeiawww.

func (*Client) CommentPolicy

func (c *Client) CommentPolicy() (*cmv1.PolicyReply, error)

CommentPolicy sends a comments v1 Policy request to politeiawww.

func (*Client) CommentTimestamps

func (c *Client) CommentTimestamps(t cmv1.Timestamps) (*cmv1.TimestampsReply, error)

CommentTimestamps sends a comments v1 Timestamps request to politeiawww.

func (*Client) CommentVote

func (c *Client) CommentVote(v cmv1.Vote) (*cmv1.VoteReply, error)

CommentVote sends a comments v1 Vote request to politeiawww.

func (*Client) CommentVotes

func (c *Client) CommentVotes(v cmv1.Votes) (*cmv1.VotesReply, error)

CommentVotes sends a comments v1 Votes request to politeiawww.

func (*Client) Comments

func (c *Client) Comments(cm cmv1.Comments) (*cmv1.CommentsReply, error)

Comments sends a comments v1 Comments request to politeiawww.

func (*Client) PiPolicy

func (c *Client) PiPolicy() (*piv1.PolicyReply, error)

PiPolicy sends a pi v1 Policy request to politeiawww.

func (*Client) PiSetBillingStatus added in v1.2.0

func (c *Client) PiSetBillingStatus(sbs piv1.SetBillingStatus) (*piv1.SetBillingStatusReply, error)

PiSetBillingStatus sends a pi v1 SetBillingStatus request to politeiawww.

func (*Client) PiSummaries added in v1.2.0

func (c *Client) PiSummaries(s piv1.Summaries) (*piv1.SummariesReply, error)

PiSummaries sends a pi v1 Summaries request to politeiawww.

func (*Client) RecordDetails

func (c *Client) RecordDetails(d rcv1.Details) (*rcv1.Record, error)

RecordDetails sends a records v1 Details request to politeiawww.

func (*Client) RecordEdit

func (c *Client) RecordEdit(e rcv1.Edit) (*rcv1.EditReply, error)

RecordEdit sends a records v1 Edit request to politeiawww.

func (*Client) RecordInventory

func (c *Client) RecordInventory(i rcv1.Inventory) (*rcv1.InventoryReply, error)

RecordInventory sends a records v1 Inventory request to politeiawww.

func (*Client) RecordInventoryOrdered

func (c *Client) RecordInventoryOrdered(i rcv1.InventoryOrdered) (*rcv1.InventoryOrderedReply, error)

RecordInventoryOrdered sends a records v1 InventoryOrdered request to politeiawww.

func (*Client) RecordNew

func (c *Client) RecordNew(n rcv1.New) (*rcv1.NewReply, error)

RecordNew sends a records v1 New request to politeiawww.

func (*Client) RecordPolicy added in v1.2.0

func (c *Client) RecordPolicy() (*rcv1.PolicyReply, error)

RecordPolicy sends a records v1 Policy request to politeiawww.

func (*Client) RecordSetStatus

func (c *Client) RecordSetStatus(ss rcv1.SetStatus) (*rcv1.SetStatusReply, error)

RecordSetStatus sends a records v1 SetStatus request to politeiawww.

func (*Client) RecordTimestamps

func (c *Client) RecordTimestamps(t rcv1.Timestamps) (*rcv1.TimestampsReply, error)

RecordTimestamps sends a records v1 Timestamps request to politeiawww.

func (*Client) Records

func (c *Client) Records(r rcv1.Records) (map[string]rcv1.Record, error)

Records sends a records v1 Records request to politeiawww.

func (*Client) TicketVoteAuthorize

func (c *Client) TicketVoteAuthorize(a tkv1.Authorize) (*tkv1.AuthorizeReply, error)

TicketVoteAuthorize sends a ticketvote v1 Authorize request to politeiawww.

func (*Client) TicketVoteCastBallot

func (c *Client) TicketVoteCastBallot(cb tkv1.CastBallot) (*tkv1.CastBallotReply, error)

TicketVoteCastBallot sends a ticketvote v1 CastBallot request to politeiawww.

func (*Client) TicketVoteDetails

func (c *Client) TicketVoteDetails(d tkv1.Details) (*tkv1.DetailsReply, error)

TicketVoteDetails sends a ticketvote v1 Details request to politeiawww.

func (*Client) TicketVoteInventory

func (c *Client) TicketVoteInventory(i tkv1.Inventory) (*tkv1.InventoryReply, error)

TicketVoteInventory sends a ticketvote v1 Inventory request to politeiawww.

func (*Client) TicketVotePolicy

func (c *Client) TicketVotePolicy() (*tkv1.PolicyReply, error)

TicketVotePolicy sends a ticketvote v1 Policy request to politeiawww.

func (*Client) TicketVoteResults

func (c *Client) TicketVoteResults(r tkv1.Results) (*tkv1.ResultsReply, error)

TicketVoteResults sends a ticketvote v1 Results request to politeiawww.

func (*Client) TicketVoteStart

func (c *Client) TicketVoteStart(s tkv1.Start) (*tkv1.StartReply, error)

TicketVoteStart sends a ticketvote v1 Start request to politeiawww.

func (*Client) TicketVoteSubmissions

func (c *Client) TicketVoteSubmissions(s tkv1.Submissions) (*tkv1.SubmissionsReply, error)

TicketVoteSubmissions sends a ticketvote v1 Submissions request to politeiawww.

func (*Client) TicketVoteSummaries

func (c *Client) TicketVoteSummaries(s tkv1.Summaries) (*tkv1.SummariesReply, error)

TicketVoteSummaries sends a ticketvote v1 Summaries request to politeiawww.

func (*Client) TicketVoteTimestamps

func (c *Client) TicketVoteTimestamps(t tkv1.Timestamps) (*tkv1.TimestampsReply, error)

TicketVoteTimestamps sends a ticketvote v1 Timestamps request to politeiawww.

func (*Client) UserRecords

func (c *Client) UserRecords(ur rcv1.UserRecords) (*rcv1.UserRecordsReply, error)

UserRecords sends a records v1 UserRecords request to politeiawww.

type ErrorReply

type ErrorReply struct {
	PluginID     string
	ErrorCode    int
	ErrorContext string
}

ErrorReply represents the request body that is returned from politeiawww when an error occurs. PluginID will only be populated if the error occurred during execution of a plugin command.

type Opts

type Opts struct {
	HTTPSCert  string
	Cookies    []*http.Cookie
	HeaderCSRF string
	Verbose    bool // Print verbose output
	RawJSON    bool // Print raw json
}

Opts contains the politeiawww client options. All values are optional.

Any provided HTTPSCert will be added to the http client's trusted cert pool, allowing you to interact with a politeiawww instance that uses a self signed cert.

Authenticated routes require a CSRF cookie as well as the corresponding CSRF header.

type RespErr

type RespErr struct {
	HTTPCode   int
	API        string
	ErrorReply ErrorReply
}

RespErr represents a politeiawww response error. A RespErr is returned anytime the politeiawww response is not a 200.

The various politeiawww APIs can have overlapping error codes. The API is included to allow the Error() method to return the correct human readable error message.

func (RespErr) Error

func (e RespErr) Error() string

Error satisfies the error interface.

Jump to

Keyboard shortcuts

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