coinjoin

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: ISC Imports: 14 Imported by: 3

Documentation

Overview

Package coinjoin defines a builder type for creating Decred CoinJoin transactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeDesc

func EncodeDesc(sc ScriptClass, amount int64, txVersion uint16, lockTime, expiry uint32) []byte

EncodeDesc encodes a description defining the parameters for a Decred coinjoin.

Types

type Blamer

type Blamer interface {
	Blame() []int
}

Blamer describes misbehaving peer IDs.

type Caller

type Caller interface {
	Call(ctx context.Context, method string, res interface{}, args ...interface{}) error
}

Caller performs a RPC method call.

type ScriptClass

type ScriptClass int
const (
	P2PKHv0 ScriptClass = iota
	P2SHv0
)

Recognized script classes

func DecodeDesc

func DecodeDesc(desc []byte) (sc ScriptClass, amount int64, txVersion uint16, lockTime, expiry uint32, err error)

DecodeDesc decodes a description defining the parameters for a compatible coinjoin.

func (ScriptClass) Match

func (sc ScriptClass) Match(script []byte, vers uint16) bool

type Tx

type Tx struct {
	Tx wire.MsgTx
	// contains filtered or unexported fields
}

Tx is a Decred CoinJoin transaction builder. It is intended for usage by CoinJoin servers, not clients.

func NewTx

func NewTx(caller Caller, sc ScriptClass, amount, feeRate int64, txVersion uint16,
	lockTime, expiry uint32) (*Tx, error)

func (*Tx) CheckLimited added in v2.1.0

func (t *Tx) CheckLimited(unmixed []byte, totalMixes int) error

CheckLimited errors if the unmixed data and a total mixed message count results in a coinjoin transaction with estimated signed transaction size exceeding the mempool's standard size limits. This makes an assumption that all inputs and outputs are secp256k1 P2PKHv0.

func (*Tx) Confirm

func (t *Tx) Confirm(confirm interface{}, pid int) error

Confirm extracts the signatures from peer pid in confirm and adds them the receiver.

confirm must have type *Tx.

func (*Tx) Join

func (t *Tx) Join(unmixed []byte, pid int) error

Join adds the inputs and outputs of a transaction in wire encoding to t. Inputs and outputs are associated with a peer id for blame assignment.

func (*Tx) MarshalBinary

func (t *Tx) MarshalBinary() ([]byte, error)

MarshalBinary marshals the transaction in wire encoding.

func (*Tx) Mix

func (t *Tx) Mix(m []byte)

Mix adds an output with m as the PkScript. The output will use the builder's output value and script version.

func (*Tx) PublishMix

func (t *Tx) PublishMix(ctx context.Context) error

PublishMix publishes a transaction using the dcrd sendrawtransaction RPC.

func (*Tx) Report

func (t *Tx) Report() interface{}

Report returns an object that can be marshaled with reflection-based encoders such as encoding/json and encoding/gob. The object includes details about the current CoinJoin transaction.

func (*Tx) Shuffle

func (t *Tx) Shuffle()

Shuffle randomly shuffles the transaction inputs and outputs. Randomness is obtained from a cryptographically-seeded PRNG. Must only be used before signing.

func (*Tx) UnmarshalBinary

func (t *Tx) UnmarshalBinary(b []byte) error

UnmarshalBinary unmarshals the transaction in wire encoding.

func (*Tx) ValidateUnmixed

func (t *Tx) ValidateUnmixed(unmixed []byte, mcount int) error

Jump to

Keyboard shortcuts

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