gelements

package
v0.0.0-...-55240d6 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 15 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertBtc

func ConvertBtc(btc float64) uint64

Types

type AddrType

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

func (AddrType) String

func (a AddrType) String() string

type Bip9Fork

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

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

type BlindRawTransactionReq

type BlindRawTransactionReq struct {
	HexString string `json:"hexstring"`
}

func (*BlindRawTransactionReq) Name

func (b *BlindRawTransactionReq) Name() string

type BlockVerbosity

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

FIXME: support options other than just raw block data

type ChainInfo

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 CreateWalletReq

type CreateWalletReq struct {
	WalletName string `json:"wallet_name"`
}

func (*CreateWalletReq) Name

func (r *CreateWalletReq) 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 DumpBlindingKeyReq

type DumpBlindingKeyReq struct {
	Address string `json:"address"`
}

func (*DumpBlindingKeyReq) Name

func (r *DumpBlindingKeyReq) Name() string

type EchoRequest

type EchoRequest struct {
}

func (*EchoRequest) Name

func (r *EchoRequest) Name() string

type Elements

type Elements struct {
	CookiePath string
	// contains filtered or unexported fields
}

func NewElements

func NewElements(username, password, cookiePath string) *Elements

func (*Elements) BlindRawTransaction

func (e *Elements) BlindRawTransaction(hex string) (string, error)

func (*Elements) CreateRawTx

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

func (*Elements) CreateWallet

func (b *Elements) CreateWallet(walletName string) (string, error)

func (*Elements) DecodeRawTx

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

func (*Elements) DumpBlindingKey

func (b *Elements) DumpBlindingKey(address string) (string, error)

func (*Elements) Echo

func (b *Elements) Echo() error

func (*Elements) Endpoint

func (b *Elements) Endpoint() string

func (*Elements) EstimateFee

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

func (*Elements) FundRawTx

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

Defaults to a segwit transaction

func (*Elements) FundRawWithOptions

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

func (*Elements) GenerateToAddress

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

func (*Elements) GetBalance

func (b *Elements) GetBalance() (uint64, error)

GetBalance returns balance in sats

func (*Elements) GetBlockHash

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

func (*Elements) GetBlockHeader

func (b *Elements) GetBlockHeader(blockHash string) (*GetBlockHeaderRes, error)

func (*Elements) GetBlockHeight

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

func (*Elements) GetChainInfo

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

func (*Elements) GetNewAddress

func (b *Elements) GetNewAddress(addrType int) (string, error)

func (*Elements) GetRawBlock

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

fetches raw block hex-string

func (*Elements) GetRawtransaction

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

func (*Elements) GetRawtransactionWithBlockHash

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

func (*Elements) GetTxOut

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

func (*Elements) ImportAddress

func (b *Elements) ImportAddress(address, label string, rescan bool) error

func (*Elements) ListWallets

func (b *Elements) ListWallets() ([]string, error)

func (*Elements) LoadWallet

func (b *Elements) LoadWallet(fileName string, loadOnStartup bool) (string, error)

func (*Elements) NextId

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

for now, use a counter as the id for requests

func (*Elements) Ping

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

func (*Elements) RawBlindRawTransaction

func (e *Elements) RawBlindRawTransaction(hex string, inputAmountBlinders []string, inputAmounts []uint64, inputAssets []string, inputAssetBlinders []string) (string, error)

func (*Elements) SendRawTx

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

func (*Elements) SendToAddress

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

func (*Elements) SendToAddressCustom

func (b *Elements) SendToAddressCustom(req *SendToAddrReq) (string, error)

func (*Elements) SetLabel

func (e *Elements) SetLabel(address, label string) error

func (*Elements) SetRpcWallet

func (b *Elements) SetRpcWallet(rpcWallet string)

func (*Elements) SetTimeout

func (b *Elements) SetTimeout(secs uint)

func (*Elements) SignRawTransactionWithWallet

func (b *Elements) SignRawTransactionWithWallet(hexString string) (SignRawTransactionWithWalletRes, error)

func (*Elements) StartUp

func (e *Elements) StartUp(host string, port uint) error

func (*Elements) UnblindRawtransaction

func (b *Elements) UnblindRawtransaction(hex string) (string, error)

type EstimateFeeRequest

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

func (*EstimateFeeRequest) Name

func (r *EstimateFeeRequest) Name() string

type FeeResponse

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

func (*FeeResponse) SatPerKb

func (fr *FeeResponse) SatPerKb() uint64

type Fork

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 GetBalanceRequest

type GetBalanceRequest struct {
}

func (*GetBalanceRequest) Name

func (r *GetBalanceRequest) Name() string

type GetBalanceRes

type GetBalanceRes struct {
	BitcoinAmt float64 `json:"bitcoin"`
}

type GetBlockChainInfoRequest

type GetBlockChainInfoRequest struct{}

func (*GetBlockChainInfoRequest) Name

func (r *GetBlockChainInfoRequest) Name() string

type GetBlockCountReq

type GetBlockCountReq struct{}

