repo

package
v0.14.2-rc1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Number of hours after purchase before a dispute may no longer be opened
	DisputeOptionTimeoutHours int = 45 * 24
	// Number of hours after dispute begins before it is resolved automatically
	DisputeTotalDurationHours int = 45 * 24

	NotifierTypeBuyerDisputeTimeout           NotificationType = "buyerDisputeTimeout"
	NotifierTypeBuyerDisputeExpiry            NotificationType = "buyerDisputeExpiry"
	NotifierTypeChatMessage                   NotificationType = "chatMessage"
	NotifierTypeChatRead                      NotificationType = "chatRead"
	NotifierTypeChatTyping                    NotificationType = "chatTyping"
	NotifierTypeCompletionNotification        NotificationType = "orderComplete"
	NotifierTypeDisputeAcceptedNotification   NotificationType = "disputeAccepted"
	NotifierTypeDisputeCloseNotification      NotificationType = "disputeClose"
	NotifierTypeDisputeOpenNotification       NotificationType = "disputeOpen"
	NotifierTypeDisputeUpdateNotification     NotificationType = "disputeUpdate"
	NotifierTypeFindModeratorResponse         NotificationType = "findModeratorResponse"
	NotifierTypeFollowNotification            NotificationType = "follow"
	NotifierTypeFulfillmentNotification       NotificationType = "fulfillment"
	NotifierTypeIncomingTransaction           NotificationType = "incomingTransaction"
	NotifierTypeModeratorAddNotification      NotificationType = "moderatorAdd"
	NotifierTypeModeratorDisputeExpiry        NotificationType = "moderatorDisputeExpiry"
	NotifierTypeModeratorRemoveNotification   NotificationType = "moderatorRemove"
	NotifierTypeOrderCancelNotification       NotificationType = "cancel"
	NotifierTypeOrderConfirmationNotification NotificationType = "orderConfirmation"
	NotifierTypeOrderDeclinedNotification     NotificationType = "orderDeclined"
	NotifierTypeOrderNewNotification          NotificationType = "order"
	NotifierTypePaymentNotification           NotificationType = "payment"
	NotifierTypePremarshalledNotifier         NotificationType = "premarshalledNotifier"
	NotifierTypeProcessingErrorNotification   NotificationType = "processingError"
	NotifierTypeRefundNotification            NotificationType = "refund"
	NotifierTypeStatusUpdateNotification      NotificationType = "statusUpdate"
	NotifierTypeTestNotification              NotificationType = "testNotification"
	NotifierTypeUnfollowNotification          NotificationType = "unfollow"
	NotifierTypeVendorDisputeTimeout          NotificationType = "vendorDisputeTimeout"
	NotifierTypeVendorFinalizedPayment        NotificationType = "vendorFinalizedPayment"
)
View Source
const (
	CurrencyCodeValidMinimumLength = 3
	CurrencyCodeValidMaximumLength = 4
)
View Source
const (
	Fiat   = "fiat"
	Crypto = "crypto"

	DefaultCryptoDivisibility = 8
	NilCurrencyCode           = CurrencyCode("")
	DefaultBlockTime          = 10 * time.Minute
)
View Source
const (
	// ListingVersion - current listing version
	ListingVersion = 5
	// TitleMaxCharacters - max size for title
	TitleMaxCharacters = 140
	// ShortDescriptionLength - min length for description
	ShortDescriptionLength = 160
	// DescriptionMaxCharacters - max length for description
	DescriptionMaxCharacters = 50000
	// MaxTags - max permitted tags
	MaxTags = 10
	// MaxCategories - max permitted categories
	MaxCategories = 10
	// MaxListItems - max items in a listing
	MaxListItems = 30
	// FilenameMaxCharacters - max filename size
	FilenameMaxCharacters = 255
	// CodeMaxCharacters - max chars for a code
	CodeMaxCharacters = 20
	// WordMaxCharacters - max chars for word
	WordMaxCharacters = 40
	// SentenceMaxCharacters - max chars for sentence
	SentenceMaxCharacters = 70
	// CouponTitleMaxCharacters - max length of a coupon title
	CouponTitleMaxCharacters = 70
	// PolicyMaxCharacters - max length for policy
	PolicyMaxCharacters = 10000
	// AboutMaxCharacters - max length for about
	AboutMaxCharacters = 10000
	// URLMaxCharacters - max length for URL
	URLMaxCharacters = 2000
	// MaxCountryCodes - max country codes
	MaxCountryCodes = 255
	// DefaultEscrowTimeout - escrow timeout in hours
	DefaultEscrowTimeout = 1080
	// SlugBuffer - buffer size for slug
	SlugBuffer = 5
	// PriceModifierMin - min price modifier
	PriceModifierMin = -99.99
	// PriceModifierMax = max price modifier
	PriceModifierMax = 1000.00
)
View Source
const JSONAPITimeFormat = `"2006-01-02T15:04:05.999999999Z07:00"` // time.RFC3339Nano
View Source
const RepoVersion = "34"

Variables

View Source
var (
	ErrCurrencyValueInsufficientPrecision         = errors.New("unable to accurately represent value as int64")
	ErrCurrencyValueNegativeRate                  = errors.New("conversion rate must be greater than zero")
	ErrCurrencyValueAmountInvalid                 = errors.New("invalid amount")
	ErrCurrencyValueDefinitionInvalid             = errors.New("invalid currency definition")
	ErrCurrencyValueInvalidCmpDifferentCurrencies = errors.New("unable to compare two different currencies")
)
View Source
var (
	ErrCurrencyCodeLengthInvalid       = errors.New("invalid length for currency code, must be three characters or four characters and begin with a 'T'")
	ErrCurrencyCodeTestSymbolInvalid   = errors.New("invalid test indicator for currency code, four characters must begin with a 'T'")
	ErrCurrencyDefinitionUndefined     = errors.New("unknown currency")
	ErrCurrencyTypeInvalid             = errors.New("currency type must be crypto or fiat")
	ErrCurrencyDivisibilityNonPositive = errors.New("currency divisibility most be greater than zero")
	ErrDictionaryIndexMismatchedCode   = errors.New("dictionary index mismatched with definition currency code")
	ErrDictionaryCurrencyCodeCollision = errors.New("currency code is used by more than one currency")

	NilCurrencyDefinition = CurrencyDefinition{Name: "", Code: NilCurrencyCode, Divisibility: 0, CurrencyType: "", BlockTime: 0 * time.Second}
)
View Source
var (
	ModeratorDisputeExpiry_firstInterval  = time.Duration(15*24) * time.Hour
	ModeratorDisputeExpiry_secondInterval = time.Duration(30*24) * time.Hour
	ModeratorDisputeExpiry_thirdInterval  = time.Duration(44*24) * time.Hour
	ModeratorDisputeExpiry_lastInterval   = time.Duration(45*24) * time.Hour
)
View Source
var (
	// ErrCryptocurrencySkuQuantityInvalid - invalid sku qty err
	ErrCryptocurrencySkuQuantityInvalid = errors.New("cryptocurrency listing quantity must be a non-negative integer")
	// ErrListingCryptoDivisibilityInvalid indicates the given divisibility doesn't match the default
	ErrListingCryptoDivisibilityInvalid = errors.New("invalid cryptocurrency divisibility")
	// ErrListingCryptoCurrencyCodeInvalid indicates the given code isn't valid or known
	ErrListingCryptoCurrencyCodeInvalid = errors.New("invalid cryptocurrency code")
	ErrShippingRegionMustBeSet          = errors.New("shipping region must be set")
	ErrShippingRegionUndefined          = errors.New("undefined shipping region")
	ErrShippingRegionMustNotBeContinent = errors.New("cannot specify continent as shipping region")
	// ErrListingDoesNotExist - non-existent listing err
	ErrListingDoesNotExist = errors.New("listing doesn't exist")
	// ErrListingAlreadyExists - duplicate listing err
	ErrListingAlreadyExists = errors.New("listing already exists")
)
View Source
var (
	ErrInvalidInlinePeerID = errors.New("inline hash does not match produced hash")
	ErrPeerInfoIsNil       = errors.New("peer info is nil")
)
View Source
var (
	// ErrModeratorInfoMissing indicates when the moderator information is
	// missing while also indicating they are a moderator
	ErrModeratorInfoMissing = errors.New("moderator is enabled but information is missing")
	// ErrMissingModeratorFee indicates the fee schedule is missing
	ErrMissingModeratorFee = errors.New("moderator info is missing fee schedule")
	// ErrUnknownModeratorFeeType indicates the feeType is unknown
	ErrUnknownModeratorFeeType = errors.New("moderator fee type is unknown")
	// ErrModeratorFeeHasNegativePercentage indicates when the percentage is non-positive but should be
	ErrModeratorFeeHasNegativePercentage = errors.New("percentage moderator fee should not be negative")
	// ErrFixedFeeHasNonZeroPercentage indicates when the percentage is not zero but should be
	ErrFixedFeeHasNonZeroPercentage = errors.New("fixed moderator fee should have a zero percentage amount")
	// ErrPercentageFeeHasFixedFee indicates that a fixed fee is included when there should not be
	ErrPercentageFeeHasFixedFee = fmt.Errorf("percentage moderator fee should not include a fixed fee or should use (%s) feeType", pb.Moderator_Fee_FIXED_PLUS_PERCENTAGE.String())
	// ErrModeratorFixedFeeIsMissing indicates when the fixed fee is missing
	ErrModeratorFixedFeeIsMissing = fmt.Errorf("fixed moderator fee is missing or should use (%s) feeType", pb.Moderator_Fee_PERCENTAGE.String())
	// ErrModeratorFixedFeeAmountIsEmpty indicates the fee is defined with an empty amount
	ErrModeratorFixedFeeAmountIsEmpty = errors.New("fixed moderator fee amount is missing or not a parseable number")
	// ErrModeratorFixedFeeIsNegative indicates that the fixed fee is non-positive
	ErrModeratorFixedFeeIsNegative = errors.New("fixed moderator fee is negative or not a parsable number")
)
View Source
var (
	BuyerDisputeTimeout_firstInterval  = time.Duration(15*24) * time.Hour
	BuyerDisputeTimeout_secondInterval = time.Duration(40*24) * time.Hour
	BuyerDisputeTimeout_thirdInterval  = time.Duration(44*24) * time.Hour
	BuyerDisputeTimeout_lastInterval   = time.Duration(45*24) * time.Hour
	BuyerDisputeTimeout_totalDuration  = time.Duration(DisputeOptionTimeoutHours) * time.Hour

	BuyerDisputeExpiry_firstInterval  = time.Duration(15*24) * time.Hour
	BuyerDisputeExpiry_secondInterval = time.Duration(40*24) * time.Hour
	BuyerDisputeExpiry_lastInterval   = time.Duration(44*24) * time.Hour
	BuyerDisputeExpiry_totalDuration  = time.Duration(DisputeTotalDurationHours) * time.Hour
)
View Source
var (
	// ErrPriceCalculationRequiresExchangeRates - exchange rates dependency err
	ErrPriceCalculationRequiresExchangeRates = errors.New("can't calculate price with exchange rates disabled")
)
View Source
var ErrRepoExists = errors.New("IPFS configuration file exists. Reinitializing would overwrite your keys. Use -f to force overwrite.")
View Source
var ErrUnknownAPITimeFormat = errors.New("unknown api time format")
View Source
var ErrUnknownMessage = errors.New("unknown or invalid message")

ErrUnknownMessage - notify an invalid message

View Source
var (
	VendorDisputeTimeout_lastInterval = time.Duration(45*24) * time.Hour
)

Functions

func CreateSlugFor added in v0.14.0

func CreateSlugFor(slugName string) string

CreateSlugFor Create a slug from a multi-lang string

func DoInit

func DoInit(repoRoot string, nBitsForKeypair int, testnet bool, password string, mnemonic string, creationDate time.Time, dbInit func(string, []byte, string, time.Time) error) error

func ExtractIDFromListing added in v0.14.0

func ExtractIDFromListing(data []byte) (*pb.ID, error)

ExtractIDFromListing returns pb.ID of the listing

func ExtractVersionFromSignedListing added in v0.14.0

func ExtractVersionFromSignedListing(data []byte) (uint, error)

ExtractVersion returns the version of the listing

func GenerateSlug added in v0.14.0

func GenerateSlug(title, repoPath string, isTestnet bool, dStore *Datastore) (string, error)

GenerateSlug - slugify the title of the listing

func GetListingFromSlug added in v0.14.0

func GetListingFromSlug(slug, repoPath string, isTestnet bool, dStore *Datastore) (*pb.SignedListing, error)

GetListingFromSlug - fetch listing for the specified slug

func GetObjectFromIPFS added in v0.12.0

func GetObjectFromIPFS(n *core.IpfsNode, p peer.ID, name string, maxCacheLen time.Duration) ([]byte, error)

GetObjectFromIPFS gets the requested name from ipfs or the local cache

func GetPathForListingSlug added in v0.14.0

func GetPathForListingSlug(slug, repoPath string, isTestnet bool) (string, error)

func GetRepoPath added in v0.9.4

func GetRepoPath(isTestnet bool, repoPath string) (string, error)

GetRepoPath returns the directory to store repo data in.

func MigrateUp added in v0.9.2

func MigrateUp(repoPath, dbPassword string, testnet bool) error

MigrateUp looks at the currently active migration version and will migrate all the way up (applying all up migrations).

func NewNotificationID added in v0.12.1

func NewNotificationID() string

func ToHtmlEntities added in v0.14.0

func ToHtmlEntities(str string) string

func ToV5Dispute added in v0.14.0

func ToV5Dispute(dispute *pb.Dispute) *pb.Dispute

ToV5Dispute scans through the dispute looking for any deprecated fields and turns them into their v5 counterpart.

func ToV5DisputeResolution added in v0.14.0

func ToV5DisputeResolution(disputeResolution *pb.DisputeResolution) *pb.DisputeResolution

ToV5DisputeResolution scans through the dispute resolution looking for any deprecated fields and turns them into their v5 counterpart.

func ToV5Order added in v0.14.0

func ToV5Order(order *pb.Order, lookupFunc func(currencyCode string) (CurrencyDefinition, error)) (*pb.Order, error)

ToV5Order scans through the order looking for any deprecated fields and turns them into their v5 counterpart.

func ToV5OrderConfirmation added in v0.14.0

