nip60

package
v0.0.0-...-4dab261 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: Unlicense Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetProofsAndMint

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

func GetSatoshisAmountFromBolt11

func GetSatoshisAmountFromBolt11(bolt11 string) (uint64, error)

func MakeTokenString

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

func ParseKeysetKeys

func ParseKeysetKeys(keys nut01.KeysMap) (map[uint64]*btcec.PublicKey, error)

Types

type HistoryEntry

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

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

type PayOptions

type PayOptions struct {
	FromMint string
}

PayOptions contains options for paying a bolt11 invoice

type ReceiveOptions

type ReceiveOptions struct {
	IntoMint                               []string
	IsNutzap                               bool
	AcceptTokensInSourceMintInTheWorseCase bool
}

ReceiveOptions contains options for receiving tokens

type SendOptions

type SendOptions struct {
	SpecificSourceMint string
	P2PK               *btcec.PublicKey
	RefundTimelock     nostr.Timestamp
	Hashlock           [32]byte
}

SendOptions contains options for sending tokens

type Token

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

func (Token) ID

func (t Token) ID() string

type TokenRef

type TokenRef struct {
	EventID  nostr.ID
	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
	// (do not do any wallet operations while handling this as that will cause a mutex deadlock).
	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.Pool,
	relays []string,
	opts WalletOptions,
) *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) DropToken

func (w *Wallet) DropToken(
	ctx context.Context,
	tokenID string,
)

DropToken silently abandons a token

func (*Wallet) PayBolt11

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

func (*Wallet) Receive

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

func (*Wallet) RemoveMint

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

func (*Wallet) SendExternal

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

func (*Wallet) SendInternal

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

func (*Wallet) SetPrivateKey

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

type WalletOptions

type WalletOptions struct {
	WithHistory bool
}

WalletOptions contains options for loading a wallet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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