Skip to content

Commit

Permalink
set default API URL to localhost:8888, add HTTP HEADER support in env…
Browse files Browse the repository at this point in the history
… var, adapt README
  • Loading branch information
Stéphane Duchesneau committed Apr 24, 2020
1 parent 76d29d2 commit feca3c3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 68 deletions.
7 changes: 7 additions & 0 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

```bash
go get -u -v github.com/eoscanada/eosc/eosc

```


Expand All @@ -30,6 +31,11 @@ go get -u -v github.com/eoscanada/eosc/eosc
安装完成后运行下面命令来导入你的私钥:

```
export EOSC_GLOBAL_API_URL=https://...
# export EOSC_GLOBAL_HTTP_HEADER_0="Authorization: bearer abcdef12323453452565676589"
# export EOSC_GLOBAL_HTTP_HEADER_1="Origin: https://...
eosc vault create --import
```

Expand All @@ -42,6 +48,7 @@ eosc vote --help
然后运行如下命令为你的候选者投票:

```
eosc vote producers [your account] [producer1] [producer2] [producer3]
```
命令中参数依次为: [你的账户名] [你要投票的BP1] [你要投票的BP2] [你要投票的BP3] (你共可以为30个BP投票)
Expand Down
104 changes: 37 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`eosc` command-line swiss-army-knife
-------------------------------
# `eosc` command-line swiss-army-knife

## Description
[点击查看中文](./README-cn.md)

`eosc` is a cross-platform (Windows, Mac and Linux) command-line tool
Expand All @@ -17,8 +17,7 @@ mainnet launch. Source code for most operations is already available
in this repository.


Installation
------------
## Installation

1. Install from https://github.com/eoscanada/eosc/releases

Expand All @@ -39,8 +38,7 @@ brew install eoscanada/tap/eosc
```


Vote now!
---------
## Getting started

Once installed run:

Expand All @@ -50,36 +48,33 @@ eosc vault create --import

to import your keys and follow instructions.

Then run:
Then set your environment variable to the API URL of your choice, optionally setting some HTTP headers:

```
eosc vote --help
```

and run something like this:
export EOSC_GLOBAL_API_URL=https://your-favorite-endpoint
```
eosc vote producers [your account] [producer1] [producer2] [producer3]
export EOSC_GLOBAL_HTTP_HEADER_0="Authorization: bearer abcdef12323453452565676589"
export EOSC_GLOBAL_HTTP_HEADER_1="Origin: https://something...
```

Make sure you have version `v0.7.0` or higher:

```
eosc version
```
Then you can

Read more below for details.
## Environment variables
---------------------
* All global flags (those you get from eosc –help) can be set with the following pattern: EOSC_GLOBAL_FLAG_NAME. The most useful are:
* `EOSC_GLOBAL_WALLET_URL` -> `--wallet-url`
* `EOSC_GLOBAL_VAULT_FILE` -> `--vault-file`

* All (sub)command flags map to the following pattern: EOSC_COMMAND_SUBCOMMAND_CMD_FLAG_NAME (ex: `EOSC_FORUM_POST_CMD_REPLY_TO` -> `eosc forum post --reply-to=...`
* `EOSC_GLOBAL_INSECURE_VAULT_PASSPHRASE` allows you to input the passphrase directly in an environment variable (useful for test automation, risky for most other uses)
* `EOSC_GLOBAL_HTTP_HEADER_0` (available for indexes 0 to 25)

eosc vault
----------
## eosc vault management

The `eosc vault` is a simple yet powerful EOS wallet.



Import keys in new wallet
=========================
### Import keys in new wallet

You can **import externally generated private keys** with `vault create --import` call.

Expand All @@ -104,8 +99,7 @@ for cryptographic primitives used.



New wallet with new keys
========================
### New wallet with new keys

Create a new wallet with:

Expand All @@ -120,8 +114,7 @@ Wallet file "./eosc-vault.json" created. Here are your public keys:
```


Add keys to an existing vault
=============================
### Add keys to an existing vault

To add an externally generated private key to an existing vault, use:

Expand All @@ -141,43 +134,6 @@ Total keys writteN: 3
The vault operations do zero network calls and can be done offline.
The file is encrypted, can safely be archived and is future proof.

Casting your votes
------------------

With an `eosc-vault.json`, you can vote:

```
$ eosc vote producers youraccount eoscanadacom someotherfavo riteproducer
Enter passphrase to unlock vault:
Voter [youraccount] voting for: [eoscanadacom]
Done
```

This will sign your vote transaction locally, and submit the
transaction to the network through the `https://mainnet.eoscanada.com`
endpoint. You can also point to some other endpoints that are on the
main network with `-u` or `--api-url`.

Find what your account is on https://eosq.app



Cryptographic primitives used
-----------------------------

The cryptography used is NaCl
([C implementation](https://tweetnacl.cr.yp.to/), [Javascript port](https://github.com/dchest/tweetnacl-js),
[Go version, which we use](https://godoc.org/golang.org/x/crypto/nacl/secretbox)). And
key derivation is [Argon2](https://en.wikipedia.org/wiki/Argon2),
using the [Go library
here](https://godoc.org/golang.org/x/crypto/argon2).

You can inspect the crypto code in our codebase regarding the
`passphrase` implementation: [it is 61 lines](./vault/passphrase.go),
including blanks and comments.



## Offline transaction signature


Expand Down Expand Up @@ -344,9 +300,23 @@ need to stitch transaction files, or gather signatures into a single
place.


## Cryptographic primitives used
-----------------------------

FAQ
---
The cryptography used is NaCl
([C implementation](https://tweetnacl.cr.yp.to/), [Javascript port](https://github.com/dchest/tweetnacl-js),
[Go version, which we use](https://godoc.org/golang.org/x/crypto/nacl/secretbox)). And
key derivation is [Argon2](https://en.wikipedia.org/wiki/Argon2),
using the [Go library
here](https://godoc.org/golang.org/x/crypto/argon2).

You can inspect the crypto code in our codebase regarding the
`passphrase` implementation: [it is 61 lines](./vault/passphrase.go),
including blanks and comments.



## FAQ

Q: Why not use `cleos` instead ?

Expand Down
6 changes: 6 additions & 0 deletions eosc/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func getAPI() *eos.API {
httpHeaders := viper.GetStringSlice("global-http-header")
api := eos.New(sanitizeAPIURL(viper.GetString("global-api-url")))

for i := 0; i < 25; i++ {
if val := os.Getenv(fmt.Sprintf("EOSC_GLOBAL_HTTP_HEADER_%d", i)); val != "" {
httpHeaders = append(httpHeaders, val)
}
}

for _, header := range httpHeaders {
headerArray := strings.SplitN(header, ": ", 2)
if len(headerArray) != 2 || strings.Contains(headerArray[0], " ") {
Expand Down
2 changes: 1 addition & 1 deletion eosc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func init() {
RootCmd.PersistentFlags().BoolP("debug", "", false, "Enables verbose API debug messages")
RootCmd.PersistentFlags().StringP("vault-file", "", "./eosc-vault.json", "Wallet file that contains encrypted key material")
RootCmd.PersistentFlags().StringSliceP("wallet-url", "", []string{}, "Base URL to wallet endpoint. You can pass this multiple times to use the multi-signer (will use each wallet to sign multi-sig transactions).")
RootCmd.PersistentFlags().StringP("api-url", "u", "https://mainnet.eoscanada.com", "API endpoint of eos.io blockchain node")
RootCmd.PersistentFlags().StringP("api-url", "u", "http://localhost:8888", "API endpoint of eos.io blockchain node")
RootCmd.PersistentFlags().StringSliceP("permission", "p", []string{}, "Permission to sign transactions with. Optionally specify more than one, or separate by comma")
RootCmd.PersistentFlags().StringSliceP("http-header", "H", []string{}, "HTTP header to add to a request. Optionally repeat this option to specify multiple headers")
RootCmd.PersistentFlags().StringP("kms-gcp-keypath", "", "", "Path to the cryptoKeys within a keyRing on GCP")
Expand Down

0 comments on commit feca3c3

Please sign in to comment.