func ToV5OrderConfirmation(orderConfirmation *pb.OrderConfirmation) *pb.OrderConfirmation

ToV5OrderConfirmation scans through the order confirmation looking for any deprecated fields and turns them into their v5 counterpart.

func ToV5OrderFulfillment added in v0.14.0

func ToV5OrderFulfillment(orderFulfillment *pb.OrderFulfillment) *pb.OrderFulfillment

ToV5OrderFulfillment scans through the order fulfillment looking for any deprecated fields and turns them into their v5 counterpart.

func ToV5Refund added in v0.14.0

func ToV5Refund(refund *pb.Refund) *pb.Refund

ToV5Refund scans through the refund looking for any deprecated fields and turns them into their v5 counterpart.

func ValidateListingOptions added in v0.14.0

func ValidateListingOptions(listingItemOptions []*pb.Listing_Item_Option, itemOptions []option) ([]*pb.Order_Item_Option, error)

ValidateListingOptions is a helper to ensure item options are valid

func ValidateShippingRegion added in v0.14.0

func ValidateShippingRegion(shippingOption *pb.Listing_ShippingOption) error

ValidateShippingRegion ensures shipping options are valid

Types

type APITime added in v0.13.5

type APITime struct {
	time.Time
}

func NewAPITime added in v0.13.5

func NewAPITime(t time.Time) *APITime

NewAPITime returns a pointer to a new APITime instance

func (APITime) MarshalJSON added in v0.13.5

func (t APITime) MarshalJSON() ([]byte, error)

func (APITime) String added in v0.13.5

func (t APITime) String() string

func (*APITime) UnmarshalJSON added in v0.13.5

func (t *APITime) UnmarshalJSON(b []byte) error

type BuyerDisputeExpiry added in v0.12.1

type BuyerDisputeExpiry struct {
	ID        string           `json:"notificationId"`
	Type      NotificationType `json:"type"`
	OrderID   string           `json:"orderId"`
	ExpiresIn uint             `json:"expiresIn"`
	Thumbnail Thumbnail        `json:"thumbnail"`
}

BuyerDisputeExpiry represents a notification about a purchase which has an open dispute that is expiring

func (BuyerDisputeExpiry) Data added in v0.12.1

func (n BuyerDisputeExpiry) Data() ([]byte, error)

func (BuyerDisputeExpiry) GetID added in v0.12.1

func (n BuyerDisputeExpiry) GetID() string

func (BuyerDisputeExpiry) GetSMTPTitleAndBody added in v0.12.1

func (n BuyerDisputeExpiry) GetSMTPTitleAndBody() (string, string, bool)

func (BuyerDisputeExpiry) GetType added in v0.12.1

func (BuyerDisputeExpiry) WebsocketData added in v0.12.1

func (n BuyerDisputeExpiry) WebsocketData() ([]byte, error)

type BuyerDisputeTimeout added in v0.12.1

type BuyerDisputeTimeout struct {
	ID        string           `json:"notificationId"`
	Type      NotificationType `json:"type"`
	OrderID   string           `json:"orderId"`
	ExpiresIn uint             `json:"expiresIn"`
	Thumbnail Thumbnail        `json:"thumbnail"`
}

BuyerDisputeTimeout represents a notification about a purchase which will soon be unable to dispute.

func (BuyerDisputeTimeout) Data added in v0.12.1

func (n BuyerDisputeTimeout) Data() ([]byte, error)

func (BuyerDisputeTimeout) GetID added in v0.12.1

func (n BuyerDisputeTimeout) GetID() string

func (BuyerDisputeTimeout) GetSMTPTitleAndBody added in v0.12.1

func (n BuyerDisputeTimeout) GetSMTPTitleAndBody() (string, string, bool)

func (BuyerDisputeTimeout) GetType added in v0.12.1

func (BuyerDisputeTimeout) WebsocketData added in v0.12.1

func (n BuyerDisputeTimeout) WebsocketData() ([]byte, error)

type Case added in v0.5.1

type Case struct {
	CaseId             string        `json:"caseId"`
	Slug               string        `json:"slug"`
	Timestamp          time.Time     `json:"timestamp"`
	Title              string        `json:"title"`
	Thumbnail          string        `json:"thumbnail"`
	Total              CurrencyValue `json:"total"`
	BuyerId            string        `json:"buyerId"`
	BuyerHandle        string        `json:"buyerHandle"`
	VendorId           string        `json:"vendorId"`
	VendorHandle       string        `json:"vendorHandle"`
	CoinType           string        `json:"coinType"`
	PaymentCoin        string        `json:"paymentCoin"`
	BuyerOpened        bool          `json:"buyerOpened"`
	State              string        `json:"state"`
	Read               bool          `json:"read"`
	UnreadChatMessages int           `json:"unreadChatMessages"`
}

type CaseStore added in v0.11.1

type CaseStore interface {
	Queryable

	// Save a new case
	Put(caseID string, state pb.OrderState, buyerOpened bool, claim string, paymentCoin string, coinType string) error

	// Save a new case
	PutRecord(*DisputeCaseRecord) error

	// Update a case with the buyer info
	UpdateBuyerInfo(caseID string, buyerContract *pb.RicardianContract, buyerValidationErrors []string, buyerPayoutAddress string, buyerOutpoints []*pb.Outpoint) error

	// Update a case with the vendor info
	UpdateVendorInfo(caseID string, vendorContract *pb.RicardianContract, vendorValidationErrors []string, vendorPayoutAddress string, vendorOutpoints []*pb.Outpoint) error

	// Mark a case as read in the database
	MarkAsRead(caseID string) error

	// Mark a case as unread in the database
	MarkAsUnread(caseID string) error

	// Mark a case as closed in the database
	MarkAsClosed(caseID string, resolution *pb.DisputeResolution) error

	// Delete a case
	Delete(caseID string) error

	// Return the case metadata given a case ID
	GetCaseMetadata(caseID string) (buyerContract, vendorContract *pb.RicardianContract, buyerValidationErrors, vendorValidationErrors []string, state pb.OrderState, read bool, timestamp time.Time, buyerOpened bool, claim string, resolution *pb.DisputeResolution, err error)

	// GetByCaseID returns the dispute payout data for a case
	GetByCaseID(caseID string) (*DisputeCaseRecord, error)

	// Return the metadata for all cases given the search terms. Also returns the original size of the query.
	GetAll(stateFilter []pb.OrderState, searchTerm string, sortByAscending bool, sortByRead bool, limit int, exclude []string) ([]Case, int, error)

	// Return the number of cases in the database
	Count() int

	// GetDisputesForDisputeExpiryNotification returns []*DisputeCaseRecord including
	// each record which needs Notifications to be generated.
	GetDisputesForDisputeExpiryNotification() ([]*DisputeCaseRecord, error)

	// UpdateDisputesLastDisputeExpiryNotifiedAt accepts []*DisputeCaseRecord and updates each records lastDisputeExpiryNotifiedAt by its CaseID
	UpdateDisputesLastDisputeExpiryNotifiedAt([]*DisputeCaseRecord) error
}

type ChatConversation added in v0.3.1

type ChatConversation struct {
	PeerId    string   `json:"peerId"`
	Unread    int      `json:"unread"`
	Last      string   `json:"lastMessage"`
	Timestamp *APITime `json:"timestamp"`
	Outgoing  bool     `json:"outgoing"`
}

type ChatMessage added in v0.3.1

type ChatMessage struct {
	MessageId string   `json:"messageId"`
	PeerId    string   `json:"peerId"`
	Subject   string   `json:"subject"`
	Message   string   `json:"message"`
	Read      bool     `json:"read"`
	Outgoing  bool     `json:"outgoing"`
	Timestamp *APITime `json:"timestamp"`
}

type ChatMessageNotification added in v0.13.5

type ChatMessageNotification ChatMessage

ChatMessageNotification handles serialization of ChatMessages for notifications

func (ChatMessageNotification) Data added in v0.13.5

func (n ChatMessageNotification) Data() ([]byte, error)

func (ChatMessageNotification) GetID added in v0.13.5

func (n ChatMessageNotification) GetID() string

func (ChatMessageNotification) GetSMTPTitleAndBody added in v0.13.5

func (n ChatMessageNotification) GetSMTPTitleAndBody() (string, string, bool)

func (ChatMessageNotification) GetType added in v0.13.5

func (ChatMessageNotification) WebsocketData added in v0.13.5

func (n ChatMessageNotification) WebsocketData() ([]byte, error)

type ChatRead added in v0.12.1

type ChatRead struct {
	MessageId string `json:"messageId"`
	PeerId    string `json:"peerId"`
	Subject   string `json:"subject"`
}

func (ChatRead) Data added in v0.12.1

func (n ChatRead) Data() ([]byte, error)

func (ChatRead) GetID added in v0.12.1

func (n ChatRead) GetID() string

func (ChatRead) GetSMTPTitleAndBody added in v0.12.1

func (n ChatRead) GetSMTPTitleAndBody() (string, string, bool)

func (ChatRead) GetType added in v0.12.1

func (n ChatRead) GetType() NotificationType

func (ChatRead) WebsocketData added in v0.12.1

func (n ChatRead) WebsocketData() ([]byte, error)

type ChatStore added in v0.11.1

type ChatStore interface {
	Queryable

	// Put a new chat message to the database
	Put(messageId string, peerId string, subject string, message string, timestamp time.Time, read bool, outgoing bool) error

	// Returns a list of open conversations
	GetConversations() []ChatConversation

	// A list of messages given a peer ID and a subject
	GetMessages(peerID string, subject string, offsetID string, limit int) []ChatMessage

	// Mark all chat messages for a peer as read. Returns the Id of the last seen message and
	// whether any messages were updated.
	// If message Id is specified it will only mark that message and earlier as read.
	MarkAsRead(peerID string, subject string, outgoing bool, messageId string) (string, bool, error)

	// Returns the incoming unread count for all messages of a given subject
	GetUnreadCount(subject string) (int, error)

	// Delete a message
	DeleteMessage(msgID string) error

	// Delete all messages from from a peer
	DeleteConversation(peerID string) error
}

type ChatTyping added in v0.12.1

type ChatTyping struct {
	MessageId string `json:"messageId"`
	PeerId    string `json:"peerId"`
	Subject   string `json:"subject"`
}

func (ChatTyping) Data added in v0.12.1

func (n ChatTyping) Data() ([]byte, error)

func (ChatTyping) GetID added in v0.12.1

func (n ChatTyping) GetID() string

func (ChatTyping) GetSMTPTitleAndBody added in v0.12.1

func (n ChatTyping) GetSMTPTitleAndBody() (string, string, bool)

func (ChatTyping) GetType added in v0.12.1

func (n ChatTyping) GetType() NotificationType

func (ChatTyping) WebsocketData added in v0.12.1

func (n ChatTyping) WebsocketData() ([]byte, error)

type CompletionNotification added in v0.12.1

type CompletionNotification struct {
	ID          string           `json:"notificationId"`
	Type        NotificationType `json:"type"`
	OrderId     string           `json:"orderId"`
	Thumbnail   Thumbnail        `json:"thumbnail"`
	BuyerHandle string           `json:"buyerHandle"`
	BuyerID     string           `json:"buyerId"`
}

func (CompletionNotification) Data added in v0.12.1

func (n CompletionNotification) Data() ([]byte, error)

func (CompletionNotification) GetID added in v0.12.1

func (n CompletionNotification) GetID() string

func (CompletionNotification) GetSMTPTitleAndBody added in v0.12.1

func (n CompletionNotification) GetSMTPTitleAndBody() (string, string, bool)

func (CompletionNotification) GetType added in v0.12.1

func (CompletionNotification) WebsocketData added in v0.12.1

func (n CompletionNotification) WebsocketData() ([]byte, error)

type Config

type Config interface {
	/* Initialize the database with the node's mnemonic seed and
	   identity key. This will be called during repo init. */
	Init(mnemonic string, identityKey []byte, password string, creationDate time.Time) error

	// Return the mnemonic string
	GetMnemonic() (string, error)

	// Return the identity key
	GetIdentityKey() ([]byte, error)

	// Returns the date the seed was created
	GetCreationDate() (time.Time, error)

	// Returns true if the database has failed to decrypt properly ex) wrong pw
	IsEncrypted() bool
}

type ConfigurationStore added in v0.11.1

type ConfigurationStore interface {
	Queryable

	// Put settings to the database, overriding all fields
	Put(settings SettingsData) error

	// Update all non-nil fields
	Update(settings SettingsData) error

	// Return the settings object
	Get() (SettingsData, error)

	// Delete all settings data
	Delete() error
}

type Coupon added in v0.5.0

type Coupon struct {
	Slug string
	Code string
	Hash string
}

type CouponStore added in v0.11.1

type CouponStore interface {
	Queryable

	// Put a list of coupons to the db
	Put(coupons []Coupon) error

	// Get a list of coupons given a slug
	Get(slug string) ([]Coupon, error)

	// Delete all coupons for a given slug
	Delete(slug string) error
}

type CurrencyCode added in v0.13.0

type CurrencyCode string

CurrencyCode is a string-based currency symbol

func (CurrencyCode) String added in v0.13.0

func (c CurrencyCode) String() string

String returns a readable representation of CurrencyCode

type CurrencyConverter added in v0.14.0

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

CurrencyConverter is suitable for converting a currency from one CurrencyDefinition to another, accounting for their differing divisibility as well as their differing exchange rate as provided by the rater. The rater can represent all rates for the reserve currency code provided.

func NewCurrencyConverter added in v0.14.0

func NewCurrencyConverter(reserveCode string, rater rater) (*CurrencyConverter, error)

NewCurrencyConverter returns a valid CurrencyConverter. The rater is verified by ensuring the rate of its reserveCode is 1.0 (ensuring it is equivalent to itself).

func NewEquivalentConverter added in v0.14.0

func NewEquivalentConverter() *CurrencyConverter

NewEquivalentConverter returns a currency converter where all rates are always returns as 1.0 making all currencies equivalent to one another

func (CurrencyConverter) GetFinalPrice added in v0.14.0

func (c CurrencyConverter) GetFinalPrice(originAmount *CurrencyValue, resultCurrency CurrencyDefinition) (*CurrencyValue, big.Accuracy, error)

GetFinalPrice returns the resulting CurrencyValue after converting the amount and divisibility of the originAmount to the target currency

type CurrencyDefinition added in v0.13.1

