gbitcoin

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBtc added in v0.8.1

func ConvertBtc(btc float64) uint64

Types

type AddrType

type AddrType int
const (
	Bech32 AddrType = iota
	P2shSegwit
	Legacy
)

func (AddrType) String

func (a AddrType) String() string

type Bip9Fork added in v0.8.1

type Bip9Fork struct {
	// defined, started, locked_in, active, failed, ??
	Status      string     `json:"status"`
	StartTime   int        `json:"start_time"`
	Timeout     uint64     `json:"timeout"`
	SinceHeight uint32     `json:"since"`
	Statistics  *Bip9Stats `json:"statistics,omitempty"`
}

type Bip9Stats added in v0.8.1

type Bip9Stats struct {
	Period    uint32 `json:"period"`
	Threshold uint32 `json:"threshold"`
	Elapsed   uint32 `json:"elapsed"`
	Count     uint32 `json:"count"`
	Possible  bool   `json:"possible"`
}

type Bitcoin

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

func NewBitcoin

func NewBitcoin(username, password string) *Bitcoin

func (*Bitcoin) CreateRawTx

func (b *Bitcoin) CreateRawTx(ins []*TxIn, outs []*TxOut, locktime *uint32, replaceable *bool) (string, error)

func (*Bitcoin) DecodeRawTx

func (b *Bitcoin) DecodeRawTx(txstring string) (*Tx, error)

func (*Bitcoin) Echo added in v0.8.3

func (b *Bitcoin) Echo() error

func (*Bitcoin) Endpoint

func (b *Bitcoin) Endpoint() string

func (*Bitcoin) EstimateFee added in v0.8.1

func (b *Bitcoin) EstimateFee(blocks uint32, mode string) (*FeeResponse, error)

func (*Bitcoin) FundRawTx

func (b *Bitcoin) FundRawTx(txstring string) (*FundRawResult, error)

Defaults to a segwit transaction

func (*Bitcoin) FundRawWithOptions

func (b *Bitcoin) FundRawWithOptions(txstring string, options *FundRawOptions, iswitness *bool) (*FundRawResult, error)

func (*Bitcoin) GenerateToAddress

func (b *Bitcoin) GenerateToAddress(address string, numBlocks uint) ([]string, error)

func (*Bitcoin) GetBlockHash added in v0.8.1

func (b *Bitcoin) GetBlockHash(height uint32) (string, error)

func (*Bitcoin) GetBlockHeight added in v0.8.3

func (b *Bitcoin) GetBlockHeight() (uint64, error)

func (*Bitcoin) GetChainInfo added in v0.8.1

func (b *Bitcoin) GetChainInfo() (*ChainInfo, error)

func (*Bitcoin) GetNewAddress

func (b *Bitcoin) GetNewAddress(addrType AddrType) (string, error)

func (*Bitcoin) GetRawBlock added in v0.8.1

func (b *Bitcoin) GetRawBlock(blockhash string) (string, error)

fetches raw block hex-string

func (*Bitcoin) GetRawtransaction added in v0.8.3

func (b *Bitcoin) GetRawtransaction(txId string) (string, error)

func (*Bitcoin) GetRawtransactionWithBlockHash added in v0.8.3

func (b *Bitcoin) GetRawtransactionWithBlockHash(txId string, blockHash string) (string, error)

func (*Bitcoin) GetTxOut added in v0.8.1

func (b *Bitcoin) GetTxOut(txid string, vout uint32) (*TxOutResp, error)

func (*Bitcoin) NextId

func (b *Bitcoin) NextId() *jrpc2.Id

for now, use a counter as the id for requests

func (*Bitcoin) Ping

func (b *Bitcoin) Ping() (bool, error)

func (*Bitcoin) SendRawTx

func (b *Bitcoin) SendRawTx(txstring string) (string, error)

func (*Bitcoin) SendToAddress

func (b *Bitcoin) SendToAddress(address, amount string) (string, error)

func (*Bitcoin) SetTimeout

func (b *Bitcoin) SetTimeout(secs uint)

func (*Bitcoin) StartUp

func (b *Bitcoin) StartUp(host, bitcoinDir string, port uint) error

type BlockVerbosity added in v0.8.1

type BlockVerbosity uint16
const (
	RawBlock BlockVerbosity = iota
	Json_TxId
	Json_TxData
)

FIXME: support options other than just raw block data

type ChainInfo added in v0.8.1

