signing

package
v0.0.0-...-c846bbc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDistributionAccountIsEmpty = fmt.Errorf("distribution account is empty")
View Source
var ErrUnsupportedCommand = fmt.Errorf("unsupported command for signature client")

Functions

This section is empty.

Types

type AccountEnvOptions

type AccountEnvOptions struct {
	DistributionPrivateKey string
	NetworkPassphrase      string
	AccountType            schema.AccountType
}

func (AccountEnvOptions) String

func (opts AccountEnvOptions) String() string

func (*AccountEnvOptions) Validate

func (opts *AccountEnvOptions) Validate() error

type AccountEnvSignatureClient

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

func NewAccountEnvSignatureClient

func NewAccountEnvSignatureClient(opts AccountEnvOptions) (*AccountEnvSignatureClient, error)

NewAccountEnvSignatureClient returns a new AccountEnvSignatureClient instance

func (*AccountEnvSignatureClient) BatchInsert

func (c *AccountEnvSignatureClient) BatchInsert(ctx context.Context, number int) (publicKeys []string, err error)

func (*AccountEnvSignatureClient) Delete

func (c *AccountEnvSignatureClient) Delete(ctx context.Context, publicKey string) error

func (*AccountEnvSignatureClient) NetworkPassphrase

func (c *AccountEnvSignatureClient) NetworkPassphrase() string

func (*AccountEnvSignatureClient) SignFeeBumpStellarTransaction

func (c *AccountEnvSignatureClient) SignFeeBumpStellarTransaction(ctx context.Context, feeBumpStellarTx *txnbuild.FeeBumpTransaction, stellarAccounts ...string) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)

func (*AccountEnvSignatureClient) SignStellarTransaction

func (c *AccountEnvSignatureClient) SignStellarTransaction(ctx context.Context, stellarTx *txnbuild.Transaction, stellarAccounts ...string) (signedStellarTx *txnbuild.Transaction, err error)

func (*AccountEnvSignatureClient) String

func (c *AccountEnvSignatureClient) String() string

type ChannelAccountDBSignatureClient

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

func NewChannelAccountDBSignatureClient

func NewChannelAccountDBSignatureClient(opts ChannelAccountDBSignatureClientOptions) (*ChannelAccountDBSignatureClient, error)

NewChannelAccountDBSignatureClient returns a new instance of the ChannelAccountDB SignatureClient.

func (*ChannelAccountDBSignatureClient) BatchInsert

func (c *ChannelAccountDBSignatureClient) BatchInsert(ctx context.Context, number int) (publicKeys []string, err error)

func (*ChannelAccountDBSignatureClient) Delete

func (c *ChannelAccountDBSignatureClient) Delete(ctx context.Context, publicKey string) error

func (*ChannelAccountDBSignatureClient) NetworkPassphrase

func (c *ChannelAccountDBSignatureClient) NetworkPassphrase() string

func (*ChannelAccountDBSignatureClient) SignFeeBumpStellarTransaction

func (c *ChannelAccountDBSignatureClient) SignFeeBumpStellarTransaction(ctx context.Context, feeBumpStellarTx *txnbuild.FeeBumpTransaction, stellarAccounts ...string) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)

func (*ChannelAccountDBSignatureClient) SignStellarTransaction

func (c *ChannelAccountDBSignatureClient) SignStellarTransaction(ctx context.Context, stellarTx *txnbuild.Transaction, stellarAccounts ...string) (signedStellarTx *txnbuild.Transaction, err error)

type ChannelAccountDBSignatureClientOptions

type ChannelAccountDBSignatureClientOptions struct {
	NetworkPassphrase    string
	DBConnectionPool     db.DBConnectionPool
	EncryptionPassphrase string
	Encrypter            sdpUtils.PrivateKeyEncrypter
	LedgerNumberTracker  preconditions.LedgerNumberTracker
}

func (*ChannelAccountDBSignatureClientOptions) Validate

type DistributionAccountDBVaultSignatureClient

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

func NewDistributionAccountDBVaultSignatureClient

func NewDistributionAccountDBVaultSignatureClient(opts DistributionAccountDBVaultSignatureClientOptions) (*DistributionAccountDBVaultSignatureClient, error)

NewDistributionAccountDBVaultSignatureClient returns a new instance of the DistributionAccountDB SignatureClient.

func (*DistributionAccountDBVaultSignatureClient) BatchInsert

func (c *DistributionAccountDBVaultSignatureClient) BatchInsert(ctx context.Context, number int) (publicKeys []string, err error)

