Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAndSetUlimit() error
- func FormatRFC3339PB(ts google_protobuf.Timestamp) string
- func GetOrderQuantity(l *pb.Listing, item *pb.Order_Item) *big.Int
- func GetSelectedSku(listing *pb.Listing, itemOptions []*pb.Order_Item_Option) (int, error)
- func GetSignedListingFromPath(p string) (*pb.SignedListing, error)
- func ParseContractForListing(hash string, contract *pb.RicardianContract) (*pb.Listing, error)
- func SameSku(selectedVariants []int, sku *pb.Listing_Item_Sku) bool
- func SignPayload(payload []byte, privKey crypto.PrivKey) ([]byte, []byte, error)
- func ValidateProfile(profile *pb.Profile) error
- func ValidateRating(rating *pb.Rating) (bool, error)
- func VerifyPayload(payload, sig, pubKey []byte) (string, error)
- type CodedError
- type ErrOutOfInventory
- type Inventory
- type InventoryListing
- type OrderRatings
- type RatingData
- type SavedRating
- type SpendRequest
- type SpendResponse
Constants ¶
const ( // RatingMin - min raring RatingMin = 1 // RatingMax - max rating RatingMax = 5 // ReviewMaxCharacters - max size for review ReviewMaxCharacters = 3000 )
const ( // VERSION - current version VERSION = "0.14.0" // USERAGENT - user-agent header string USERAGENT = "/openbazaar-go:" + VERSION + "/" )
const ( // ChatMessageMaxCharacters - limit for chat msg ChatMessageMaxCharacters = 20000 // ChatSubjectMaxCharacters - limit for chat subject ChatSubjectMaxCharacters = 500 // DefaultPointerPrefixLength - default ipfs pointer prefix DefaultPointerPrefixLength = 14 )
const ( // EscrowReleaseSize - size in bytes for escrow op EscrowReleaseSize = 337 // CryptocurrencyPurchasePaymentAddressMaxLength - max permissible length for an address CryptocurrencyPurchasePaymentAddressMaxLength = 512 )
const ( // PostStatusMaxCharacters - Maximum length of the status field of a post PostStatusMaxCharacters = 280 // PostLongFormMaxCharacters - Maximum length of the longForm field of a post PostLongFormMaxCharacters = 50000 // PostMaximumTotalTags - Maximum number of tags a post can have PostMaximumTotalTags = 50 // PostMaximumTotalChannels - Maximum number of channels a post can be addressed to PostMaximumTotalChannels = 30 // PostTagsMaxCharacters - Maximum character length of a tag PostTagsMaxCharacters = 256 // PostChannelsMaxCharacters - Maximum character length of a channel PostChannelsMaxCharacters = 256 // PostReferenceMaxCharacters - Maximum character length of a reference PostReferenceMaxCharacters = 256 )
Constants for validation
const DefaultCurrencyDivisibility uint = 8
DefaultCurrencyDivisibility is the Divisibility of the Currency if not defined otherwise
Variables ¶
var ( // EscrowTimeLockedError - custom err for time locked escrow EscrowTimeLockedError error // ErrPrematureReleaseOfTimedoutEscrowFunds - custom err for premature escrow funds release ErrPrematureReleaseOfTimedoutEscrowFunds = fmt.Errorf("escrow can only be released when in dispute for %s days", (time.Duration(repo.DisputeTotalDurationHours) * time.Hour).String()) )
var ( // ErrPurchaseUnknownListing - unavailable listing err ErrPurchaseUnknownListing = errors.New("order contains a hash of a listing that is not currently for sale") // ErrPriceCalculationRequiresExchangeRates - exchange rates dependency err ErrPriceCalculationRequiresExchangeRates = errors.New("can't calculate price with exchange rates disabled") // ErrCryptocurrencyListingCoinTypeRequired - missing coinType err ErrCryptocurrencyListingCoinTypeRequired = errors.New("cryptocurrency listings require a coinType") // ErrCryptocurrencyPurchasePaymentAddressRequired - missing payment address err ErrCryptocurrencyPurchasePaymentAddressRequired = errors.New("paymentAddress required for cryptocurrency items") // ErrCryptocurrencyPurchasePaymentAddressTooLong - invalid payment address ErrCryptocurrencyPurchasePaymentAddressTooLong = errors.New("paymentAddress required is too long") // ErrFulfillIncorrectDeliveryType - incorrect delivery type err ErrFulfillIncorrectDeliveryType = errors.New("incorrect delivery type for order") // ErrFulfillCryptocurrencyTXIDNotFound - missing txn id err ErrFulfillCryptocurrencyTXIDNotFound = errors.New("a transactionID is required to fulfill crypto listings") // ErrFulfillCryptocurrencyTXIDTooLong - invalid txn id err ErrFulfillCryptocurrencyTXIDTooLong = errors.New("transactionID should be no longer than " + strconv.Itoa(MaxTXIDSize)) // ErrUnknownWallet is returned when a wallet is not present on the node ErrUnknownWallet = errors.New("Unknown wallet type") // ErrInvalidSpendAddress is returned when the wallet is unable to decode the string address into a valid destination to send funds to ErrInvalidSpendAddress = errors.New("ERROR_INVALID_ADDRESS") // ErrInsufficientFunds is returned when the wallet is unable to send the amount specified due to the balance being too low ErrInsufficientFunds = errors.New("ERROR_INSUFFICIENT_FUNDS") // ErrInvalidAmount is returned when the string representation of the amount to spend is not an integer ErrInvalidAmount = errors.New("Spend amount is invalid or empty") // ErrSpendAmountIsDust is returned when the requested amount to spend out of the wallet would be considered "dust" by the network. This means the value is too low for the network to bother sending the amount and has a high likelihood of not being accepted or being outright rejected. ErrSpendAmountIsDust = errors.New("ERROR_DUST_AMOUNT") // ErrUnknownOrder is returned when the requested amount to spend is unable to be associated with the appropriate order ErrOrderNotFound = errors.New("ERROR_ORDER_NOT_FOUND") )
var ( // ErrPostUnknownValidationPanic - post has an unknown panic error ErrPostUnknownValidationPanic = errors.New("unexpected validation panic") // ErrPostSlugNotEmpty - post slug is empty error ErrPostSlugNotEmpty = errors.New("slug must not be empty") // ErrPostSlugTooLong - post slug longer than max characters error ErrPostSlugTooLong = fmt.Errorf("slug is longer than the max of %d", repo.SentenceMaxCharacters) // ErrPostSlugContainsSpaces - post slug has spaces error ErrPostSlugContainsSpaces = errors.New("slugs cannot contain spaces") // ErrPostSlugContainsSlashes - post slug has file separators ErrPostSlugContainsSlashes = errors.New("slugs cannot contain file separators") // ErrPostInvalidType - post type is invalid error ErrPostInvalidType = errors.New("invalid post type") // ErrPostStatusTooLong - post 'status' is longer than max characters error ErrPostStatusTooLong = fmt.Errorf("status is longer than the max of %d", PostStatusMaxCharacters) // ErrPostBodyTooLong - post 'longForm' is longer than max characters error ErrPostBodyTooLong = fmt.Errorf("post is longer than the max of %d characters", PostLongFormMaxCharacters) // ErrPostTagsTooMany - post tags longer than max length error ErrPostTagsTooMany = fmt.Errorf("tags in the post is longer than the max of %d", PostMaximumTotalTags) // ErrPostTagsEmpty - post has empty tags error ErrPostTagsEmpty = errors.New("tags must not be empty") // ErrPostTagTooLong - post tag has characters longer than max length error ErrPostTagTooLong = fmt.Errorf("tags must be less than max of %d characters", PostTagsMaxCharacters) // ErrPostChannelsTooMany - post channels longer than max length error ErrPostChannelsTooMany = fmt.Errorf("channels in the post is longer than the max of %d", PostMaximumTotalChannels) // ErrPostChannelTooLong - post channel has characters longer than max length error ErrPostChannelTooLong = fmt.Errorf("channels must be less than max of %d characters", PostChannelsMaxCharacters) // ErrPostReferenceEmpty - post has an empty reference error ErrPostReferenceEmpty = errors.New("reference must not be empty") // ErrPostReferenceTooLong - post reference has characters longer than max length error ErrPostReferenceTooLong = fmt.Errorf("reference is longer than the max of %d", PostReferenceMaxCharacters) // ErrPostReferenceContainsSpaces - post reference has spaces error ErrPostReferenceContainsSpaces = errors.New("reference cannot contain spaces") // ErrPostImagesTooMany - post images longer than max error ErrPostImagesTooMany = fmt.Errorf("number of post images is greater than the max of %d", repo.MaxListItems) // ErrPostImageTinyFormatInvalid - post tiny image hash incorrectly formatted error ErrPostImageTinyFormatInvalid = errors.New("tiny image hashes must be properly formatted CID") // ErrPostImageSmallFormatInvalid - post small image hash incorrectly formatted error ErrPostImageSmallFormatInvalid = errors.New("small image hashes must be properly formatted CID") // ErrPostImageMediumFormatInvalid - post medium image hash incorrectly formatted error ErrPostImageMediumFormatInvalid = errors.New("medium image hashes must be properly formatted CID") // ErrPostImageLargeFInvalidormat - post large image hash incorrectly formatted error ErrPostImageLargeFormatInvalid = errors.New("large image hashes must be properly formatted CID") // ErrPostImageOriginalFormatInvalid - post original image hash incorrectly formatted error ErrPostImageOriginalFormatInvalid = errors.New("original image hashes must be properly formatted CID") // ErrPostImageFilenameNil - post image filename is nil error ErrPostImageFilenameNil = errors.New("image file names must not be nil") // ErrPostImageFilenameTooLong - post image filename length longer than max ErrPostImageFilenameTooLong = fmt.Errorf("image filename length must be less than the max of %d", repo.FilenameMaxCharacters) )
Errors
var DisputeWg = new(sync.WaitGroup)
DisputeWg - waitgroup for disputes
var ErrCaseNotFound = errors.New("case not found")
ErrCaseNotFound - case not found err
var ErrCloseFailureCaseExpired = errors.New("unable to close expired case")
ErrCloseFailureCaseExpired - tried closing expired case err
var ErrCloseFailureNoOutpoints = errors.New("unable to close case with missing outpoints")
ErrCloseFailureNoOutpoints indicates when a dispute cannot be closed due to neither party including outpoints with their dispute
var ErrInvalidKey = errors.New("invalid key")
var ( // ErrInventoryNotFoundForSlug - inventory not found error ErrInventoryNotFoundForSlug = errors.New("could not find slug in inventory") )
var ErrNoListings = errors.New("no listings to set moderators on")
ErrNoListings - no listing error FIXME : This is not used anywhere
var ErrOpenFailureOrderExpired = errors.New("unable to open case because order is too old to dispute")
ErrOpenFailureOrderExpired - tried disputing expired order err
var ErrorProfileNotFound = errors.New("profile not found")
ErrorProfileNotFound - profile not found error
var (
// MaxTXIDSize - max length for order txnID
MaxTXIDSize = 512
)
var ModeratorPointerID multihash.Multihash
ModeratorPointerID moderator ipfs multihash
var Node *developertaskNode
Node - ob node
var OfflineMessageWaitGroup sync.WaitGroup
OfflineMessageWaitGroup - used for offline msgs
Functions ¶
func CheckAndSetUlimit ¶
func CheckAndSetUlimit() error
CheckAndSetUlimit raises the file descriptor limit
func FormatRFC3339PB ¶
func FormatRFC3339PB(ts google_protobuf.Timestamp) string
FormatRFC3339PB returns the given `google_protobuf.Timestamp` as a RFC3339 formatted string
func GetOrderQuantity ¶
GetOrderQuantity - return the specified item quantity
func GetSelectedSku ¶
GetSelectedSku - return the specified item SKU
func GetSignedListingFromPath ¶
func GetSignedListingFromPath(p string) (*pb.SignedListing, error)
func ParseContractForListing ¶
ParseContractForListing - return the listing identified by the hash from the contract
func SameSku ¶
func SameSku(selectedVariants []int, sku *pb.Listing_Item_Sku) bool
SameSku - check if the variants have the same SKU
func SignPayload ¶
SignPayload produces a signature for the given private key and payload and returns it and the public key or an error
func ValidateProfile ¶
ValidateProfile - validate fetched profile
func ValidateRating ¶
ValidateRating - validates rating for API GET and Post/Update
func VerifyPayload ¶
VerifyPayload proves the payload and signature are authentic for the provided public key and returns the peer ID for that pubkey with no error on success
Types ¶
type CodedError ¶
type CodedError struct { Reason string `json:"reason,omitempty"` Code string `json:"code,omitempty"` }
CodedError is an error that is machine readable
func (CodedError) Error ¶
func (err CodedError) Error() string
type ErrOutOfInventory ¶
type ErrOutOfInventory struct { CodedError RemainingInventory string `json:"remainingInventory"` }
ErrOutOfInventory is a codedError returned from vendor nodes when buyers try purchasing too many of an item
func NewErrOutOfInventory ¶
func NewErrOutOfInventory(inventoryRemaining *big.Int) ErrOutOfInventory
NewErrOutOfInventory - return out of inventory err with available inventory
func (ErrOutOfInventory) Error ¶
func (err ErrOutOfInventory) Error() string
type Inventory ¶
type Inventory map[string]*InventoryListing
Inventory is the complete inventory representation stored on IPFS It maps slug -> quantity information
type InventoryListing ¶
type InventoryListing struct { Inventory string `json:"inventory"` LastUpdated string `json:"lastUpdated"` }
InventoryListing is the listing representation stored on IPFS
type OrderRatings ¶
type OrderRatings struct { OrderID string `json:"orderId"` Ratings []RatingData `json:"ratings"` }
OrderRatings - record ratings for an order
type RatingData ¶
type RatingData struct { Slug string `json:"slug"` Overall int `json:"overall"` Quality int `json:"quality"` Description int `json:"description"` DeliverySpeed int `json:"deliverySpeed"` CustomerService int `json:"customerService"` Review string `json:"review"` Anonymous bool `json:"anonymous"` }
RatingData - record rating in detail
type SavedRating ¶
type SavedRating struct { Slug string `json:"slug"` Count int `json:"count"` Average float32 `json:"average"` Ratings []string `json:"ratings"` }
SavedRating - represent saved rating
type SpendRequest ¶
type SpendRequest struct { Amount string `json:"amount"` Currency *repo.CurrencyDefinition `json:"currency"` CurrencyCode string `json:"currencyCode"` Address string `json:"address"` FeeLevel string `json:"feeLevel"` Memo string `json:"memo"` OrderID string `json:"orderId"` RequireAssociatedOrder bool `json:"requireOrder"` SpendAll bool `json:"spendAll"` // contains filtered or unexported fields }
type SpendResponse ¶
type SpendResponse struct { Amount string `json:"amount"` ConfirmedBalance string `json:"confirmedBalance"` UnconfirmedBalance string `json:"unconfirmedBalance"` Currency *repo.CurrencyDefinition `json:"currency"` Memo string `json:"memo"` OrderID string `json:"orderId"` Timestamp time.Time `json:"timestamp"` Txid string `json:"txid"` PeerID string `json:"-"` ConsumedInput bool `json:"-"` }
Source Files ¶
- completion.go
- confirmation.go
- core.go
- disputes.go
- errors.go
- follow.go
- fulfillment.go
- images.go
- inbound_message_scanner.go
- inventory.go
- listings.go
- message_retriever.go
- moderation.go
- net.go
- order.go
- pointer_republisher.go
- posts.go
- profile.go
- ratings.go
- record_aging_notifier.go
- refunds.go
- signatures.go
- signed_listings.go
- spend.go
- ulimit_unix.go
- utils.go