btcqr

package module
v0.0.0-...-51060f2 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: ISC Imports: 6 Imported by: 8

README

go.btcqr

Package btcqr provides a wrapper to Russ Cox' qr package to create QR codes following the BIP0021 standard.

Install

Installation is easy, just use go get:

go get github.com/GeertJohan/go.btcqr

Usage

View example/example.go, or read the docs on godoc.org/github.com/GeertJohan/go.btcqr

License

This package is licensed under the ISC license. For more information view the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = &Config{
	Scheme: "bitcoin",
	Level:  M,
}

DefaultConfig contains the default config values used by the package-level functions. You can override these values, or create a custom *Config (safer).

View Source
var (

	// ErrNegativeAmount is returned when amount is negative
	ErrNegativeAmount = errors.New("amount can not be negative")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Scheme is the scheme name/urn used in the URI.
	// When empty, "bitcoin" will be used.
	Scheme string

	// Level denotes a QR error correction level.
	// For more information see the Level type and constants.
	Level Level

	// Debug logger
	Logger *log.Logger
}

Config allows the user of this package

type Level

type Level int

A Level denotes a QR error correction level. From least to most tolerant of errors, they are L, M, Q, H.

const (
	L Level = iota // 20% redundant
	M              // 38% redundant
	Q              // 55% redundant
	H              // 65% redundant
)

type Request

type Request struct {
	// Config used to generate the QR code
	// When empty, DefaultConfig is used.
	Config *Config

	// Address to which the coins should be sent
	// The address is assumed to be a valid and correct bitcoin address
	Address string

	// Amount as float64 (optional)
	// When left empty (zero), it will not be encoded into the QR code
	Amount float64

	// Label for the address (optional)
	// When left emtpy, it will not be encoded into the QR code
	Label string

	// Optional message string to be shown to the sender
	Message string

	// Optional parameters to be encoded in the URI
	Params map[string]string
}

Request to be encoded to QR code

func (*Request) GenerateQR

func (r *Request) GenerateQR() (*qr.Code, error)

GenerateQR generates a for the receiver *Request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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