buxclient

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 10 Imported by: 0

README

BUX: Go Client

Release Build Status Report codecov Mergify Status

Go Gitpod Ready-to-Code standard-readme compliant Makefile Included


Get started using BUX in five minutes

Table of Contents


About

Read more about BUX


Installation

go-buxclient requires a supported release of Go.

go get -u github.com/BuxOrg/go-buxclient

Documentation

View the generated documentation

GoDoc


Repository Features

This repository was created using MrZ's go-template

Built-in Features
Package Dependencies
Library Deployment

Releases are automatically created when you create a new git tag!

If you want to manually make releases, please install GoReleaser:

goreleaser for easy binary or library deployment to GitHub and can be installed:

  • using make: make install-releaser
  • using brew: brew install goreleaser

The .goreleaser.yml file is used to configure goreleaser.


Automatic releases via GitHub Actions from creating a new tag:

make tag version=1.2.3

Manual Releases (optional)

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production (manually).


Makefile Commands

View all makefile commands

make help

List of all current commands:

all                           Runs multiple commands
clean                         Remove previous builds and any cached data
clean-mods                    Remove all the Go mod cache
coverage                      Shows the test coverage
diff                          Show the git diff
generate                      Runs the go generate command in the base of the repo
godocs                        Sync the latest tag with GoDocs
help                          Show this help message
install                       Install the application
install-all-contributors      Installs all contributors locally
install-go                    Install the application (Using Native Go)
install-releaser              Install the GoReleaser application
lint                          Run the golangci-lint application (install if not found)
release                       Full production release (creates release in GitHub)
release                       Runs common.release then runs godocs
release-snap                  Test the full release (build binaries)
release-test                  Full production test release (everything except deploy)
replace-version               Replaces the version in HTML/JS (pre-deploy)
tag                           Generate a new tag and push (tag version=0.0.0)
tag-remove                    Remove a tag if found (tag-remove version=0.0.0)
tag-update                    Update an existing tag to current commit (tag-update version=0.0.0)
test                          Runs lint and ALL tests
test-ci                       Runs all tests via CI (exports coverage)
test-ci-no-race               Runs all tests via CI (no race) (exports coverage)
test-ci-short                 Runs unit tests via CI (exports coverage)
test-no-lint                  Runs just tests
test-short                    Runs vet, lint and tests (excludes integration tests)
test-unit                     Runs tests and outputs coverage
uninstall                     Uninstall the application (and remove files)
update-contributors           Regenerates the contributors html/list
update-linter                 Update the golangci-lint package (macOS only)
vet                           Run the Go vet application

Usage

Checkout all the examples!


Examples & Tests

All unit tests and examples run via GitHub Actions and uses Go version 1.19.x. View the configuration file.


Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Benchmarks

Run the Go benchmarks:

make bench

Code Standards

Read more about this Go project's code standards.


Usage

// http example
func main() {

	// Generate keys
	keys, _ := xpriv.Generate()

	// Create a client
	client, _ := buxclient.New(
        buxclient.WithXPriv(keys.XPriv()),
        buxclient.WithHTTP("localhost:3001"),
        buxclient.WithSignRequest(true))
    
    fmt.Println(client.IsSignRequest())
}

Checkout all the examples!


Contributing

All kinds of contributions are welcome!
To get started, take a look at code standards.
View the contributing guidelines and follow the code of conduct.


License

License

Documentation

Overview

Package buxclient is a Go client for interacting with Bux Servers

If you have any suggestions or comments, please feel free to open an issue on this GitHub repository!

