walletextension

package
v0.23.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

README

The Ten gateway

See the documentation here.

Developer notes

Running gateway frontend locally requires building static files first. To do that, run npm run build in tools/walletextension/frontend folder.

The precompiled binaries for macOS ARM64, macOS AMD64, Windows AMD64 and Linux AMD64 can be built by running the following commands from the tools/walletextension/main folder:

env GOOS=darwin GOARCH=amd64 go build -o ../bin/wallet_extension_macos_amd64 .
    env GOOS=darwin GOARCH=arm64 go build -o ../bin/wallet_extension_macos_arm64 .
env GOOS=windows GOARCH=amd64 go build -o ../bin/wallet_extension_win_amd64.exe .
env GOOS=linux GOARCH=amd64 go build -o ../bin/wallet_extension_linux_amd64 .

The binaries will be created in the tools/walletextension/bin folder.

Structure

This package follows the same structure of host and enclave.

It uses a container to wrap the services that are required to allow the wallet extension to fulfill the business logic.

Running Wallet Extension with Docker

To build a docker image use docker build command. Please note that you need to run it from the root of the repository. To run the container you can use ./docker_run.sh. You can add parameters to the script, and they are passed to the wallet extension (example: -host=0.0.0.0 to be able to access wallet extension endpoints via localhost).

HTTP Endpoints

For interacting with Ten Gateway, there are the following HTTP endpoints available:

  • GET /v1/join

It generates and returns userID which needs to be added as a query parameter "u" to the URL in your Metamask (or another provider) as it identifies you.

  • POST /v1/authenticate?token=$EncryptionToken

With this endpoint, you submit a signed message in the format Register <userID> for <account> from that account which proves that you hold private keys for it, and it links that account with your userID.

  • GET /v1/query/address?token=$EncryptionToken&a=$Address

This endpoint responds with a JSON of true or false if the address "a" is already registered for user "u"

  • POST "/v1/revoke?token=$EncryptionToken"

When this endpoint is triggered, the userId with the authenticated viewing keys should be deleted.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type WalletExtension

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

WalletExtension handles the management of viewing keys and the forwarding of Ethereum JSON-RPC requests.

func New

func New(
	hostAddrHTTP string,
	hostAddrWS string,
	userAccountManager *useraccountmanager.UserAccountManager,
	storage storage.Storage,
	stopControl *stopcontrol.StopControl,
	version string,
	logger gethlog.Logger,
	config *config.Config,
) *WalletExtension

func (*WalletExtension) AddAddressToUser

func (w *WalletExtension) AddAddressToUser(hexUserID string, address string, signature []byte) error

AddAddressToUser checks if a message is in correct format and if signature is valid. If all checks pass we save address and signature against userID

func (*WalletExtension) DeleteUser

func (w *WalletExtension) DeleteUser(hexUserID string) error

DeleteUser deletes user and accounts associated with user from the database for given userID

func (*WalletExtension) GenerateAndStoreNewUser

func (w *WalletExtension) GenerateAndStoreNewUser() (string, error)

GenerateAndStoreNewUser generates new key-pair and userID, stores it in the database and returns hex encoded userID and error

func (*WalletExtension) GenerateViewingKey

func (w *WalletExtension) GenerateViewingKey(addr gethcommon.Address) (string, error)

GenerateViewingKey generates the user viewing key and waits for signature

func (*WalletExtension) GetTenNodeHealthStatus added in v0.21.0

func (w *WalletExtension) GetTenNodeHealthStatus() (bool, error)

func (*WalletExtension) IsStopping

func (w *WalletExtension) IsStopping() bool

IsStopping returns whether the WE is stopping

func (*WalletExtension) Logger

func (w *WalletExtension) Logger() gethlog.Logger

Logger returns the WE set logger

func (*WalletExtension) ProxyEthRequest

func (w *WalletExtension) ProxyEthRequest(request *common.RPCRequest, conn userconn.UserConn, hexUserID string) (map[string]interface{}, error)

ProxyEthRequest proxys an incoming user request to the enclave

func (*WalletExtension) SubmitViewingKey

func (w *WalletExtension) SubmitViewingKey(address gethcommon.Address, signature []byte) error

SubmitViewingKey checks the signed viewing key and stores it

func (*WalletExtension) UserExists

func (w *WalletExtension) UserExists(hexUserID string) bool

func (*WalletExtension) UserHasAccount

func (w *WalletExtension) UserHasAccount(hexUserID string, address string) (bool, error)

UserHasAccount checks if provided account exist in the database for given userID

func (*WalletExtension) Version

func (w *WalletExtension) Version() string

Jump to

Keyboard shortcuts

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