Documentation ¶
Index ¶
- Variables
- func Base64File(filename string) (string, error)
- func CleanAndExpandPath(path string) string
- 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 CreateProposalNameRegex() 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 FetchTxWithBlockExplorers(address string, amount uint64, txnotbefore int64, minConfirmations uint64) (string, uint64, error)
- func FileExists(name string) bool
- func FnoStringToAmount(fnostr string) (uint64, error)
- 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 RandomUint64() (uint64, 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 SubsciptionReqAuth(cmd string) bool
- func Timestamp(host string, digests []*[sha256.Size]byte) error
- func ValidSubscription(cmd string) bool
- func Verify(host string, digests []string) (*v1.VerifyReply, error)
- func VerifyChallenge(id *identity.PublicIdentity, challenge []byte, signature string) error
- func WSJSON(cmd, id string, payload interface{}) ([][]byte, error)
- func WSRead(c *websocket.Conn) (string, string, interface{}, error)
- func WSWrite(c *websocket.Conn, cmd, id string, payload interface{}) error
- func Zero(in []byte)
- type BEBackupTransaction
- type BEPrimaryTransaction
- type BEPrimaryTransactionScriptPubkey
- type BEPrimaryTransactionVout
- type FaucetResponse
- type PaywallGatewayNewOrderResponse
- type TxDetails
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCannotVerifyPayment is emitted when a transaction cannot be verified // because it cannot reach either of the block explorer servers. ErrCannotVerifyPayment = errors.New("cannot verify payment at this time") )
var (
ErrInvalidWSCommand = errors.New("invalid webssocket command")
)
Functions ¶
func Base64File ¶
Base64File returns the base64 content of a file.
func CleanAndExpandPath ¶
CleanAndExpandPath expands environment variables and leading ~ in the passed path, cleans the result, and returns it.
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 CreateProposalNameRegex ¶
func CreateProposalNameRegex() string
CreateProposalNameRegex 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 FetchTxWithBlockExplorers ¶
func FetchTxWithBlockExplorers(address string, amount uint64, txnotbefore int64, minConfirmations uint64) (string, uint64, error)
FetchTxWithBlockExplorers uses public block explorers to look for a transaction for the given address that equals or exceeds the given amount, occurs after the txnotbefore time and has the minimum number of confirmations.
func FileExists ¶
FilesExists reports whether the named file or directory exists.
func FnoStringToAmount ¶
FnoStringToAmount converts a FNO amount as a string into a uint64 representing atoms. Supported input variations: "1", ".1", "0.1"
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 RandomUint64 ¶
RandomInt returns a random unsigned integer.
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 SubsciptionReqAuth ¶
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 ValidSubscription ¶
func Verify ¶
func Verify(host string, digests []string) (*v1.VerifyReply, error)
Verify sends a fnotime 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 FNO) 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 FNO) 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.
type TxDetails ¶
type TxDetails struct { Address string // Transaction address TxID string // Transacion ID Amount uint64 // Transaction amount (in atoms) Timestamp int64 // Transaction timestamp Confirmations uint64 // Number of confirmations }
TxDetails is an object representing a transaction that is used to standardize the different responses from fnodata and insight.
func FetchTxsForAddress ¶
FetchTxsForAddress fetches the transactions that have been sent to the provided wallet address from the fnodata block explorer. If the fnodata request fails the insight block explorer is tried.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package version provides a single location to house the version information for fnod and other utilities provided in the same repository.
|
Package version provides a single location to house the version information for fnod and other utilities provided in the same repository. |