openbazaar-go/schema

Version: 0.12.4

Source: https://github.com/OpenBazaar/openbazaar-go/

import "github.com/OpenBazaar/openbazaar-go/schema"

Overview

Index

Constants

const (
    // SQL Statements
    PragmaUserVersionSQL                    = "pragma user_version = 0;"
    CreateTableConfigSQL                    = "create table config (key text primary key not null, value blob);"
    CreateTableFollowersSQL                 = "create table followers (peerID text primary key not null, proof blob);"
    CreateTableFollowingSQL                 = "create table following (peerID text primary key not null);"
    CreateTableOfflineMessagesSQL           = "create table offlinemessages (url text primary key not null, timestamp integer, message blob);"
    CreateTablePointersSQL                  = "create table pointers (pointerID text primary key not null, key text, address text, cancelID text, purpose integer, timestamp integer);"
    CreateTableKeysSQL                      = "create table keys (scriptAddress text primary key not null, purpose integer, keyIndex integer, used integer, key text, coin text);"
    CreateIndexKeysSQL                      = "create index index_keys on keys (coin);"
    CreateTableUnspentTransactionOutputsSQL = "create table utxos (outpoint text primary key not null, value integer, height integer, scriptPubKey text, watchOnly integer, coin text);"
    CreateIndexUnspentTransactionOutputsSQL = "create index index_utxos on utxos (coin);"
    CreateTableSpentTransactionOutputsSQL   = "create table stxos (outpoint text primary key not null, value integer, height integer, scriptPubKey text, watchOnly integer, spendHeight integer, spendTxid text, coin text);"
    CreateIndexSpentTransactionOutputsSQL   = "create index index_stxos on stxos (coin);"
    CreateTableTransactionsSQL              = "create table txns (txid text primary key not null, value integer, height integer, timestamp integer, watchOnly integer, tx blob, coin text);"
    CreateIndexTransactionsSQL              = "create index index_txns on txns (coin);"
    CreateTableTransactionMetadataSQL       = "create table txmetadata (txid text primary key not null, address text, memo text, orderID text, thumbnail text, canBumpFee integer);"
    CreateTableInventorySQL                 = "create table inventory (invID text primary key not null, slug text, variantIndex integer, count integer);"
    CreateIndexInventorySQL                 = "create index index_inventory on inventory (slug);"
    CreateTablePurchasesSQL                 = "create table purchases (orderID text primary key not null, contract blob, state integer, read integer, timestamp integer, total integer, thumbnail text, vendorID text, vendorHandle text, title text, shippingName text, shippingAddress text, paymentAddr text, funded integer, transactions blob, lastDisputeTimeoutNotifiedAt integer not null default 0, lastDisputeExpiryNotifiedAt integer not null default 0, disputedAt integer not null default 0, coinType not null default '', paymentCoin not null default '');"
    CreateIndexPurchasesSQL                 = "create index index_purchases on purchases (paymentAddr, timestamp);"
    CreateTableSalesSQL                     = "create table sales (orderID text primary key not null, contract blob, state integer, read integer, timestamp integer, total integer, thumbnail text, buyerID text, buyerHandle text, title text, shippingName text, shippingAddress text, paymentAddr text, funded integer, transactions blob, needsSync integer, lastDisputeTimeoutNotifiedAt integer not null default 0, coinType not null default '', paymentCoin not null default '');"
    CreateIndexSalesSQL                     = "create index index_sales on sales (paymentAddr, timestamp);"
    CreatedTableWatchedScriptsSQL           = "create table watchedscripts (scriptPubKey text primary key not null, coin text);"
    CreateIndexWatchedScriptsSQL            = "create index index_watchscripts on watchedscripts (coin);"
    CreateTableDisputedCasesSQL             = "create table cases (caseID text primary key not null, buyerContract blob, vendorContract blob, buyerValidationErrors blob, vendorValidationErrors blob, buyerPayoutAddress text, vendorPayoutAddress text, buyerOutpoints blob, vendorOutpoints blob, state integer, read integer, timestamp integer, buyerOpened integer, claim text, disputeResolution blob, lastDisputeExpiryNotifiedAt integer not null default 0, coinType not null default '', paymentCoin not null default '');"
    CreateIndexDisputedCasesSQL             = "create index index_cases on cases (timestamp);"
    CreateTableChatSQL                      = "create table chat (messageID text primary key not null, peerID text, subject text, message text, read integer, timestamp integer, outgoing integer);"
    CreateIndexChatSQL                      = "create index index_chat on chat (peerID, subject, read, timestamp);"
    CreateTableNotificationsSQL             = "create table notifications (notifID text primary key not null, serializedNotification blob, type text, timestamp integer, read integer);"
    CreateIndexNotificationsSQL             = "create index index_notifications on notifications (read, type, timestamp);"
    CreateTableCouponsSQL                   = "create table coupons (slug text, code text, hash text);"
    CreateIndexCouponsSQL                   = "create index index_coupons on coupons (slug);"
    CreateTableModeratedStoresSQL           = "create table moderatedstores (peerID text primary key not null);"

    // Configuration defaults
    DataPushNodeOne = "QmY8puEnVx66uEet64gAf4VZRo7oUyMCwG6KdB9KM92EGQ"
    DataPushNodeTwo = "QmPPg2qeF3n2KvTRXRZLaTwHCw8JxzF4uZK93RfMoDvf2o"

    BootstrapNodeTestnet_BrooklynFlea     = "/ip4/165.227.117.91/tcp/4001/ipfs/Qmaa6De5QYNqShzPb9SGSo8vLmoUte8mnWgzn4GYwzuUYA"
    BootstrapNodeTestnet_Shipshewana      = "/ip4/46.101.221.165/tcp/4001/ipfs/QmVAQYg7ygAWTWegs8HSV2kdW1MqW8WMrmpqKG1PQtkgTC"
    BootstrapNodeDefault_LeMarcheSerpette = "/ip4/107.170.133.32/tcp/4001/ipfs/QmUZRGLhcKXF1JyuaHgKm23LvqcoMYwtb9jmh8CkP4og3K"
    BootstrapNodeDefault_BrixtonVillage   = "/ip4/139.59.174.197/tcp/4001/ipfs/QmZfTbnpvPwxCjpCG3CXJ7pfexgkBZ2kgChAiRJrTK1HsM"
    BootstrapNodeDefault_Johari           = "/ip4/139.59.6.222/tcp/4001/ipfs/QmRDcEDK9gSViAevCHiE6ghkaBCU7rTuQj4BDpmCzRvRYg"
    BootstrapNodeDefault_DuoSearch        = "/ip4/46.101.198.170/tcp/4001/ipfs/QmePWxsFT9wY3QuukgVDB7XZpqdKhrqJTHTXU7ECLDWJqX"
)
const (
    CurrentSchemaVersion  = "8"
    IdentityKeyLength     = 4096
    DefaultSeedPassphrase = "Secret Passphrase"
)