type CurrencyDefinition struct {
	// Name describes the colloquial term for the currency
	Name string `json:"name,omitempty"`
	// Code describes the currency as an uppercase string similar to ISO 4217
	Code CurrencyCode `json:"code"`
	// Divisibility indicates the number of decimal places the currency can be divided in
	// base10. Ex: 8 suggests a maximum divisibility of 0.00000001
	Divisibility uint `json:"divisibility"`
	// CurrencyType indicates whether the currency is "fiat" or "crypto" currency
	CurrencyType string `json:"currencyType,omitempty"`
	// BlockTime is the general/approximate duration for a block to be mined
	BlockTime time.Duration `json:"-"`
}

CurrencyDefinition defines the characteristics of a currency

func NewUnknownCryptoDefinition added in v0.14.0

func NewUnknownCryptoDefinition(code string, div uint) CurrencyDefinition

NewUnknownCryptoDefinition returns a suitable crypto definition when one does not already exist in local dictionaries

func (CurrencyDefinition) ConfirmationsPerHour added in v0.14.0

func (c CurrencyDefinition) ConfirmationsPerHour() uint32

ConfirmationsPerHour will calculate the no of confirmations in 1 hr this is valid only for a crypto

func (CurrencyDefinition) CurrencyCode added in v0.13.1

func (c CurrencyDefinition) CurrencyCode() CurrencyCode

CurrencyCode returns the CurrencyCode of the definition

func (CurrencyDefinition) Equal added in v0.13.1

Equal indicates if the receiver and other have the same code and divisibility

func (CurrencyDefinition) String added in v0.13.1

func (c CurrencyDefinition) String() string

String returns a readable representation of CurrencyDefinition

func (CurrencyDefinition) Valid added in v0.13.1

func (c CurrencyDefinition) Valid() error

Valid asserts that the CurrencyDefinition is either valid or has at least one error

type CurrencyDictionary added in v0.13.1

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

CurrencyDictionary represents a collection of CurrencyDefinitions keyed by their CurrencyCode in string form

func AllCurrencies added in v0.14.0

func AllCurrencies() *CurrencyDictionary

AllCurrencies returns the singleton representing all known currency definitions

func FiatCurrencies added in v0.14.0

func FiatCurrencies() *CurrencyDictionary

FiatCurrencies returns the mainnet crypto currency definition singleton

func MainnetCurrencies added in v0.14.0

func MainnetCurrencies() *CurrencyDictionary

MainnetCurrencies returns the mainnet crypto currency definition singleton

func NewCurrencyDictionary added in v0.13.1

func NewCurrencyDictionary(defs map[string]CurrencyDefinition) (*CurrencyDictionary, error)

NewCurrencyDictionary returns a CurrencyDictionary for managing CurrencyDefinitions

func TestnetCurrencies added in v0.14.0

func TestnetCurrencies() *CurrencyDictionary

TestnetCurrencies returns the mainnet crypto currency definition singleton

func (CurrencyDictionary) AsMap added in v0.14.0

AsMap returns a cloned map of all known the definitions

func (CurrencyDictionary) Lookup added in v0.13.1

Lookup returns the CurrencyDefinition out of the loaded dictionary. Lookup normalizes the code before lookup and recommends using CurrencyDefinition.CurrencyCode().String() from the response as a normalized code.

type CurrencyDictionaryProcessingError added in v0.13.1

type CurrencyDictionaryProcessingError map[string]error

CurrencyDictionaryProcessingError represents a list of errors after processing a CurrencyDictionary

func (CurrencyDictionaryProcessingError) All added in v0.14.0

func (CurrencyDictionaryProcessingError) Error added in v0.13.1

Error satisfies the Error interface without needing the process the set of errors

type CurrencyValue added in v0.13.1

type CurrencyValue struct {
	Amount   *big.Int
	Currency CurrencyDefinition
}

CurrencyValue represents the amount and variety of currency

func NewCurrencyValue added in v0.13.1

func NewCurrencyValue(amount string, currency CurrencyDefinition) (*CurrencyValue, error)

NewCurrencyValue accepts string amounts and currency codes, and creates a valid CurrencyValue

func NewCurrencyValueFromBigInt added in v0.14.0

func NewCurrencyValueFromBigInt(amt *big.Int, def CurrencyDefinition) *CurrencyValue

NewCurrencyValueFromBigInt is a convenience function which converts a big.Int and CurrencyDefinition into a new CurrencyValue

func NewCurrencyValueFromInt added in v0.13.1

func NewCurrencyValueFromInt(amount int64, currency CurrencyDefinition) (*CurrencyValue, error)

NewCurrencyValueFromInt is a convenience function which converts an int64 into a string and passes the arguments to NewCurrencyValue

func NewCurrencyValueFromProtobuf added in v0.14.0

func NewCurrencyValueFromProtobuf(amount string, currency *pb.CurrencyDefinition) (*CurrencyValue, error)

NewCurrencyValueFromProtobuf consumes the string and pb.CurrencyDefinition objects from parsed Listings and converts them into CurrencyValue objects

func NewCurrencyValueFromUint added in v0.13.1

func NewCurrencyValueFromUint(amount uint64, currency CurrencyDefinition) (*CurrencyValue, error)

NewCurrencyValueFromUint is a convenience function which converts an int64 into a string and passes the arguments to NewCurrencyValue

func NewCurrencyValueWithLookup added in v0.14.0

func NewCurrencyValueWithLookup(amount, currencyCode string) (*CurrencyValue, error)

NewCurrencyValueWithLookup accepts a string value as a base10 integer and uses the currency code to lookup the CurrencyDefinition

func (*CurrencyValue) AddBigFloatProduct added in v0.14.0

func (c *CurrencyValue) AddBigFloatProduct(factor *big.Float) *CurrencyValue

AddBigFloatProduct will add to itself the product of itself and the float argument and return the result

func (*CurrencyValue) AddBigInt added in v0.14.0

func (c *CurrencyValue) AddBigInt(addend *big.Int) *CurrencyValue

AddBigInt will add the addend to the amount and return the value sum

func (*CurrencyValue) AdjustDivisibility added in v0.14.0

func (c *CurrencyValue) AdjustDivisibility(div uint) (*CurrencyValue, big.Accuracy, error)

AdjustDivisibility updates the Currency.Divisibility and adjusts the Amount to match the new value. An error will be returned if the new divisibility is invalid or produces an unreliable result. This is a helper function which is equivalent to ConvertTo using a copy of the CurrencyDefinition using the updated divisibility and an exchangeRatio of 1.0

func (*CurrencyValue) AmountBigInt added in v0.14.0

func (c *CurrencyValue) AmountBigInt() *big.Int

AmountBigInt returns the big.Int representation of the amount

func (*CurrencyValue) AmountInt64 added in v0.13.1

func (c *CurrencyValue) AmountInt64() (int64, error)

AmountInt64 returns a valid int64 or an error

func (*CurrencyValue) AmountString added in v0.14.0

func (c *CurrencyValue) AmountString() string

AmountString returns the string representation of the amount

func (*CurrencyValue) AmountUint64 added in v0.13.1

func (c *CurrencyValue) AmountUint64() (uint64, error)

AmountUint64 returns a valid int64 or an error

func (*CurrencyValue) Cmp added in v0.14.0

func (c *CurrencyValue) Cmp(other *CurrencyValue) (int, error)

Cmp exposes the (*big.Int).Cmp behavior after verifying currency and adjusting for different currency divisibilities.

func (*CurrencyValue) ConvertTo added in v0.13.1

func (c *CurrencyValue) ConvertTo(final CurrencyDefinition, reserveConverter *CurrencyConverter) (*CurrencyValue, big.Accuracy, error)

ConvertTo will convert c.Amount into the final CurrencyDefinition through the reserve CurrencyConverter. As long as the provided reserveConverter has rates between the reserve currency and the current and final CurrencyDefintions, it will provide the result. Errors are raised if any rate is unavailable. The accuracy indicates if decimal values were trimmed when converting the value back to integer.

func (*CurrencyValue) ConvertUsingProtobufDef added in v0.14.0

func (c *CurrencyValue) ConvertUsingProtobufDef(convertTo *pb.CurrencyDefinition, reserve *CurrencyConverter) (*CurrencyValue, big.Accuracy, error)

ConvertUsingProtobufDef will use the currency code provided in pb.CurrencyDefinition to find the locally defined currency and exchange rate and will convert the amount into target currency. If the divisibility provided by the pb.CurrencyDefinition is different than the one provided for the exchange rate, the converted amount will be adjusted to match the provided divisibility.

func (*CurrencyValue) Equal added in v0.13.1

func (c *CurrencyValue) Equal(other *CurrencyValue) bool

Equal indicates if the amount and variety of currency is equivalent

func (*CurrencyValue) IsNegative added in v0.14.0

func (c *CurrencyValue) IsNegative() bool

IsNegative returns true if Amount is valid and less-than zero

func (*CurrencyValue) IsPositive added in v0.14.0

func (c *CurrencyValue) IsPositive() bool

IsPositive returns true if Amount is valid and greater-than zero

func (*CurrencyValue) IsZero added in v0.14.0

func (c *CurrencyValue) IsZero() bool

IsZero returns true if Amount is valid and equal to zero

func (*CurrencyValue) MarshalJSON added in v0.14.0

func (c *CurrencyValue) MarshalJSON() ([]byte, error)

func (*CurrencyValue) MulBigFloat added in v0.14.0

func (c *CurrencyValue) MulBigFloat(factor *big.Float) (*CurrencyValue, big.Accuracy)

MulBigFloat will multiple the amount and the factor and return the product result cast to a big.Int along with the big.Accuracy of the cast

func (*CurrencyValue) MulBigInt added in v0.14.0

func (c *CurrencyValue) MulBigInt(factor *big.Int) *CurrencyValue

MulBigInt will multiply the amount and the factor and return the product result

func (*CurrencyValue) Normalize added in v0.14.0

func (c *CurrencyValue) Normalize() (*CurrencyValue, error)

Normalize updates the CurrencyValue to match the divisibility of the locally defined CurrencyDefinition

func (*CurrencyValue) String added in v0.13.1

func (c *CurrencyValue) String() string

String returns a string representation of a CurrencyValue

func (*CurrencyValue) SubBigInt added in v0.14.0

func (c *CurrencyValue) SubBigInt(subtrahend *big.Int) *CurrencyValue

SubBigInt will subtract the subtrahend from the amount and return the value difference

func (*CurrencyValue) UnmarshalJSON added in v0.14.0

func (c *CurrencyValue) UnmarshalJSON(b []byte) error

func (*CurrencyValue) Valid added in v0.13.1

func (c *CurrencyValue) Valid() error

Valid returns an error if the CurrencyValue is invalid

type Datastore

type Datastore interface {
	Config() Config
	Followers() FollowerStore
	Following() FollowingStore
	OfflineMessages() OfflineMessageStore
	Pointers() PointerStore
	Settings() ConfigurationStore
	Inventory() InventoryStore
	Purchases() PurchaseStore
	Sales() SaleStore
	Cases() CaseStore
	Chat() ChatStore
	Notifications() NotificationStore
	Coupons() CouponStore
	TxMetadata() TransactionMetadataStore
	ModeratedStores() ModeratedStore
	Messages() MessageStore
	Ping() error
	Close()
}

type DisputeAcceptedNotification added in v0.12.1

type DisputeAcceptedNotification struct {
	ID               string           `json:"notificationId"`
	Type             NotificationType `json:"type"`
	OrderId          string           `json:"orderId"`
	Thumbnail        Thumbnail        `json:"thumbnail"`
	OherPartyID      string           `json:"otherPartyId"`
	OtherPartyHandle string           `json:"otherPartyHandle"`
	Buyer            string           `json:"buyer"`
}

func (DisputeAcceptedNotification) Data added in v0.12.1

func (n DisputeAcceptedNotification) Data() ([]byte, error)

func (DisputeAcceptedNotification) GetID added in v0.12.1

func (DisputeAcceptedNotification) GetSMTPTitleAndBody added in v0.12.1

func (n DisputeAcceptedNotification) GetSMTPTitleAndBody() (string, string, bool)

func (DisputeAcceptedNotification) GetType added in v0.12.1

func (DisputeAcceptedNotification) WebsocketData added in v0.12.1

func (n DisputeAcceptedNotification) WebsocketData() ([]byte, error)

type DisputeCaseRecord added in v0.12.1

type DisputeCaseRecord struct {
	CaseID                      string
	Claim                       string
	OrderState                  pb.OrderState
	Timestamp                   time.Time
	LastDisputeExpiryNotifiedAt time.Time
	BuyerContract               *pb.RicardianContract
	BuyerOutpoints              []*pb.Outpoint
	BuyerPayoutAddress          string
	VendorContract              *pb.RicardianContract
	VendorOutpoints             []*pb.Outpoint
	VendorPayoutAddress         string
	IsBuyerInitiated            bool
	CoinType                    string
	PaymentCoin                 *CurrencyCode
}

DisputeCaseRecord is a one-to-one relationship with records in the SQL datastore

func (*DisputeCaseRecord) BuildModeratorDisputeExpiryFirstNotification added in v0.12.1

func (r *DisputeCaseRecord) BuildModeratorDisputeExpiryFirstNotification(createdAt time.Time) *Notification

BuildModeratorDisputeExpiryFirstNotification returns a Notification with ExpiresIn set for the First Interval

func (*DisputeCaseRecord) BuildModeratorDisputeExpiryLastNotification added in v0.12.1

func (r *DisputeCaseRecord) BuildModeratorDisputeExpiryLastNotification(createdAt time.Time) *Notification

BuildModeratorDisputeExpiryLastNotification returns a Notification with ExpiresIn set for the Last Interval

func (*DisputeCaseRecord) BuildModeratorDisputeExpirySecondNotification added in v0.12.1

func (r *DisputeCaseRecord) BuildModeratorDisputeExpirySecondNotification(createdAt time.Time) *Notification

BuildModeratorDisputeExpirySecondNotification returns a Notification with ExpiresIn set for the Second Interval

func (*DisputeCaseRecord) BuildModeratorDisputeExpiryThirdNotification added in v0.12.1

func (r *DisputeCaseRecord) BuildModeratorDisputeExpiryThirdNotification(createdAt time.Time) *Notification

BuildModeratorDisputeExpiryThirdNotification returns a Notification with ExpiresIn set for the Third Interval