func (*DistributionAccountDBVaultSignatureClient) Delete

func (*DistributionAccountDBVaultSignatureClient) NetworkPassphrase

func (c *DistributionAccountDBVaultSignatureClient) NetworkPassphrase() string

func (*DistributionAccountDBVaultSignatureClient) SignFeeBumpStellarTransaction

func (c *DistributionAccountDBVaultSignatureClient) SignFeeBumpStellarTransaction(ctx context.Context, feeBumpStellarTx *txnbuild.FeeBumpTransaction, publicKeys ...string) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)

func (*DistributionAccountDBVaultSignatureClient) SignStellarTransaction

func (c *DistributionAccountDBVaultSignatureClient) SignStellarTransaction(ctx context.Context, stellarTx *txnbuild.Transaction, publicKeys ...string) (signedStellarTx *txnbuild.Transaction, err error)

type DistributionAccountDBVaultSignatureClientOptions

type DistributionAccountDBVaultSignatureClientOptions struct {
	NetworkPassphrase    string
	DBConnectionPool     db.DBConnectionPool
	EncryptionPassphrase string
	Encrypter            sdpUtils.PrivateKeyEncrypter
}

func (*DistributionAccountDBVaultSignatureClientOptions) Validate

type DistributionAccountResolver

type DistributionAccountResolver interface {
	DistributionAccount(ctx context.Context, tenantID string) (schema.TransactionAccount, error)
	DistributionAccountFromContext(ctx context.Context) (schema.TransactionAccount, error)
	HostDistributionAccount() schema.TransactionAccount
}

DistributionAccountResolver is an interface that provides the distribution iven the provided keyword.

type DistributionAccountResolverImpl

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

DistributionAccountResolverImpl is a DistributionAccountResolver that resolves the distribution account from the database.

func (*DistributionAccountResolverImpl) DistributionAccount

func (r *DistributionAccountResolverImpl) DistributionAccount(ctx context.Context, tenantID string) (schema.TransactionAccount, error)

DistributionAccount returns the tenant's distribution account stored in the database.

func (*DistributionAccountResolverImpl) DistributionAccountFromContext

func (r *DistributionAccountResolverImpl) DistributionAccountFromContext(ctx context.Context) (schema.TransactionAccount, error)

DistributionAccountFromContext returns the tenant's distribution account from the tenant object stored in the context provided.

func (*DistributionAccountResolverImpl) HostDistributionAccount

func (r *DistributionAccountResolverImpl) HostDistributionAccount() schema.TransactionAccount

HostDistributionAccount returns the host distribution account from the database.

type DistributionAccountResolverOptions

type DistributionAccountResolverOptions struct {
	AdminDBConnectionPool            db.DBConnectionPool
	HostDistributionAccountPublicKey string
	MTNDBConnectionPool              db.DBConnectionPool
}

func (DistributionAccountResolverOptions) Validate

type SignatureClient

type SignatureClient interface {
	NetworkPassphrase() string
	SignStellarTransaction(ctx context.Context, stellarTx *txnbuild.Transaction, stellarAccounts ...string) (signedStellarTx *txnbuild.Transaction, err error)
	SignFeeBumpStellarTransaction(ctx context.Context, feeBumpStellarTx *txnbuild.FeeBumpTransaction, stellarAccounts ...string) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)
	BatchInsert(ctx context.Context, number int) (publicKeys []string, err error)
	Delete(ctx context.Context, publicKey string) error
}

func NewSignatureClient

func NewSignatureClient(accType schema.AccountType, opts SignatureClientOptions) (SignatureClient, error)

type SignatureClientOptions

type SignatureClientOptions struct {
	// Shared:
	NetworkPassphrase string

	// DistributionAccountEnv:
	DistributionPrivateKey string

	// DistributionAccountDB:
	DistAccEncryptionPassphrase string

	// ChannelAccountDB:
	ChAccEncryptionPassphrase string

	// *AccountDB:
	DBConnectionPool    db.DBConnectionPool
	LedgerNumberTracker preconditions.LedgerNumberTracker
	Encrypter           sdpUtils.PrivateKeyEncrypter // (optional)
}

type SignatureRouterOptions