Variables

var (
    DataPushNodes = []string{DataPushNodeOne, DataPushNodeTwo}

    BootstrapAddressesDefault = []string{
        BootstrapNodeDefault_LeMarcheSerpette,
        BootstrapNodeDefault_BrixtonVillage,
        BootstrapNodeDefault_Johari,
        BootstrapNodeDefault_DuoSearch,
    }
    BootstrapAddressesTestnet = []string{
        BootstrapNodeTestnet_BrooklynFlea,
        BootstrapNodeTestnet_Shipshewana,
    }
)
var (
    // Errors
    ErrorEmptyMnemonic = errors.New("mnemonic string must not be empty")
)
var MalformedConfigError error = errors.New("Config file is malformed")

func CreateIdentityKey

func CreateIdentityKey(mnemonic string) ([]byte, error)

IdentityKey will return a []byte representing a node’s verifiable identity based on the provided mnemonic string. If the string is empty, it will return an error

func GenerateTempPath

func GenerateTempPath() string

GenerateTempPath returns a string path representing the location where it is okay to store temporary data. No structure or created or deleted as part of this operation.

func GetDropboxApiToken

func GetDropboxApiToken(cfgBytes []byte) (string, error)

func GetRepublishInterval

func GetRepublishInterval(cfgBytes []byte) (time.Duration, error)

