signing

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN secretType = iota
	ENV_VAR
	LEDGER
	KEYRING_BACKEND
	GITHUB_SEC
)
View Source
const DefaultFaucetURL = "https://faucet.gitopia.com/"
View Source
const (
	GAS_ADJUSTMENT = 1.8
)

Variables

View Source
var ErrGitopiaKeyNotConfigured = errors.New("gitopia key not configured in OS keyring")

ErrGitopiaKeyNotConfigured is returned when no mnemonic is found in the OS keyring.

Functions

func DefaultFeeGranter

func DefaultFeeGranter() string

DefaultFeeGranter returns the configured fee granter address.

func GenerateMnemonic

func GenerateMnemonic() (string, error)

GenerateMnemonic creates a new 24-word BIP-39 mnemonic using 256-bit entropy.

func NewMarshaler

func NewMarshaler() codec.ProtoCodecMarshaler

func ParseTxResponse

func ParseTxResponse(marshaler codec.ProtoCodecMarshaler, txResponse *tx.GetTxResponse, resp codec.ProtoMarshaler) error

ParseTxResponse parses the data from a transaction response and unmarshals the first message response into the provided type.

func StoreInFile

func StoreInFile(mnemonic string) error

StoreInFile persists a mnemonic to the wallet key file with secure permissions.

func StoreInKeyring

func StoreInKeyring(mnemonic string) error

StoreInKeyring stores a mnemonic in the OS keyring under the gitopia service.

Types

type Account

type Account struct {
	Address       string `json:"address"`
	PathIncrement int    `json:"pathIncrement"`
}

type AutoGeneratedWallet

type AutoGeneratedWallet interface {
	IsAutoGenerated() bool
}

AutoGeneratedWallet is optionally implemented by wallets that were auto-generated.

type FeeGrantSetter

type FeeGrantSetter interface {
	SetFeeGranter(granter string)
}

FeeGrantSetter is optionally implemented by wallets that can have a fee granter set.

type FeeGrantStatus

type FeeGrantStatus struct {
	Claimed bool   `json:"claimed"`
	Error   string `json:"error,omitempty"`
	Message string `json:"message,omitempty"`
}

FeeGrantStatus reports the outcome of a fee grant claim attempt.

func ClaimFeeGrant

func ClaimFeeGrant(ctx context.Context, address, faucetURL string) FeeGrantStatus

ClaimFeeGrant sends a POST request to the faucet to claim a fee grant for the given address. It is best-effort: on any failure (network, timeout, non-200) it returns a FeeGrantStatus with Claimed=false and an error description, but never a Go error.

type GitopiaWallet

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

func (GitopiaWallet) Address

func (gw GitopiaWallet) Address() string

func (GitopiaWallet) Export

func (gw GitopiaWallet) Export() ([]byte, error)

Export returns the wallet data in JSON format for git-remote-gitopia

func (GitopiaWallet) IsAutoGenerated

func (gw GitopiaWallet) IsAutoGenerated() bool

IsAutoGenerated returns true if this wallet was auto-generated (not from user config).

func (*GitopiaWallet) SetFeeGranter

func (gw *GitopiaWallet) SetFeeGranter(granter string)

SetFeeGranter sets the fee granter address so transactions use fee grants.

func (GitopiaWallet) SignAndBroadcast

func (gw GitopiaWallet) SignAndBroadcast(ctx context.Context, grpcConn *grpc.ClientConn, msgs []sdk.Msg) (*tx.GetTxResponse, error)

func (GitopiaWallet) SignData

func (gw GitopiaWallet) SignData(data []byte) (string, error)

func (GitopiaWallet) Type

func (gw GitopiaWallet) Type() secretType

type GitopiaWalletFile

type GitopiaWalletFile struct {
	Name          string    `json:"name"`
	Mnemonic      string    `json:"mnemonic"`
	HDpath        string    `json:"HDpath"`
	Password      string    `json:"password"`
	Prefix        string    `json:"prefix"`
	PathIncrement int       `json:"pathIncrement"`
	Accounts      []Account `json:"accounts"`
}

type Wallet

type Wallet interface {
	SignData(data []byte) (string, error)
	SignAndBroadcast(ctx context.Context, grpcConn *grpc.ClientConn, msgs []sdk.Msg) (*tx.GetTxResponse, error)
	Type() secretType
	Address() string
	Export() ([]byte, error) // Export wallet data for git-remote-gitopia
}

func FromFile

func FromFile(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)

FromFile reads the mnemonic from the wallet key file and constructs a Wallet.

func FromKeyring

func FromKeyring(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)

FromKeyring opens the OS keyring, retrieves the stored mnemonic, and constructs a Wallet with feegrant support.

func FromMnemonic

func FromMnemonic(mnemonic string) (Wallet, error)

FromMnemonic constructs a GitopiaWallet from a raw BIP-39 mnemonic. This is a convenience helper so that callers (e.g. WalletFromHeaders) can build a signing.Wallet without needing to parse wallet files or keyrings.

It derives the first Cosmos HD path (m/44'/118'/0'/0/0) using Secp256k1. NOTE: This should be used only in trusted environments, as the mnemonic is handled in-memory.

func FromMnemonicWithFeegrant

func FromMnemonicWithFeegrant(ctx context.Context, mnemonic string, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)

FromMnemonicWithFeegrant constructs a GitopiaWallet from a mnemonic and sets feegrant if available.

func InitGitopiaWallet

func InitGitopiaWallet(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient) (Wallet, error)

func InitWallet

func InitWallet(ctx context.Context, bankClient banktypes.QueryClient, feegrantClient feegrant.QueryClient, backend string) (Wallet, error)

InitWallet creates a Wallet using the specified backend. Supported backends: "keyring", "mnemonic", "file", "auto" (or empty). The "auto" backend tries: env var -> wallet key file -> legacy wallet file -> auto-generate. OS keyring is only used when explicitly set via GITOPIA_WALLET_BACKEND=keyring.

func NewTestWallet

func NewTestWallet(address string, signErr error) Wallet

NewTestWallet returns a Wallet suitable for handler-level testing. If signErr is non-nil, SignAndBroadcast will return it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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