cmd

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MPL-2.0 Imports: 25 Imported by: 13

README

Below is the command structure for bat-go microservices using cobra

create a macaroon

# needs an example.yaml file to work
./bat-go macaroon create

with options

MACAROON_SECRET=a9ed2c16-3cf6-446f-8978-e707bead3979 \
./bat-go macaroon create --config "macaroon-config.yaml"

start rewards rest server

./bat-go serve rewards rest

with options

./bat-go serve rewards rest \
  --config "config.yaml" \
  --ratios-token "abc" --ratios-service "123" --environment "local" \
  --base-currency "USD" --address ":4321"

start rewards grpc server

./bat-go serve rewards grpc

with options

./bat-go serve rewards grpc \
  --config "config.yaml" \
  --ratios-token "abc" --ratios-service "123" --environment "local" \
  --base-currency "USD" --address ":4321"

check server fingerprints

./bat-go get-cert-fingerprint "brave.com:443"

paypal settlement

transform

./bat-go settlement paypal transform \
  --input "paypal-settlement-from-antifraud.json" \
  --currency "JPY"

with other options

./bat-go settlement paypal transform \
  --input "paypal-settlement-from-antifraud.json" \
  --currency "JPY" \
  --rate "104.75" \
  --out "paypal-settlement-from-antifraud-complete.json"

complete

./bat-go settlement paypal complete \
  --input "paypal-settlement-from-antifraud.json" \
  --txn-id "30ad1991-b2d3-4897-ae52-09efcd174235"

with output option

./bat-go settlement paypal complete \
  --input "paypal-settlement-from-antifraud.json" \
  --txn-id "30ad1991-b2d3-4897-ae52-09efcd174235" \
  --out   "paypal-settlement-complete.json"

email

./bat-go settlement paypal email \
  --input "paypal-settlement-from-antifraud.json"

gemini settlement

upload

./bat-go settlement gemini upload \
  --input "gemini-contribution-signed.json" \
  --all-txs-input "4ae996f5-679b-46c6-9aea-9892f763ffe6" \
  --sig 0

with output

./bat-go settlement gemini upload \
  --input "gemini-contribution-signed.json" \
  --all-txs-input "4ae996f5-679b-46c6-9aea-9892f763ffe6" \
  --sig 0 \
  --out "gemini-contribution-signed-completed.json"

checkstatus

./bat-go settlement gemini checkstatus \
  --input "gemini-contribution-signed.json" \
  --all-txs-input "4ae996f5-679b-46c6-9aea-9892f763ffe6"

bitflyer settlement

equivalent envs are available as flags ENV_KEY -> --env-key

refresh token

After running the refres token command, you will need to copy the value in the printed auth.access_token field into your .env file and source that file. This can now be used with the other bitflyer commands. The env name should be BITFLYER_TOKEN.

BITFLYER_CLIENT_ID=
BITFLYER_CLIENT_SECRET=
BITFLYER_EXTRA_CLIENT_SECRET=
BITFLYER_SERVER=
./bat-go settlement bitflyer token

at this point, it makes sense to run the sign-settlement command so that transactions are split across multiple files, however this is not strictly necessary to do because we do all of the transforms needed in the upload step.

upload

BITFLYER_SOURCE_FROM=tipping
BITFLYER_SERVER=
# omit to execute
BITFLYER_DRYRUN=1 # seconds to delay
./bat-go bitflyer upload \
  --in "bitflyer-transactions.json" \
  --exclude-limited true # if a transaction ever hits transfer limit, do not send it

checkstatus

BITFLYER_SOURCE_FROM=tipping
BITFLYER_SERVER=
./bat-go bitflyer checkstatus \
  --in "bitflyer-transactions.json"

wallet

create

./bat-go wallet create \
  --provider "uphold" \
  --name "test"

vault create wallet

./bat-go vault create-wallet

create offline

./bat-go vault create-wallet --offline true

transfer funds

with vault inputs

./bat-go wallet transfer-funds \
  --provider "uphold" \
  --from "1234567890" \
  --to "1234567890" \
  --usevault true \ # get secrets from vault
  --value "10.5"

with env inputs

ED25519_PRIVATE_KEY= \
UPHOLD_PROVIDER_ID= \
./bat-go wallet transfer-funds \
  --provider "uphold" \
  --from "1234567890" \
  --to "1234567890" \
  --value "10.5"

vault

init

./bat-go vault init \
  --key-shares 1 \
  --key-threshold 1 \
  ./key.asc

import key

ED25519_PRIVATE_KEY=
ED25519_PUBLIC_KEY=
UPHOLD_PROVIDER_ID=
GEMINI_CLIENT_ID=
GEMINI_CLIENT_KEY=
GEMINI_CLIENT_SECRET=
./bat-go vault import-key \
  --config "config.yaml"

only import a subset of the keys with --wallet-refs

./bat-go vault import-key \
  --config "config.yaml" \
  --wallet-refs "gemini-referral"

sign settlement

uses inputs from vault

./bat-go vault sign-settlement \
  --config "config.yaml" \
  --input "contributions.json" \
  --providers "uphold,gemini"

unseal

unseals vault

