account

package
v0.0.0-...-449d51e Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowedSignMessagesHash = map[string]*struct{}{
	"55c85f40d49bf654adcd277bd44f91fb1ac51b680e34b9f0d022b96c4f91e5ea": nil,
}

Functions

func InitElectionPriceCalculator

func InitElectionPriceCalculator(vochainURI string) (*electionprice.Calculator, error)

InitElectionPriceCalculator initializes the election price calculator with the factors from the Vochain. It returns the election price calculator or an error if it fails to get the factors.

func NewSigner

func NewSigner(secret, creatorEmail string) (*ethereum.SignKeys, string, error)

OrganizationSigner calculates a signer for the organization and the nonce used to calculate the private key of thath signer. The private key is calculated using the SHA256 hash of the secret, the creator email and the nonce. It returns the signer, the nonce and an error if the private key calculation fails.

func OrganizationSigner

func OrganizationSigner(secret, creatorEmail, nonce string) (*ethereum.SignKeys, error)

OrganizationSigner calculates a signer for the organization using the SHA256 hash of the secret, the creator email and the nonce. It returns the signer and an error if the private key calculation fails. It allows to recalculate the signer using the same secret, creator email and nonce for an organization.

func SignMessage

func SignMessage(message []byte, signer *ethereum.SignKeys) ([]byte, error)

SignMessage signs a message with the account's private key. It uses the Ethereum message signature format. Only a subset of messages are allowed to be signed.

Types

type Account

type Account struct {
	TxCosts           map[models.TxType]uint64
	ElectionPriceCalc *electionprice.Calculator
	// contains filtered or unexported fields
}

Account handles the account operations that include signing transactions, creating faucet packages, etc.

func New

func New(privateKey string, apiEndpoint string) (*Account, error)

New creates a new account with the given private key and API endpoint. If the account doesn't exist, it creates a new one.

func (*Account) FaucetPackage

func (a *Account) FaucetPackage(toAddr string, amount uint64) (*models.FaucetPackage, error)

FaucetPackage generates a faucet package for the given address and amount.

func (*Account) SignTransaction

func (a *Account) SignTransaction(tx *models.Tx, signer *ethereum.SignKeys) ([]byte, error)

SignTransaction signs a transaction with the account's private key. Returns the payload of the signed protobuf transaction (models.SignedTx).

Jump to

Keyboard shortcuts

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