EthWallet (eth_wallet v0.0.13)

Documentation for EthWallet.

    1. keys operations
    1. generate signed tx

    tx generated path: build_tx -> hash_for_signing(serialize -> rlp encode -> kec) -> gen sig -> get signed tx -> to raw tx-> send tx to node

Link to this section Summary

Functions

decrypt key with password.

encrypt key with password.

generate keys with/without privkey.

iex> EthWallet.generate_keys(<<21, ..., 166>>)

recover pubkey by recovcery id, generated by sign compact

sign uncompact, as sign in bitcoin.

sign compact, as sign in ethereum.

signed transaction to raw transaction

verify uncompact, fit to sign()

verify compact, fit to sign_compact()

Link to this section Functions

Link to this function

build_tx(to_str, value, data, nonce, gas_price, gas_limit)

Specs

build_tx(String.t(), integer(), binary(), integer(), integer(), integer()) ::
  Transction.t()

build transaction

Link to this function

decrypt_key(payload, password)

decrypt key with password.

## Examples

iex> EthWallet.decrypt_key(payload, "bbc")

"ddd"

Link to this function

encrypt_key(encrypted_key, password)

encrypt key with password.

## Examples

iex> EthWallet.encrypt_key("ddd", "abc")

<<40, 28, 220, 122, 235, 180, 216, 145, 142, 171, 53, 146, 25, 136, 47, 215>>

Link to this function

generate_keys()

generate keys with/without privkey.

## Examples

iex> EthWallet.generate_keys()

%{

addr: "0xd705f740d934acfb27df7bf71aadc00f20d03c7a",
priv: <<21, ..., 166>>,
pub: <<4, ..., 165, ...>>

}

Link to this function

generate_keys(priv)

Specs

generate_keys(binary()) :: map()

iex> EthWallet.generate_keys(<<21, ..., 166>>)

%{

addr: "0xd705f740d934acfb27df7bf71aadc00f20d03c7a",
priv: <<21, ..., 166, ...>>,
pub: <<4, ..., 165, ...>>

}

Link to this function

recover(digest, signature, recovery_id_handled, chain_id \\ nil)

Specs

recover(binary(), binary(), integer(), nil | integer()) ::
  {:ok, binary()} | {:error, String.t()}

recover pubkey by recovcery id, generated by sign compact

Link to this function

sign(digest, privkey)

Specs

sign(binary(), binary()) :: binary()

sign uncompact, as sign in bitcoin.

Link to this function

sign_compact(digest, privkey, chain_id \\ nil)

Specs

sign_compact(<<_::256>>, <<_::256>>, nil | integer()) :: %{
  v: integer(),
  r: integer(),
  s: integer(),
  sig: <<_::512>>
}

sign compact, as sign in ethereum.

Link to this function

sign_tx(tx, private_key, chain_id \\ nil)

Specs

sign transaction

Link to this function

signed_tx_to_raw_tx(signed_tx)

Specs

signed_tx_to_raw_tx(EthWallet.Transaction.t()) :: String.t()

signed transaction to raw transaction

Link to this function

verify(msg, sig, pubkey)

Specs

verify(binary(), binary(), binary()) :: boolean()

verify uncompact, fit to sign()

Link to this function

verify_compact(msg, sig, pubkey)

Specs

verify_compact(binary(), binary(), binary()) :: boolean()

verify compact, fit to sign_compact()