walletextension

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: AGPL-3.0 Imports: 20 Imported by: 0

README

👛 The Obscuro wallet extension

See the documentation here.

Developer notes

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. Ro run the container you can use ./docker_run.sh. You can add parameters to the script, and they are passed to wallet extension (example: -host=0.0.0.0 to be able to access wallet extension endpoints via localhost).

HTTP Endpoints

For interacting with Obscuro Gateway, there are the following HTTP endpoint 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?u=$UserId

With this endpoint, you submit a signed message in a 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?u=$UserId&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?u=$UserId"

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 added in v0.14.0

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

func (*WalletExtension) AddAddressToUser added in v0.14.0

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

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

func (*WalletExtension) DeleteUser added in v0.14.0

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

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

func (*WalletExtension) GenerateAndStoreNewUser added in v0.14.0

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 added in v0.14.0

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

GenerateViewingKey generates the user viewing key and waits for signature

func (*WalletExtension) IsStopping added in v0.14.0

func (w *WalletExtension) IsStopping() bool

IsStopping returns whether the WE is stopping

func (*WalletExtension) Logger added in v0.14.0

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

Logger returns the WE set logger

func (*WalletExtension) ProxyEthRequest added in v0.14.0

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

ProxyEthRequest proxys an incoming user request to the enclave

func (*WalletExtension) SubmitViewingKey added in v0.14.0

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

SubmitViewingKey checks the signed viewing key and stores it

func (*WalletExtension) UserExists added in v0.18.0

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

func (*WalletExtension) UserHasAccount added in v0.14.0

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 added in v0.18.0

func (w *WalletExtension) Version() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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