Documentation
¶
Index ¶
- func Base64File(filename string) (string, error)
- func ConvertBodyToByteArray(r io.Reader, print bool) []byte
- func ConvertDigest(d string) ([sha256.Size]byte, bool)
- func ConvertSignature(s string) ([identity.SignatureSize]byte, error)
- func ConvertStringToken(token string) ([]byte, error)
- func CreateProposalTitleRegex() string
- func DerivePaywallAddress(params *chaincfg.Params, xpub string, index uint32) (string, error)
- func Digest(b []byte) []byte
- func DigestFile(filename string) (string, error)
- func DigestFileBytes(filename string) ([]byte, error)
- func FQDN() string
- func GenCertPair(curve elliptic.Curve, org, certFile, keyFile string) error
- func GetErrorFromJSON(r io.Reader) (interface{}, error)
- func GetProposalName(payload string) (string, error)
- func IdentityFromString(id string) (*identity.PublicIdentity, error)
- func IsDigest(digest string) bool
- func IsValidProposalName(str string) bool
- func LoadFile(filename string) (mimeType string, digest string, payload string, err error)
- func MimeFile(filename string) (string, error)
- func NewClient(skipVerify bool, certFilename string) (*http.Client, error)
- func NormalizeAddress(addr, defaultPort string) string
- func ParseGetParams(r *http.Request, dst interface{}) error
- func PayWithTestnetFaucet(faucetURL string, address string, amount uint64, overridetoken string) (string, error)
- func Random(n int) ([]byte, error)
- func RemoteIdentity(skipTLSVerify bool, host, cert string) (*identity.PublicIdentity, error)
- func RespondWithCopy(w http.ResponseWriter, code int, contentType string, body []byte) error
- func RespondWithError(w http.ResponseWriter, code int, message string)
- func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
- func Timestamp(host string, digests []*[sha256.Size]byte) error
- func Verify(host string, digests []string) (*v1.VerifyReply, error)
- func VerifyChallenge(id *identity.PublicIdentity, challenge []byte, signature string) error
- func VerifyTxWithBlockExplorers(address string, amount uint64, txid string, txnotbefore int64) (confirmed bool, err error)
- type BEBackupTransaction
- type BEPrimaryTransaction
- type BEPrimaryTransactionScriptPubkey
- type BEPrimaryTransactionVout
- type FaucetResponse
- type PaywallGatewayNewOrderResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base64File ¶
Base64File returns the base64 content of a file.
func ConvertBodyToByteArray ¶
ConvertBodyToByteArray converts a response body into a byte array and optionally prints it to stdout.
func ConvertDigest ¶
ConvertDigest converts a string into a digest.
func ConvertSignature ¶
func ConvertSignature(s string) ([identity.SignatureSize]byte, error)
ConvertSignature converts a hex encoded signature to a proper sized byte slice.
func ConvertStringToken ¶
ConvertStringToken verifies and converts a string token to a proper sized []byte.
func CreateProposalTitleRegex ¶
func CreateProposalTitleRegex() string
CreateProposalTitleRegex returns a regex string for matching the proposal name
func DerivePaywallAddress ¶
DerivePaywallAddress derives a paywall address using the provided xpub and index.
func DigestFile ¶
DigestFile returns the SHA256 of a file.
func DigestFileBytes ¶
DigestFileBytes returns the SHA256 of a file.
func FQDN ¶
func FQDN() string
FQDN returns the fully qualified domain name of the machine it is running on.
func GenCertPair ¶
GenCertPair generates a key/cert pair to the paths provided.
func GetErrorFromJSON ¶
GetErrorFromJSON returns the error that is embedded in a JSON reply.
func GetProposalName ¶
ProposalName returns a proposal name
func IdentityFromString ¶
func IdentityFromString(id string) (*identity.PublicIdentity, error)
IdentityFromString converts a string public key into a public identity structure.
func IsValidProposalName ¶
IsValidProposalName reports whether str is a valid proposal name
func LoadFile ¶
LoadFile loads a file of disk and returns the MIME type, the sha256 digest and the payload encoded as base64. If any of the intermediary operations fail the function will return an error instead.
func NormalizeAddress ¶
NormalizeAddress returns addr with the passed default port appended if there is not already a port specified.
func ParseGetParams ¶
ParseGetParams parses the query params from the GET request into a struct. This method requires the struct type to be defined with `schema` tags.
func PayWithTestnetFaucet ¶
func PayWithTestnetFaucet(faucetURL string, address string, amount uint64, overridetoken string) (string, error)
PayWithTestnetFaucet makes a request to the testnet faucet.
func RemoteIdentity ¶
func RemoteIdentity(skipTLSVerify bool, host, cert string) (*identity.PublicIdentity, error)
RemoteIdentity fetches the identity from politeiad.
func RespondWithCopy ¶
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, code int, message string)
func RespondWithJSON ¶
func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
func Timestamp ¶
Timestamp sends a Timestamp request to the provided host. The caller is responsible for assembling the host string based on what net to use.
func Verify ¶
Verify sends a dcrtime Verify command to the provided host. It checks and validates the entire reply. A single failure is considered terminal and an error is returned. If the reply is valid it is returned to the caller for further processing. This means that the caller can be assured that all checks have been done and the data is readily usable.
func VerifyChallenge ¶
func VerifyChallenge(id *identity.PublicIdentity, challenge []byte, signature string) error
VerifyChallenge checks that the signature returned from politeiad is the challenge signed with the given identity.
Types ¶
type BEBackupTransaction ¶
type BEBackupTransaction struct {
Address string `json:"address"` // Transaction address
TxId string `json:"txid"` // Transaction id
Amount json.Number `json:"amount"` // Transaction amount (in DCR)
Confirmations uint64 `json:"confirmations"` // Number of confirmations
Timestamp int64 `json:"ts"` // Transaction timestamp
}
BEBackupTransaction is an object representing a transaction; it's part of the data returned from the URL for the backup block explorer when fetching the transactions for an address.
type BEPrimaryTransaction ¶
type BEPrimaryTransaction struct {
TxId string `json:"txid"` // Transaction id
Vout []BEPrimaryTransactionVout `json:"vout"` // Transaction outputs
Confirmations uint64 `json:"confirmations"` // Number of confirmations
Timestamp int64 `json:"time"` // Transaction timestamp
}
BEPrimaryTransaction is an object representing a transaction; it's part of the data returned from the URL for the primary block explorer when fetching the transactions for an address.
type BEPrimaryTransactionScriptPubkey ¶
type BEPrimaryTransactionScriptPubkey struct {
Addresses []string `json:"addresses"` // Array of transaction input addresses
}
BEPrimaryTransactionScriptPubkey holds the script info for a transaction.
type BEPrimaryTransactionVout ¶
type BEPrimaryTransactionVout struct {
Amount json.Number `json:"value"` // Transaction amount (in DCR)
ScriptPubkey BEPrimaryTransactionScriptPubkey `json:"scriptPubkey"` // Transaction script info
}
BEPrimaryTransactionVout holds the transaction amount information.
type FaucetResponse ¶
FaucetResponse represents the expected JSON response from the testnet faucet.
type PaywallGatewayNewOrderResponse ¶
PaywallGatewayNewOrderResponse respresents the expected JSON response to a PaywallGatewayNewOrder command.