func (*DisputeCaseRecord) Contract added in v0.12.1

func (r *DisputeCaseRecord) Contract() *pb.RicardianContract

Contract returns the contract from the dispute if one has been supplied by either the buyer or vendor

func (*DisputeCaseRecord) IsExpired added in v0.12.1

func (r *DisputeCaseRecord) IsExpired(when time.Time) bool

IsExpired returns a bool indicating whether the case is still open

func (*DisputeCaseRecord) IsExpiredNow added in v0.12.1

func (r *DisputeCaseRecord) IsExpiredNow() bool

IsExpired returns a bool indicating whether the case is still open right now

func (*DisputeCaseRecord) ResolutionPaymentContract added in v0.12.4

func (r *DisputeCaseRecord) ResolutionPaymentContract(ratio PayoutRatio) (contract *pb.RicardianContract)

ResolutionPaymentContract returns the preferred contract to be used when resolving a pending DisputeCaseRecord based on the provided PayoutRatio

func (*DisputeCaseRecord) ResolutionPaymentFeePerByte added in v0.12.4

func (r *DisputeCaseRecord) ResolutionPaymentFeePerByte(ratio PayoutRatio, defaultFee big.Int) *big.Int

ResolutionPaymentFeePerByte returns the preferred outpoints to be used when resolving a pending DisputeCaseResolution based on the provided PayoutRatio

func (*DisputeCaseRecord) ResolutionPaymentOutpoints added in v0.12.4

func (r *DisputeCaseRecord) ResolutionPaymentOutpoints(ratio PayoutRatio) (outpoints []*pb.Outpoint)

ResolutionPaymentOutpoints returns the preferred outpoints to be used when resolving a pending DisputeCaseResolution based on the provided PayoutRatio

type DisputeCloseNotification added in v0.12.1

type DisputeCloseNotification struct {
	ID               string           `json:"notificationId"`
	Type             NotificationType `json:"type"`
	OrderId          string           `json:"orderId"`
	Thumbnail        Thumbnail        `json:"thumbnail"`
	OtherPartyID     string           `json:"otherPartyId"`
	OtherPartyHandle string           `json:"otherPartyHandle"`
	Buyer            string           `json:"buyer"`
}

func (DisputeCloseNotification) Data added in v0.12.1

func (n DisputeCloseNotification) Data() ([]byte, error)

func (DisputeCloseNotification) GetID added in v0.12.1

func (n DisputeCloseNotification) GetID() string

func (DisputeCloseNotification) GetSMTPTitleAndBody added in v0.12.1

func (n DisputeCloseNotification) GetSMTPTitleAndBody() (string, string, bool)

func (DisputeCloseNotification) GetType added in v0.12.1

func (DisputeCloseNotification) WebsocketData added in v0.12.1

func (n DisputeCloseNotification) WebsocketData() ([]byte, error)

type DisputeOpenNotification added in v0.12.1

type DisputeOpenNotification struct {
	ID             string           `json:"notificationId"`
	Type           NotificationType `json:"type"`
	OrderId        string           `json:"orderId"`
	Thumbnail      Thumbnail        `json:"thumbnail"`
	DisputerID     string           `json:"disputerId"`
	DisputerHandle string           `json:"disputerHandle"`
	DisputeeID     string           `json:"disputeeId"`
	DisputeeHandle string           `json:"disputeeHandle"`
	Buyer          string           `json:"buyer"`
}

func (DisputeOpenNotification) Data added in v0.12.1

func (n DisputeOpenNotification) Data() ([]byte, error)

func (DisputeOpenNotification) GetID added in v0.12.1

func (n DisputeOpenNotification) GetID() string

func (DisputeOpenNotification) GetSMTPTitleAndBody added in v0.12.1

func (n DisputeOpenNotification) GetSMTPTitleAndBody() (string, string, bool)

func (DisputeOpenNotification) GetType added in v0.12.1

func (DisputeOpenNotification) WebsocketData added in v0.12.1

func (n DisputeOpenNotification) WebsocketData() ([]byte, error)

type DisputeUpdateNotification added in v0.12.1

type DisputeUpdateNotification struct {
	ID             string           `json:"notificationId"`
	Type           NotificationType `json:"type"`
	OrderId        string           `json:"orderId"`
	Thumbnail      Thumbnail        `json:"thumbnail"`
	DisputerID     string           `json:"disputerId"`
	DisputerHandle string           `json:"disputerHandle"`
	DisputeeID     string           `json:"disputeeId"`
	DisputeeHandle string           `json:"disputeeHandle"`
	Buyer          string           `json:"buyer"`
}

func (DisputeUpdateNotification) Data added in v0.12.1

func (n DisputeUpdateNotification) Data() ([]byte, error)

func (DisputeUpdateNotification) GetID added in v0.12.1

func (DisputeUpdateNotification) GetSMTPTitleAndBody added in v0.12.1

func (n DisputeUpdateNotification) GetSMTPTitleAndBody() (string, string, bool)

func (DisputeUpdateNotification) GetType added in v0.12.1

func (DisputeUpdateNotification) WebsocketData added in v0.12.1

func (n DisputeUpdateNotification) WebsocketData() ([]byte, error)

type ErrCryptocurrencyListingIllegalField added in v0.14.0

type ErrCryptocurrencyListingIllegalField string

ErrCryptocurrencyListingIllegalField - invalid field err

func (ErrCryptocurrencyListingIllegalField) Error added in v0.14.0

type ErrCryptocurrencyPurchaseIllegalField added in v0.14.0

type ErrCryptocurrencyPurchaseIllegalField string

ErrCryptocurrencyPurchaseIllegalField - invalid purchase field err

func (ErrCryptocurrencyPurchaseIllegalField) Error added in v0.14.0

type ErrMarketPriceListingIllegalField added in v0.14.0

type ErrMarketPriceListingIllegalField string

ErrMarketPriceListingIllegalField - invalid listing field err

func (ErrMarketPriceListingIllegalField) Error added in v0.14.0

type ErrPriceModifierOutOfRange added in v0.14.0

type ErrPriceModifierOutOfRange struct {
	Min float64
	Max float64
}

ErrPriceModifierOutOfRange - customize limits for price modifier

func (ErrPriceModifierOutOfRange) Error added in v0.14.0

type FollowNotification added in v0.12.1

type FollowNotification struct {
	ID     string           `json:"notificationId"`
	Type   NotificationType `json:"type"`
	PeerId string           `json:"peerId"`
}

func (FollowNotification) Data added in v0.12.1

func (n FollowNotification) Data() ([]byte, error)

func (FollowNotification) GetID added in v0.12.1

func (n FollowNotification) GetID() string

func (FollowNotification) GetSMTPTitleAndBody added in v0.12.1

func (n FollowNotification) GetSMTPTitleAndBody() (string, string, bool)

func (FollowNotification) GetType added in v0.12.1

func (FollowNotification) WebsocketData added in v0.12.1

func (n FollowNotification) WebsocketData() ([]byte, error)

type Follower added in v0.7.0

type Follower struct {
	PeerId string `json:"peerId"`
	Proof  []byte `json:"proof"`
}

type FollowerStore added in v0.11.1

type FollowerStore interface {
	Queryable

	// Put a B58 encoded follower ID and proof to the database
	Put(follower string, proof []byte) error

	/* Get followers from the database.
	   The offset and limit arguments can be used to for lazy loading. */
	Get(offsetId string, limit int) ([]Follower, error)

	// Delete a follower from the database
	Delete(follower string) error

	// Return the number of followers in the database
	Count() int

	// Are we followed by this peer?
	FollowsMe(peerId string) bool
}

type FollowingStore added in v0.11.1

type FollowingStore interface {
	Queryable

	// Put a B58 encoded peer ID to the database
	Put(peer string) error

	/* Get a list of following peers from the database.
	   The offset and limit arguments can be used to for lazy loading. */
	Get(offsetId string, limit int) ([]string, error)

	// Delete a peer from the database
	Delete(peer string) error

	// Return the number of peers in the database
	Count() int

	// Am I following this peer?
	IsFollowing(peerId string) bool
}

type FulfillmentNotification added in v0.12.1

type FulfillmentNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	Thumbnail    Thumbnail        `json:"thumbnail"`
	VendorHandle string           `json:"vendorHandle"`
	VendorID     string           `json:"vendorId"`
}

func (FulfillmentNotification) Data added in v0.12.1

func (n FulfillmentNotification) Data() ([]byte, error)

func (FulfillmentNotification) GetID added in v0.12.1

func (n FulfillmentNotification) GetID() string

func (FulfillmentNotification) GetSMTPTitleAndBody added in v0.12.1

func (n FulfillmentNotification) GetSMTPTitleAndBody() (string, string, bool)

func (FulfillmentNotification) GetType added in v0.12.1

func (FulfillmentNotification) WebsocketData added in v0.12.1

func (n FulfillmentNotification) WebsocketData() ([]byte, error)

type GroupChatMessage added in v0.6.0

type GroupChatMessage struct {
	PeerIds []string `json:"peerIds"`
	Subject string   `json:"subject"`
	Message string   `json:"message"`
}

type IncomingTransaction added in v0.12.1

type IncomingTransaction struct {
	Txid          string         `json:"txid"`
	Value         *CurrencyValue `json:"value"`
	Address       string         `json:"address"`
	Status        string         `json:"status"`
	Memo          string         `json:"memo"`
	Timestamp     time.Time      `json:"timestamp"`
	Confirmations int32          `json:"confirmations"`
	OrderId       string         `json:"orderId"`
	Thumbnail     string         `json:"thumbnail"`
	Height        int32          `json:"height"`
	CanBumpFee    bool           `json:"canBumpFee"`
}

func (IncomingTransaction) Data added in v0.12.1

func (n IncomingTransaction) Data() ([]byte, error)

func (IncomingTransaction) GetID added in v0.12.1

func (n IncomingTransaction) GetID() string

func (IncomingTransaction) GetSMTPTitleAndBody added in v0.12.1

func (n IncomingTransaction) GetSMTPTitleAndBody() (string, string, bool)

func (IncomingTransaction) GetType added in v0.12.1

func (IncomingTransaction) WebsocketData added in v0.12.1

func (n IncomingTransaction) WebsocketData() ([]byte, error)

type IndividualListingContainer added in v0.14.0

type IndividualListingContainer struct {
	Listing `json:"listing"`
}

IndividualListingContainer is a wrapper for a single listing

type InventoryStore added in v0.11.1

type InventoryStore interface {
	Queryable

	/* Put an inventory count for a listing
	   Override the existing count if it exists */
	Put(slug string, variantIndex int, count *big.Int) error

	// Return the count for a specific listing including variants
	GetSpecific(slug string, variantIndex int) (*big.Int, error)

	// Get the count for all variants of a given listing
	Get(slug string) (map[int]*big.Int, error)

	// Fetch all inventory maps for each slug
	GetAll() (map[string]map[int]*big.Int, error)

	// Delete a listing and related count
	Delete(slug string, variant int) error

	// Delete all variants of a given slug
	DeleteAll(slug string) error
}

type Item added in v0.14.0

type Item struct {
	ListingHash    string         `json:"listingHash"`
	Quantity       string         `json:"bigQuantity"`
	Options        options        `json:"options"`
	Shipping       shippingOption `json:"shipping"`
	Memo           string         `json:"memo"`
	Coupons        []string       `json:"coupons"`
	PaymentAddress string         `json:"paymentAddress"`
}

Item represents a purchased item

type KeyStore added in v0.11.1

type KeyStore interface {
	Queryable
	wallet.Keys
}

type Listing added in v0.14.0

type Listing struct {
	proto.Message
	// contains filtered or unexported fields
}

Listing represents a trade offer which can be accepted by another party on the OpenBazaar network

func CreateListing added in v0.14.0

func CreateListing(r []byte, isTestnet bool, dstore *Datastore, repoPath string) (Listing, error)

CreateListing will create a pb Listing

func NewListingFromProtobuf added in v0.14.0

func NewListingFromProtobuf(l *pb.Listing) (*Listing, error)

NewListingFromProtobuf - return Listing from pb.Listing

func UnmarshalJSONListing added in v0.14.0

func UnmarshalJSONListing(data []byte) (*Listing, error)

UnmarshalJSONListing - unmarshal listing

func UpdateListing added in v0.14.0

func UpdateListing(r []byte, isTestnet bool, dstore *Datastore, repoPath string) (Listing, error)

UpdateListing will update a pb Listing

func (*Listing) GetAcceptedCurrencies added in v0.14.0

func (l *Listing) GetAcceptedCurrencies() []string

GetAcceptedCurrencies returns the listing's list of accepted currency codes

func (*Listing) GetCategories added in v0.14.0

func (l *Listing) GetCategories() []string

GetCategories returns a list of categories for the listing

func (*Listing) GetCondition added in v0.14.0

func (l *Listing) GetCondition() string

GetCondition returns listing item condition

func (*Listing) GetContractType added in v0.14.0

func (l *Listing) GetContractType() string

GetContractType returns listing's contract type

func (*Listing) GetCoupons added in v0.14.0

func (l *Listing) GetCoupons() (ListingCoupons, error)

GetCoupons returns listing coupons with discount amount normalized as a CurrencyValue

func (*Listing) GetCryptoCurrencyCode added in v0.14.0

func (l *Listing) GetCryptoCurrencyCode() string

GetCryptoCurrencyCode returns the listing crypto currency code

func (*Listing) GetCryptoDivisibility added in v0.14.0

func (l *Listing) GetCryptoDivisibility() uint32

GetCryptoDivisibility returns the listing crypto divisibility

func (*Listing) GetDescription added in v0.14.0

func (l *Listing) GetDescription() string

GetDescription returns item description

func (*Listing) GetEscrowTimeoutHours added in v0.14.0

func (l *Listing) GetEscrowTimeoutHours() uint32

GetEscrowTimeout return listing's escrow timeout in hours

func (*Listing) GetFormat added in v0.14.0

func (l *Listing) GetFormat() string

GetFormat returns the listing's pricing format

func (*Listing) GetImages added in v0.14.0

func (l *Listing) GetImages() []*ListingImage

GetImages return set of listing item images

func (*Listing) GetInventory added in v0.14.0

func (l *Listing) GetInventory() (map[int]*big.Int, error)

GetInventory - returns a map of skus and quantityies

