Documentation
¶
Index ¶
- Variables
- func ChainParams(chain string) (*chaincfg.Params, error)
- func DeriveAddress(client *rpcclient.Client, descriptor string, index int) (*string, error)
- func GetCanonicalDescriptor(client *rpcclient.Client, descriptor string) (*string, error)
- func ImportDescriptors(client *rpcclient.Client, descriptors []descriptor) error
- type Bus
- func (b *Bus) AbortRescan() error
- func (b *Bus) ClientFactory() (*rpcclient.Client, error)
- func (b *Bus) Close(ctx context.Context)
- func (b *Bus) DumpLatestRescanTime() error
- func (b *Bus) EstimateSmartFee(target int64, mode string) btcutil.Amount
- func (b *Bus) FlushCache()
- func (b *Bus) GetBestBlockHash() (*chainhash.Hash, error)
- func (b *Bus) GetBlock(hash *chainhash.Hash) (*types.Block, error)
- func (b *Bus) GetBlockChainInfo() (*btcjson.GetBlockChainInfoResult, error)
- func (b *Bus) GetBlockCount() (int64, error)
- func (b *Bus) GetBlockHash(height int64) (*chainhash.Hash, error)
- func (b *Bus) GetTransaction(hash string) (*types.Transaction, error)
- func (b *Bus) GetTransactionHex(hash *chainhash.Hash) (string, error)
- func (b *Bus) ImportAccounts(accounts []config.Account) error
- func (b *Bus) ListTransactions(blockHash *string) ([]btcjson.ListTransactionsResult, error)
- func (b *Bus) NewCache()
- func (b *Bus) SendTransaction(tx string) (*chainhash.Hash, error)
- func (b *Bus) UnloadWallet()
- func (b *Bus) Worker(config *config.Configuration, circulationCheck bool, forceImportDesc bool)
- type CreateWalletResult
- type Currency
- type ExplorerStatus
- type ImportDesciptorRequest
- type ImportDescriptorResult
- type Network
- type RescanResult
- type Status
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBitcoindUnreachable indicates that an RPC call to the bitcoind node // was not successful. Use this error during sanity checks. ErrBitcoindUnreachable = errors.New("bitcoind unreachable") // ErrWalletDisabled indicates that wallet features have been disabled on // the connected Bitcoin node. SatStack relies on wallet RPCs to function. ErrWalletDisabled = errors.New("bitcoind wallet is disabled") // ErrCreateWallet indicates that the wallet RPC createwallet was not // successful. ErrCreateWallet = errors.New("failed to create wallet") // ErrLoadWallet indicates that the wallet RPC loadwallet was not // successful. ErrLoadWallet = errors.New("failed to load wallet") // ErrUnsupportedBitcoindVersion indicates that the connected bitcoind node // has a version that is not supported by SatStack. ErrUnsupportedBitcoindVersion = errors.New("unsupported bitcoind version") // ErrUnrecognizedChain indicates that the Chain returned by bitcoind in // its response to the getblockchaininfo RPC, is unrecognized by LSS. // // This usually means that the value doesn't correspond to a Currency or // network that libcore can understand. ErrUnrecognizedChain = errors.New("unrecognized chain") // ErrFailedToGetBlock indicates that an error was encountered while // trying to get a block. ErrFailedToGetBlock = errors.New("failed to get block") // ErrMalformedChainHash indicates that a chain hash (transaction or block) // could not be parsed. ErrMalformedChainHash = errors.New("malformed chain hash") // ErrFailedToDetectTxIndex indicates an irrecoverable error while trying // to detect presence of a transaction index. Normally, this error should // not be ignored silently. ErrFailedToDetectTxIndex = errors.New("failed to detect txindex") // ErrFailedToDetectBlockFilter indicates an irrecoverable error while trying // to detect presence of a compact block filter index. Normally, this error // should not be ignored silently. ErrFailedToDetectBlockFilter = errors.New("failed to detect block filter") // ErrInvalidDescriptor indicates that a malformed descriptor was // encountered. ErrInvalidDescriptor = errors.New("invalid descriptor") // ErrDeriveAddress indicates that an address could not be derived from a // descriptor. ErrDeriveAddress = errors.New("failed to derive address") // ErrAddressInfo indicates that an error was encountered while trying to // fetch address info. ErrAddressInfo = errors.New("failed to get address info") )
Functions ¶
func ChainParams ¶
ChainParams returns the *chaincfg.Params instance corresponding to the network that the underlying node is connected to.
This value is useful for several operations in btcd, and can be accessed via the Bus struct.
func DeriveAddress ¶
func GetCanonicalDescriptor ¶
GetCanonicalDescriptor returns the descriptor in canonical form, along with its computed checksum.
func ImportDescriptors ¶
Types ¶
type Bus ¶
type Bus struct { // Informational fields Chain string Pruned bool TxIndex bool BlockFilter bool Currency Currency // Based on Chain value, for interoperability with libcore // Thread-safe Bus cache, to query results typically by hash Cache *cache.Cache // btcd network params Params *chaincfg.Params // IsPendingScan is a boolean field to indicate if satstack is currently // waiting for descriptors to be scanned or other initial operations like "running the numbers" // before the bridge can operate correctly // // This value can be exported for use by other packages to avoid making // explorer requests before satstack is able to serve them. IsPendingScan bool // contains filtered or unexported fields }
Bus represents a transport allowing access to Bitcoin RPC methods.
It maintains a pool of btcd rpcclient objects in a buffered channel to allow concurrent invocation of RPC methods.
func New ¶
func New(host string, user string, pass string, proxy string, noTLS bool, unloadWallet bool) (*Bus, error)
New initializes a Bus struct that embeds a btcd RPC client.
func (*Bus) AbortRescan ¶ added in v0.18.0
func (*Bus) Close ¶
Close performs cleanup operations on the Bus, notably shutting down the rpcclient.Client connections.
The cleanup must be performed within a timeout set by the passed context, to prevent hanging on connections indefinitely held by bitcoind.
func (*Bus) DumpLatestRescanTime ¶ added in v0.18.0
func (*Bus) EstimateSmartFee ¶
func (*Bus) FlushCache ¶
func (b *Bus) FlushCache()
FlushCache clears the Bus cache storage, and sets the value of Bus.Cache to nil.
func (*Bus) GetBlockChainInfo ¶
func (b *Bus) GetBlockChainInfo() (*btcjson.GetBlockChainInfoResult, error)
func (*Bus) GetBlockCount ¶ added in v0.18.0
func (*Bus) GetTransaction ¶
func (b *Bus) GetTransaction(hash string) (*types.Transaction, error)
func (*Bus) GetTransactionHex ¶
func (*Bus) ImportAccounts ¶
ImportAccounts will import the descriptors corresponding to the accounts into the Bitcoin Core wallet. This is a blocking operation.
func (*Bus) ListTransactions ¶
func (b *Bus) ListTransactions(blockHash *string) ([]btcjson.ListTransactionsResult, error)
func (*Bus) NewCache ¶
func (b *Bus) NewCache()
NewCache initializes a new cache storage and assigns it to the Cache field of Bus.
func (*Bus) UnloadWallet ¶
func (b *Bus) UnloadWallet()
type CreateWalletResult ¶ added in v0.16.0
type Currency ¶
type Currency = string
Currency represents the currency type (btc) and the network params (Mainnet, testnet3, regtest, etc) in libcore parlance.
func CurrencyFromChain ¶
currencyFromChain is an adapter function to convert a chain (network) value to a Currency type that's understood by libcore.
type ExplorerStatus ¶
type ExplorerStatus struct { Version string `json:"version"` TxIndex bool `json:"txindex"` BlockFilter bool `json:"block_filter"` Pruned bool `json:"pruned"` Chain string `json:"chain"` Currency Currency `json:"currency"` Status Status `json:"status"` SyncProgress *float64 `json:"sync_progress,omitempty"` ScanProgress *float64 `json:"scan_progress,omitempty"` }
ExplorerStatus represents the structure of payload returned by GetStatus service method.
type ImportDesciptorRequest ¶ added in v0.16.0
type ImportDesciptorRequest struct { Descriptor string `json:"desc"` //(string, required) Descriptor to import. Active bool `json:"active,omitempty"` //(boolean, optional, default=false) Set this descriptor to be the active descriptor for the corresponding output type/externality Range []int `json:"range,omitempty"` //(numeric or array) If a ranged descriptor is used, this specifies the end or the range (in the form [begin,end]) to import NextIndex int `json:"next_index,omitempty"` //(numeric) If a ranged descriptor is set to active, this specifies the next index to generate addresses from Timestamp uint32 `json:"timestamp"` /*(integer / string, required) Time from which to start rescanning the blockchain for this descriptor, in UNIX epoch time Use the string "now" to substitute the current synced blockchain time. "now" can be specified to bypass scanning, for outputs which are known to never have been used, and 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest timestamp of all descriptors being imported will be scanned.*/ Internal bool `json:"internal,omitempty"` //(boolean, optional, default=false) Whether matching outputs should be treated as not incoming payments (e.g. change) }
see https://developer.bitcoin.org/reference/rpc/importdescriptors.html for specs
type ImportDescriptorResult ¶ added in v0.16.0
type RescanResult ¶ added in v0.18.0
type Status ¶
type Status string
Status indicates the state of LSS with regards to the readiness of the connected Bitcoin Core node.
const ( // Initializing is a Status to indicate the initial state of LSS, while it // is warming up. Initializing Status = "initializing" // NodeDisconnected is a Status to indicate that the bitcoind instance is // unreachable. This is typically returned in the response of the status // endpoint. NodeDisconnected Status = "node-disconnected" // Ready is a Status to indicate that LSS is ready to accept explorer API // requests from Ledger Live. Ready Status = "ready" // Syncing is a Status to indicate that the Bitcoin Core node is currently // downloading and validating blocks. Syncing Status = "syncing" // PendingScan is a Status to indicate that the worker is awaiting import // of descriptors. This is typically the case when LSS is launched, while it // is "running the numbers". // // Use this Status when Bus.IsPendingScan is set to true. PendingScan Status = "pending-scan" // Scanning is a Status to indicate that the Bitcoin Core node is currently // importing account descriptors into its wallet. Scanning Status = "scanning" )