core

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT Imports: 63 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RatingMin - min raring
	RatingMin = 1
	// RatingMax - max rating
	RatingMax = 5
	// ReviewMaxCharacters - max size for review
	ReviewMaxCharacters = 3000
)
View Source
const (
	// VERSION - current version
	VERSION = "0.14.6"
	// USERAGENT - user-agent header string
	USERAGENT = "/openbazaar-go:" + VERSION + "/"
)
View Source
const (
	// ChatMessageMaxCharacters - limit for chat msg
	ChatMessageMaxCharacters = 20000
	// ChatSubjectMaxCharacters - limit for chat subject
	ChatSubjectMaxCharacters = 500
	// DefaultPointerPrefixLength - default ipfs pointer prefix
	DefaultPointerPrefixLength = 14
)
View Source
const (

	// EscrowReleaseSize - size in bytes for escrow op
	EscrowReleaseSize = 337
	// CryptocurrencyPurchasePaymentAddressMaxLength - max permissible length for an address
	CryptocurrencyPurchasePaymentAddressMaxLength = 512
)
View Source
const (
	// PostStatusMaxCharacters - Maximum length of the status field of a post
	PostStatusMaxCharacters = 280
	// PostLongFormMaxCharacters - Maximum length of the longForm field of a post
	PostLongFormMaxCharacters = 50000
	// PostMaximumTotalTags - Maximum number of tags a post can have
	PostMaximumTotalTags = 50
	// PostMaximumTotalChannels - Maximum number of channels a post can be addressed to
	PostMaximumTotalChannels = 30
	// PostTagsMaxCharacters - Maximum character length of a tag
	PostTagsMaxCharacters = 256
	// PostChannelsMaxCharacters - Maximum character length of a channel
	PostChannelsMaxCharacters = 256
	// PostReferenceMaxCharacters - Maximum character length of a reference
	PostReferenceMaxCharacters = 256
)

Constants for validation

View Source
const DefaultCurrencyDivisibility uint = 8

DefaultCurrencyDivisibility is the Divisibility of the Currency if not defined otherwise

Variables

View Source
var (
	// EscrowTimeLockedError - custom err for time locked escrow
	EscrowTimeLockedError error
	// ErrPrematureReleaseOfTimedoutEscrowFunds - custom err for premature escrow funds release
	ErrPrematureReleaseOfTimedoutEscrowFunds = fmt.Errorf("escrow can only be released when in dispute for %s days", (time.Duration(repo.DisputeTotalDurationHours) * time.Hour).String())
)
View Source
var (
	// ErrPurchaseUnknownListing - unavailable listing err
	ErrPurchaseUnknownListing = errors.New("order contains a hash of a listing that is not currently for sale")

	// ErrPriceCalculationRequiresExchangeRates - exchange rates dependency err
	ErrPriceCalculationRequiresExchangeRates = errors.New("can't calculate price with exchange rates disabled")

	// ErrCryptocurrencyListingCoinTypeRequired - missing coinType err
	ErrCryptocurrencyListingCoinTypeRequired = errors.New("cryptocurrency listings require a coinType")
	// ErrCryptocurrencyPurchasePaymentAddressRequired - missing payment address err
	ErrCryptocurrencyPurchasePaymentAddressRequired = errors.New("paymentAddress required for cryptocurrency items")
	// ErrCryptocurrencyPurchasePaymentAddressTooLong - invalid payment address
	ErrCryptocurrencyPurchasePaymentAddressTooLong = errors.New("paymentAddress required is too long")

	// ErrFulfillIncorrectDeliveryType - incorrect delivery type err
	ErrFulfillIncorrectDeliveryType = errors.New("incorrect delivery type for order")
	// ErrFulfillCryptocurrencyTXIDNotFound - missing txn id err
	ErrFulfillCryptocurrencyTXIDNotFound = errors.New("a transactionID is required to fulfill crypto listings")
	// ErrFulfillCryptocurrencyTXIDTooLong - invalid txn id err
	ErrFulfillCryptocurrencyTXIDTooLong = errors.New("transactionID should be no longer than " + strconv.Itoa(MaxTXIDSize))

	// ErrUnknownWallet is returned when a wallet is not present on the node
	ErrUnknownWallet = errors.New("Unknown wallet type")

	// ErrInvalidSpendAddress is returned when the wallet is unable to decode the string address into a valid destination to send funds to
	ErrInvalidSpendAddress = errors.New("ERROR_INVALID_ADDRESS")

	// ErrInsufficientFunds is returned when the wallet is unable to send the amount specified due to the balance being too low
	ErrInsufficientFunds = errors.New("ERROR_INSUFFICIENT_FUNDS")

	// ErrInvalidAmount is returned when the string representation of the amount to spend is not an integer
	ErrInvalidAmount = errors.New("Spend amount is invalid or empty")

	// ErrSpendAmountIsDust is returned when the requested amount to spend out of the wallet would be considered "dust" by the network. This means the value is too low for the network to bother sending the amount and has a high likelihood of not being accepted or being outright rejected.
	ErrSpendAmountIsDust = errors.New("ERROR_DUST_AMOUNT")

	// ErrUnknownOrder is returned when the requested amount to spend is unable to be associated with the appropriate order
	ErrOrderNotFound = errors.New("ERROR_ORDER_NOT_FOUND")
)
View Source
var (
	// ErrPostUnknownValidationPanic - post has an unknown panic error
	ErrPostUnknownValidationPanic = errors.New("unexpected validation panic")

	// ErrPostSlugNotEmpty - post slug is empty error
	ErrPostSlugNotEmpty = errors.New("slug must not be empty")

	// ErrPostSlugTooLong - post slug longer than max characters error
	ErrPostSlugTooLong = fmt.Errorf("slug is longer than the max of %d", repo.SentenceMaxCharacters)

	// ErrPostSlugContainsSpaces - post slug has spaces error
	ErrPostSlugContainsSpaces = errors.New("slugs cannot contain spaces")

	// ErrPostSlugContainsSlashes - post slug has file separators
	ErrPostSlugContainsSlashes = errors.New("slugs cannot contain file separators")

	// ErrPostInvalidType - post type is invalid error
	ErrPostInvalidType = errors.New("invalid post type")

	// ErrPostStatusTooLong - post 'status' is longer than max characters error
	ErrPostStatusTooLong = fmt.Errorf("status is longer than the max of %d", PostStatusMaxCharacters)

	// ErrPostBodyTooLong - post 'longForm' is longer than max characters error
	ErrPostBodyTooLong = fmt.Errorf("post is longer than the max of %d characters", PostLongFormMaxCharacters)

	// ErrPostTagsTooMany - post tags longer than max length error
	ErrPostTagsTooMany = fmt.Errorf("tags in the post is longer than the max of %d", PostMaximumTotalTags)

	// ErrPostTagsEmpty - post has empty tags error
	ErrPostTagsEmpty = errors.New("tags must not be empty")

	// ErrPostTagTooLong - post tag has characters longer than max length error
	ErrPostTagTooLong = fmt.Errorf("tags must be less than max of %d characters", PostTagsMaxCharacters)

	// ErrPostChannelsTooMany - post channels longer than max length error
	ErrPostChannelsTooMany = fmt.Errorf("channels in the post is longer than the max of %d", PostMaximumTotalChannels)

	// ErrPostChannelTooLong - post channel has characters longer than max length error
	ErrPostChannelTooLong = fmt.Errorf("channels must be less than max of %d characters", PostChannelsMaxCharacters)

	// ErrPostReferenceEmpty - post has an empty reference error
	ErrPostReferenceEmpty = errors.New("reference must not be empty")

	// ErrPostReferenceTooLong - post reference has characters longer than max length error
	ErrPostReferenceTooLong = fmt.Errorf("reference is longer than the max of %d", PostReferenceMaxCharacters)

	// ErrPostReferenceContainsSpaces - post reference has spaces error
	ErrPostReferenceContainsSpaces = errors.New("reference cannot contain spaces")

	// ErrPostImagesTooMany - post images longer than max error
	ErrPostImagesTooMany = fmt.Errorf("number of post images is greater than the max of %d", repo.MaxListItems)

	// ErrPostImageTinyFormatInvalid - post tiny image hash incorrectly formatted error
	ErrPostImageTinyFormatInvalid = errors.New("tiny image hashes must be properly formatted CID")

	// ErrPostImageSmallFormatInvalid - post small image hash incorrectly formatted error
	ErrPostImageSmallFormatInvalid = errors.New("small image hashes must be properly formatted CID")

	// ErrPostImageMediumFormatInvalid - post medium image hash incorrectly formatted error
	ErrPostImageMediumFormatInvalid = errors.New("medium image hashes must be properly formatted CID")

	// ErrPostImageLargeFInvalidormat - post large image hash incorrectly formatted error
	ErrPostImageLargeFormatInvalid = errors.New("large image hashes must be properly formatted CID")

	// ErrPostImageOriginalFormatInvalid - post original image hash incorrectly formatted error
	ErrPostImageOriginalFormatInvalid = errors.New("original image hashes must be properly formatted CID")

	// ErrPostImageFilenameNil - post image filename is nil error
	ErrPostImageFilenameNil = errors.New("image file names must not be nil")

	// ErrPostImageFilenameTooLong - post image filename length longer than max
	ErrPostImageFilenameTooLong = fmt.Errorf("image filename length must be less than the max of %d", repo.FilenameMaxCharacters)
)