func (*Listing) GetLanguage added in v0.14.0

func (l *Listing) GetLanguage() string

GetLanguage return listing's language

func (*Listing) GetModerators added in v0.14.0

func (l *Listing) GetModerators() []string

GetModerators returns accepted moderators for the listing

func (*Listing) GetNsfw added in v0.14.0

func (l *Listing) GetNsfw() bool

GetNSFW returns whether the listing is marked as inappropriate for general viewing or otherwise "Not Safe For Work"

func (*Listing) GetPrice added in v0.14.0

func (l *Listing) GetPrice() (*CurrencyValue, error)

GetPrice returns the listing price. For CRYPTOCURRENCY listings, this value would be zero in the denomination of the cryptocurrency being traded and the item value in all other cases. In the event that the shema version or contract type are unrecognizable, an error is returned.

func (*Listing) GetPriceModifier added in v0.14.0

func (l *Listing) GetPriceModifier() float32

GetPriceModifier return listing's price modifier

func (*Listing) GetProcessingTime added in v0.14.0

func (l *Listing) GetProcessingTime() string

GetProcessingTime returns the expected time for vendor to process listing fulfillment

func (*Listing) GetProtobuf added in v0.14.0

func (l *Listing) GetProtobuf() *pb.Listing

GetProtobuf returns the current state of pb.Listing managed by Listing

func (*Listing) GetRefundPolicy added in v0.14.0

func (l *Listing) GetRefundPolicy() string

GetRefundPolicy return the refund policy for the listing

func (*Listing) GetShippingOptions added in v0.14.0

func (l *Listing) GetShippingOptions() ([]*pb.Listing_ShippingOption, error)

GetShippingOptions returns all shipping options

func (*Listing) GetShippingRegions added in v0.14.0

func (l *Listing) GetShippingRegions() ([]string, []string)

GetShippingRegions returns all region strings for the defined shipping services

func (*Listing) GetShortDescription added in v0.14.0

func (l *Listing) GetShortDescription() string

GetShortDescription returns the item description truncated down to the ShortDescriptionLength maximum

func (*Listing) GetSkus added in v0.14.0

func (l *Listing) GetSkus() ([]*pb.Listing_Item_Sku, error)

GetSkus returns the listing SKUs

func (*Listing) GetSlug added in v0.14.0

func (l *Listing) GetSlug() string

GetSlug returns the listing slug

func (*Listing) GetTags added in v0.14.0

func (l *Listing) GetTags() []string

GetTags returns a list of tags for the listing

func (*Listing) GetTaxes added in v0.14.0

func (l *Listing) GetTaxes() ListingTaxes

GetTaxes returns listing tax information

func (*Listing) GetTermsAndConditions added in v0.14.0

func (l *Listing) GetTermsAndConditions() string

GetTermsAndConditions return the terms for the listings purchase contract

func (*Listing) GetTitle added in v0.14.0

func (l *Listing) GetTitle() string

GetTitle returns the listing item title

func (*Listing) GetVendorID added in v0.14.0

func (l *Listing) GetVendorID() *PeerInfo

GetVendorID returns the vendor peer ID

func (*Listing) GetVersion added in v0.14.0

func (l *Listing) GetVersion() uint32

GetVersion returns the schema version of the Listing

func (*Listing) GetWeightGrams added in v0.14.0

func (l *Listing) GetWeightGrams() float32

GetGrams returns listing item weight in grams

func (*Listing) MarshalJSON added in v0.14.0

func (l *Listing) MarshalJSON() ([]byte, error)

MarshalJSON returns the json serialization of the underlying protobuf

func (*Listing) MarshalProtobuf added in v0.14.0

func (l *Listing) MarshalProtobuf() ([]byte, error)

MarshalProtobuf returns the byte serialization of the underlying protobuf

func (*Listing) Normalize added in v0.14.0

func (l *Listing) Normalize() (*Listing, error)

Normalize converts legacy schema listing data from other users on the network to fit the latest schema for consumption via the API for local use. NOTE: Legacy nodes do not understand the latest schema. As such, normalized listings must not be used as part of the RicardianContract and must be serialized and used as they were provided by the originating node.

func (*Listing) ProtoMessage added in v0.14.0

func (*Listing) ProtoMessage()

func (*Listing) Reset added in v0.14.0

func (l *Listing) Reset()

func (*Listing) SetAcceptedCurrencies added in v0.14.0

func (l *Listing) SetAcceptedCurrencies(codes ...string) error

SetAcceptedCurrencies the listing's accepted currency codes. Assumes the node serving the listing has already validated the wallet supports the currencies.

func (*Listing) SetCryptocurrencyListingDefaults added in v0.14.0

func (l *Listing) SetCryptocurrencyListingDefaults() error

SetCryptocurrencyListingDefaults ensures appropriate defaults are set for Crypto listings

func (*Listing) SetModerators added in v0.14.0

func (l *Listing) SetModerators(mods []string) error

SetModerators updates the listing's accepted moderators

func (*Listing) Sign added in v0.14.0

func (l *Listing) Sign(n listingSigner) (*SignedListing, error)

Sign verifies the Listing and returns a SignedListing

func (*Listing) String added in v0.14.0

func (l *Listing) String() string

func (*Listing) UpdateCouponsFromDatastore added in v0.14.0

func (l *Listing) UpdateCouponsFromDatastore(cdb couponGetter) error

UpdateCouponsFromDatastore will get all coupons from the datastore and update the internal protobuf with the codes that match the coupon's hash, if any.

func (*Listing) ValidateCryptoListing added in v0.14.0

func (l *Listing) ValidateCryptoListing() error

func (*Listing) ValidateListing added in v0.14.0

func (l *Listing) ValidateListing(testnet bool) (err error)

ValidateListing ensures all listing state is valid

func (*Listing) ValidatePurchaseItemOptions added in v0.14.0

func (l *Listing) ValidatePurchaseItemOptions(itemOptions []option) error

ValidatePurchaseItemOptions ensures item options are valid

func (*Listing) ValidateSkus added in v0.14.0

func (l *Listing) ValidateSkus() error

ValidateSkus ensures valid SKU state

type ListingCoupon added in v0.14.0

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

ListingCoupon represents an coupon which can be applied to a listing for a discount

func (*ListingCoupon) GetAmountOff added in v0.14.0

func (c *ListingCoupon) GetAmountOff() *CurrencyValue

GetAmountOff returns the value to reduce listing by

func (*ListingCoupon) GetListingSlug added in v0.14.0

func (c *ListingCoupon) GetListingSlug() string

GetListingSlug returns the slug for the coupon's listing

func (*ListingCoupon) GetPercentOff added in v0.14.0

func (c *ListingCoupon) GetPercentOff() float32

GetPercentOff returns the percentage amount to reduce listing by

func (*ListingCoupon) GetRedemptionCode added in v0.14.0

func (c *ListingCoupon) GetRedemptionCode() (string, error)

GetRedemptionCode returns the coupon redemption code

func (*ListingCoupon) GetRedemptionHash added in v0.14.0

func (c *ListingCoupon) GetRedemptionHash() (string, error)

GetRedemptionHash returns the hashed representation of the code

func (*ListingCoupon) GetTitle added in v0.14.0

func (c *ListingCoupon) GetTitle() string

GetTitle returns the coupon's title

func (*ListingCoupon) SetRedemptionCode added in v0.14.0

func (c *ListingCoupon) SetRedemptionCode(code string) error

SetRedemptionCode sets the coupon's redemption code

type ListingCoupons added in v0.14.0

type ListingCoupons []*ListingCoupon

ListingCoupons is a set of listing coupons

func (ListingCoupons) GetProtobuf added in v0.14.0

func (cs ListingCoupons) GetProtobuf() []*pb.Listing_Coupon

GetProtobuf converts ListingCoupons into its protobuf representation

type ListingImage added in v0.14.0

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

ListingImage represents the underlying protobuf image

func (*ListingImage) GetFilename added in v0.14.0

func (i *ListingImage) GetFilename() string

GetFilename returns the image filename

func (*ListingImage) GetLarge added in v0.14.0

func (i *ListingImage) GetLarge() string

GetLarge returns the image's large size

func (*ListingImage) GetMedium added in v0.14.0

func (i *ListingImage) GetMedium() string

GetMedium returns the image's medium size

func (*ListingImage) GetOriginal added in v0.14.0

func (i *ListingImage) GetOriginal() string

GetOriginal returns the image's original size

func (*ListingImage) GetSmall added in v0.14.0

func (i *ListingImage) GetSmall() string

GetSmall returns the image's small size

func (*ListingImage) GetTiny added in v0.14.0

func (i *ListingImage) GetTiny() string

GetTiny returns the image's tiny size

func (*ListingImage) SetLarge added in v0.14.0

func (i *ListingImage) SetLarge(cid string) error

SetLarge updates CID for the large image

func (*ListingImage) SetMedium added in v0.14.0

func (i *ListingImage) SetMedium(cid string) error

SetMedium updates CID for the medium image

func (*ListingImage) SetOriginal added in v0.14.0

func (i *ListingImage) SetOriginal(cid string) error

SetOriginal updates CID for the original image

func (*ListingImage) SetSmall added in v0.14.0

func (i *ListingImage) SetSmall(cid string) error

SetSmall updates CID for the small image

func (*ListingImage) SetTiny added in v0.14.0

func (i *ListingImage) SetTiny(cid string) error

SetTiny updates CID for the tiny image

func (*ListingImage) String added in v0.14.0

func (i *ListingImage) String() string

String satisfies Stringer and returns the image filename

type ListingIndexData added in v0.14.0

type ListingIndexData struct {
	Hash               string           `json:"hash"`
	Slug               string           `json:"slug"`
	Title              string           `json:"title"`
	Categories         []string         `json:"categories"`
	NSFW               bool             `json:"nsfw"`
	ContractType       string           `json:"contractType"`
	Description        string           `json:"description"`
	Thumbnail          ListingThumbnail `json:"thumbnail"`
	Price              *CurrencyValue   `json:"price"`
	Modifier           float32          `json:"modifier"`
	ShipsTo            []string         `json:"shipsTo"`
	FreeShipping       []string         `json:"freeShipping"`
	Language           string           `json:"language"`
	AverageRating      float32          `json:"averageRating"`
	RatingCount        uint32           `json:"ratingCount"`
	ModeratorIDs       []string         `json:"moderators"`
	AcceptedCurrencies []string         `json:"acceptedCurrencies"`
	CryptoCurrencyCode string           `json:"coinType"`
}

ListingIndexData reprents a single node in the Listing index

func UnmarshalJSONSignedListingIndex added in v0.14.0

func UnmarshalJSONSignedListingIndex(data []byte) ([]ListingIndexData, error)

UnmarshalJSONSignedListingIndex consumes a []byte payload of JSON representing a list of SignedListings and returns a parsed instance or an error if the payload cannot be successfully parsed

type ListingMetadata added in v0.14.0

type ListingMetadata struct {
	Version uint `json:"version"`
}

ListingMetadata -

type ListingPrice added in v0.13.0

type ListingPrice struct {
	Amount           uint64  `json:"amount"`
	CurrencyCode     string  `json:"currencyCode"`
	PriceModifier    float32 `json:"priceModifier"`
	CoinDivisibility uint32  `json:"coinDivisibility"`
}

type ListingTax added in v0.14.0

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

ListingTax describes how a listing is taxed in each region

func (ListingTax) GetApplicableRegions added in v0.14.0

func (t ListingTax) GetApplicableRegions() []string

GetApplicableRegions returns the regions affected by the tax

func (ListingTax) GetRate added in v0.14.0

func (t ListingTax) GetRate() float32

GetRate returns the tax rate

func (ListingTax) GetTaxableShipping added in v0.14.0

func (t ListingTax) GetTaxableShipping() bool

GetTaxableShipping indicates whether the shipping is subject to the tax

func (ListingTax) GetType added in v0.14.0

func (t ListingTax) GetType() string

GetType returns the tax type

type ListingTaxes added in v0.14.0

type ListingTaxes []ListingTax

ListingTaxes is a set of taxes

type ListingThumbnail added in v0.14.0

type ListingThumbnail struct {
	Tiny   string `json:"tiny"`
	Small  string `json:"small"`
	Medium string `json:"medium"`
}

type Message added in v0.13.5

type Message struct {
	Msg pb.Message
}

Message - wrapper for pb.Message

func (*Message) GetMessageType added in v0.13.5

func (m *Message) GetMessageType() pb.Message_MessageType

GetMessageType - return the pb.Message messageType

func (*Message) GetPayload added in v0.13.5

func (m *Message) GetPayload() *any.Any

GetPayload - return the pb.Message payload

func (*Message) MarshalJSON added in v0.13.5

func (m *Message) MarshalJSON() ([]byte, error)

MarshalJSON - invoke the pb.Message marshaller

func (*Message) UnmarshalJSON added in v0.13.5

func (m *Message) UnmarshalJSON(b []byte) error

UnmarshalJSON - invoke the pb.Message unmarshaller

type MessageStore added in v0.13.5

type MessageStore interface {
	Queryable

	// Save a new message
	Put(messageID, orderID string, mType pb.Message_MessageType, peerID string, msg Message, err string, receivedAt int64, pubkey []byte) error

	// GetByOrderIDType returns the message for specified order and type
	GetByOrderIDType(orderID string, mType pb.Message_MessageType) (*Message, string, error)

	// GetAllErrored returns the all messages with error
	GetAllErrored() ([]OrderMessage, error)

	// MarkAsResolved sets the message as resolved and will no longer return
	// with GetAllErrored
	MarkAsResolved(OrderMessage) error
}

MessageStore is the messages table interface

type Metadata added in v0.5.1

type Metadata struct {
	Txid       string
	Address    string
	Memo       string
	OrderId    string
	Thumbnail  string
	CanBumpFee bool
}

type Migration added in v0.9.2

type Migration interface {
	Up(repoPath string, dbPassword string, testnet bool) error
	Down(repoPath string, dbPassword string, testnet bool) error
}

type ModeratedStore added in v0.11.1

type ModeratedStore interface {
	Queryable

	// Put a B58 encoded peer ID to the database
	Put(peerId string) error

	/* Get the moderated store list from the database.
	   The offset and limit arguments can be used to for lazy loading. */
	Get(offsetId string, limit int) ([]string, error)

	// Delete a moderated store from the database
	Delete(peerId string) error
}

