wallet

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package wallet manages local treechat-style BSV wallets for the CLI.

A wallet is a Treechat/Shuallet-style keyfile with separate payment and ordinals WIF keys (`payPk` and `ordPk`). The payment key derives the address used by the CLI's BSV billing lane.

This package deliberately does NOT sign or broadcast transactions. Keygen, import, and address derivation are local and safe; spending is left to the billing "pay" flow (see cmd/billing_wallet.go), which is where on-chain signing/settlement gets wired.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir() (string, error)

Dir is where wallet keyfiles live (alongside the treecli config).

func Save

func Save(file *File) (string, error)

Save writes the wallet keyfile with owner-only permissions and returns its path. The basename is the label if present, otherwise the address.

Types

type File

type File struct {
	Label      string `json:"label,omitempty"`
	PayWIF     string `json:"payPk"`
	OrdWIF     string `json:"ordPk"`
	PublicKey  string `json:"publicKey,omitempty"`
	Address    string `json:"address,omitempty"`
	OrdAddress string `json:"ordinalsAddress,omitempty"`
	CreatedAt  string `json:"created_at,omitempty"`
}

File is the on-disk Shuallet-compatible keyfile. `payPk` and `ordPk` are the canonical Treechat wallet fields; address fields are derived convenience metadata for CLI display.

func FromWIF

func FromWIF(wif, label string) (*File, error)

FromWIF builds a Shuallet-compatible wallet from an existing payment WIF. Legacy single-key imports reuse the payment key as the ordinals key so the resulting keyfile still has Treechat's required `payPk`/`ordPk` shape.

func Generate

func Generate(label string) (*File, error)

Generate creates a brand-new random wallet.

func List

func List() ([]*File, error)

List returns the saved wallets sorted by name.

func Load

func Load(name string) (*File, error)

Load reads a wallet by label/name (with or without the .json suffix).

func ParseImport

func ParseImport(data []byte, label string) (*File, error)

ParseImport tolerantly reads a treechat-style wallet export and extracts the payment key. The address is re-derived from the WIF and cross-checked against any address the file declares.

func Resolve

func Resolve(name string) (*File, error)

Resolve returns the wallet to act on: the named one, or the only one when no name is given and exactly one exists.

func (*File) Name

func (file *File) Name() string

Name is the wallet's display name: its label, or its address if unlabeled.

func (*File) Redacted

func (file *File) Redacted() string

Redacted returns the WIF with the middle masked, for display.

Jump to

Keyboard shortcuts

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