Errors

View Source
var DisputeWg = new(sync.WaitGroup)

DisputeWg - waitgroup for disputes

View Source
var ErrCaseNotFound = errors.New("case not found")

ErrCaseNotFound - case not found err

View Source
var ErrCloseFailureCaseExpired = errors.New("unable to close expired case")

ErrCloseFailureCaseExpired - tried closing expired case err

View Source
var ErrCloseFailureNoOutpoints = errors.New("unable to close case with missing outpoints")

ErrCloseFailureNoOutpoints indicates when a dispute cannot be closed due to neither party including outpoints with their dispute

View Source
var ErrInvalidKey = errors.New("invalid key")
View Source
var (

	// ErrInventoryNotFoundForSlug - inventory not found error
	ErrInventoryNotFoundForSlug = errors.New("could not find slug in inventory")
)
View Source
var ErrNoListings = errors.New("no listings to set moderators on")

ErrNoListings - no listing error FIXME : This is not used anywhere

View Source
var ErrOpenFailureOrderExpired = errors.New("unable to open case because order is too old to dispute")

ErrOpenFailureOrderExpired - tried disputing expired order err

View Source
var ErrorProfileNotFound = errors.New("profile not found")

ErrorProfileNotFound - profile not found error

View Source
var (
	// MaxTXIDSize - max length for order txnID
	MaxTXIDSize = 512
)
View Source
var ModeratorPointerID multihash.Multihash

ModeratorPointerID moderator ipfs multihash

View Source
var OfflineMessageWaitGroup sync.WaitGroup

OfflineMessageWaitGroup - used for offline msgs

Functions

func CheckAndSetUlimit added in v0.9.3

func CheckAndSetUlimit() error

CheckAndSetUlimit raises the file descriptor limit

func FormatRFC3339PB added in v0.10.1

func FormatRFC3339PB(ts google_protobuf.Timestamp) string

FormatRFC3339PB returns the given `google_protobuf.Timestamp` as a RFC3339 formatted string

func GetItemSurchargeAmount added in v0.14.4

func GetItemSurchargeAmount(nrl *repo.Listing, options []*pb.Order_Item_Option) (*big.Int, error)

func GetNormalizedListing added in v0.14.4

func GetNormalizedListing(listingHash string, contract *pb.RicardianContract) (*repo.Listing, error)

func GetOrderQuantity added in v0.12.0

func GetOrderQuantity(l *pb.Listing, item *pb.Order_Item) *big.Int

GetOrderQuantity - return the specified item quantity

func GetOriginalAmount added in v0.14.4

func GetOriginalAmount(nrl *repo.Listing, item *pb.Order_Item) (*repo.CurrencyValue, error)

func GetSelectedSku added in v0.5.1

func GetSelectedSku(listing *pb.Listing, itemOptions []*pb.Order_Item_Option) (int, error)

GetSelectedSku - return the specified item SKU

