testutils

package
v0.0.0-...-71c933f Latest Latest
Warning

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

Go to latest
Published: May 15, 2025 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NUM_BLOCKS int64 = 110
)

Variables

This section is empty.

Functions

func AddHTLCWitnessToInputs

func AddHTLCWitnessToInputs(inputs cashu.Proofs, preimage string, signingKey *btcec.PrivateKey) (cashu.Proofs, error)

it will add signatures if signingKey is not nil

func AddHTLCWitnessToOutputs

func AddHTLCWitnessToOutputs(outputs cashu.BlindedMessages, preimage string, signingKey *btcec.PrivateKey) (cashu.BlindedMessages, error)

it will add signatures if signingKey is not nil

func AddP2PKWitnessToInputs

func AddP2PKWitnessToInputs(inputs cashu.Proofs, signingKeys []*btcec.PrivateKey) (cashu.Proofs, error)

func AddP2PKWitnessToOutputs

func AddP2PKWitnessToOutputs(
	outputs cashu.BlindedMessages,
	signingKeys []*btcec.PrivateKey,
) (cashu.BlindedMessages, error)

func BlindedMessagesFromSpendingCondition

func BlindedMessagesFromSpendingCondition(
	splitAmounts []uint64,
	keysetId string,
	spendingCondition nut10.SpendingCondition,
) (
	cashu.BlindedMessages,
	[]string,
	[]*secp256k1.PrivateKey,
	error,
)

func CLNClient

func CLNClient(clnNode *cln.CLN) (*lightning.CLNClient, error)

func ConstructProofs

func ConstructProofs(blindedSignatures cashu.BlindedSignatures,
	secrets []string, rs []*secp256k1.PrivateKey, keyset nut01.Keyset) (cashu.Proofs, error)

func CreateBlindedMessages

func CreateBlindedMessages(amount uint64, keysetId string) (cashu.BlindedMessages, []string, []*secp256k1.PrivateKey, error)

func CreateTestMint

func CreateTestMint(
	backend lightning.Client,
	dbpath string,
	inputFeePpk uint,
	limits mint.MintLimits,
) (*mint.Mint, error)

func CreateTestMintServer

func CreateTestMintServer(
	backend lightning.Client,
	port int,
	rotateKeyset bool,
	dbpath string,
	inputFeePpk uint,
) (*mint.MintServer, error)

func CreateTestWallet

func CreateTestWallet(walletpath, defaultMint string) (*wallet.Wallet, error)

func Fees

func Fees(proofs cashu.Proofs, mint string) (uint, error)

func FundCashuWallet

func FundCashuWallet(ctx context.Context, wallet *wallet.Wallet, backend LightningBackend, amount uint64) error

func FundNode

func FundNode(ctx context.Context, bitcoind *btcdocker.Bitcoind, lightningNode LightningBackend) error

func GenerateRandomBytes

func GenerateRandomBytes() ([]byte, error)

func GetAvailablePort

func GetAvailablePort() (int, error)

func GetProofsWithSpendingCondition

func GetProofsWithSpendingCondition(
	amount uint64,
	spendingCondition nut10.SpendingCondition,
	mint *mint.Mint,
	payer LightningBackend,
) (cashu.Proofs, error)

func GetValidProofsForAmount

func GetValidProofsForAmount(amount uint64, mint *mint.Mint, payer LightningBackend) (cashu.Proofs, error)

func LndClient

func LndClient(lnd *lnd.Lnd) (*lightning.LndClient, error)

func MineBlocks

func MineBlocks(bitcoind *btcdocker.Bitcoind, numBlocks int64) error

func MintConfig

func MintConfig(
	backend lightning.Client,
	port int,
	rotateKeyset bool,
	dbpath string,
	inputFeePpk uint,
	limits mint.MintLimits,
) (*mint.Config, error)

func OpenChannel

func OpenChannel(
	ctx context.Context,
	bitcoind *btcdocker.Bitcoind,
	from LightningBackend,
	to LightningBackend,
	amount uint64,
) error

func SyncNode

func SyncNode(node LightningBackend) error

Types

type CLNBackend

type CLNBackend struct {
	*cln.CLN
	// contains filtered or unexported fields
}

func NewCLNBackend

func NewCLNBackend(cln *cln.CLN) *CLNBackend

