EthWallet (eth_wallet v0.0.13)
Documentation for EthWallet
.
- keys operations
- 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
build transaction
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.
sign transaction
signed transaction to raw transaction
verify uncompact, fit to sign()
verify compact, fit to sign_compact()
Link to this section Functions
build_tx(to_str, value, data, nonce, gas_price, gas_limit)
Specs
build transaction
decrypt_key(payload, password)
decrypt key with password.
## Examples
iex> EthWallet.decrypt_key(payload, "bbc")
"ddd"
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>>
generate_keys()
generate keys with/without privkey.
## Examples
iex> EthWallet.generate_keys()
%{
addr: "0xd705f740d934acfb27df7bf71aadc00f20d03c7a",
priv: <<21, ..., 166>>,
pub: <<4, ..., 165, ...>>
}
generate_keys(priv)
Specs
iex> EthWallet.generate_keys(<<21, ..., 166>>)
%{
addr: "0xd705f740d934acfb27df7bf71aadc00f20d03c7a",
priv: <<21, ..., 166, ...>>,
pub: <<4, ..., 165, ...>>
}
recover(digest, signature, recovery_id_handled, chain_id \\ nil)
Specs
recover pubkey by recovcery id, generated by sign compact
sign(digest, privkey)
Specs
sign uncompact, as sign in bitcoin.
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.
sign_tx(tx, private_key, chain_id \\ nil)
Specs
sign_tx(EthWallet.Transaction.t(), binary(), integer() | nil) :: EthWallet.Transaction.t()
sign transaction
signed_tx_to_raw_tx(signed_tx)
Specs
signed_tx_to_raw_tx(EthWallet.Transaction.t()) :: String.t()
signed transaction to raw transaction
verify(msg, sig, pubkey)
Specs
verify uncompact, fit to sign()
verify_compact(msg, sig, pubkey)
Specs
verify compact, fit to sign_compact()