kaminarigosdk

package module
v0.0.0-...-985a39b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 0 Imported by: 0

README

Kaminari Go SDK

A Golang package for the using Kaminari API.

Installation
go get -u github.com/BoostyLabs/kaminari-go-sdk
Basic Usage

Grab your API token and Secret Key. With that creds and Kaminari's API url you could initialize client.

package main

import (
    "log"

    kaminari "github.com/BoostyLabs/kaminari-go-sdk"
    "github.com/BoostyLabs/kaminari-go-sdk/client"
)

func main() {
    cl, err := client.DefaultClient(&client.Config{
        ApiKey:     "[API_KEY]",
        SecretKey:  "[SECRET_KEY]",
        ApiUrl:     "[API_URL]",
    })
    if err != nil {
    	log.Println(err)
        return	
    }

    balance, err := cl.GetBalance("1")
    if err != nil {
        log.Println(err)
        return
    }

    log.Println("your balance", balance)
}

More examples you could find in client_test.go file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	TotalBalance int64 `json:"totalBalance"`
	FrozenAmount int64 `json:"frozenAmount"`
}

type BitcoinInvoiceIsPaid

type BitcoinInvoiceIsPaid struct {
	BitcoinAddress string `json:"bitcoin_address"`
}

type ConvertLnUrlInvoiceToLNDRequest

type ConvertLnUrlInvoiceToLNDRequest struct {
	LnrulInvoice string `json:"lnurl_invoice"`
	Amount       int    `help:"amount should be specified in satoshis"`
	Nonce        string `json:"nonce"`
}

type ConvertLnUrlInvoiceToLNDResponse

type ConvertLnUrlInvoiceToLNDResponse struct {
	Invoice string `json:"invoice"`
}

type CreateInvoiceRequest

type CreateInvoiceRequest struct {
	Amount      int64  `json:"amount"`
	Description string `json:"description"`
	MerchantID  string `json:"merchant_id"`
	Nonce       string `json:"nonce"`
	GroupID     string `json:"group_id"`
}

type CreateLightningInvoiceResponse

type CreateLightningInvoiceResponse struct {
	ID      string `json:"id"`
	Invoice string `json:"invoice"`
}

type EstimateOnChainTxRequest

type EstimateOnChainTxRequest struct {
	BitcoinAddress string `json:"bitcoin_address"`
	Amount         int64  `json:"amount"`
	Nonce          string `json:"nonce"`
}

type EstimateOnChainTxResponse

type EstimateOnChainTxResponse struct {
	Fee int64 `json:"amount"`
}

type Event

type Event struct {
	EventType              EventType               `json:"event_type"`
	LightningInvoiceIsPaid *LightningInvoiceIsPaid `json:"lightning_invoice_is_paid,omitempty"`
	BitcoinInvoiceIsPaid   *BitcoinInvoiceIsPaid   `json:"bitcoin_invoice_is_paid,omitempty"`
}

type EventType

type EventType int32
const (
	EventType_EVENT_TYPE_UNSPECIFIED               EventType = 0
	EventType_EVENT_TYPE_LIGHTNING_INVOICE_IS_PAID EventType = 1
	EventType_EVENT_TYPE_BITCOIN_INVOICE_IS_PAID   EventType = 2
)

type FilteredLightningInvoice

type FilteredLightningInvoice struct {
	ID             string        `json:"id"`
	EncodedInvoice string        `json:"encoded_invoice"`
	Description    string        `json:"description"`
	Amount         int64         `json:"amount"`
	Status         InvoiceStatus `json:"status"`
	CreatedAt      *Timestamp    `json:"created_at"`
}

type FilteredLightningTransaction

type FilteredLightningTransaction struct {
	ID          string            `json:"id"`
	MerchantID  string            `json:"merchant_id"`
	Status      TransactionStatus `json:"status"`
	Source      string            `json:"source"`
	Destination string            `json:"destination"`
	Amount      int64             `json:"amount"`
	CreatedAt   *Timestamp        `json:"created_at"`
	Direction   TransactionType   `json:"direction"`
	ExplorerUrl string            `json:"explorer_url"`
}

type FilteredOnChainInvoice

type FilteredOnChainInvoice struct {
	BitcoinAddress string        `json:"bitcoin_address"`
	Description    string        `json:"description"`
	Amount         int64         `json:"amount"`
	Status         InvoiceStatus `json:"status"`
	CreatedAt      *Timestamp    `json:"created_at"`
}

type FilteredOnChainTransaction

type FilteredOnChainTransaction struct {
	ID            string            `json:"id"`
	MerchantID    string            `json:"merchant_id"`
	Status        TransactionStatus `json:"status"`
	Source        string            `json:"source"`
	Destination   string            `json:"destination"`
	Amount        int64             `json:"amount"`
	CreatedAt     *Timestamp        `json:"created_at"`
	Direction     TransactionType   `json:"direction"`
	Confirmations int32             `json:"confirmations"`
	BlockNumber   int64             `json:"block_number"`
	ExplorerUrl   string            `json:"explorer_url"`
}

type GetLightningAddrForMerchantRequest

type GetLightningAddrForMerchantRequest struct {
	MerchantID string `json:"merchantId"`
	Nonce      string `json:"nonce"`
}

type GetLightningAddrForMerchantResponse

type GetLightningAddrForMerchantResponse struct {
	Invoice string `json:"invoice"`
}

type GetLightningAddrResponse

type GetLightningAddrResponse struct {
	Invoice string `json:"invoice"`
}

type GetLightningInvoiceRequest

type GetLightningInvoiceRequest struct {
	ID    string `json:"id"`
	Nonce string `json:"nonce"`
}

type GetLightningInvoiceResponse