func (*GetBlockCountReq) Name

func (r *GetBlockCountReq) Name() string

type GetBlockHashRequest

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

func (*GetBlockHashRequest) Name

func (r *GetBlockHashRequest) Name() string

type GetBlockHeaderReq

type GetBlockHeaderReq struct {
	BlockHash string
	Verbose   bool
}

func (*GetBlockHeaderReq) Name

func (r *GetBlockHeaderReq) Name() string

type GetBlockHeaderRequest

type GetBlockHeaderRequest struct {
	BlockHash string `json:"blockhash"`
}

type GetBlockHeaderRes

type GetBlockHeaderRes struct {
	Hash              string  `json:"hash"`
	Confirmations     uint32  `json:"confirmations"`
	Height            uint32  `json:"height"`
	Version           uint32  `json:"version"`
	VersionHex        string  `json:"versionHex"`
	Merkleroot        string  `json:"merkleroot"`
	Time              uint64  `json:"time"`
	Mediantime        uint64  `json:"mediantime"`
	Nonce             uint32  `json:"nonce"`
	Bits              string  `json:"bits"`
	Difficulty        float64 `json:"difficulty"`
	Chainwork         string  `json:"chainwork"`
	NTx               uint32  `json:"nTx"`
	Previousblockhash string  `json:"previousblockhash"`
	Nextblockhash     string  `json:"nextblockhash"`
}

type GetBlockRequest

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

func (*GetBlockRequest) Name

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

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

func (*GetRawTransactionReq) Name

func (r *GetRawTransactionReq) Name() string

type GetTxOutRequest

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

func (*GetTxOutRequest) Name

func (r *GetTxOutRequest) Name() string

type ImportAddressReq

type ImportAddressReq struct {
	Address string `json:"address"`
	Label   string `json:"label"`
	Rescan  bool   `json:"rescan"`
}

func (*ImportAddressReq) Name

func (r *ImportAddressReq) Name() string

type ListWalletsReq

type ListWalletsReq struct{}

func (*ListWalletsReq) Name

func (l *ListWalletsReq) Name() string

type LoadWalletReq

type LoadWalletReq struct {
	FileName      string `json:"filename"`
	LoadOnStartup bool   `json:"load_on_startup"`
}

func (*LoadWalletReq) Name

func (r *LoadWalletReq) 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 PsbtInput

type PsbtInput struct {
	TxId     string `json:"txid"`
	Vout     uint32 `json:"vout"`
	Sequence uint32 `json:"sequence"`
}

type PsbtOutput

type PsbtOutput struct {
	Values map[string]float64 `json:"values"`
	Data   string             `json:"data"`
}

type RawBlindRawTransactionReq

type RawBlindRawTransactionReq struct {
	HexString           string   `json:"hexstring"`
	InputAmountBlinders []string `json:"inputamountblinders"`
	InputAmounts        []uint64 `json:"inputamounts"`
	InputAssets         []string `json:"inputassets"`
	InputAssetBlinders  []string `json:"inputassetblinders"`
	IgnoreBlindFail     bool     `json:"ignoreblindfails"`
}

func (*RawBlindRawTransactionReq) Name

type RejectObj

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"`
	AssetLabel            string `json:"assetlabel"`
}

func (*SendToAddrReq) Name

func (r *SendToAddrReq) Name() string

type SetLabelReq

type SetLabelReq struct {
	Address string `json:"address"`
	Label   string `json:"label"`
}

func (*SetLabelReq) Name

func (r *SetLabelReq) Name() string

type SignRawTransactionWithWalletReq

type SignRawTransactionWithWalletReq struct {
	HexString string `json:"hexstring"`
}

func (*SignRawTransactionWithWalletReq) Name

type SignRawTransactionWithWalletRes

type SignRawTransactionWithWalletRes struct {
	Hex      string    `json:"hex"`
	Complete bool      `json:"complete"`
	Errors   []TxError `json:"errors"`
	Warning  string    `json:"warning"`
}

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 TxError

type TxError struct {
	TxId      string `json:"txid"`
	Vout      uint32 `json:"vout"`
	ScriptSig string `json:"scriptSig"`
	Sequence  uint32 `json:"sequence"`
	Error     string `json:"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

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"`
}

type UnblindRawTransactionReq

type UnblindRawTransactionReq struct {
	Hex string `json:"hex"`
}

func (*UnblindRawTransactionReq) Name

func (u *UnblindRawTransactionReq) Name() string

type UnblindRawTransactionRes

type UnblindRawTransactionRes struct {
	Hex string `json:"hex"`
}

type WalletCreatFundedPsbtRes

type WalletCreatFundedPsbtRes struct {
}

type WalletCreateFundedPsbtReq

type WalletCreateFundedPsbtReq struct {
	Inputs  []PsbtInput  `json:"inputs"`
	Outputs []PsbtOutput `json:"outputs"`
}

type WalletRes

type WalletRes struct {
	WalletName string `json:"name"`
	Warning    string `json:"warning"`
}

Jump to

Keyboard shortcuts

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