type SignatureRouterOptions struct {
	// Shared for ALL signers:
	NetworkPassphrase string

	// HOST.STELLAR.ENV:
	HostPrivateKey string

	// DISTRIBUTION_ACCOUNT.STELLAR.ENV:
	DistributionPrivateKey string

	// DISTRIBUTION_ACCOUNT.STELLAR.DB_VAULT:
	DistAccEncryptionPassphrase string

	// CHANNEL_ACCOUNT.STELLAR.DB:
	ChAccEncryptionPassphrase string
	LedgerNumberTracker       preconditions.LedgerNumberTracker

	// *.STELLAR.DB_VAULT:
	DBConnectionPool db.DBConnectionPool
	Encrypter        sdpUtils.PrivateKeyEncrypter // (optional)
}

type SignatureService

type SignatureService struct {
	SignerRouter
	DistributionAccountResolver
	// contains filtered or unexported fields
}

func NewMockSignatureService

func NewMockSignatureService(t mockConstructorTestingTNewMockSignatureService) (
	sigService SignatureService,
	signerRouter *mocks.MockSignerRouter,
	distAccResolver *mocks.MockDistributionAccountResolver,
)

NewMockSignatureService is a constructor for the SignatureService with mock clients.

func NewSignatureService

func NewSignatureService(opts SignatureServiceOptions) (SignatureService, error)

NewSignatureService creates a new signature service instance, given the distribution signer type and the options.

func (*SignatureService) NetworkPassphrase

func (ss *SignatureService) NetworkPassphrase() string

func (*SignatureService) Validate

func (s *SignatureService) Validate() error

type SignatureServiceOptions

type SignatureServiceOptions struct {
	// Shared:
	NetworkPassphrase string

	// DistributionAccountEnv:
	DistributionPrivateKey string

	// DistributionAccountDB:
	DistAccEncryptionPassphrase string

	// ChannelAccountDB:
	ChAccEncryptionPassphrase string

	// *AccountDB:
	DBConnectionPool    db.DBConnectionPool
	LedgerNumberTracker preconditions.LedgerNumberTracker
	Encrypter           sdpUtils.PrivateKeyEncrypter

	// DistributionAccountResolver
	DistributionAccountResolver
}

type SignerRouter

type SignerRouter interface {
	NetworkPassphrase() string
	SupportedAccountTypes() []schema.AccountType
	SignStellarTransaction(ctx context.Context, stellarTx *txnbuild.Transaction, stellarAccounts ...schema.TransactionAccount) (signedStellarTx *txnbuild.Transaction, err error)
	SignFeeBumpStellarTransaction(ctx context.Context, feeBumpStellarTx *txnbuild.FeeBumpTransaction, stellarAccounts ...schema.TransactionAccount) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)
	BatchInsert(ctx context.Context, accountType schema.AccountType, number int) (stellarAccounts []schema.TransactionAccount, err error)
	Delete(ctx context.Context, stellarAccount schema.TransactionAccount) error
}

func NewSignerRouter

func NewSignerRouter(opts SignatureRouterOptions, accountTypes ...schema.AccountType) (SignerRouter, error)

type SignerRouterImpl

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

func NewSignerRouterImpl

func NewSignerRouterImpl(network string, strategies map[schema.AccountType]SignatureClient) SignerRouterImpl

func (*SignerRouterImpl) BatchInsert

func (r *SignerRouterImpl) BatchInsert(
	ctx context.Context,
	accountType schema.AccountType,
	number int,
) (stellarAccounts []schema.TransactionAccount, err error)

func (*SignerRouterImpl) Delete

func (r *SignerRouterImpl) Delete(
	ctx context.Context,
	account schema.TransactionAccount,
) error

func (*SignerRouterImpl) NetworkPassphrase

func (r *SignerRouterImpl) NetworkPassphrase() string

func (*SignerRouterImpl) RouteSigner

func (r *SignerRouterImpl) RouteSigner(distAcctountType schema.AccountType) (SignatureClient, error)

func (*SignerRouterImpl) SignFeeBumpStellarTransaction

func (r *SignerRouterImpl) SignFeeBumpStellarTransaction(
	ctx context.Context,
	feeBumpStellarTx *txnbuild.FeeBumpTransaction,
	accounts ...schema.TransactionAccount,
) (signedFeeBumpStellarTx *txnbuild.FeeBumpTransaction, err error)

func (*SignerRouterImpl) SignStellarTransaction

func (r *SignerRouterImpl) SignStellarTransaction(
	ctx context.Context,
	stellarTx *txnbuild.Transaction,
	accounts ...schema.TransactionAccount,
) (signedStellarTx *txnbuild.Transaction, err error)

func (*SignerRouterImpl) SupportedAccountTypes

func (r *SignerRouterImpl) SupportedAccountTypes() []schema.AccountType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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