type GetLightningInvoiceResponse struct {
	Invoice *FilteredLightningInvoice `json:"invoice"`
}

type GetLightningTransactionRequest

type GetLightningTransactionRequest struct {
	ID    string `json:"id"`
	Nonce string `json:"nonce"`
}

type GetLightningTransactionResponse

type GetLightningTransactionResponse struct {
	Transaction *FilteredLightningTransaction `json:"transaction"`
}

type GetOnChainInvoiceRequest

type GetOnChainInvoiceRequest struct {
	BitcoinAddress string `json:"bitcoin_address"`
	Nonce          string `json:"nonce"`
}

type GetOnChainInvoiceResponse

type GetOnChainInvoiceResponse struct {
	Invoice *FilteredOnChainInvoice `json:"invoice"`
}

type GetOnChainTransactionRequest

type GetOnChainTransactionRequest struct {
	ID    string `json:"id"`
	Nonce string `json:"nonce"`
}

type GetOnChainTransactionResponse

type GetOnChainTransactionResponse struct {
	Transaction *FilteredOnChainTransaction `json:"transaction"`
}

type GetStatisticRequest

type GetStatisticRequest struct {
	GroupID string    `json:"group_id"`
	Type    EventType `json:"type"`
	Nonce   string    `json:"nonce"`
}

type GetStatisticResponse

type GetStatisticResponse struct {
	Statistic string `json:"statistic"`
}

type Interface

type Interface interface {
	GetBalance(nonce string) (*Balance, error)

	GetSignature(url string, nonce string, body []byte) (string, error)

	EstimateOnChainTx(req *EstimateOnChainTxRequest) (*EstimateOnChainTxResponse, error)

	GetLightningAddress(nonce string) (*GetLightningAddrResponse, error)
	GetLightningAddressForMerchant(req *GetLightningAddrForMerchantRequest) (*GetLightningAddrForMerchantResponse, error)
	ConvertLnUrlInvoiceToLND(req *ConvertLnUrlInvoiceToLNDRequest) (*ConvertLnUrlInvoiceToLNDResponse, error)

	CreateOnChainInvoice(*CreateInvoiceRequest) (string, error)
	CreateLightningInvoice(*CreateInvoiceRequest) (*CreateLightningInvoiceResponse, error)

	SendOnChainPayment(*SendOnChainPaymentRequest) error
	SendLightningPayment(*SendLightningPaymentRequest) error

	GetOnChainInvoice(*GetOnChainInvoiceRequest) (*GetOnChainInvoiceResponse, error)
	GetLightningInvoice(*GetLightningInvoiceRequest) (*GetLightningInvoiceResponse, error)

	GetOnChainTransaction(*GetOnChainTransactionRequest) (*GetOnChainTransactionResponse, error)
	GetLightningTransaction(*GetLightningTransactionRequest) (*GetLightningTransactionResponse, error)

	VerifyWebhookSignature(*VerifyWebhookSignatureRequest) (*VerifyWebhookSignatureResponse, error)

	GetStatistic(*GetStatisticRequest) (*GetStatisticResponse, error)
}

type InvoiceStatus

type InvoiceStatus int32
const (
	InvoiceStatus_INVOICE_STATUS_UNSPECIFIED InvoiceStatus = 0
	InvoiceStatus_INVOICE_STATUS_PAID        InvoiceStatus = 1
	InvoiceStatus_INVOICE_STATUS_UNPAID      InvoiceStatus = 2
)

type LightningInvoiceIsPaid

type LightningInvoiceIsPaid struct {
	Id string `json:"id"`
}

type SendLightningPaymentRequest

type SendLightningPaymentRequest struct {
	Invoice    string `json:"invoice"`
	MerchantID string `json:"merchant_id"`
	Nonce      string `json:"nonce"`
}

type SendOnChainPaymentRequest

type SendOnChainPaymentRequest struct {
	BitcoinAddress string `json:"bitcoin_address"`
	Amount         int64  `json:"amount"`
	MerchantID     string `json:"merchant_id"`
	Nonce          string `json:"nonce"`
}

type Timestamp

type Timestamp struct {
	// Represents seconds of UTC time since Unix epoch
	// 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
	// 9999-12-31T23:59:59Z inclusive.
	Seconds int64 `json:"seconds,omitempty"`
	// Non-negative fractions of a second at nanosecond resolution. Negative
	// second values with fractions must still have non-negative nanos values
	// that count forward in time. Must be from 0 to 999,999,999
	// inclusive.
	Nanos int32 `json:"nanos,omitempty"`
}

type TransactionStatus

type TransactionStatus int32
const (
	TransactionStatus_TRANSACTION_STATUS_UNSPECIFIED         TransactionStatus = 0
	TransactionStatus_TRANSACTION_STATUS_FAILED              TransactionStatus = 1
	TransactionStatus_TRANSACTION_STATUS_SUCCESS             TransactionStatus = 2
	TransactionStatus_TRANSACTION_STATUS_PENDING             TransactionStatus = 3
	TransactionStatus_TRANSACTION_STATUS_WAITING_TO_FINALIZE TransactionStatus = 4
)

type TransactionType

type TransactionType int32
const (
	TransactionType_TRANSACTION_TYPE_UNSPECIFIED TransactionType = 0
	TransactionType_TRANSACTION_TYPE_INCOMING    TransactionType = 1
	TransactionType_TRANSACTION_TYPE_OUTGOING    TransactionType = 2
)

type VerifyWebhookSignatureRequest

type VerifyWebhookSignatureRequest struct {
	Signature string `json:"signature"`
	Event     []byte `json:"event"`
	Nonce     string `json:"nonce"`
}

type VerifyWebhookSignatureResponse

type VerifyWebhookSignatureResponse struct {
	IsValid bool `json:"is_valid"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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