package
1.9.25
Repository: https://github.com/p9c/pod.git
Documentation: pkg.go.dev

# README

Neutrino: Privacy-Preserving Bitcoin Light Client

Build Status Godoc Coverage Status

Neutrino is an experimental Bitcoin light client written in Go and designed with mobile Lightning Network clients in mind. It uses a new proposal for compact block filters to minimize bandwidth and storage use on the client side, while attempting to preserve privacy and minimize processor load on full nodes serving light clients.

Mechanism of operation

The light client synchronizes only block headers and a chain of compact block filter headers specifying the correct filters for each block. Filters are loaded lazily and stored in the database upon request; blocks are loaded lazily and not saved. There are multiple known major issues with the client, so it is not recommended to use it with real money at this point.

Usage

The client is instantiated as an object using NewChainService and then started. Upon start, the client sets up its database and other relevant files and connects to the p2p network. At this point, it becomes possible to query the client.

Queries

There are various types of queries supported by the client. There are many ways to access the database, for example, to get block headers by height and hash; in addition, it's possible to get a full block from the network using GetBlockFromNetwork by hash. However, the most useful methods are specifically tailored to scan the blockchain for data relevant to a wallet or a smart contract platform such as a Lightning Network node like lnd. These are described below.

Rescan

Rescan allows a wallet to scan a chain for specific TXIDs, outputs, and addresses. A start and end block may be specified along with other options. If no end block is specified, the rescan continues until stopped. If no start block is specified, the rescan begins with the latest known block. While a rescan runs, it notifies the client of each connected and disconnected block; the notifications follow the btcjson format with the option to use any of the relevant notifications. It's important to note that "recvtx" and "redeemingtx" notifications are only sent when a transaction is confirmed, not when it enters the mempool; the client does not currently support accepting 0-confirmation transactions.

GetUtxo

GetUtxo allows a wallet or smart contract platform to check that a UTXO exists on the blockchain and has not been spent. It is highly recommended to specify a start block; otherwise, in the event that the UTXO doesn't exist on the blockchain, the client will download all the filters back to block 1 searching for it. The client scans from the tip of the chain backwards, stopping when it finds the UTXO having been either spent or created; if it finds neither, it keeps scanning backwards until it hits the specified start block or, if a start block isn't specified, the first block in the blockchain. It returns a SpendReport containing either a TxOut including the PkScript required to spend the output, or containing information about the spending transaction, spending input, and block height in which the spending transaction was seen.

Stopping the client

Calling Stop on the ChainService client allows the user to stop the client; the method doesn't return until the ChainService is cleanly shut down.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddAddrs adds addresses to the filter.
AddInputs adds inputs to watch to the filter.
DisableDisconnectedNtfns tells the rescan not to send `OnBlockDisconnected` and `OnFilteredBlockDisconnected` notifications when rewinding.
DoneChan allows the caller to pass a channel that will get closed when the query is finished.
Encoding is a query option that allows the caller to set a message encoding for the query messages.
EndBlock specifies the end block.
NewChainService returns a new chain service configured to connect to the bitcoin network type specified by chainParams.
NewUtxoScanner creates a new instance of UtxoScanner using the given chain interface.
NotificationHandlers specifies notification handlers for the rescan.
NumRetries is a query option that lets the query know the maximum number of times each peer should be queried.
PeerConnectTimeout is a query option that lets the query know how long to wait for the underlying chain service to connect to a peer before giving up on a query in case we don't have any peers.
PersistToDisk allows the caller to tell that the filter should be kept on disk once it's found.
QueryOptions pass onto the underlying queries.
QuitChan specifies the quit channel.
Rewind rewinds the rescan to the specified height (meaning, disconnects down to the block immediately after the specified height) and restarts it from that point with the (possibly) newly expanded filter.
StartBlock specifies the start block.
StartTime specifies the start time.
Timeout is a query option that lets the query know how long to wait for each peer we ask the query to answer it before moving on.
TxIdx specifies a hint transaction index into the block in which the UTXO is created (eg, coinbase is 0, next transaction is 1, etc.).
WatchAddrs specifies the addresses to watch/filter for.
WatchInputs specifies the outpoints to watch for on-chain spends.

# Variables

BanDuration is the duration of a ban.
BanThreshold is the maximum ban score before a peer is banned.
ConnectionRetryInterval is the base amount of time to wait in between retries when connecting to persistent peers.
No description provided by the author
40 MB.
DefaultFilterCacheSize is the size (in bytes) of filters neutrino will keep in memory if no size is specified in the neutrino.Config.
DisableDNSSeed disables getting initial addresses for Bitcoin nodes from DNS.
No description provided by the author
ErrGetUtxoCancelled signals that a GetUtxo request was cancelled.
ErrRescanExit is an error returned to the caller in case the ongoing rescan exits.
ErrShuttingDown signals that neutrino received a shutdown request.
No description provided by the author
No description provided by the author
MaxPeers is the maximum number of connections the client maintains.
QueryEncoding specifies the default encoding (witness or not) for `getdata` and other similar messages.
QueryNumRetries specifies how many times to retry sending a query to each peer before we've concluded we aren't going to get a valid response.
QueryPeerConnectTimeout specifies how long to wait for the underlying chain service to connect to a peer before giving up on a query in case we don't have any peers.
QueryTimeout specifies how long to wait for a peer to answer a query.
RequiredServices describes the services that are required to be supported by outbound peers.
Services describes the services that are supported by the server.
No description provided by the author
TargetOutbound is the number of outbound peers to target.
UserAgentName is the user agent name and is used to help identify ourselves to other bitcoin peers.
UserAgentVersion is the user agent version and is used to help identify ourselves to other bitcoin peers.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
InputWithScript couples an previous outpoint along with its input script.
Rescan is an object that represents a long-running rescan/notification client with updateable filters.
No description provided by the author
SpendReport is a struct which describes the current spentness state of a particular output.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
QueryOption is a functional option argument to any of the network query methods, such as GetBlock and GetCFilter (when that resorts to a network query).
RescanOption is a functional option argument to any of the rescan and notification subscription methods.
UpdateOption is a functional option argument for the Rescan.Update method.