func GetSignedListingFromPath added in v0.13.1

func GetSignedListingFromPath(p string) (*pb.SignedListing, error)

func GetTotalCouponCodeDiscount added in v0.14.4

func GetTotalCouponCodeDiscount(nrl *repo.Listing, couponCodes []string, itemAmount *repo.CurrencyValue) (*big.Int, error)

func ParseContractForListing added in v0.5.5

func ParseContractForListing(hash string, contract *pb.RicardianContract) (*pb.Listing, error)

ParseContractForListing - return the listing identified by the hash from the contract

func SameSku added in v0.5.1

func SameSku(selectedVariants []int, sku *pb.Listing_Item_Sku) bool

SameSku - check if the variants have the same SKU

func SignPayload added in v0.13.1

func SignPayload(payload []byte, privKey crypto.PrivKey) ([]byte, []byte, error)

SignPayload produces a signature for the given private key and payload and returns it and the public key or an error

func ValidateProfile added in v0.5.3

func ValidateProfile(profile *pb.Profile) error

ValidateProfile - validate fetched profile

func ValidateRating added in v0.6.0

func ValidateRating(rating *pb.Rating) (bool, error)

ValidateRating - validates rating for API GET and Post/Update

func VerifyPayload added in v0.13.1

func VerifyPayload(payload, sig, pubKey []byte) (string, error)

VerifyPayload proves the payload and signature are authentic for the provided public key and returns the peer ID for that pubkey with no error on success

Types

type CodedError added in v0.12.0

type CodedError struct {
	Reason string `json:"reason,omitempty"`
	Code   string `json:"code,omitempty"`
}

CodedError is an error that is machine readable

func (CodedError) Error added in v0.12.0

func (err CodedError) Error() string

type ErrOutOfInventory added in v0.12.0

type ErrOutOfInventory struct {
	CodedError
	RemainingInventory string `json:"remainingInventory"`
}

ErrOutOfInventory is a codedError returned from vendor nodes when buyers try purchasing too many of an item

func NewErrOutOfInventory added in v0.12.0

func NewErrOutOfInventory(inventoryRemaining *big.Int) ErrOutOfInventory

NewErrOutOfInventory - return out of inventory err with available inventory

func (ErrOutOfInventory) Error added in v0.12.0

func (err ErrOutOfInventory) Error() string

type Inventory added in v0.12.0

type Inventory map[string]*InventoryListing

Inventory is the complete inventory representation stored on IPFS It maps slug -> quantity information

type InventoryListing added in v0.12.0

type InventoryListing struct {
	Inventory   string `json:"inventory"`
	LastUpdated string `json:"lastUpdated"`
}

InventoryListing is the listing representation stored on IPFS

type OpenBazaarNode

type OpenBazaarNode struct {
	// IPFS node object
	IpfsNode *core.IpfsNode

	// An implementation of the custom DHT used by OpenBazaar
	DHT *dht.IpfsDHT

	// The roothash of the node directory inside the openbazaar repo.
	// This directory hash is published on IPNS at our peer ID making
	// the directory publicly viewable on the network.
	RootHash string

	// The path to the openbazaar repo in the file system
	RepoPath string

	// The OpenBazaar network service for direct communication between peers
	Service net.NetworkService

	// Database for storing node specific data
	Datastore repo.Datastore

	// Websocket channel used for pushing data to the UI
	Broadcast chan repo.Notifier

	// A map of cryptocurrency wallets
	Multiwallet multiwallet.MultiWallet

	// Storage for our outgoing messages
	MessageStorage sto.OfflineMessagingStorage

	// A service that periodically checks the dht for outstanding messages
	MessageRetriever *ret.MessageRetriever

	// OfflineMessageFailoverTimeout is the duration until the protocol
	// will stop looking for the peer to send a direct message and failover to
	// sending an offline message
	OfflineMessageFailoverTimeout time.Duration

	// A service that periodically republishes active pointers
	PointerRepublisher *rep.PointerRepublisher

	// Optional nodes to push user data to
	PushNodes []peer.ID

	// The user-agent for this node
	UserAgent string

	// A dialer for Tor if available
	TorDialer proxy.Dialer

	// Manage blocked peers
	BanManager *net.BanManager

	// Allow other nodes to push data to this node for storage
	AcceptStoreRequests bool

	// RecordAgingNotifier is a worker that walks the cases datastore to
	// notify the user as disputes age past certain thresholds
	RecordAgingNotifier *recordAgingNotifier

	// Generic pubsub interface
	Pubsub ipfs.Pubsub

	// The master private key derived from the mnemonic
	MasterPrivateKey *hdkeychain.ExtendedKey

	// The number of DHT records to collect before returning. The larger the number
	// the slower the query but the less likely we will get an old record.
	IPNSQuorumSize uint

	TestnetEnable        bool
	RegressionTestEnable bool

	PublishLock sync.Mutex

	InitalPublishComplete bool

	// InboundMsgScanner is a worker that scans the messages
	// table and tries to retry a failed order message
	InboundMsgScanner *inboundMessageScanner
	// contains filtered or unexported fields
}

OpenBazaarNode - represent ob node which encapsulates ipfsnode, wallet etc

var Node *OpenBazaarNode

Node - ob node

func (*OpenBazaarNode) BuildTransactionRecords added in v0.6.2

func (n *OpenBazaarNode) BuildTransactionRecords(contract *pb.RicardianContract, records []*wallet.TransactionRecord, state pb.OrderState) ([]*pb.TransactionRecord, *pb.TransactionRecord, error)

BuildTransactionRecords - Used by the GET order API to build transaction records suitable to be included in the order response

func (*OpenBazaarNode) CalcOrderID added in v0.12.3

func (n *OpenBazaarNode) CalcOrderID(order *pb.Order) (string, error)

CalcOrderID - return b58 encoded orderID

func (*OpenBazaarNode) CalculateOrderTotal added in v0.1.1

func (n *OpenBazaarNode) CalculateOrderTotal(contract *pb.RicardianContract) (*big.Int, error)

func (*OpenBazaarNode) CancelOfflineOrder added in v0.2.0