gpg -d ./share-0.gpg | ./bat-go vault unseal

generate

json-schema

generates json schemas

go run main.go generate json-schema

with override

go run main.go generate json-schema --overwrite

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenerateCmd = &cobra.Command{
	Use:   "generate",
	Short: "entrypoint to generate subcommands",
}

GenerateCmd is the generate command

View Source
var (
	// GetCertFingerprintCmd is the GetCertFingerprint command
	GetCertFingerprintCmd = &cobra.Command{
		Use:   "get-cert-fingerprint",
		Short: "A helper for fetching tls fingerprint info for pinning",
		Run:   Perform("get cert fingerprint", GetCertFingerprint),
	}
)
View Source
var JSONSchemaCmd = &cobra.Command{
	Use:   "json-schema",
	Short: "entrypoint to generate json schema for project",
	Run:   Perform("generate json schema", jsonSchemaRun),
}

JSONSchemaCmd is the json schema command

View Source
var (
	// RootCmd is the base command (what the binary is called)
	RootCmd = &cobra.Command{
		Use:   "bat-go",
		Short: "bat-go provides go based services and processes for BAT",
	}
)
View Source
var ServeCmd = &cobra.Command{
	Use:   "serve",
	Short: "entrypoint to serve a micro-service",
}

ServeCmd the serve command

View Source
var VersionCmd = &cobra.Command{
	Use:   "version",
	Short: "get the version of this binary",
	Run:   versionRun,
}

VersionCmd is the command to get the code's version information

Functions

func CheckFingerprints added in v0.4.0

func CheckFingerprints(ctx context.Context, addresses []string) error

CheckFingerprints checks the fingerprints at the following address

func Execute

func Execute(version, commit, buildTime string)

Execute - the main entrypoint for all subcommands in bat-go

func GetCertFingerprint added in v0.4.0

func GetCertFingerprint(cmd *cobra.Command, args []string) error

GetCertFingerprint runs the command for GetCertFingerprint

func Must added in v0.4.0

func Must(err error)

Must helper to make sure there is no errors

func Perform added in v0.4.0

func Perform(action string, fn func(cmd *cobra.Command, args []string) error) func(cmd *cobra.Command, args []string)

Perform performs a run

func SetupRouter added in v0.4.0

func SetupRouter(ctx context.Context) *chi.Mux

SetupRouter sets up a router

Types

type FlagBuilder added in v0.4.0

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

FlagBuilder creates a flag builder

func NewFlagBuilder added in v0.4.0

func NewFlagBuilder(command *cobra.Command) *FlagBuilder

NewFlagBuilder creates a new FlagBuilder from one command

func (*FlagBuilder) AddCommand added in v0.4.0

func (fb *FlagBuilder) AddCommand(command *cobra.Command) *FlagBuilder

AddCommand adds a command

func (*FlagBuilder) Bind added in v0.4.0

func (fb *FlagBuilder) Bind(key string) *FlagBuilder

Bind runs the BindPFlag function

func (*FlagBuilder) Bool added in v0.4.0

func (fb *FlagBuilder) Bool(key string, defaultValue bool, description string) *FlagBuilder

Bool attaches a bool flag to the command

func (*FlagBuilder) Concat added in v0.4.0

func (fb *FlagBuilder) Concat(builders ...*FlagBuilder) *FlagBuilder

Concat combine flag builders

func (*FlagBuilder) Duration added in v0.5.0

func (fb *FlagBuilder) Duration(key string, defaultValue time.Duration, description string) *FlagBuilder

Duration attaches a string flag to the command

func (*FlagBuilder) Env added in v0.4.0

func (fb *FlagBuilder) Env(env string) *FlagBuilder

Env attaches an env

func (*FlagBuilder) Flag added in v0.4.0

func (fb *FlagBuilder) Flag() *FlagBuilder

Flag resets the builder to allow for chaining

func (*FlagBuilder) Float64 added in v0.4.0

func (fb *FlagBuilder) Float64(key string, defaultValue float64, description string) *FlagBuilder

Float64 attaches a float64 type flag to the command

func (*FlagBuilder) Int added in v0.4.0

func (fb *FlagBuilder) Int(key string, defaultValue int, description string) *FlagBuilder

Int attaches an int flag to the command

func (*FlagBuilder) Require added in v0.4.0

func (fb *FlagBuilder) Require() *FlagBuilder

Require requires the flag

func (*FlagBuilder) SetKey added in v0.4.0

func (fb *FlagBuilder) SetKey(key string) *FlagBuilder

SetKey sets the key to be shared across methods

func (*FlagBuilder) String added in v0.4.0

func (fb *FlagBuilder) String(key string, defaultValue string, description string) *FlagBuilder

String attaches a string flag to the command

func (*FlagBuilder) StringSlice added in v0.4.0

func (fb *FlagBuilder) StringSlice(key string, defaultValue []string, description string) *FlagBuilder

StringSlice attaches a string slice flag to the command

func (*FlagBuilder) Uint added in v0.4.0

func (fb *FlagBuilder) Uint(key string, defaultValue uint, description string) *FlagBuilder

Uint attaches an uint flag to the command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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