wallet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package wallet provides the necessary components to use Stellar accounts for Perun payment channels.

Index

Constants

View Source
const SignatureLength = 64

SignatureLength is the length of a signature in bytes.

Variables

View Source
var Backend = backend{}

Functions

func NewRandomAddress

func NewRandomAddress(rng *rand.Rand) wallet.Address

NewRandomAddress creates a new random address.

Types

type Account

type Account struct {

	// ParticipantAddress references the ParticipantAddress of the Participant this account belongs to.
	ParticipantAddress keypair.FromAddress
	// CCAddr is the cross-chain address of the participant.
	CCAddr [types.CCAddressLength]byte
	// contains filtered or unexported fields
}

Account is used for signing channel state.

func NewAccount added in v0.3.0

func NewAccount(privateKey string, addr keypair.FromAddress, ccAddr [types.CCAddressLength]byte) *Account

NewAccount creates a new account with the given private key and addresses.

func NewRandomAccount

func NewRandomAccount(rng *rand.Rand) (*Account, *keypair.Full, error)

NewRandomAccount creates a new account with a random private key. It also creates a random key pair, using its address as the account'privateKey Account.ParticipantAddress.

func NewRandomAccountWithAddress

func NewRandomAccountWithAddress(rng *rand.Rand, addr *keypair.FromAddress) (*Account, error)

NewRandomAccountWithAddress creates a new account with a random private key and the given address as Account.ParticipantAddress.

func (Account) Address

func (a Account) Address() wallet.Address

Address returns the Participant this account belongs to.

func (Account) Participant

func (a Account) Participant() *types.Participant

Participant returns the Participant this account belongs to.

func (Account) SignData

func (a Account) SignData(data []byte) ([]byte, error)

SignData signs the given data with the account's private key.

type EphemeralWallet

type EphemeralWallet struct {
	// contains filtered or unexported fields
}

EphemeralWallet is a wallet that stores accounts in memory.

func NewEphemeralWallet

func NewEphemeralWallet() *EphemeralWallet

NewEphemeralWallet creates a new EphemeralWallet instance.

func (*EphemeralWallet) AddAccount

func (e *EphemeralWallet) AddAccount(acc *Account) error

AddAccount adds the given account to the wallet.

func (*EphemeralWallet) AddNewAccount

func (e *EphemeralWallet) AddNewAccount(rng *rand.Rand) (*Account, *keypair.Full, error)

AddNewAccount generates a new account and adds it to the wallet.

func (*EphemeralWallet) DecrementUsage

func (e *EphemeralWallet) DecrementUsage(address wallet.Address)

DecrementUsage decrements the usage counter of the account associated with the given address.

func (*EphemeralWallet) IncrementUsage

func (e *EphemeralWallet) IncrementUsage(address wallet.Address)

IncrementUsage increments the usage counter of the account associated with the given address.

func (*EphemeralWallet) LockAll

func (e *EphemeralWallet) LockAll()

LockAll locks all accounts.

func (*EphemeralWallet) Unlock

Unlock unlocks the account associated with the given address.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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