type ModeratorAddNotification added in v0.12.1

type ModeratorAddNotification struct {
	ID     string           `json:"notificationId"`
	Type   NotificationType `json:"type"`
	PeerId string           `json:"peerId"`
}

func (ModeratorAddNotification) Data added in v0.12.1

func (n ModeratorAddNotification) Data() ([]byte, error)

func (ModeratorAddNotification) GetID added in v0.12.1

func (n ModeratorAddNotification) GetID() string

func (ModeratorAddNotification) GetSMTPTitleAndBody added in v0.12.1

func (n ModeratorAddNotification) GetSMTPTitleAndBody() (string, string, bool)

func (ModeratorAddNotification) GetType added in v0.12.1

func (ModeratorAddNotification) WebsocketData added in v0.12.1

func (n ModeratorAddNotification) WebsocketData() ([]byte, error)

type ModeratorDisputeExpiry added in v0.12.1

type ModeratorDisputeExpiry struct {
	ID        string           `json:"notificationId"`
	Type      NotificationType `json:"type"`
	CaseID    string           `json:"disputeCaseId"`
	ExpiresIn uint             `json:"expiresIn"`
	Thumbnail Thumbnail        `json:"thumbnail"`
}

ModeratorDisputeExpiry represents a notification about an open dispute which will soon be expired and automatically resolved. The Type indicates the age of the dispute case and the CaseID references the cases caseID in the database schema

func (ModeratorDisputeExpiry) Data added in v0.12.1

func (n ModeratorDisputeExpiry) Data() ([]byte, error)

func (ModeratorDisputeExpiry) GetID added in v0.12.1

func (n ModeratorDisputeExpiry) GetID() string

func (ModeratorDisputeExpiry) GetSMTPTitleAndBody added in v0.12.1

func (n ModeratorDisputeExpiry) GetSMTPTitleAndBody() (string, string, bool)

func (ModeratorDisputeExpiry) GetType added in v0.12.1

func (ModeratorDisputeExpiry) WebsocketData added in v0.12.1

func (n ModeratorDisputeExpiry) WebsocketData() ([]byte, error)

type ModeratorRemoveNotification added in v0.12.1

type ModeratorRemoveNotification struct {
	ID     string           `json:"notificationId"`
	Type   NotificationType `json:"type"`
	PeerId string           `json:"peerId"`
}

func (ModeratorRemoveNotification) Data added in v0.12.1

func (n ModeratorRemoveNotification) Data() ([]byte, error)

func (ModeratorRemoveNotification) GetID added in v0.12.1

func (ModeratorRemoveNotification) GetSMTPTitleAndBody added in v0.12.1

func (n ModeratorRemoveNotification) GetSMTPTitleAndBody() (string, string, bool)

func (ModeratorRemoveNotification) GetType added in v0.12.1

func (ModeratorRemoveNotification) WebsocketData added in v0.12.1

func (n ModeratorRemoveNotification) WebsocketData() ([]byte, error)

type Notification added in v0.12.1

type Notification struct {
	ID           string           `json:"-"`
	CreatedAt    *APITime         `json:"timestamp"`
	IsRead       bool             `json:"read"`
	NotifierData Notifier         `json:"notification"`
	NotifierType NotificationType `json:"-"`
}

Notification represents both a record from the Notifications Datastore as well as an unmarshalling envelope for the Notifier interface field NotifierData. NOTE: Only ID, NotifierData and NotifierType fields are valid in both contexts. This is because (*Notification).MarshalJSON only wraps the NotifierData field. NotifierData describes ID and NotifierType and will also be valid when unmarshalled. TODO: Ecapsulate the whole Notification struct inside of MarshalJSON and update persisted serializations to match in the Notifications Datastore

func NewNotification added in v0.12.1

func NewNotification(n Notifier, createdAt time.Time, isRead bool) *Notification

NewNotification is a helper that returns a properly instantiated *Notification

func (*Notification) Data added in v0.12.1

func (n *Notification) Data() ([]byte, error)

func (*Notification) GetID added in v0.12.1

func (n *Notification) GetID() string

func (*Notification) GetSMTPTitleAndBody added in v0.12.1

func (n *Notification) GetSMTPTitleAndBody() (string, string, bool)

func (*Notification) GetType added in v0.12.1

func (n *Notification) GetType() NotificationType

func (*Notification) GetTypeString added in v0.12.1

func (n *Notification) GetTypeString() string

func (*Notification) GetUnixCreatedAt added in v0.12.1

func (n *Notification) GetUnixCreatedAt() int

func (*Notification) MarshalJSON added in v0.12.1

func (n *Notification) MarshalJSON() ([]byte, error)

func (*Notification) UnmarshalJSON added in v0.12.1

func (n *Notification) UnmarshalJSON(data []byte) error

func (*Notification) WebsocketData added in v0.12.1

func (n *Notification) WebsocketData() ([]byte, error)

type NotificationStore added in v0.11.1

type NotificationStore interface {
	Queryable

	// PutRecord persists a Notification to the database
	PutRecord(*Notification) error

	// Mark notification as read
	MarkAsRead(notifID string) error

	// Mark all notifications as read
	MarkAllAsRead() error

	// Fetch notifications from database
	GetAll(offsetID string, limit int, typeFilter []string) ([]*Notification, int, error)

	// Returns the unread count for all notifications
	GetUnreadCount() (int, error)

	// Delete a notification
	Delete(notifID string) error
}

type NotificationType added in v0.12.1

type NotificationType string

func (NotificationType) String added in v0.12.1

func (t NotificationType) String() string

type Notifier added in v0.12.1

type Notifier interface {
	// GetID returns the unique string identifier for the Notifier and is used to
	// uniquely persist the Notifier in the DB. Some Notifiers are not persisted.
	// Until we can represent this as part of the interface, the Notifiers which
	// do not get persisted can safely return an empty string. Notifiers which are
	// persisted and return a non-unique GetID() string will eventually fail the DB's
	// uniqueness constraints during runtime.
	GetID() string

	// GetType returns the type as a NotificationType
	GetType() NotificationType

	// GetSMTPTitleAndBody returns the title and body strings to be used
	// in any notification content. The bool can return false to bypass the
	// SMTP notification for this Notifier.
	GetSMTPTitleAndBody() (string, string, bool)

	// Data returns the marhsalled []byte suitable for transmission to the client
	// over the HTTP connection
	Data() ([]byte, error)

	// WebsocketData returns the marhsalled []byte suitable for transmission to the client
	// over the websocket connection
	WebsocketData() ([]byte, error)
}

Notifier is an interface which is used to send data to the frontend

type OfflineMessageStore added in v0.11.1

type OfflineMessageStore interface {
	Queryable

	// Put a URL from a retrieved message
	Put(url string) error

	// Does the given URL exist in the database?
	Has(url string) bool

	// Save a message with the url
	SetMessage(url string, message []byte) error

	// Get all entries with a message
	GetMessages() (map[string][]byte, error)

	// Delete the given message
	DeleteMessage(url string) error
}

type OrderCancelNotification added in v0.12.1

type OrderCancelNotification struct {
	ID          string           `json:"notificationId"`
	Type        NotificationType `json:"type"`
	OrderId     string           `json:"orderId"`
	Thumbnail   Thumbnail        `json:"thumbnail"`
	BuyerHandle string           `json:"buyerHandle"`
	BuyerID     string           `json:"buyerId"`
}

func (OrderCancelNotification) Data added in v0.12.1

func (n OrderCancelNotification) Data() ([]byte, error)

func (OrderCancelNotification) GetID added in v0.12.1

func (n OrderCancelNotification) GetID() string

func (OrderCancelNotification) GetSMTPTitleAndBody added in v0.12.1

func (n OrderCancelNotification) GetSMTPTitleAndBody() (string, string, bool)

func (OrderCancelNotification) GetType added in v0.12.1

func (OrderCancelNotification) WebsocketData added in v0.12.1

func (n OrderCancelNotification) WebsocketData() ([]byte, error)

type OrderConfirmationNotification added in v0.12.1

type OrderConfirmationNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	Thumbnail    Thumbnail        `json:"thumbnail"`
	VendorHandle string           `json:"vendorHandle"`
	VendorID     string           `json:"vendorId"`
}

func (OrderConfirmationNotification) Data added in v0.12.1

func (OrderConfirmationNotification) GetID added in v0.12.1

func (OrderConfirmationNotification) GetSMTPTitleAndBody added in v0.12.1

func (n OrderConfirmationNotification) GetSMTPTitleAndBody() (string, string, bool)

func (OrderConfirmationNotification) GetType added in v0.12.1

func (OrderConfirmationNotification) WebsocketData added in v0.12.1

func (n OrderConfirmationNotification) WebsocketData() ([]byte, error)

type OrderDeclinedNotification added in v0.12.1

type OrderDeclinedNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	Thumbnail    Thumbnail        `json:"thumbnail"`
	VendorHandle string           `json:"vendorHandle"`
	VendorID     string           `json:"vendorId"`
}

func (OrderDeclinedNotification) Data added in v0.12.1

func (n OrderDeclinedNotification) Data() ([]byte, error)

func (OrderDeclinedNotification) GetID added in v0.12.1

func (OrderDeclinedNotification) GetSMTPTitleAndBody added in v0.12.1

func (n OrderDeclinedNotification) GetSMTPTitleAndBody() (string, string, bool)

func (OrderDeclinedNotification) GetType added in v0.12.1

func (OrderDeclinedNotification) WebsocketData added in v0.12.1

func (n OrderDeclinedNotification) WebsocketData() ([]byte, error)

type OrderMessage added in v0.14.0

type OrderMessage struct {
	MessageID   string `json:"messageID"`
	OrderID     string `json:"orderID"`
	MessageType int32  `json:"message_type"`
	Message     []byte `json:"message"`
	MsgErr      string `json:"error"`
	PeerID      string `json:"peerID"`
	PeerPubkey  []byte `json:"pubkey"`
}

type OrderNotification added in v0.12.1

type OrderNotification struct {
	BuyerHandle   string           `json:"buyerHandle"`
	BuyerID       string           `json:"buyerId"`
	ID            string           `json:"notificationId"`
	ListingType   string           `json:"listingType"`
	OrderId       string           `json:"orderId"`
	Price         *CurrencyValue   `json:"price"`
	PriceModifier float32          `json:"priceModifier"`
	Slug          string           `json:"slug"`
	Thumbnail     Thumbnail        `json:"thumbnail"`
	Title         string           `json:"title"`
	Type          NotificationType `json:"type"`
}

func (OrderNotification) Data added in v0.12.1

func (n OrderNotification) Data() ([]byte, error)

func (OrderNotification) GetID added in v0.12.1

func (n OrderNotification) GetID() string

func (OrderNotification) GetSMTPTitleAndBody added in v0.12.1

func (n OrderNotification) GetSMTPTitleAndBody() (string, string, bool)

func (OrderNotification) GetType added in v0.12.1

func (n OrderNotification) GetType() NotificationType

func (OrderNotification) WebsocketData added in v0.12.1

func (n OrderNotification) WebsocketData() ([]byte, error)

type OrderNotificationV4 added in v0.14.0

type OrderNotificationV4 struct {
	BuyerHandle   string           `json:"buyerHandle"`
	BuyerID       string           `json:"buyerId"`
	ID            string           `json:"notificationId"`
	ListingType   string           `json:"listingType"`
	OrderId       string           `json:"orderId"`
	Price         ListingPrice     `json:"price"`
	PriceModifier float32          `json:"priceModifier"`
	Slug          string           `json:"slug"`
	Thumbnail     Thumbnail        `json:"thumbnail"`
	Title         string           `json:"title"`
	Type          NotificationType `json:"type"`
}

type PaymentNotification added in v0.12.1

type PaymentNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	FundingTotal *CurrencyValue   `json:"fundingTotal"`
	CoinType     string           `json:"coinType"`
}

func (PaymentNotification) Data added in v0.12.1

func (n PaymentNotification) Data() ([]byte, error)

func (PaymentNotification) GetID added in v0.12.1

func (n PaymentNotification) GetID() string

func (PaymentNotification) GetSMTPTitleAndBody added in v0.12.1

func (n PaymentNotification) GetSMTPTitleAndBody() (string, string, bool)

func (PaymentNotification) GetType added in v0.12.1

func (PaymentNotification) WebsocketData added in v0.12.1

func (n PaymentNotification) WebsocketData() ([]byte, error)

type PayoutRatio added in v0.12.4

type PayoutRatio struct{ Buyer, Vendor float32 }

func (PayoutRatio) BuyerAny added in v0.12.4

func (r PayoutRatio) BuyerAny() bool

func (PayoutRatio) BuyerMajority added in v0.12.4

func (r PayoutRatio) BuyerMajority() bool

func (PayoutRatio) EvenMajority added in v0.12.4

func (r PayoutRatio) EvenMajority() bool

func (PayoutRatio) Validate added in v0.12.4

func (r PayoutRatio) Validate() error

func (PayoutRatio) VendorAny added in v0.12.4

func (r PayoutRatio) VendorAny() bool

func (PayoutRatio) VendorMajority added in v0.12.4

func (r PayoutRatio) VendorMajority() bool

type PeerInfo added in v0.14.0

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

PeerInfo represents a signed identity on OpenBazaar

func NewPeerInfoFromProtobuf added in v0.14.0

func NewPeerInfoFromProtobuf(id *pb.ID) *PeerInfo

NewPeerInfoFromProtobuf translates a pb.ID protobuf into a PeerInfo

func (*PeerInfo) BitcoinKey added in v0.14.0

func (p *PeerInfo) BitcoinKey() []byte

func (*PeerInfo) BitcoinSignature added in v0.14.0

func (p *PeerInfo) BitcoinSignature() []byte

func (*PeerInfo) Equal added in v0.14.0

func (p *PeerInfo) Equal(other *PeerInfo) bool

func (*PeerInfo) GeneratePeerIDFromIdentityKey added in v0.14.0

func (p *PeerInfo) GeneratePeerIDFromIdentityKey() (string, error)

func (*PeerInfo) Handle added in v0.14.0

func (p *PeerInfo) Handle() string

func (*PeerInfo) Hash added in v0.14.0

func (p *PeerInfo) Hash() (string, error)

Hash returns the public hash based on the PeerKeychain.Identity key material

func (*PeerInfo) IdentityKey added in v0.14.0