type ChainInfo struct {
	Chain                string               `json:"chain"`
	Blocks               uint32               `json:"blocks"`
	Headers              uint32               `json:"headers"`
	BestBlockHash        string               `json:"bestblockhash"`
	Difficulty           float64              `json:"difficulty"`
	MedianTime           uint64               `json:"mediantime"`
	VerificationProgress float64              `json:"verificationprogress"`
	InitialBlockDownload bool                 `json:"initialblockdownload"`
	ChainWork            string               `json:"chainwork"`
	SizeOnDisk           uint64               `json:"size_on_disk"`
	Pruned               bool                 `json:"pruned"`
	SoftForks            []*Fork              `json:"softforks"`
	Bip9SoftForks        map[string]*Bip9Fork `json:"softforks"`
	Warnings             string               `json:"warnings"`
}

type CreateRawTransactionReq

type CreateRawTransactionReq struct {
	Ins         []*TxIn           `json:"inputs"`
	Outs        []json.RawMessage `json:"outputs"`
	Locktime    *uint32           `json:"locktime,omitempty"`
	Replaceable *bool             `json:"replaceable,omitempty"`
}

func (*CreateRawTransactionReq) Name

func (r *CreateRawTransactionReq) Name() string

type DecodeRawTransactionReq

type DecodeRawTransactionReq struct {
	TxString  string `json:"hexstring"`
	IsWitness *bool  `json:"iswitness,omitempty"`
}

func (*DecodeRawTransactionReq) Name

func (r *DecodeRawTransactionReq) Name() string

type EchoRequest added in v0.8.3

type EchoRequest struct {
}

func (*EchoRequest) Name added in v0.8.3

func (r *EchoRequest) Name() string

type EstimateFeeRequest added in v0.8.1

type EstimateFeeRequest struct {
	Blocks uint32 `json:"conf_target"`
	Mode   string `json:"estimate_mode,omitempty"`
}

func (*EstimateFeeRequest) Name added in v0.8.1

func (r *EstimateFeeRequest) Name() string

type FeeResponse added in v0.8.1

type FeeResponse struct {
	FeeRate float64  `json:"feerate,omitempty"`
	Errors  []string `json:"errors,omitempty"`
	Blocks  uint32   `json:"blocks"`
}

func (*FeeResponse) SatPerKb added in v0.8.1

func (fr *FeeResponse) SatPerKb() uint64

type Fork added in v0.8.1

type Fork struct {
	Id      string     `json:"id"`
	Version uint       `json:"version"`
	Reject  *RejectObj `json:"reject"`
}

type FundRawOptions

type FundRawOptions struct {
	ChangeAddress   string `json:"changeAddress,omitempty"`
	ChangePosition  *uint  `json:"changePosition,omitempty"`
	ChangeType      string `json:"change_type,omitempty"`
	IncludeWatching *bool  `json:"includeWatching,omitempty"`
	LockUnspents    *bool  `json:"lockUnspents,omitempty"`
	FeeRate         string `json:"feeRate,omitempty"`
	// The fee will be equally deducted from the amount of each specified output.
	// Those recipients will receive less bitcoins than you enter in their
	//   corresponding amount field.
	// If no outputs are specified here, the sender pays the fee.
	// array values: The zero-based output index to deduct fee from,
	//   before a change output is added.
	SubtractFeeFromOutputs []uint `json:"subtractFeeFromOutputs,omitempty"`
	Replaceable            *bool  `json:"replaceable,omitempty"`
	ConfirmationTarget     uint   `json:"conf_target,omitempty"`
	EstimateMode           string `json:"estimate_mode,omitempty"`
}

type FundRawResult

type FundRawResult struct {
	TxString string  `json:"hex"`
	Fee      float64 `json:"fee"`
	// Position of the added change output, or -1
	ChangePosition int `json:"chanepos"`
}

func (*FundRawResult) HasChange

func (f *FundRawResult) HasChange() bool

type FundRawTransactionReq

type FundRawTransactionReq struct {
	TxString  string          `json:"hexstring"`
	Options   *FundRawOptions `json:"options,omitempty"`
	IsWitness *bool           `json:"iswitness,omitempty"`
}

func (*FundRawTransactionReq) Name

func (r *FundRawTransactionReq) Name() string

type GenerateToAddrRequest

type GenerateToAddrRequest struct {
	NumBlocks uint   `json:"nblocks"`
	Address   string `json:"address"`
	MaxTries  uint   `json:"maxtries,omitempty"`
}

func (*GenerateToAddrRequest) Name

func (r *GenerateToAddrRequest) Name() string

type GetBlockChainInfoRequest added in v0.8.1

type GetBlockChainInfoRequest struct{}

func (*GetBlockChainInfoRequest) Name added in v0.8.1

func (r *GetBlockChainInfoRequest) Name() string

type GetBlockCountReq added in v0.8.3

type GetBlockCountReq struct{}

func (*GetBlockCountReq) Name added in v0.8.3

func (r *GetBlockCountReq) Name() string