By BuxOrg (https://github.com/BuxOrg)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuxClient

type BuxClient struct {
	transports.TransportService
	// contains filtered or unexported fields
}

BuxClient is the go-buxclient

func New

func New(opts ...ClientOps) (*BuxClient, error)

New create a new bux client

func (*BuxClient) CreateAccessKey added in v0.1.2

func (b *BuxClient) CreateAccessKey(ctx context.Context, metadata *buxmodels.Metadata) (*buxmodels.AccessKey, transports.ResponseError)

CreateAccessKey creates new access key

func (*BuxClient) DraftToRecipients

func (b *BuxClient) DraftToRecipients(ctx context.Context, recipients []*transports.Recipients,
	metadata *buxmodels.Metadata,
) (*buxmodels.DraftTransaction, transports.ResponseError)

DraftToRecipients initialize a new P2PKH draft transaction to a list of recipients

func (*BuxClient) DraftTransaction

func (b *BuxClient) DraftTransaction(ctx context.Context, transactionConfig *buxmodels.TransactionConfig,
	metadata *buxmodels.Metadata,
) (*buxmodels.DraftTransaction, transports.ResponseError)

DraftTransaction initialize a new draft transaction

func (*BuxClient) FinalizeTransaction

func (b *BuxClient) FinalizeTransaction(draft *buxmodels.DraftTransaction) (string, transports.ResponseError)

FinalizeTransaction will finalize the transaction

func (*BuxClient) GetAccessKey added in v0.1.2

GetAccessKey gets the access key given by id

func (*BuxClient) GetAccessKeys added in v0.1.2

func (b *BuxClient) GetAccessKeys(ctx context.Context, metadataConditions *buxmodels.Metadata) ([]*buxmodels.AccessKey, transports.ResponseError)

GetAccessKeys gets all the access keys filtered by the metadata

func (*BuxClient) GetDestinationByAddress added in v0.1.2

func (b *BuxClient) GetDestinationByAddress(ctx context.Context, address string) (*buxmodels.Destination, transports.ResponseError)

GetDestinationByAddress gets the destination by address

func (*BuxClient) GetDestinationByID added in v0.1.2

func (b *BuxClient) GetDestinationByID(ctx context.Context, id string) (*buxmodels.Destination, transports.ResponseError)

GetDestinationByID gets the destination by id

func (*BuxClient) GetDestinationByLockingScript added in v0.1.2

func (b *BuxClient) GetDestinationByLockingScript(ctx context.Context,
	lockingScript string,
) (*buxmodels.Destination, transports.ResponseError)

GetDestinationByLockingScript gets the destination by locking script

func (*BuxClient) GetDestinations added in v0.1.2

func (b *BuxClient) GetDestinations(ctx context.Context,
	metadataConditions *buxmodels.Metadata,
) ([]*buxmodels.Destination, transports.ResponseError)

GetDestinations gets all destinations that match the metadata filter

func (*BuxClient) GetTransaction

func (b *BuxClient) GetTransaction(ctx context.Context, txID string) (*buxmodels.Transaction, transports.ResponseError)

GetTransaction get a transaction by id

func (*BuxClient) GetTransactions

func (b *BuxClient) GetTransactions(ctx context.Context, conditions map[string]interface{},
	metadata *buxmodels.Metadata, queryParams *transports.QueryParams,
) ([]*buxmodels.Transaction, transports.ResponseError)

GetTransactions get all transactions matching search criteria

func (*BuxClient) GetTransactionsCount added in v0.3.4

func (b *BuxClient) GetTransactionsCount(ctx context.Context, conditions map[string]interface{},
	metadata *buxmodels.Metadata,
) (int64, transports.ResponseError)

GetTransactionsCount get number of user transactions

func (*BuxClient) GetTransport

func (b *BuxClient) GetTransport() *transports.TransportService

GetTransport returns the current transport service

func (*BuxClient) GetXPub added in v0.1.2

GetXPub gets the current xpub

func (*BuxClient) IsSignRequest

func (b *BuxClient) IsSignRequest() bool

IsSignRequest return whether to sign all requests

func (*BuxClient) NewDestination added in v0.1.2

NewDestination create a new destination and return it

func (*BuxClient) NewPaymail added in v0.1.7

func (b *BuxClient) NewPaymail(ctx context.Context, rawXPub, paymailAddress, avatar, publicName string, metadata *buxmodels.Metadata) transports.ResponseError

NewPaymail will create a new paymail

func (*BuxClient) NewXpub added in v0.1.7

func (b *BuxClient) NewXpub(ctx context.Context, rawXPub string, metadata *buxmodels.Metadata) transports.ResponseError

NewXpub registers a new xpub - admin key needed

func (*BuxClient) RecordTransaction

func (b *BuxClient) RecordTransaction(ctx context.Context, hex, draftID string,
	metadata *buxmodels.Metadata,
) (*buxmodels.Transaction, transports.ResponseError)

RecordTransaction record a new transaction

func (*BuxClient) RevokeAccessKey added in v0.1.2

func (b *BuxClient) RevokeAccessKey(ctx context.Context, id string) (*buxmodels.AccessKey, transports.ResponseError)

RevokeAccessKey revoked the access key given by id

func (*BuxClient) SendToRecipients

func (b *BuxClient) SendToRecipients(ctx context.Context, recipients []*transports.Recipients,
	metadata *buxmodels.Metadata,
) (*buxmodels.Transaction, transports.ResponseError)

SendToRecipients send to recipients

func (*BuxClient) SetAdminKey

func (b *BuxClient) SetAdminKey(adminKeyString string) error

SetAdminKey set the admin key to use to create new xpubs

func (*BuxClient) SetSignRequest

func (b *BuxClient) SetSignRequest(signRequest bool)

SetSignRequest turn the signing of the http request on or off

func (*BuxClient) UnreserveUtxos added in v0.3.9

func (b *BuxClient) UnreserveUtxos(ctx context.Context, referenceID string) transports.ResponseError

UnreserveUtxos unreserves utxos from draft transaction

func (*BuxClient) UpdateDestinationMetadataByAddress added in v0.1.7

func (b *BuxClient) UpdateDestinationMetadataByAddress(ctx context.Context, address string,
	metadata *buxmodels.Metadata,
) (*buxmodels.Destination, transports.ResponseError)

UpdateDestinationMetadataByAddress updates the destination metadata by address

func (*BuxClient) UpdateDestinationMetadataByID added in v0.1.7

func (b *BuxClient) UpdateDestinationMetadataByID(ctx context.Context, id string,
	metadata *buxmodels.Metadata,
) (*buxmodels.Destination, transports.ResponseError)

UpdateDestinationMetadataByID updates the destination metadata by id

func (*BuxClient) UpdateDestinationMetadataByLockingScript added in v0.1.7

func (b *BuxClient) UpdateDestinationMetadataByLockingScript(ctx context.Context, lockingScript string,
	metadata *buxmodels.Metadata,
) (*buxmodels.Destination, transports.ResponseError)

UpdateDestinationMetadataByLockingScript updates the destination metadata by locking script

func (*BuxClient) UpdateTransactionMetadata added in v0.1.7

func (b *BuxClient) UpdateTransactionMetadata(ctx context.Context, txID string,
	metadata *buxmodels.Metadata,
) (*buxmodels.Transaction, transports.ResponseError)

UpdateTransactionMetadata update the metadata of a transaction

func (*BuxClient) UpdateXPubMetadata added in v0.1.7

func (b *BuxClient) UpdateXPubMetadata(ctx context.Context, metadata *buxmodels.Metadata) (*buxmodels.Xpub, transports.ResponseError)

UpdateXPubMetadata update the metadata of the logged in xpub

type ClientOps

type ClientOps func(c *BuxClient)

ClientOps are used for client options

func WithAccessKey

func WithAccessKey(accessKeyString string) ClientOps

WithAccessKey will set the access key on the client

func WithAdminKey

func WithAdminKey(adminKey string) ClientOps

WithAdminKey will set the admin key for admin requests

func WithHTTP

func WithHTTP(serverURL string) ClientOps

WithHTTP will overwrite the default client with a custom client

func WithHTTPClient

func WithHTTPClient(serverURL string, httpClient *http.Client) ClientOps

WithHTTPClient will overwrite the default client with a custom client

func WithSignRequest

func WithSignRequest(signRequest bool) ClientOps

WithSignRequest will set whether to sign all requests

func WithXPriv

func WithXPriv(xPrivString string) ClientOps

WithXPriv will set xPrivString on the client

func WithXPub

func WithXPub(xPubString string) ClientOps

WithXPub will set xPubString on the client

Directories

Path Synopsis
examples
Package transports encapsulates the different ways to communicate with BUX
Package transports encapsulates the different ways to communicate with BUX
Package utils contains utility functions for the wallet like hashes and crypto functions
Package utils contains utility functions for the wallet like hashes and crypto functions

Jump to

Keyboard shortcuts

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