func (p *PeerInfo) IdentityKey() (ipfs.PubKey, error)

func (*PeerInfo) IdentityKeyBytes added in v0.14.0

func (p *PeerInfo) IdentityKeyBytes() []byte

func (*PeerInfo) Protobuf added in v0.14.0

func (p *PeerInfo) Protobuf() *pb.ID

func (*PeerInfo) String added in v0.14.0

func (p *PeerInfo) String() string

func (*PeerInfo) Valid added in v0.14.0

func (p *PeerInfo) Valid() error

Valid ensures the PeerInfo is valid as derived by the provided protobuf

func (*PeerInfo) VerifyBitcoinSignature added in v0.14.0

func (p *PeerInfo) VerifyBitcoinSignature() error

VerifyBitcoinSignature checks that the bitcoin key and the peer id both agree

func (*PeerInfo) VerifyIdentity added in v0.14.0

func (p *PeerInfo) VerifyIdentity() error

VerifyIdentity checks that the peer id, identity key both agree

type PeerKeychain added in v0.14.0

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

PeerKeychain holds bytes representing key material suitable for extracting with libp2p-crypto

type PointerStore added in v0.11.1

type PointerStore interface {
	Queryable

	// Put a pointer to the database
	Put(p ipfs.Pointer) error

	// Delete a pointer from the database
	Delete(id peer.ID) error

	// Delete all pointers of a given purpose
	DeleteAll(purpose ipfs.Purpose) error

	// Fetch a specific pointer
	Get(id peer.ID) (ipfs.Pointer, error)

	// Fetch all pointers of the given type
	GetByPurpose(purpose ipfs.Purpose) ([]ipfs.Pointer, error)

	// Fetch the entire list of pointers
	GetAll() ([]ipfs.Pointer, error)
}

type PremarshalledNotifier added in v0.12.1

type PremarshalledNotifier struct {
	Payload []byte
}

PremarshalledNotifier is a hack to allow []byte data to be transferred through the Notifier interface without having to do things the right way. You should not be using this and should prefer to use an existing Notifier struct or create a new one following the pattern of the TestNotification

func (PremarshalledNotifier) Data added in v0.12.1

func (n PremarshalledNotifier) Data() ([]byte, error)

func (PremarshalledNotifier) GetID added in v0.12.1

func (n PremarshalledNotifier) GetID() string

func (PremarshalledNotifier) GetSMTPTitleAndBody added in v0.12.1

func (n PremarshalledNotifier) GetSMTPTitleAndBody() (string, string, bool)

func (PremarshalledNotifier) GetType added in v0.12.1

func (PremarshalledNotifier) WebsocketData added in v0.12.1

func (n PremarshalledNotifier) WebsocketData() ([]byte, error)

type ProcessingErrorNotification added in v0.12.1

type ProcessingErrorNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	Thumbnail    Thumbnail        `json:"thumbnail"`
	VendorHandle string           `json:"vendorHandle"`
	VendorID     string           `json:"vendorId"`
}

func (ProcessingErrorNotification) Data added in v0.12.1

func (n ProcessingErrorNotification) Data() ([]byte, error)

func (ProcessingErrorNotification) GetID added in v0.12.1

func (ProcessingErrorNotification) GetSMTPTitleAndBody added in v0.12.1

func (n ProcessingErrorNotification) GetSMTPTitleAndBody() (string, string, bool)

func (ProcessingErrorNotification) GetType added in v0.12.1

func (ProcessingErrorNotification) WebsocketData added in v0.12.1

func (n ProcessingErrorNotification) WebsocketData() ([]byte, error)

type Profile added in v0.14.0

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

Profile presents the user's metadata. The profile state is maintained within a *pb.Profile internally which captures all state changes suitable to be persisted via marshaling to JSON. This struct should ensure the integrity of *pb.Profile to its data as indicated by the set schema version.

func NewProfileFromProtobuf added in v0.14.0

func NewProfileFromProtobuf(p *pb.Profile) (*Profile, error)

NewProfileFromProtobuf returns a Profile wrapped around a profile protobuf

func UnmarshalJSONProfile added in v0.14.0

func UnmarshalJSONProfile(data []byte) (*Profile, error)

UnmarshalJSONProfile consumes a JSON byte slice and returns a Profile-wrapped unmarshaled protobuf

func (*Profile) DisableModeration added in v0.14.0

func (p *Profile) DisableModeration() error

DisableModeration sets the profile so moderationr is disabled and all fee schedules are removed

func (*Profile) GetModeratedFixedFee added in v0.14.0

func (p *Profile) GetModeratedFixedFee() (*CurrencyValue, error)

GetModeratedFixedFee returns the fixed CurrencyValue for moderator services currently set on the Profile

func (*Profile) GetProtobuf added in v0.14.0

func (p *Profile) GetProtobuf() *pb.Profile

GetProtobuf returns the underlying protobuf which represents the persistable state of the profile. (Note: This method is a shim to access data which isn't represented in this package's Profile methods. Consider adding missing getters and setters which repsect the schema version instead of using the protobuf directly for manipulation.)

func (*Profile) GetVersion added in v0.14.0

func (p *Profile) GetVersion() uint32

GetVersion returns the schema version for the profile protobuf

func (*Profile) IsModerationEnabled added in v0.14.0

func (p *Profile) IsModerationEnabled() bool

IsModerationEnabled checks if the Moderator flag and info are present

func (*Profile) NormalizeDataForAllSchemas added in v0.14.0

func (p *Profile) NormalizeDataForAllSchemas() *Profile