func (n *OpenBazaarNode) CancelOfflineOrder(contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

CancelOfflineOrder - cancel order

func (*OpenBazaarNode) CheckoutBreakdown added in v0.14.4

func (n *OpenBazaarNode) CheckoutBreakdown(data *repo.PurchaseData) (repo.CheckoutBreakdown, error)

CheckoutBreakdown - returns order total and breakdown of charges

func (*OpenBazaarNode) CloseDispute added in v0.3.0

func (n *OpenBazaarNode) CloseDispute(orderID string, buyerPercentage, vendorPercentage float32, resolution string, paymentCoinHint *repo.CurrencyCode) error

CloseDispute - close a dispute

func (*OpenBazaarNode) CompleteOrder added in v0.2.2

func (n *OpenBazaarNode) CompleteOrder(orderRatings *OrderRatings, contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

CompleteOrder - complete the order

func (*OpenBazaarNode) ConfirmOfflineOrder added in v0.2.0

func (n *OpenBazaarNode) ConfirmOfflineOrder(oldState pb.OrderState, contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

ConfirmOfflineOrder - confirm offline order

func (*OpenBazaarNode) CreateListing added in v0.12.0

func (n *OpenBazaarNode) CreateListing(r []byte) (string, error)

CreateListing - add a listing

func (*OpenBazaarNode) DeleteListing added in v0.1.1

func (n *OpenBazaarNode) DeleteListing(slug string) error

DeleteListing Deletes the listing directory, removes the listing from the index, and deletes the inventory

func (*OpenBazaarNode) DeletePost added in v0.10.1

func (n *OpenBazaarNode) DeletePost(slug string) error

DeletePost [Deletes the post directory, and removes the post from the index]

func (*OpenBazaarNode) DisputeIsActive added in v0.12.1

func (n *OpenBazaarNode) DisputeIsActive(contract *pb.RicardianContract) (bool, error)

DisputeIsActive - check if the dispute is active

func (*OpenBazaarNode) EncryptMessage

func (n *OpenBazaarNode) EncryptMessage(peerID peer.ID, peerKey *libp2p.PubKey, message []byte) (ct []byte, rerr error)

EncryptMessage This is a placeholder until the libsignal is operational.

For now we will just encrypt outgoing offline messages with the long lived identity key.
Optionally you may provide a public key, to avoid doing an IPFS lookup

func (*OpenBazaarNode) EstimateOrderTotal added in v0.5.5

func (n *OpenBazaarNode) EstimateOrderTotal(data *repo.PurchaseData) (*big.Int, error)

EstimateOrderTotal - returns order total in satoshi/wei

func (*OpenBazaarNode) FetchAvatar added in v0.6.0

func (n *OpenBazaarNode) FetchAvatar(peerID string, size string, useCache bool) (io.ReadSeeker, error)

FetchAvatar - fetch image avatar from ipfs

func (*OpenBazaarNode) FetchHeader added in v0.6.0

func (n *OpenBazaarNode) FetchHeader(peerID string, size string, useCache bool) (io.ReadSeeker, error)

FetchHeader - fetch image header from ipfs

func (*OpenBazaarNode) FetchImage added in v0.6.0

func (n *OpenBazaarNode) FetchImage(peerID string, imageType string, size string, useCache bool) (io.ReadSeeker, error)

FetchImage - fetch ipfs image

func (*OpenBazaarNode) FetchProfile added in v0.5.0

func (n *OpenBazaarNode) FetchProfile(peerID string, useCache bool) (pb.Profile, error)

FetchProfile - fetch peer's profile

func (*OpenBazaarNode) Follow

func (n *OpenBazaarNode) Follow(peerID string) error

Follow - follow a peer

func (*OpenBazaarNode) FulfillOrder added in v0.2.1

func (n *OpenBazaarNode) FulfillOrder(fulfillment *pb.OrderFulfillment, contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

FulfillOrder - fulfill the order

func (*OpenBazaarNode) GeneratePostSlug added in v0.10.1

func (n *OpenBazaarNode) GeneratePostSlug(status string) (string, error)

GeneratePostSlug [Create a slug for the post based on the status, if a slug is missing]

func (*OpenBazaarNode) GetBase64Image added in v0.6.3

func (n *OpenBazaarNode) GetBase64Image(url string) (base64ImageData, filename string, err error)

GetBase64Image - fetch the image and return it as base64 encoded string

func (*OpenBazaarNode) GetListingCount

func (n *OpenBazaarNode) GetListingCount() int

GetListingCount Return the current number of listings

func (*OpenBazaarNode) GetListingFromHash added in v0.1.1

func (n *OpenBazaarNode) GetListingFromHash(hash string) (*pb.SignedListing, error)

GetListingFromHash - fetch listing for the specified hash

func (*OpenBazaarNode) GetListingFromSlug added in v0.1.1

func (n *OpenBazaarNode) GetListingFromSlug(slug string) (*pb.SignedListing, error)

GetListingFromSlug - fetch listing for the specified slug

func (*OpenBazaarNode) GetListings added in v0.2.3

func (n *OpenBazaarNode) GetListings() ([]byte, error)

GetListings - fetch all listings

func (*OpenBazaarNode) GetLocalInventory added in v0.12.0

func (n *OpenBazaarNode) GetLocalInventory() (Inventory, error)

GetLocalInventory gets the inventory from the database

func (*OpenBazaarNode) GetLocalInventoryForSlug added in v0.12.0

func (n *OpenBazaarNode) GetLocalInventoryForSlug(slug string) (*InventoryListing, error)

GetLocalInventoryForSlug gets the local inventory for the given slug

func (*OpenBazaarNode) GetModeratorFee added in v0.3.0

func (n *OpenBazaarNode) GetModeratorFee(transactionTotal *big.Int, txCurrencyCode string) (*big.Int, error)

GetModeratorFee is called by the Moderator when determining their take of the dispute

func (*OpenBazaarNode) GetNodeID added in v0.14.0

func (n *OpenBazaarNode) GetNodeID() (*pb.ID, error)

GetNodeID returns the protobuf representing the node's identity and crypto keys with the peer ID

func (*OpenBazaarNode) GetOrder added in v0.13.8

func (n *OpenBazaarNode) GetOrder(orderID string) (*pb.OrderRespApi, error)

GetOrder - provide API response order object by orderID

func (*OpenBazaarNode) GetPeerStatus

func (n *OpenBazaarNode) GetPeerStatus(peerID string) (string, error)

GetPeerStatus - check if a peer is online/offline

func (*OpenBazaarNode) GetPostCount added in v0.10.1

func (n *OpenBazaarNode) GetPostCount() int

GetPostCount [Return the current number of posts]

func (*OpenBazaarNode) GetPostFromHash added in v0.10.1

func (n *OpenBazaarNode) GetPostFromHash(hash string) (*pb.SignedPost, error)

GetPostFromHash [Get a post based on the hash]

func (*OpenBazaarNode) GetPostFromSlug added in v0.10.1

func (n *OpenBazaarNode) GetPostFromSlug(slug string) (*pb.SignedPost, error)

GetPostFromSlug [Get a post based on the slug]

func (*OpenBazaarNode) GetPosts added in v0.10.1

func (n *OpenBazaarNode) GetPosts() ([]byte, error)

GetPosts [Get a list of the posts]

func (*OpenBazaarNode) GetProfile

func (n *OpenBazaarNode) GetProfile() (pb.Profile, error)

GetProfile - fetch user profile

func (*OpenBazaarNode) GetPublishedInventoryBytes added in v0.12.0

func (n *OpenBazaarNode) GetPublishedInventoryBytes(p peer.ID, useCache bool) ([]byte, error)

GetPublishedInventoryBytes gets a byte slice representing the given peer's inventory that it published to IPFS

func (*OpenBazaarNode) GetPublishedInventoryBytesForSlug added in v0.12.0

func (n *OpenBazaarNode) GetPublishedInventoryBytesForSlug(p peer.ID, slug string, useCache bool) ([]byte, error)

GetPublishedInventoryBytesForSlug gets a byte slice representing the given slug's inventory from IPFS

func (*OpenBazaarNode) GetRatingCounts added in v0.9.4

func (n *OpenBazaarNode) GetRatingCounts() (uint32, float32, error)

GetRatingCounts - fetch rating count

func (*OpenBazaarNode) IPFSIdentityString added in v0.12.0

func (n *OpenBazaarNode) IPFSIdentityString() string

IPFSIdentityString - IPFS identifier

func (*OpenBazaarNode) IsFulfilled added in v0.2.1

func (n *OpenBazaarNode) IsFulfilled(contract *pb.RicardianContract) bool

IsFulfilled - check is order is fulfilled

func (*OpenBazaarNode) IsItemForSale added in v0.2.0

func (n *OpenBazaarNode) IsItemForSale(listing *pb.Listing) bool

IsItemForSale Check to see we are selling the given listing. Used when validating an order. FIXME: This won't scale well. We will need to store the hash of active listings in a db to do an indexed search.

func (*OpenBazaarNode) IsModerator added in v0.5.0

func (n *OpenBazaarNode) IsModerator() bool

IsModerator - Am I a moderator?

func (*OpenBazaarNode) LookupCurrency added in v0.14.0

func (n *OpenBazaarNode) LookupCurrency(currencyCode string) (repo.CurrencyDefinition, error)

LookupCurrency looks up the CurrencyDefinition from available currencies

func (*OpenBazaarNode) NewOrderConfirmation added in v0.2.0

func (n *OpenBazaarNode) NewOrderConfirmation(contract *pb.RicardianContract, addressRequest bool) (*pb.RicardianContract, error)

NewOrderConfirmation - add order confirmation to the contract

func (*OpenBazaarNode) NotifyModerators added in v0.5.1

func (n *OpenBazaarNode) NotifyModerators(addedMods, removedMods []string) error

NotifyModerators - notify moderators(peers)

func (*OpenBazaarNode) OpenDispute added in v0.3.0

func (n *OpenBazaarNode) OpenDispute(orderID string, contract *pb.RicardianContract, records []*wallet.TransactionRecord, claim string) error

OpenDispute - open a dispute

func (*OpenBazaarNode) PatchProfile added in v0.4.3

func (n *OpenBazaarNode) PatchProfile(patch map[string]interface{}) error

PatchProfile - patch user profile

func (*OpenBazaarNode) ProcessDisputeOpen added in v0.3.0

func (n *OpenBazaarNode) ProcessDisputeOpen(rc *pb.RicardianContract, peerID string) error

ProcessDisputeOpen - process an open dispute

func (*OpenBazaarNode) PublishInventory added in v0.12.0

func (n *OpenBazaarNode) PublishInventory() error

PublishInventory stores an inventory on IPFS

func (*OpenBazaarNode) Purchase

func (n *OpenBazaarNode) Purchase(data *repo.PurchaseData) (orderID string, paymentAddress string, paymentAmount *repo.CurrencyValue, vendorOnline bool, err error)

Purchase - add ricardian contract

func (*OpenBazaarNode) RefundOrder added in v0.2.1

func (n *OpenBazaarNode) RefundOrder(contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

RefundOrder - refund buyer

func (*OpenBazaarNode) RegressionNetworkEnabled added in v0.11.1

func (n *OpenBazaarNode) RegressionNetworkEnabled() bool

RegressionNetworkEnabled indicates whether the node is operating with regression parameters

func (*OpenBazaarNode) RejectOfflineOrder added in v0.2.0

func (n *OpenBazaarNode) RejectOfflineOrder(contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

RejectOfflineOrder - reject offline order

func (*OpenBazaarNode) ReleaseFunds added in v0.3.0

func (n *OpenBazaarNode) ReleaseFunds(contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

ReleaseFunds - release funds

func (*OpenBazaarNode) ReleaseFundsAfterTimeout added in v0.7.0

func (n *OpenBazaarNode) ReleaseFundsAfterTimeout(contract *pb.RicardianContract, records []*wallet.TransactionRecord) error

ReleaseFundsAfterTimeout - release funds

func (*OpenBazaarNode) RemoveSelfAsModerator added in v0.1.1

func (n *OpenBazaarNode) RemoveSelfAsModerator() error

RemoveSelfAsModerator - relinquish moderatorship

func (*OpenBazaarNode) ResendCachedOrderMessage added in v0.13.5

func (n *OpenBazaarNode) ResendCachedOrderMessage(orderID string, msgType pb.Message_MessageType) error

ResendCachedOrderMessage will retrieve the ORDER message from the datastore and resend it to the peerID for which it was originally intended

func (*OpenBazaarNode) ReserveCurrencyConverter added in v0.14.0

func (n *OpenBazaarNode) ReserveCurrencyConverter() (*repo.CurrencyConverter, error)

ReserveCurrencyConverter will attempt to build a CurrencyConverter based on the reserve currency, or will panic if unsuccessful

func (*OpenBazaarNode) SeedNode

func (n *OpenBazaarNode) SeedNode() error

SeedNode - publish to IPNS

func (*OpenBazaarNode) SendBlock added in v0.9.3

func (n *OpenBazaarNode) SendBlock(peerID string, id cid.Cid) error

SendBlock - send requested ipfs block to peer

func (*OpenBazaarNode) SendCancel added in v0.2.0

func (n *OpenBazaarNode) SendCancel(peerID, orderID string) error

SendCancel - send order canceled msg to peer

func (*OpenBazaarNode) SendChat added in v0.3.1

func (n *OpenBazaarNode) SendChat(peerID string, chatMessage *pb.Chat) error

SendChat - send chat msg to peer

func (*OpenBazaarNode) SendDisputeClose added in v0.3.0

func (n *OpenBazaarNode) SendDisputeClose(peerID string, k *libp2p.PubKey, resolutionMessage *pb.RicardianContract, orderID string) error

SendDisputeClose - send dispute closed msg to peer

func (*OpenBazaarNode) SendDisputeOpen added in v0.3.0

func (n *OpenBazaarNode) SendDisputeOpen(peerID string, k *libp2p.PubKey, disputeMessage *pb.RicardianContract, orderID string) error

SendDisputeOpen - send open dispute msg to peer

func (*OpenBazaarNode) SendDisputeUpdate added in v0.3.0

func (n *OpenBazaarNode) SendDisputeUpdate(peerID string, updateMessage *pb.DisputeUpdate) error

SendDisputeUpdate - send update dispute msg to peer

func (*OpenBazaarNode) SendError added in v0.11.1

func (n *OpenBazaarNode) SendError(peerID string, k *libp2p.PubKey, errorMessage pb.Message) error

SendError - send error msg to peer

func (*OpenBazaarNode) SendFundsReleasedByVendor added in v0.12.1

func (n *OpenBazaarNode) SendFundsReleasedByVendor(peerID string, marshalledPeerPublicKey []byte, orderID string) error

SendFundsReleasedByVendor - send funds released by vendor msg to peer

func (*OpenBazaarNode) SendModeratorAdd added in v0.5.1

func (n *OpenBazaarNode) SendModeratorAdd(peerID string) error

SendModeratorAdd - send add moderator msg to peer

func (*OpenBazaarNode) SendModeratorRemove added in v0.5.1

func (n *OpenBazaarNode) SendModeratorRemove(peerID string) error

SendModeratorRemove - send remove moderator msg to peer

func (*OpenBazaarNode) SendOfflineAck

func (n *OpenBazaarNode) SendOfflineAck(peerID string, pointerID peer.ID) error

SendOfflineAck - send ack to offline peer

func (*OpenBazaarNode) SendOfflineMessage

func (n *OpenBazaarNode) SendOfflineMessage(p peer.ID, k *libp2p.PubKey, m *pb.Message) error

SendOfflineMessage Supply of a public key is optional, if nil is instead provided n.EncryptMessage does a lookup

func (*OpenBazaarNode) SendOfflineRelay added in v0.12.4

func (n *OpenBazaarNode) SendOfflineRelay(peerID string, encryptedMessage []byte) error

SendOfflineRelay - send and offline relay message to the peer. Used for relaying messages from a client node to another peer.

func (*OpenBazaarNode) SendOrder added in v0.1.1

func (n *OpenBazaarNode) SendOrder(peerID string, contract *pb.RicardianContract) (resp *pb.Message, err error)

SendOrder - send order created msg to peer

func (*OpenBazaarNode) SendOrderCompletion added in v0.2.2

func (n *OpenBazaarNode) SendOrderCompletion(peerID string, k *libp2p.PubKey, completionMessage *pb.RicardianContract) error

SendOrderCompletion - send order completion msg to peer

func (*OpenBazaarNode) SendOrderConfirmation added in v0.2.0

func (n *OpenBazaarNode) SendOrderConfirmation(peerID string, contract *pb.RicardianContract) error

SendOrderConfirmation - send order confirmed msg to peer

func (*OpenBazaarNode) SendOrderFulfillment added in v0.2.1

func (n *OpenBazaarNode) SendOrderFulfillment(peerID string, k *libp2p.PubKey, fulfillmentMessage *pb.RicardianContract) error

SendOrderFulfillment - send order fulfillment msg to peer

func (*OpenBazaarNode) SendOrderPayment added in v0.13.5

func (n *OpenBazaarNode) SendOrderPayment(spend *SpendResponse) error

SendOrderPayment - send order payment msg to seller from buyer

func (*OpenBazaarNode) SendProcessingError added in v0.13.5

func (n *OpenBazaarNode) SendProcessingError(pid, oid string, attemptedMessage pb.Message_MessageType, latestContract *pb.RicardianContract) error

SendProcessingError will encapsulate the failing state in a message to be sent back to pid When pid receives the OrderProcessingError, it will analyze the contract and send the messages that this node is missing to resynchronize the order

func (*OpenBazaarNode) SendRefund added in v0.2.1

func (n *OpenBazaarNode) SendRefund(peerID string, refundMessage *pb.RicardianContract) error

SendRefund - send refund msg to peer

func (*OpenBazaarNode) SendReject added in v0.2.0

func (n *OpenBazaarNode) SendReject(peerID string, rejectMessage *pb.OrderReject) error

SendReject - send order rejected msg to peer

func (*OpenBazaarNode) SendStore added in v0.9.3

func (n *OpenBazaarNode) SendStore(peerID string, ids []cid.Cid) error

SendStore - send requested stores to peer

func (*OpenBazaarNode) SetAvatarImages added in v0.2.0

func (n *OpenBazaarNode) SetAvatarImages(base64ImageData string) (*pb.Profile_Image, error)

SetAvatarImages - set avatar image from the base64 encoded image string

func (*OpenBazaarNode) SetCurrencyOnListings added in v0.13.1

func (n *OpenBazaarNode) SetCurrencyOnListings(currencies []string) error

SetCurrencyOnListings - set currencies accepted for a listing

func (*OpenBazaarNode) SetHeaderImages added in v0.2.0

func (n *OpenBazaarNode) SetHeaderImages(base64ImageData string) (*pb.Profile_Image, error)

SetHeaderImages - set header image from the base64 encoded string

func (*OpenBazaarNode) SetListingInventory

func (n *OpenBazaarNode) SetListingInventory(l repo.Listing) error

SetListingInventory sets the inventory for the listing in the database. Does some basic validation to make sure the inventory uses the correct variants.

func (*OpenBazaarNode) SetModeratorsOnListings added in v0.4.3

func (n *OpenBazaarNode) SetModeratorsOnListings(moderators []string) error

SetModeratorsOnListings - set moderators for a listing

func (*OpenBazaarNode) SetPriceOnListings added in v0.14.3

func (n *OpenBazaarNode) SetPriceOnListings(percentage float64) error

func (*OpenBazaarNode) SetProductImages added in v0.2.0

func (n *OpenBazaarNode) SetProductImages(base64ImageData, filename string) (*pb.Profile_Image, error)

SetProductImages - use the original image ina base64 string format and generate tiny, small, medium and large images for the product

func (*OpenBazaarNode) SetSelfAsModerator added in v0.1.1

func (n *OpenBazaarNode) SetSelfAsModerator(moderator *pb.Moderator) error

SetSelfAsModerator - set self as a moderator

func (*OpenBazaarNode) SetUpRepublisher added in v0.9.3

func (n *OpenBazaarNode) SetUpRepublisher(interval time.Duration)

SetUpRepublisher - periodic publishing to IPNS

func (*OpenBazaarNode) Sign added in v0.14.0

func (n *OpenBazaarNode) Sign(payload []byte) ([]byte, error)

Sign returns a signature for the payload signed by the IPFS private key

func (*OpenBazaarNode) SignDispute added in v0.3.0

func (n *OpenBazaarNode) SignDispute(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignDispute - sign the dispute

func (*OpenBazaarNode) SignDisputeResolution added in v0.3.0

func (n *OpenBazaarNode) SignDisputeResolution(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignDisputeResolution - add signature to DisputeResolution

func (*OpenBazaarNode) SignOrder added in v0.2.0

func (n *OpenBazaarNode) SignOrder(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignOrder - add signature to the order

func (*OpenBazaarNode) SignOrderCompletion added in v0.2.2

func (n *OpenBazaarNode) SignOrderCompletion(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignOrderCompletion - sign order on completion

func (*OpenBazaarNode) SignOrderConfirmation added in v0.2.0

func (n *OpenBazaarNode) SignOrderConfirmation(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignOrderConfirmation - sign the added order confirmation

func (*OpenBazaarNode) SignOrderFulfillment added in v0.2.1

func (n *OpenBazaarNode) SignOrderFulfillment(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignOrderFulfillment - add signature to order fulfillment

func (*OpenBazaarNode) SignPost added in v0.10.1

func (n *OpenBazaarNode) SignPost(post *pb.Post) (*pb.SignedPost, error)

SignPost [Add the peer's identity to the post and sign it]

func (*OpenBazaarNode) SignRefund added in v0.2.1

func (n *OpenBazaarNode) SignRefund(contract *pb.RicardianContract) (*pb.RicardianContract, error)

SignRefund - add signature to refund

func (*OpenBazaarNode) Spend added in v0.13.0

func (n *OpenBazaarNode) Spend(args *SpendRequest) (*SpendResponse, error)

Spend will attempt to move funds from the node to the destination address described in the SpendRequest for the amount indicated.

func (*OpenBazaarNode) StartInboundMsgScanner added in v0.14.0

func (n *OpenBazaarNode) StartInboundMsgScanner()

StartInboundMsgScanner - start the notifier

func (*OpenBazaarNode) StartMessageRetriever added in v0.12.1

func (n *OpenBazaarNode) StartMessageRetriever()

StartMessageRetriever will collect the required options from the OpenBazaarNode and begin the MessageRetriever in the background

func (*OpenBazaarNode) StartPointerRepublisher added in v0.12.1

func (n *OpenBazaarNode) StartPointerRepublisher()

StartPointerRepublisher - setup republisher for IPNS

func (*OpenBazaarNode) StartRecordAgingNotifier added in v0.12.1

func (n *OpenBazaarNode) StartRecordAgingNotifier()

StartRecordAgingNotifier - start the notifier

func (*OpenBazaarNode) TestNetworkEnabled added in v0.11.1

func (n *OpenBazaarNode) TestNetworkEnabled() bool

TestNetworkEnabled indicates whether the node is operating with test parameters

func (*OpenBazaarNode) Unfollow

func (n *OpenBazaarNode) Unfollow(peerID string) error

Unfollow - unfollow a peer

func (*OpenBazaarNode) UpdateEachListingOnIndex added in v0.11.1

func (n *OpenBazaarNode) UpdateEachListingOnIndex(updateListing func(*repo.ListingIndexData) error) error

UpdateEachListingOnIndex will visit each listing in the index and execute the function with a pointer to the listing passed as the argument. The function should return an error to further processing.

func (*OpenBazaarNode) UpdateFollow

func (n *OpenBazaarNode) UpdateFollow() error

UpdateFollow This function updates the follow and following lists in the node's root directory

as well as adds the current follow, following, and listing counts to the profile.
We only do this when a user updates his node to avoid needing to make network calls
each time a new follower or unfollow request comes in.

func (*OpenBazaarNode) UpdateListing added in v0.12.0

func (n *OpenBazaarNode) UpdateListing(r []byte, publish bool) error

UpdateListing - update the listing

func (*OpenBazaarNode) UpdatePostHashes added in v0.10.1

func (n *OpenBazaarNode) UpdatePostHashes(hashes map[string]string) error

UpdatePostHashes [Update the hashes in the posts.json file]

func (*OpenBazaarNode) UpdatePostIndex added in v0.10.1

func (n *OpenBazaarNode) UpdatePostIndex(post *pb.SignedPost) error

UpdatePostIndex [Update the posts index]

func (*OpenBazaarNode) UpdateProfile

func (n *OpenBazaarNode) UpdateProfile(profile *pb.Profile) error

UpdateProfile - update user profile

func (*OpenBazaarNode) ValidateAndSaveRating added in v0.2.2

func (n *OpenBazaarNode) ValidateAndSaveRating(contract *pb.RicardianContract) (retErr error)

ValidateAndSaveRating - validates rating

func (*OpenBazaarNode) ValidateCaseContract added in v0.3.0

func (n *OpenBazaarNode) ValidateCaseContract(contract *pb.RicardianContract) []string

ValidateCaseContract - validate contract details

func (*OpenBazaarNode) ValidateDirectPaymentAddress added in v0.2.0

func (n *OpenBazaarNode) ValidateDirectPaymentAddress(order *pb.Order) error

ValidateDirectPaymentAddress - validate address

func (*OpenBazaarNode) ValidateDisputeResolution added in v0.3.0

func (n *OpenBazaarNode) ValidateDisputeResolution(contract *pb.RicardianContract) error

ValidateDisputeResolution - validate dispute resolution

func (*OpenBazaarNode) ValidateModeratedPaymentAddress added in v0.2.1

func (n *OpenBazaarNode) ValidateModeratedPaymentAddress(order *pb.Order, timeout time.Duration) error

ValidateModeratedPaymentAddress - validate moderator address

func (*OpenBazaarNode) ValidateMultiwalletHasPreferredCurrencies added in v0.13.0

func (n *OpenBazaarNode) ValidateMultiwalletHasPreferredCurrencies(data repo.SettingsData) error

func (*OpenBazaarNode) ValidateOrder added in v0.2.0

func (n *OpenBazaarNode) ValidateOrder(contract *pb.RicardianContract, checkInventory bool) error

ValidateOrder - check the order validity wrt signatures etc

func (*OpenBazaarNode) ValidateOrderCompletion added in v0.2.2

func (n *OpenBazaarNode) ValidateOrderCompletion(contract *pb.RicardianContract) error

ValidateOrderCompletion - validate order signatures on completion

func (*OpenBazaarNode) ValidateOrderConfirmation added in v0.2.1

func (n *OpenBazaarNode) ValidateOrderConfirmation(contract *pb.RicardianContract, validateAddress bool) error

ValidateOrderConfirmation - validate address and signatures for order confirmation

func (*OpenBazaarNode) ValidateOrderFulfillment added in v0.2.1

func (n *OpenBazaarNode) ValidateOrderFulfillment(fulfillment *pb.OrderFulfillment, contract *pb.RicardianContract) error

ValidateOrderFulfillment - validate order details

func (*OpenBazaarNode) ValidatePaymentAmount added in v0.4.0

func (n *OpenBazaarNode) ValidatePaymentAmount(requestedAmount, paymentAmount *big.Int) bool

ValidatePaymentAmount - validate amount requested

func (*OpenBazaarNode) VerifySignatureOnDisputeOpen added in v0.3.0

func (n *OpenBazaarNode) VerifySignatureOnDisputeOpen(contract *pb.RicardianContract, peerID string) error

VerifySignatureOnDisputeOpen - verify signatures in an open dispute

func (*OpenBazaarNode) VerifySignaturesOnRefund added in v0.2.1

func (n *OpenBazaarNode) VerifySignaturesOnRefund(contract *pb.RicardianContract) error

VerifySignaturesOnRefund - verify signatures on refund

func (*OpenBazaarNode) WaitForMessageRetrieverCompletion added in v0.12.1

func (n *OpenBazaarNode) WaitForMessageRetrieverCompletion()

WaitForMessageRetrieverCompletion will return once the MessageRetriever has finished processing messages

type OrderRatings added in v0.2.2

type OrderRatings struct {
	OrderID string       `json:"orderId"`
	Ratings []RatingData `json:"ratings"`
}

OrderRatings - record ratings for an order

type RatingData added in v0.2.2

type RatingData struct {
	Slug            string `json:"slug"`
	Overall         int    `json:"overall"`
	Quality         int    `json:"quality"`
	Description     int    `json:"description"`
	DeliverySpeed   int    `json:"deliverySpeed"`
	CustomerService int    `json:"customerService"`
	Review          string `json:"review"`
	Anonymous       bool   `json:"anonymous"`
}

RatingData - record rating in detail

type SavedRating added in v0.6.0

type SavedRating struct {
	Slug    string   `json:"slug"`
	Count   int      `json:"count"`
	Average float32  `json:"average"`
	Ratings []string `json:"ratings"`
}

SavedRating - represent saved rating

type SpendRequest added in v0.13.0

type SpendRequest struct {
	Amount                 string                   `json:"amount"`
	Currency               *repo.CurrencyDefinition `json:"currency"`
	CurrencyCode           string                   `json:"currencyCode"`
	Address                string                   `json:"address"`
	FeeLevel               string                   `json:"feeLevel"`
	Memo                   string                   `json:"memo"`
	OrderID                string                   `json:"orderId"`
	RequireAssociatedOrder bool                     `json:"requireOrder"`
	SpendAll               bool                     `json:"spendAll"`
	// contains filtered or unexported fields
}

type SpendResponse added in v0.13.0

type SpendResponse struct {
	Amount             string                   `json:"amount"`
	ConfirmedBalance   string                   `json:"confirmedBalance"`
	UnconfirmedBalance string                   `json:"unconfirmedBalance"`
	Currency           *repo.CurrencyDefinition `json:"currency"`
	Memo               string                   `json:"memo"`
	OrderID            string                   `json:"orderId"`
	Timestamp          time.Time                `json:"timestamp"`
	Txid               string                   `json:"txid"`
	PeerID             string                   `json:"-"`
	ConsumedInput      bool                     `json:"-"`
}

Jump to

Keyboard shortcuts

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