account

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	AccountTypeEVM = "ethereum"
	AccountTypeAR  = "arweave"
)

Variables

View Source
var (
	ERR_INVALID_ID           = errors.New("err_invalid_id")
	ERR_INVALID_ACCOUNT_TYPE = errors.New("err_invalid_account_type")
	ERR_INVALID_NONCE        = errors.New("err_invalid_nonce")
	ERR_NONCE_TOO_LOW        = errors.New("err_nonce_too_low")
	ERR_INVALID_SIGNATURE    = errors.New("err_invalid_signature")
	ERR_INVALID_TRANSACTION  = errors.New("err_invalid_transaction")
)

Functions

func DecodeArSig

func DecodeArSig(sig string) (s []byte, pub *rsa.PublicKey, addr string, err error)

func DecodeEthSig

func DecodeEthSig(sig string) []byte

func IDCheck

func IDCheck(id string) (accountType, accid string, err error)

func IsArAddress

func IsArAddress(addr string) bool

Types

type Account

type Account struct {
	ID    string // ID is eth address, notice: Case Sensitive
	Type  string
	Nonce int64
}

func New

func New(id string) (*Account, error)

func (*Account) UpdateNonce

func (a *Account) UpdateNonce(nonce int64)

func (*Account) Verify

func (a *Account) Verify(tx Transaction) (nonce int64, err error)

Verify & return transaction's nonce

func (*Account) VerifySig

func (a *Account) VerifySig(tx Transaction) (err error)

only verify signature

type Transaction

type Transaction struct {
	Nonce string
	Hash  []byte
	Sig   string
}

Jump to

Keyboard shortcuts

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