NormalizeDataForAllSchemas converts existing data from its current schema into legacy schema. This does not guarantee success as legacy schema that was abandoned due to unacceptable constraints will not be able to fulfill the full capability of the newer schema. (Ex: FixedFee.BigAmount can support full precision, whereas FixedFee.Amount is limited to math.MaxInt64

func (*Profile) SetModeratorFixedFee added in v0.14.0

func (p *Profile) SetModeratorFixedFee(fee *CurrencyValue) error

SetModeratorFixedFee sets the profile to be a moderator with a fixed fee schedule

func (*Profile) SetModeratorFixedPlusPercentageFee added in v0.14.0

func (p *Profile) SetModeratorFixedPlusPercentageFee(fee *CurrencyValue, percentage float32) error

SetModeratorFixedPlusPercentageFee sets the profile to be a moderator with a fixed fee plus percentage schedule

func (*Profile) SetModeratorPercentageFee added in v0.14.0

func (p *Profile) SetModeratorPercentageFee(percentage float32) error

SetModeratorPercentageFee sets the profile to be a moderator with a percentage fee schedule

func (*Profile) Valid added in v0.14.0

func (p *Profile) Valid() error

Valid indicates whether the Profile is valid by returning an error when any part of the data is not as expected

type Purchase added in v0.5.1

type Purchase struct {
	OrderId            string        `json:"orderId"`
	Slug               string        `json:"slug"`
	Timestamp          time.Time     `json:"timestamp"`
	Title              string        `json:"title"`
	Thumbnail          string        `json:"thumbnail"`
	Total              CurrencyValue `json:"total"`
	VendorId           string        `json:"vendorId"`
	VendorHandle       string        `json:"vendorHandle"`
	ShippingName       string        `json:"shippingName"`
	ShippingAddress    string        `json:"shippingAddress"`
	CoinType           string        `json:"coinType"`
	PaymentCoin        string        `json:"paymentCoin"`
	State              string        `json:"state"`
	Read               bool          `json:"read"`
	Moderated          bool          `json:"moderated"`
	UnreadChatMessages int           `json:"unreadChatMessages"`
}

type PurchaseData added in v0.14.0

type PurchaseData struct {
	ShipTo               string  `json:"shipTo"`
	Address              string  `json:"address"`
	City                 string  `json:"city"`
	State                string  `json:"state"`
	PostalCode           string  `json:"postalCode"`
	CountryCode          string  `json:"countryCode"`
	AddressNotes         string  `json:"addressNotes"`
	Moderator            string  `json:"moderator"`
	Items                []Item  `json:"items"`
	AlternateContactInfo string  `json:"alternateContactInfo"`
	RefundAddress        *string `json:"refundAddress"` //optional, can be left out of json
	PaymentCoin          string  `json:"paymentCoin"`
}

PurchaseData represents purchase request metadata

type PurchaseRecord added in v0.12.1

type PurchaseRecord struct {
	Contract                     *pb.RicardianContract
	DisputedAt                   time.Time
	OrderID                      string
	OrderState                   pb.OrderState
	Timestamp                    time.Time
	LastDisputeTimeoutNotifiedAt time.Time
	LastDisputeExpiryNotifiedAt  time.Time
}

PurchaseRecord represents a one-to-one relationship with records in the SQL datastore

func (*PurchaseRecord) BuildBuyerDisputeExpiryFirstNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeExpiryFirstNotification(createdAt time.Time) *Notification

BuildBuyerDisputeExpiryFirstNotification returns a Notification with ExpiresIn set for the First Interval

func (*PurchaseRecord) BuildBuyerDisputeExpiryLastNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeExpiryLastNotification(createdAt time.Time) *Notification

BuildBuyerDisputeExpiryLastNotification returns a Notification with ExpiresIn set for the Last Interval

func (*PurchaseRecord) BuildBuyerDisputeExpirySecondNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeExpirySecondNotification(createdAt time.Time) *Notification

BuildBuyerDisputeExpirySecondNotification returns a Notification with ExpiresIn set for the Second Interval

func (*PurchaseRecord) BuildBuyerDisputeTimeoutFirstNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeTimeoutFirstNotification(createdAt time.Time) *Notification

BuildBuyerDisputeTimeoutFirstNotification returns a Notification with ExpiresIn set for the First Interval

func (*PurchaseRecord) BuildBuyerDisputeTimeoutLastNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeTimeoutLastNotification(createdAt time.Time) *Notification

BuildBuyerDisputeTimeoutLastNotification returns a Notification with ExpiresIn set for the Last Interval

func (*PurchaseRecord) BuildBuyerDisputeTimeoutSecondNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeTimeoutSecondNotification(createdAt time.Time) *Notification

BuildBuyerDisputeTimeoutSecondNotification returns a Notification with ExpiresIn set for the Second Interval

func (*PurchaseRecord) BuildBuyerDisputeTimeoutThirdNotification added in v0.12.1

func (r *PurchaseRecord) BuildBuyerDisputeTimeoutThirdNotification(createdAt time.Time) *Notification

BuildBuyerDisputeTimeoutThirdNotification returns a Notification with ExpiresIn set for the Third Interval

func (*PurchaseRecord) IsDisputeable added in v0.12.1

func (r *PurchaseRecord) IsDisputeable() bool

IsDisputeable returns whether the Purchase is in a state that it can be disputed with a third-party moderator

func (*PurchaseRecord) IsModeratedContract added in v0.12.1

func (r *PurchaseRecord) IsModeratedContract() bool

IsModeratedContract returns whether the contract includes a third-party moderator

type PurchaseStore added in v0.11.1

type PurchaseStore interface {
	Queryable

	// Save or update an order
	Put(orderID string, contract pb.RicardianContract, state pb.OrderState, read bool) error

	// Mark an order as read in the database
	MarkAsRead(orderID string) error

	// Mark an order as unread in the database
	MarkAsUnread(orderID string) error

	// Update the funding level for the contract
	UpdateFunding(orderId string, funded bool, records []*wallet.TransactionRecord) error

	// Delete an order
	Delete(orderID string) error

	// Return a purchase given the payment address
	GetByPaymentAddress(addr btc.Address) (contract *pb.RicardianContract, state pb.OrderState, funded bool, records []*wallet.TransactionRecord, err error)

	// Return a purchase given the order ID
	GetByOrderId(orderId string) (contract *pb.RicardianContract, state pb.OrderState, funded bool, records []*wallet.TransactionRecord, read bool, currencyCode *CurrencyCode, err error)

	// Return the metadata for all purchases. Also returns the original size of the query.
	GetAll(stateFilter []pb.OrderState, searchTerm string, sortByAscending bool, sortByRead bool, limit int, exclude []string) ([]Purchase, int, error)

	// Return unfunded orders.
	GetUnfunded() ([]UnfundedOrder, error)

	// Return the number of purchases in the database
	Count() int

	// GetPurchasesForDisputeTimeoutNotification returns []*PurchaseRecord including
	// each record which needs buyerDisputeTimeout Notifications to be generated.
	GetPurchasesForDisputeTimeoutNotification() ([]*PurchaseRecord, error)

	// GetPurchasesForDisputeExpiryNotification returns []*PurchaseRecord including
	// each record which needs buyerDisputeExpiry Notifications to be generated.
	GetPurchasesForDisputeExpiryNotification() ([]*PurchaseRecord, error)

	// UpdatePurchasesLastDisputeTimeoutNotifiedAt  accepts []*PurchaseRecord and updates each records lastDisputeTimeoutNotifiedAt by its OrderID
	UpdatePurchasesLastDisputeTimeoutNotifiedAt([]*PurchaseRecord) error

	// UpdatePurchasesLastDisputeExpiryNotifiedAt  accepts []*PurchaseRecord and updates each records lastDisputeExpiryNotifiedAt by its OrderID
	UpdatePurchasesLastDisputeExpiryNotifiedAt([]*PurchaseRecord) error
}

type Queryable added in v0.11.1

type Queryable interface {
	Lock()
	Unlock()
	BeginTransaction() (*sql.Tx, error)
	PrepareQuery(string) (*sql.Stmt, error)
	PrepareAndExecuteQuery(string, ...interface{}) (*sql.Rows, error)
	ExecuteQuery(string, ...interface{}) (sql.Result, error)
}

type RefundNotification added in v0.12.1

type RefundNotification struct {
	ID           string           `json:"notificationId"`
	Type         NotificationType `json:"type"`
	OrderId      string           `json:"orderId"`
	Thumbnail    Thumbnail        `json:"thumbnail"`
	VendorHandle string           `json:"vendorHandle"`
	VendorID     string           `json:"vendorId"`
}

func (RefundNotification) Data added in v0.12.1

func (n RefundNotification) Data() ([]byte, error)

func (RefundNotification) GetID added in v0.12.1

func (n RefundNotification) GetID() string

func (RefundNotification) GetSMTPTitleAndBody added in v0.12.1

func (n RefundNotification) GetSMTPTitleAndBody() (string, string, bool)

func (RefundNotification) GetType added in v0.12.1

func (RefundNotification) WebsocketData added in v0.12.1

func (n RefundNotification) WebsocketData() ([]byte, error)

type SMTPSettings

type SMTPSettings struct {
	Notifications  bool   `json:"notifications"`
	ServerAddress  string `json:"serverAddress"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	SenderEmail    string `json:"senderEmail"`
	RecipientEmail string `json:"recipientEmail"`
}

type Sale added in v0.5.1

type Sale struct {
	OrderId            string        `json:"orderId"`
	Slug               string        `json:"slug"`
	Timestamp          time.Time     `json:"timestamp"`
	Title              string        `json:"title"`
	Thumbnail          string        `json:"thumbnail"`
	Total              CurrencyValue `json:"total"`
	BuyerId            string        `json:"buyerId"`
	BuyerHandle        string        `json:"buyerHandle"`
	ShippingName       string        `json:"shippingName"`
	ShippingAddress    string        `json:"shippingAddress"`
	CoinType           string        `json:"coinType"`
	PaymentCoin        string        `json:"paymentCoin"`
	State              string        `json:"state"`
	Read               bool          `json:"read"`
	Moderated          bool          `json:"moderated"`
	UnreadChatMessages int           `json:"unreadChatMessages"`
}

type SaleRecord added in v0.12.1

type SaleRecord struct {
	Contract                     *pb.RicardianContract
	OrderID                      string
	OrderState                   pb.OrderState
	Timestamp                    time.Time
	LastDisputeTimeoutNotifiedAt time.Time
}

SaleRecord represents a one-to-one relationship with records in the SQL datastore

func (*SaleRecord) BuildVendorDisputeTimeoutLastNotification added in v0.12.1

func (r *SaleRecord) BuildVendorDisputeTimeoutLastNotification(createdAt time.Time) *Notification

BuildVendorDisputeTimeoutLastNotification returns a Notification that alerts a SaleRecord is more than 45 days old and already expired

func (*SaleRecord) IsDisputeable added in v0.12.1

func (r *SaleRecord) IsDisputeable() bool

IsDisputeable returns whether the Sale is in a state that it can be disputed with a third-party moderator

func (*SaleRecord) IsModeratedContract added in v0.12.1

func (r *SaleRecord) IsModeratedContract() bool

IsModeratedContract indicates whether the SaleRecord has a contract which includes a third-party moderator

func (*SaleRecord) SupportsTimedEscrowRelease added in v0.12.1

func (r *SaleRecord) SupportsTimedEscrowRelease() bool

SupportsTimedEscrowRelease indicates whether the underlying AcceptedCurrency supports a time-bassed release behavior. TODO: Express this from the wallet-interface instead

type SaleStore added in v0.11.1

type SaleStore interface {
	Queryable

	// Save or update a sale
	Put(orderID string, contract pb.RicardianContract, state pb.OrderState, read bool) error

	// Mark an order as read in the database
	MarkAsRead(orderID string) error

	// Mark an order as unread in the database
	MarkAsUnread(orderID string) error

	// Update the funding level for the contract
	UpdateFunding(orderId string, funded bool, records []*wallet.TransactionRecord) error

	// Delete an order
	Delete(orderID string) error

	// Return a sale given the payment address
	GetByPaymentAddress(addr btc.Address) (contract *pb.RicardianContract, state pb.OrderState, funded bool, records []*wallet.TransactionRecord, err error)

	// Return a sale given the order ID
	GetByOrderId(orderId string) (contract *pb.RicardianContract, state pb.OrderState, funded bool, records []*wallet.TransactionRecord, read bool, currencyCode *CurrencyCode, err error)

	// Return the metadata for all sales. Also returns the original size of the query.
	GetAll(stateFilter []pb.OrderState, searchTerm string, sortByAscending bool, sortByRead bool, limit int, exclude []string) ([]Sale, int, error)

	// Return unfunded orders.
	GetUnfunded() ([]UnfundedOrder, error)

	// Return the number of sales in the database
	Count() int

	// GetSalesForDisputeTimeoutNotification returns []*SaleRecord including
	// each record which needs Notifications to be generated.
	GetSalesForDisputeTimeoutNotification() ([]*SaleRecord, error)

	// UpdateSalesLastDisputeTimeoutNotifiedAt  accepts []*SaleRecord and updates each records lastDisputeTimeoutNotifiedAt by its CaseID
	UpdateSalesLastDisputeTimeoutNotifiedAt([]*SaleRecord) error
}

type SettingsData

type SettingsData struct {
	PaymentDataInQR     *bool              `json:"paymentDataInQR"`
	ShowNotifications   *bool              `json:"showNotifications"`
	ShowNsfw            *bool              `json:"showNsfw"`
	ShippingAddresses   *[]ShippingAddress `json:"shippingAddresses"`
	LocalCurrency       *string            `json:"localCurrency"`
	Country             *string            `json:"country"`
	TermsAndConditions  *string            `json:"termsAndConditions"`
	RefundPolicy        *string            `json:"refundPolicy"`
	BlockedNodes        *[]string          `json:"blockedNodes"`
	StoreModerators     *[]string          `json:"storeModerators"`
	MisPaymentBuffer    *float32           `json:"mispaymentBuffer"`
	SMTPSettings        *SMTPSettings      `json:"smtpSettings"`
	Version             *string            `json:"version"`
	PreferredCurrencies *[]string          `json:"preferredCurrencies"`
}

type ShippingAddress

type ShippingAddress struct {
	Name           string `json:"name"`
	Company        string `json:"company"`
	AddressLineOne string `json:"addressLineOne"`
	AddressLineTwo string `json:"addressLineTwo"`
	City           string `json:"city"`
	State          string `json:"state"`
	Country        string `json:"country"`
	PostalCode     string `json:"postalCode"`
	AddressNotes   string `json:"addressNotes"`
}

type SignedListing added in v0.14.0

type SignedListing struct {
	proto.Message
	// contains filtered or unexported fields
}

SignedListing represents a finalized listing which has been signed by the vendor

func NewSignedListingFromProtobuf added in v0.14.0

func NewSignedListingFromProtobuf(sl *pb.SignedListing) SignedListing

func UnmarshalJSONSignedListing added in v0.14.0

func UnmarshalJSONSignedListing(data []byte) (SignedListing, error)

UnmarshalJSONSignedListing extracts a SignedListing from marshaled JSON

func (SignedListing) GetAcceptedCurrencies added in v0.14.0

func (l SignedListing) GetAcceptedCurrencies() []string

GetAcceptedCurrencies returns the list of currencies which the listing may be purchased with

func (SignedListing) GetCryptoCurrencyCode added in v0.14.0

func (l SignedListing) GetCryptoCurrencyCode() string

GetCryptoCurrencyCode returns the currency code of the sold cryptocurrency listing

func (SignedListing) GetCryptoDivisibility added in v0.14.0

func (l SignedListing) GetCryptoDivisibility() uint32

GetCryptoDivisibility returns the divisibility of a cryptocurrency's listing sold inventory

func (SignedListing) GetListing added in v0.14.0

func (l SignedListing) GetListing() *Listing

GetListing returns the underlying repo.Listing object

func (SignedListing) GetListingSigProtobuf added in v0.14.0

func (l SignedListing) GetListingSigProtobuf() *pb.Signature

GetListingSigProtobuf returns the protobuf signature suitable for attaching to a pb.RicardianContract

func (SignedListing) GetPrice added in v0.14.0

func (l SignedListing) GetPrice() (*CurrencyValue, error)

GetPrice returns the price

func (SignedListing) GetSignature added in v0.14.0

func (l SignedListing) GetSignature() []byte

GetSignature returns the signature on the listing

func (SignedListing) GetSlug added in v0.14.0

func (l SignedListing) GetSlug() string

GetSlug returns the slug

func (SignedListing) GetTitle added in v0.14.0

func (l SignedListing) GetTitle() string

GetTitle returns the title

func (SignedListing) GetVendorID added in v0.14.0

func (l SignedListing) GetVendorID() *PeerInfo

GetVendorID returns the PeerInfo for the listing

func (SignedListing) GetVersion added in v0.14.0

func (l SignedListing) GetVersion() uint32

GetVersion returns the schema version

func (SignedListing) MarshalJSON added in v0.14.0

func (l SignedListing) MarshalJSON() ([]byte, error)

func (*SignedListing) Normalize added in v0.14.0

func (l *SignedListing) Normalize() error

Normalize is a helper method which will mutate the listing protobuf in-place but maintain the original signature for external verification purposes.

func (*SignedListing) ProtoMessage added in v0.14.0

func (*SignedListing) ProtoMessage()

func (*SignedListing) Reset added in v0.14.0

func (l *SignedListing) Reset()

func (*SignedListing) String added in v0.14.0

func (l *SignedListing) String() string

func (SignedListing) ValidateListing added in v0.14.0

func (l SignedListing) ValidateListing(isTestnet bool) error

ValidateListing ensures all listing state is valid

func (SignedListing) VerifySignature added in v0.14.0

func (l SignedListing) VerifySignature() error

VerifySignature checks the listings signature was produced by the vendor's Identity key and that the key was derived from the vendor's peerID

type SpentTransactionOutputStore added in v0.11.1

type SpentTransactionOutputStore interface {
	Queryable
	wallet.Stxos
}

type StatusNotification added in v0.12.1

type StatusNotification struct {
	Status string `json:"status"`
}

func (StatusNotification) Data added in v0.12.1

func (n StatusNotification) Data() ([]byte, error)

func (StatusNotification) GetID added in v0.12.1

func (n StatusNotification) GetID() string

func (StatusNotification) GetSMTPTitleAndBody added in v0.12.1

func (n StatusNotification) GetSMTPTitleAndBody() (string, string, bool)

func (StatusNotification) GetType added in v0.12.1

func (StatusNotification) WebsocketData added in v0.12.1

func (n StatusNotification) WebsocketData() ([]byte, error)

type TestNotification added in v0.12.1

type TestNotification struct{}

func (TestNotification) Data added in v0.12.1

func (TestNotification) Data() ([]byte, error)

func (TestNotification) GetID added in v0.12.1

func (TestNotification) GetID() string

func (TestNotification) GetSMTPTitleAndBody added in v0.12.1

func (TestNotification) GetSMTPTitleAndBody() (string, string, bool)

func (TestNotification) GetType added in v0.12.1

func (TestNotification) WebsocketData added in v0.12.1

func (n TestNotification) WebsocketData() ([]byte, error)

type Thumbnail added in v0.12.1

type Thumbnail struct {
	Tiny  string `json:"tiny"`
	Small string `json:"small"`
}

type TransactionMetadataStore added in v0.11.1

type TransactionMetadataStore interface {
	Queryable

	// Put metadata for a transaction to the db
	Put(m Metadata) error

	// Get the metadata given the txid
	Get(txid string) (Metadata, error)

	// Get a map of the txid to each metadata object
	GetAll() (map[string]Metadata, error)

	// Delete a metadata entry
	Delete(txid string) error
}

type TransactionStore added in v0.11.1

type TransactionStore interface {
	Queryable
	wallet.Txns
}

type UnfollowNotification added in v0.12.1

type UnfollowNotification struct {
	ID     string           `json:"notificationId"`
	Type   NotificationType `json:"type"`
	PeerId string           `json:"peerId"`
}

func (UnfollowNotification) Data added in v0.12.1

func (n UnfollowNotification) Data() ([]byte, error)

func (UnfollowNotification) GetID added in v0.12.1

func (n UnfollowNotification) GetID() string

func (UnfollowNotification) GetSMTPTitleAndBody added in v0.12.1

func (n UnfollowNotification) GetSMTPTitleAndBody() (string, string, bool)

func (UnfollowNotification) GetType added in v0.12.1

func (UnfollowNotification) WebsocketData added in v0.12.1

func (n UnfollowNotification) WebsocketData() ([]byte, error)

type UnfundedOrder added in v0.13.5

type UnfundedOrder struct {
	OrderId        string
	Timestamp      time.Time
	PaymentCoin    string
	PaymentAddress string
}

type UnspentTransactionOutputStore added in v0.11.1

type UnspentTransactionOutputStore interface {
	Queryable
	wallet.Utxos
}

type VendorDisputeTimeout added in v0.12.1

type VendorDisputeTimeout struct {
	ID        string           `json:"notificationId"`
	Type      NotificationType `json:"type"`
	OrderID   string           `json:"purchaseOrderId"`
	ExpiresIn uint             `json:"expiresIn"`
	Thumbnail Thumbnail        `json:"thumbnail"`
}

VendorDisputeTimeout represents a notification about a sale which will soon be unable to dispute. The Type indicates the age of the purchase and OrderID references the purchases orderID in the database schema

func (VendorDisputeTimeout) Data added in v0.12.1

func (n VendorDisputeTimeout) Data() ([]byte, error)

func (VendorDisputeTimeout) GetID added in v0.12.1

func (n VendorDisputeTimeout) GetID() string

func (VendorDisputeTimeout) GetSMTPTitleAndBody added in v0.12.1

func (n VendorDisputeTimeout) GetSMTPTitleAndBody() (string, string, bool)

func (VendorDisputeTimeout) GetType added in v0.12.1

func (VendorDisputeTimeout) WebsocketData added in v0.12.1

func (n VendorDisputeTimeout) WebsocketData() ([]byte, error)

type VendorFinalizedPayment added in v0.12.1

type VendorFinalizedPayment struct {
	ID      string           `json:"notificationId"`
	Type    NotificationType `json:"type"`
	OrderID string           `json:"orderId"`
}

VendorFinalizedPayment represents a notification about a purchase which will soon be unable to dispute.

func (VendorFinalizedPayment) Data added in v0.12.1

func (n VendorFinalizedPayment) Data() ([]byte, error)

func (VendorFinalizedPayment) GetID added in v0.12.1

func (n VendorFinalizedPayment) GetID() string

func (VendorFinalizedPayment) GetSMTPTitleAndBody added in v0.12.1

func (n VendorFinalizedPayment) GetSMTPTitleAndBody() (string, string, bool)

func (VendorFinalizedPayment) GetType added in v0.12.1

func (VendorFinalizedPayment) WebsocketData added in v0.12.1

func (n VendorFinalizedPayment) WebsocketData() ([]byte, error)

type WatchedScriptStore added in v0.11.1

type WatchedScriptStore interface {
	Queryable
	wallet.WatchedScripts
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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