func GetTestnetBootstrapAddrs

func GetTestnetBootstrapAddrs(cfgBytes []byte) ([]string, error)

func InitializeDatabaseSQL

func InitializeDatabaseSQL(encryptionPassword string) string

InitializeDatabaseSQL returns the executeable SQL string which initializes the database schema. It assumes the target is an empty SQLite3 database which supports encryption via the PRAGMA key statement

func MustDefaultConfig

func MustDefaultConfig() *config.Config

func MustNewCustomSchemaManager

func MustNewCustomSchemaManager(ctx SchemaContext) *openbazaarSchemaManager

MustNewCustomSchemaManager returns a new schema manager or panics

func NewCustomSchemaManager

func NewCustomSchemaManager(ctx SchemaContext) (*openbazaarSchemaManager, error)

NewCustomSchemaManger allows a custom SchemaContext to be provided

func NewMnemonic

func NewMnemonic() (string, error)

NewMnemonic will return a randomly-generated BIP-39 compliant mnemonic

func NewSchemaManager

func NewSchemaManager() (*openbazaarSchemaManager, error)

NewSchemaManager returns a service that handles the data storage directory required during runtime. This service also ensures no errors can be produced at runtime after initial creation. An error may be produced if the SchemaManager is unable to verify the availability of the data storage directory.

func OpenbazaarPathTransform

func OpenbazaarPathTransform(basePath string, testModeEnabled bool) (path string, err error)

DefaultPathTransform accepts a string path representing the location where application data can be stored and returns a string representing the location where OpenBazaar prefers to store its schema on the filesystem relative to that path. If the path cannot be transformed, an error will be returned

func PragmaKey

func PragmaKey(password string) string

PragmaKey returns the executable SQL string to encrypt the database

type APIConfig

type APIConfig struct {
    Authenticated bool
    AllowedIPs    []string
    Username      string
    Password      string
    CORS          *string
    Enabled       bool
    HTTPHeaders   map[string]interface{}
    SSL           bool
    SSLCert       string
    SSLKey        string
}

func GetAPIConfig

func GetAPIConfig(cfgBytes []byte) (*APIConfig, error)

type CoinConfig

type CoinConfig struct {
    Type             string
    API              string
    APITestnet       string
    MaxFee           int
    FeeAPI           string
    HighFeeDefault   int
    MediumFeeDefault int
    LowFeeDefault    int
}

type DataSharing

type DataSharing struct {
    AcceptStoreRequests bool
    PushTo              []string
}

func GetDataSharing

func GetDataSharing(cfgBytes []byte) (*DataSharing, error)

type ResolverConfig

type ResolverConfig struct {
    Id  string `json:".id"`
    Eth string `json:".eth"`
}

func GetResolverConfig

func GetResolverConfig(cfgBytes []byte) (*ResolverConfig, error)

type SchemaContext

type SchemaContext struct {
    DataPath        string
    IdentityKey     []byte
    Mnemonic        string
    OS              string
    SchemaPassword  string
    TestModeEnabled bool
}

SchemaContext are the parameters which the SchemaManager derive its source of truth. When their zero values are provided, a reasonable default will be assumed during runtime.

type TorConfig

type TorConfig struct {
    Password   string
    TorControl string
}

func GetTorConfig

func GetTorConfig(cfgBytes []byte) (*TorConfig, error)

type WalletConfig

type WalletConfig struct {
    Type             string
    Binary           string
    MaxFee           int
    FeeAPI           string
    HighFeeDefault   int
    MediumFeeDefault int
    LowFeeDefault    int
    TrustedPeer      string
}

func GetWalletConfig

func GetWalletConfig(cfgBytes []byte) (*WalletConfig, error)

type WalletsConfig

type WalletsConfig struct {
    BTC CoinConfig `json:"BTC"`
    BCH CoinConfig `json:"BCH"`
    LTC CoinConfig `json:"LTC"`
    ZEC CoinConfig `json:"ZEC"`
}

func GetWalletsConfig

func GetWalletsConfig(cfgBytes []byte) (*WalletsConfig, error)

Generated by godoc2md