bisquit

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

README

Build Status Go Report Card GoDoc

Bisquit: Bisq API client

(c) 2021 Bernd Fix brf@hoi-polloi.org >Y<

bisquit is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

bisquit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.

SPDX-License-Identifier: AGPL3.0-or-later

Prerequisites

This library is intended to be used with Go1.16+ and might not work correctly on previous versions.

Protobuf compiler

You need to have a newer protobuf compiler for Go installed on your system; make sure you installed necessary dependencies:

go get -u google.golang.org/grpc
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
Protobuf definitions

You also need the Protobuf definitions from the Bisq source tree (found at proto/src/main/proto/grpc.proto and proto/src/main/proto/pb.proto to generate Go stubs for the gRPC process. These files are copied to this repository and are kept up to date if possible; if I miss to update them you can just copy them over from the newest Bisq source tree and modify both of them by adding

option go_package = ".;bisquit";

in the option section at the beginning of the *.proto files.

Building

Generating Protobuf stubs

To generate the Go code for the Protobuf definitions run

./proto-gen.sh

This should generate three new Go files: grpc_grpc.pb.go, grpc.pb.go and pb.pb.go.

Compiling the library

Make sure all dependencies are installed by running

go mod tidy

and then build the library with

go build

Testing

Bisq daemon

You need a running Bisq daemon (v1.5.4+) with enabled gRPC and API password to run the unit tests. Use

export BISQ_API_PASSWORD="my_secret"
export BISQ_API_HOST="localhost:9998"

to pass the API password and host settings to the tests.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientConnected    = fmt.Errorf("Client already connected")
	ErrClientNotConnected = fmt.Errorf("Client not connected")
)

Error codes

Functions

This section is empty.

Types

type Client

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

Client for Bisq API calls

func NewClient

func NewClient(host, passwd string) *Client

NewClient instaniates a new Bisq client

func (*Client) CancelOffer

func (c *Client) CancelOffer(ctx context.Context, ID string) error

CancelOffer to terminate an active offering

func (*Client) Close

func (c *Client) Close() error

Close connection to Bisq gRPC server

func (*Client) ConfirmPaymentReceived

func (c *Client) ConfirmPaymentReceived(ctx context.Context, tradeID string) error

ConfirmPaymentReceived closes an arbitration process for payments

func (*Client) ConfirmPaymentStarted

func (c *Client) ConfirmPaymentStarted(ctx context.Context, tradeID string) error

ConfirmPaymentStarted starts the arbitration process for payments

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) (err error)

Connect to Bisq gRPC server

func (*Client) CreateOffer

func (c *Client) CreateOffer(ctx context.Context, req *CreateOfferRequest) (*OfferInfo, error)

CreateOffer to create a new offering

func (*Client) CreatePaymentAccount

func (c *Client) CreatePaymentAccount(ctx context.Context, form string) (*PaymentAccount, error)

CreatePaymentAccount creates a new payment account

func (*Client) GetAddressBalance

func (c *Client) GetAddressBalance(ctx context.Context, addr string) (*AddressBalanceInfo, error)

GetAddressBalance returns the balance for a Bitcoin address

func (*Client) GetBalances

func (c *Client) GetBalances(ctx context.Context, curr string) (*BalancesInfo, error)

GetBalances returns balance info for given currency

func (*Client) GetFundingAddresses

func (c *Client) GetFundingAddresses(ctx context.Context) ([]*AddressBalanceInfo, error)

GetFundingAddresses returns a list of available funding addresses

func (*Client) GetMarketPrice

func (c *Client) GetMarketPrice(ctx context.Context, curr string) (float64, error)

GetMarketPrice returns the price of Bitcoin in the given currency

func (*Client) GetMyOffer

func (c *Client) GetMyOffer(ctx context.Context, ID string) (*OfferInfo, error)

GetMyOffer returns our offer for a given ID

func (*Client) GetMyOffers

func (c *Client) GetMyOffers(ctx context.Context, dir, curr string) ([]*OfferInfo, error)

GetMyOffers returns all of our offers for given criteria

func (*Client) GetOffer

func (c *Client) GetOffer(ctx context.Context, ID string) (*OfferInfo, error)

GetOffer returns the offer for a given ID

func (*Client) GetOffers

func (c *Client) GetOffers(ctx context.Context, dir, curr string) ([]*OfferInfo, error)

