mixclient

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: ISC Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const MinPeers = 4

MinPeers is the minimum number of peers required for a mix run to proceed.

Variables

View Source
var (
	ErrTooFewPeers = errors.New("not enough peers required to mix")

	ErrUnknownPRs = errors.New("unable to participate in reformed session referencing unknown PRs")
)

Functions

This section is empty.

Types

type Client

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

Client manages local mixing client sessions.

func NewClient

func NewClient(w Wallet) *Client

NewClient creates a wallet's mixing client manager.

func (*Client) Dicemix

func (c *Client) Dicemix(ctx context.Context, rand io.Reader, cj *CoinJoin) error

Dicemix performs a new mixing session for a coinjoin mix transaction.

func (*Client) ExpireMessages

func (c *Client) ExpireMessages(height uint32)

ExpireMessages will cause the removal all mixpool messages and sessions that indicate an expiry height at or before the height parameter and removes any pending DiceMix sessions that did not complete.

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run runs the client manager, blocking until after the context is cancelled.

func (*Client) SetLogger

func (c *Client) SetLogger(l slog.Logger)

type CoinJoin

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

CoinJoin tracks the in-progress coinjoin transaction for a single peer as the mixing protocol is performed.

func NewCoinJoin

func NewCoinJoin(gen GenFunc, change *wire.TxOut, mixValue int64, prExpiry uint32, mcount uint32) *CoinJoin

NewCoinJoin creates the initial coinjoin transaction. Inputs must be contributed to the coinjoin by one or more calls to AddInput.

func (*CoinJoin) AddInput

func (c *CoinJoin) AddInput(input *wire.TxIn, prevScript []byte, prevScriptVersion uint16,
	privKey *secp256k1.PrivateKey) error

AddInput adds an contributed input to the coinjoin transaction.

The private key is used to generate a UTXO signature proof demonstrating that this wallet is able to spend the UTXO. The private key is not retained by the CoinJoin structure and may be zerod from memory after AddInput returns.

func (*CoinJoin) MixedIndices

func (c *CoinJoin) MixedIndices() []int

MixedIndices returns the peer's mixed transaction output indices.

func (*CoinJoin) Tx

func (c *CoinJoin) Tx() *wire.MsgTx

Tx returns the coinjoin transaction.

type GenFunc

type GenFunc func(count uint32) (wire.MixVect, error)

GenFunc generates fresh secp256k1 P2PKH hash160s from the wallet.

type Wallet

type Wallet interface {
	BestBlock() (uint32, chainhash.Hash)

	// Mixpool returns access to the wallet's mixing message pool.
	//
	// The mixpool should only be used for message access and deletion,
	// but never publishing; SubmitMixMessage must be used instead for
	// message publishing.
	Mixpool() *mixpool.Pool

	// SubmitMixMessage submits a mixing message to the wallet's mixpool
	// and broadcasts it to the network.
	SubmitMixMessage(ctx context.Context, msg mixing.Message) error

	// SignInput adds a signature script to a transaction input.
	SignInput(tx *wire.MsgTx, index int, prevScript []byte) error

	// PublishTransaction adds the transaction to the wallet and publishes
	// it to the network.
	PublishTransaction(ctx context.Context, tx *wire.MsgTx) error
}

Wallet signs mix transactions and listens for and broadcasts mixing protocol messages.

While wallets are responsible for generating mixed addresses, this duty is performed by the generator function provided to NewCoinJoin rather than this interface. This allows each CoinJoin to pass in a generator closure for different BIP0032 accounts and branches.

Jump to

Keyboard shortcuts

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