type GetBlockHashRequest added in v0.8.1

type GetBlockHashRequest struct {
	BlockHeight uint32 `json:"height"`
}

func (*GetBlockHashRequest) Name added in v0.8.1

func (r *GetBlockHashRequest) Name() string

type GetBlockRequest added in v0.8.1

type GetBlockRequest struct {
	BlockHash string `json:"blockhash"`
	// valid options: 0,1,2
	Verbosity BlockVerbosity `json:"verbosity"`
}

func (*GetBlockRequest) Name added in v0.8.1

func (r *GetBlockRequest) Name() string

type GetNewAddressRequest

type GetNewAddressRequest struct {
	Label       string `json:"label,omitempty"`
	AddressType string `json:"address_type,omitempty"`
}

func (*GetNewAddressRequest) Name

func (r *GetNewAddressRequest) Name() string

type GetRawTransactionReq added in v0.8.3

type GetRawTransactionReq struct {
	TxId      string `json:"txid"`
	Blockhash string `json:"blockhash,omitempty"`
}

func (*GetRawTransactionReq) Name added in v0.8.3

func (r *GetRawTransactionReq) Name() string

type GetTxOutRequest added in v0.8.1

type GetTxOutRequest struct {
	TxId           string `json:"txid"`
	Vout           uint32 `json:"n"`
	IncludeMempool bool   `json:"include_mempool"`
}

func (*GetTxOutRequest) Name added in v0.8.1

func (r *GetTxOutRequest) Name() string

type OutScript

type OutScript struct {
	Script
	RequiredSigs uint     `json:"reqSigs"`
	Type         string   `json:"type"`
	Addresses    []string `json:"addresses"`
}

type PingRequest

type PingRequest struct{}

func (*PingRequest) Name

func (r *PingRequest) Name() string

type RejectObj added in v0.8.1

type RejectObj struct {
	Status bool `json:"status"`
}

type Script

type Script struct {
	Asm string `json:"asm"`
	Hex string `json:"hex"`
}

type SendRawTransactionReq

type SendRawTransactionReq struct {
	TxString      string `json:"hexstring"`
	AllowHighFees *bool  `json:"allowhighfees,omitempty"`
}

func (*SendRawTransactionReq) Name

func (r *SendRawTransactionReq) Name() string

type SendToAddrReq

type SendToAddrReq struct {
	Address               string `json:"address"`
	Amount                string `json:"amount"`
	Comment               string `json:"comment,omitempty"`
	CommentTo             string `json:"comment_to,omitempty"`
	SubtractFeeFromAmount bool   `json:"subtractfeefromamount,omitempty"`
	Replaceable           bool   `json:"replaceable,omitempty"`
	ConfirmationTarget    uint   `json:"conf_target,omitempty"`
	FeeEstimateMode       string `json:"estimate_mode,omitempty"`
}

func (*SendToAddrReq) Name

func (r *SendToAddrReq) Name() string

type Tx

type Tx struct {
	TxId        string      `json:"txid"`
	Hash        string      `json:"hash"`
	Size        uint        `json:"size"`
	VirtualSize uint        `json:"vsize"`
	Weight      uint        `json:"weight"`
	Version     uint        `json:"version"`
	Locktime    uint32      `json:"locktime"`
	Inputs      []*TxInput  `json:"vin"`
	Outputs     []*TxOutput `json:"vout"`
}

func (*Tx) FindOutputIndex

func (tx *Tx) FindOutputIndex(address string) (uint32, error)

type TxIn

type TxIn struct {
	TxId     string `json:"txid"`
	Vout     uint   `json:"vout"`
	Sequence uint   `json:"sequence,omitempty"`
}

type TxInput

type TxInput struct {
	TxId            string   `json:"txid"`
	Vout            uint     `json:"vout"`
	ScriptSignature *Script  `json:"scriptSig"`
	TxInWitness     []string `json:"txinwitness,omitempty"`
	Sequence        uint     `json:"sequence"`
}

type TxOut

type TxOut struct {
	Address string
	Satoshi uint64
}

func (*TxOut) Marshal

func (o *TxOut) Marshal() []byte

type TxOutResp added in v0.8.1

type TxOutResp struct {
	BestBlockHash string     `json:"bestblock"`
	Confirmations uint32     `json:"confirmations"`
	Value         float64    `json:"value"`
	ScriptPubKey  *OutScript `json:"scriptPubKey"`
	Coinbase      bool       `json:"coinbase"`
}

type TxOutput

type TxOutput struct {
	// The value in BTC
	Value        float64    `json:"value"`
	Index        uint       `json:"n"`
	ScriptPubKey *OutScript `json:"scriptPubKey"`
}

Jump to

Keyboard shortcuts

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