signing

package
v0.0.0-...-4443e38 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DistSigClientsDescription = map[SignatureClientType]string{
	DistributionAccountEnvSignatureClientType: "uses the the same distribution account for all tenants, as well as for the HOST, through the secret configured in DISTRIBUTION_SEED.",
	DistributionAccountDBSignatureClientType:  "uses the one different distribution account private key per tenant, and stores them in the database, encrypted with the DISTRIBUTION_ACCOUNT_ENCRYPTION_PASSPHRASE.",
}
View Source
var ErrDistributionAccountIsEmpty = fmt.Errorf("distribution account is empty")
View Source
var ErrUnsupportedCommand = fmt.Errorf("unsupported command for signature client")

Functions

func DistSigClientsDescriptionStr

func DistSigClientsDescriptionStr() string

Types

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)

func (*ChannelAccountDBSignatureClient) Type

type ChannelAccountDBSignatureClientOptions

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

func (*ChannelAccountDBSignatureClientOptions) Validate

type DistributionAccountDBSignatureClient

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

func NewDistributionAccountDBSignatureClient

func NewDistributionAccountDBSignatureClient(opts DistributionAccountDBSignatureClientOptions) (*DistributionAccountDBSignatureClient, error)

NewDistributionAccountDBSignatureClient returns a new instance of the DistributionAccountDB SignatureClient.

func (*DistributionAccountDBSignatureClient) BatchInsert

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

func (*DistributionAccountDBSignatureClient) Delete

func (*DistributionAccountDBSignatureClient) NetworkPassphrase

func (c *DistributionAccountDBSignatureClient) NetworkPassphrase() string

func (*DistributionAccountDBSignatureClient) SignFeeBumpStellarTransaction

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

func (*DistributionAccountDBSignatureClient) SignStellarTransaction

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

func (*DistributionAccountDBSignatureClient) Type

type DistributionAccountDBSignatureClientOptions

type DistributionAccountDBSignatureClientOptions struct {
	NetworkPassphrase    string
	DBConnectionPool     db.DBConnectionPool
	EncryptionPassphrase string
	Encrypter            utils.PrivateKeyEncrypter
}

func (*DistributionAccountDBSignatureClientOptions) Validate

type DistributionAccountEnvOptions

type DistributionAccountEnvOptions struct {
	DistributionPrivateKey string
	NetworkPassphrase      string
}

func (DistributionAccountEnvOptions) String

func (opts DistributionAccountEnvOptions) String() string

func (*DistributionAccountEnvOptions) Validate

func (opts *DistributionAccountEnvOptions) Validate() error

type DistributionAccountEnvSignatureClient

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

func NewDistributionAccountEnvSignatureClient

func NewDistributionAccountEnvSignatureClient(opts DistributionAccountEnvOptions) (*DistributionAccountEnvSignatureClient, error)

NewDistributionAccountEnvSignatureClient returns a new DistributionAccountEnvSignatureClient instance

func (*DistributionAccountEnvSignatureClient) BatchInsert

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

func (*DistributionAccountEnvSignatureClient) Delete

func (*DistributionAccountEnvSignatureClient) NetworkPassphrase

func (c *DistributionAccountEnvSignatureClient) NetworkPassphrase() string

func (*DistributionAccountEnvSignatureClient) SignFeeBumpStellarTransaction

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

func (*DistributionAccountEnvSignatureClient) SignStellarTransaction

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

func (*DistributionAccountEnvSignatureClient) String

func (*DistributionAccountEnvSignatureClient) Type

type DistributionAccountResolver

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

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.DistributionAccount, error)

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

func (*DistributionAccountResolverImpl) DistributionAccountFromContext

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

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

func (*DistributionAccountResolverImpl) HostDistributionAccount

func (r *DistributionAccountResolverImpl) HostDistributionAccount() string

HostDistributionAccount returns the host distribution account from the database.

type DistributionAccountResolverOptions

type DistributionAccountResolverOptions struct {
	AdminDBConnectionPool            db.DBConnectionPool
	HostDistributionAccountPublicKey string
}

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
	Type() string
}

func NewSignatureClient

func NewSignatureClient(sigType SignatureClientType, 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           utils.PrivateKeyEncrypter // (optional)
}

type SignatureClientType

type SignatureClientType string
const (
	ChannelAccountDBSignatureClientType       SignatureClientType = "CHANNEL_ACCOUNT_DB"
	DistributionAccountEnvSignatureClientType SignatureClientType = "DISTRIBUTION_ACCOUNT_ENV"
	DistributionAccountDBSignatureClientType  SignatureClientType = "DISTRIBUTION_ACCOUNT_DB"
	HostAccountEnvSignatureClientType         SignatureClientType = "HOST_ACCOUNT_ENV"
)

func AllSignatureClientTypes

func AllSignatureClientTypes() []SignatureClientType

func DistributionSignatureClientTypes

func DistributionSignatureClientTypes() []SignatureClientType

func ParseSignatureClientDistributionType

func ParseSignatureClientDistributionType(sigClientType string) (SignatureClientType, error)

func ParseSignatureClientType

func ParseSignatureClientType(sigClientType string) (SignatureClientType, error)

func (SignatureClientType) DistributionAccountType

func (s SignatureClientType) DistributionAccountType() (schema.DistributionAccountType, error)

type SignatureService

type SignatureService struct {
	ChAccountSigner   SignatureClient
	DistAccountSigner SignatureClient
	HostAccountSigner SignatureClient
	DistributionAccountResolver
	// contains filtered or unexported fields
}

func NewMockSignatureService

func NewMockSignatureService(t mockConstructorTestingTNewMockSignatureService) (
	sigService SignatureService,
	chAccSigClient *mocks.MockSignatureClient,
	distAccSigClient *mocks.MockSignatureClient,
	hostAccSigClient *mocks.MockSignatureClient,
	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

	// DistributionAccount:
	DistributionSignerType SignatureClientType

	// DistributionAccountEnv:
	DistributionPrivateKey string

	// DistributionAccountDB:
	DistAccEncryptionPassphrase string

	// ChannelAccountDB:
	ChAccEncryptionPassphrase string

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

	// DistributionAccountResolver
	DistributionAccountResolver
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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