GetOffers returns all offers for given criteria

func (*Client) GetPaymentAccountForm

func (c *Client) GetPaymentAccountForm(ctx context.Context, mthdID string) (map[string]interface{}, error)

GetPaymentAccountForm returns a template for payment accounts

func (*Client) GetPaymentAccounts

func (c *Client) GetPaymentAccounts(ctx context.Context) ([]*PaymentAccount, error)

GetPaymentAccounts returns a list of payment accounts

func (*Client) GetPaymentMethods

func (c *Client) GetPaymentMethods(ctx context.Context) ([]*PaymentMethod, error)

GetPaymentMethods returns all available payment methods

func (*Client) GetTrade

func (c *Client) GetTrade(ctx context.Context, ID string) (*TradeInfo, error)

GetTrade returns the offer information for a trade with given ID

func (*Client) GetTradeStatistics

func (c *Client) GetTradeStatistics(ctx context.Context) ([]*TradeStatistics3, error)

GetTradeStatistics returns a list of past trades

func (*Client) GetTransaction

func (c *Client) GetTransaction(ctx context.Context, txID string) (*TxInfo, error)

GetTransaction with the specified ID

func (*Client) GetTxFeeRate

func (c *Client) GetTxFeeRate(ctx context.Context) (*TxFeeRateInfo, error)

GetTxFeeRate returns information about the proposed fee rate

func (*Client) GetUnusedBsqAddress

func (c *Client) GetUnusedBsqAddress(ctx context.Context) (string, error)

GetUnusedBsqAddress returns an unused BSQ address in the wallet

func (*Client) GetVersion

func (c *Client) GetVersion(ctx context.Context) (string, error)

GetVersion returns the version of the Bisq server

func (*Client) KeepFunds

func (c *Client) KeepFunds(ctx context.Context, tradeID string) error

KeepFunds cancels a payment process

func (*Client) LockWallet

func (c *Client) LockWallet(ctx context.Context) error

LockWallet locks a wallet from further usage

func (*Client) RemoveWalletPassword

func (c *Client) RemoveWalletPassword(ctx context.Context, passwd string) error

RemoveWalletPassword removes password protection from the wallet

func (*Client) SendBsq

func (c *Client) SendBsq(ctx context.Context, address, amount, txFeeRate string) (*TxInfo, error)

SendBsq to transfer given amount of BSQ to address

func (*Client) SendBtc

func (c *Client) SendBtc(ctx context.Context, address, amount, txFeeRate, memo string) (*TxInfo, error)

SendBtc to send given amount of Bitcoin to address

func (*Client) SetTxFeeRatePreference

func (c *Client) SetTxFeeRatePreference(ctx context.Context, pref uint64) (*TxFeeRateInfo, error)

SetTxFeeRatePreference sets the preferred TxFeeRate

func (*Client) SetWalletPassword

func (c *Client) SetWalletPassword(ctx context.Context, passwdOld, passwdNew string) error

SetWalletPassword sets a new password for the wallet

func (*Client) TakeOffer

func (c *Client) TakeOffer(ctx context.Context, offerID, accountID, takerFeeCurrency string) (*TradeInfo, error)

TakeOffer accepts an offer with given ID

func (*Client) UnlockWallet

func (c *Client) UnlockWallet(ctx context.Context, passwd string, timeout uint64) error

UnlockWallet with password for given period of time

func (*Client) UnsetTxFeeRatePreference

func (c *Client) UnsetTxFeeRatePreference(ctx context.Context) (*TxFeeRateInfo, error)

UnsetTxFeeRatePreference unsets any previously specified preferene

func (*Client) WithdrawFunds

func (c *Client) WithdrawFunds(ctx context.Context, tradeID, address, memo string) error

WithdrawFunds cancels a trade and withdraws Bitcoins to an address

type PasswordCredential

type PasswordCredential string

PasswordCredential for Bisq API authentication: Must match "apiPassword=..." in "bisq.properties"

func (PasswordCredential) GetRequestMetadata

func (c PasswordCredential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata for API password authentication

func (PasswordCredential) RequireTransportSecurity

func (c PasswordCredential) RequireTransportSecurity() bool

RequireTransportSecurity signals that insecure (local) connections are fine

Jump to

Keyboard shortcuts

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