nip60

package
v0.0.0-...-3d1c7b5 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProofsAndMint

func GetProofsAndMint(tokenStr string) (cashu.Proofs, string, error)

func MakeTokenString

func MakeTokenString(proofs cashu.Proofs, mint string) string

Types

type HistoryEntry

type HistoryEntry struct {
	In     bool // in = received, out = sent
	Amount uint64

	TokenReferences []TokenRef
	// contains filtered or unexported fields
}

type ReceiveOption

type ReceiveOption func(*receiveSettings)

func WithMintDestination

func WithMintDestination(url string) ReceiveOption

func WithNutzap

func WithNutzap() ReceiveOption

type SendOption

type SendOption func(opts *sendSettings)

func WithMint

func WithMint(url string) SendOption

func WithP2PK

func WithP2PK(pubkey string) SendOption

func WithRefundable

func WithRefundable(timelock nostr.Timestamp) SendOption

type SwapOption

type SwapOption func(*swapSettings)

func WithSignedOutputs

func WithSignedOutputs() SwapOption

func WithSpendingCondition

func WithSpendingCondition(sc nut10.SpendingCondition) SwapOption

type Token

type Token struct {
	Mint    string       `json:"mint"`
	Proofs  cashu.Proofs `json:"proofs"`
	Deleted []string     `json:"del,omitempty"`
	// contains filtered or unexported fields
}

func (Token) ID

func (t Token) ID() string

type TokenRef

type TokenRef struct {
	EventID  string
	Created  bool
	IsNutzap bool
}

type Wallet

type Wallet struct {
	sync.Mutex

	// PublishUpdate must be set to a function that publishes event to the user relays
	// (if all arguments are their zero values that means it is a wallet update event).
	PublishUpdate func(
		event nostr.Event,
		deleted *Token,
		received *Token,
		change *Token,
		isHistory bool,
	)

	// Processed, if not nil, is called every time a received event is processed
	Processed func(*nostr.Event, error)

	// Stable is closed when we have gotten an EOSE from all relays
	Stable chan struct{}

	// properties that come in events
	PrivateKey *btcec.PrivateKey
	PublicKey  *btcec.PublicKey
	Mints      []string
	Tokens     []Token
	History    []HistoryEntry
	// contains filtered or unexported fields
}

func LoadWallet

func LoadWallet(
	ctx context.Context,
	kr nostr.Keyer,
	pool *nostr.SimplePool,
	relays []string,
) *Wallet

func LoadWalletWithHistory

func LoadWalletWithHistory(
	ctx context.Context,
	kr nostr.Keyer,
	pool *nostr.SimplePool,
	relays []string,
) *Wallet

func (*Wallet) AddMint

func (w *Wallet) AddMint(ctx context.Context, urls ...string) error

func (*Wallet) Balance

func (w *Wallet) Balance() uint64

func (*Wallet) Close

func (w *Wallet) Close() error

Close waits for pending operations to end

func (*Wallet) PayBolt11

func (w *Wallet) PayBolt11(ctx context.Context, invoice string, opts ...SendOption) (string, error)

func (*Wallet) Receive

func (w *Wallet) Receive(
	ctx context.Context,
	proofs cashu.Proofs,
	mint string,
	opts ...ReceiveOption,
) error

func (*Wallet) RemoveMint

func (w *Wallet) RemoveMint(ctx context.Context, urls ...string) error

func (*Wallet) Send

func (w *Wallet) Send(ctx context.Context, amount uint64, opts ...SendOption) (cashu.Proofs, string, error)

func (*Wallet) SendExternal

func (w *Wallet) SendExternal(
	ctx context.Context,
	mint string,
	targetAmount uint64,
	opts ...SendOption,
) (cashu.Proofs, error)

func (*Wallet) SetPrivateKey

func (w *Wallet) SetPrivateKey(ctx context.Context, privateKey string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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