func (*CLNBackend) ConnectToPeer

func (clnContainer *CLNBackend) ConnectToPeer(peer *Peer) error

func (*CLNBackend) CreateHodlInvoice

func (clnContainer *CLNBackend) CreateHodlInvoice(amount uint64, hash string) (*Invoice, error)

NOTE: CLN does not support HODL invoices (unless using a plugin). These will not be used in the tests. Rather will do it through LND.

func (*CLNBackend) CreateInvoice

func (clnContainer *CLNBackend) CreateInvoice(amount uint64) (*Invoice, error)

func (*CLNBackend) Info

func (clnContainer *CLNBackend) Info() (*NodeInfo, error)

func (*CLNBackend) LookupInvoice

func (clnContainer *CLNBackend) LookupInvoice(hash string) (*Invoice, error)

func (*CLNBackend) NewAddress

func (clnContainer *CLNBackend) NewAddress() (btcutil.Address, error)

func (*CLNBackend) OpenChannel

func (clnContainer *CLNBackend) OpenChannel(to *Peer, amount uint64) error

func (*CLNBackend) PayInvoice

func (clnContainer *CLNBackend) PayInvoice(invoice string) error

func (*CLNBackend) Post

func (clnContainer *CLNBackend) Post(url string, body interface{}) (*http.Response, error)

func (*CLNBackend) SettleHodlInvoice

func (clnContainer *CLNBackend) SettleHodlInvoice(preimage string) error

func (*CLNBackend) Synced

func (clnContainer *CLNBackend) Synced() (bool, error)

type InfoResponse

type InfoResponse struct {
	Id                 string `json:"id"`
	BitcoindSyncWarn   string `json:"warning_bitcoind_sync"`
	LightningdSyncWarn string `json:"warning_lightningd_sync"`
}

type Invoice

type Invoice struct {
	PaymentRequest string
	Hash           string
	Preimage       string
}

type LightningBackend

type LightningBackend interface {
	Info() (*NodeInfo, error)
	Synced() (bool, error)
	NewAddress() (btcutil.Address, error)
	ConnectToPeer(peer *Peer) error
	OpenChannel(to *Peer, amount uint64) error
	PayInvoice(string) error
	CreateInvoice(amount uint64) (*Invoice, error)
	LookupInvoice(hash string) (*Invoice, error)
	CreateHodlInvoice(amount uint64, hash string) (*Invoice, error)
	SettleHodlInvoice(preimage string) error
}

type LndBackend

type LndBackend struct {
	*lnd.Lnd
}

func (*LndBackend) ConnectToPeer

func (lndContainer *LndBackend) ConnectToPeer(peer *Peer) error

func (*LndBackend) CreateHodlInvoice

func (lndContainer *LndBackend) CreateHodlInvoice(amount uint64, hash string) (*Invoice, error)

func (*LndBackend) CreateInvoice

func (lndContainer *LndBackend) CreateInvoice(amount uint64) (*Invoice, error)

func (*LndBackend) Info

func (lndContainer *LndBackend) Info() (*NodeInfo, error)

func (*LndBackend) LookupInvoice

func (lndContainer *LndBackend) LookupInvoice(hash string) (*Invoice, error)

func (*LndBackend) NewAddress

func (lndContainer *LndBackend) NewAddress() (btcutil.Address, error)

func (*LndBackend) OpenChannel

func (lndContainer *LndBackend) OpenChannel(to *Peer, amount uint64) error

func (*LndBackend) PayInvoice

func (lndContainer *LndBackend) PayInvoice(invoice string) error

func (*LndBackend) SettleHodlInvoice

func (lndContainer *LndBackend) SettleHodlInvoice(preimage string) error

func (*LndBackend) Synced

func (lndContainer *LndBackend) Synced() (bool, error)

type NodeInfo

type NodeInfo struct {
	Pubkey string
	Addr   string
}

type NutshellMintContainer

type NutshellMintContainer struct {
	testcontainers.Container
	Host string
}

func CreateNutshellMintContainer

func CreateNutshellMintContainer(ctx context.Context, inputFeePpk int, lnd *lnd.Lnd) (*NutshellMintContainer, error)

type Peer

type Peer struct {
	Pubkey string
	Addr   string
}

Jump to

Keyboard shortcuts

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