一、Account

// Account represents an Ethereum account located at a specific location defined
// by the optional URL field.
// Account,代表一个位于由可选的URL字段定义的具体位置的以太坊账户
// Address,地址是20个字节,由私钥衍生。。URL,可选字段,后端的资源位置
type Account struct {
Address common.Address `json:"address"` // Ethereum account address derived from the key
URL URL `json:"url"` // Optional resource locator within a backend
}

二、Wallet

type Wallet interface {
// URL retrieves the canonical path under which this wallet is reachable. It is
// user by upper layers to define a sorting order over all wallets from multiple
// backends.
// URL 用来获取这个钱包可以访问的规范路径。被上层使用,为所有来自于各种backend的钱包定义一个排序
URL() URL // Status returns a textual status to aid the user in the current state of the
// wallet. It also returns an error indicating any failure the wallet might have
// encountered.
// Status 返回钱包的当前状态的文本来帮助使用者。同时返回一个错误来指示钱包可能会遇到的任何错误
Status() (string, error) // Open initializes access to a wallet instance. It is not meant to unlock or
// decrypt account keys, rather simply to establish a connection to hardware
// wallets and/or to access derivation seeds.
//
// The passphrase parameter may or may not be used by the implementation of a
// particular wallet instance. The reason there is no passwordless open method
// is to strive towards a uniform wallet handling, oblivious to the different
// backend providers.
//
// Please note, if you open a wallet, you must close it to release any allocated
// resources (especially important when working with hardware wallets).
// Open 初始化对钱包实例的访问。这个方法并不意味着解锁或者解密账户秘钥,而是简单地建立与硬件钱包的连接和/或访问衍生种子。
// 请注意,如果你open了一个钱包,你必须close它。不然有些资源可能没有释放。特别是使用硬件钱包的时候需要特别注意。
Open(passphrase string) error // Close releases any resources held by an open wallet instance.
// Close 释放一个打开的钱包实例的占用的任何资源。
Close() error // Accounts retrieves the list of signing accounts the wallet is currently aware
// of. For hierarchical deterministic wallets, the list will not be exhaustive,
// rather only contain the accounts explicitly pinned during account derivation.
// Accounts 用来获取钱包正发现的账户列表。对于分层次的钱包,这个列表不会详尽的列出所有的账号,而是只包含在帐户派生期间明确固定的帐户。
Accounts() []Account // Contains returns whether an account is part of this particular wallet or not.
// Contains 返回一个账号是否属于本钱包。
Contains(account Account) bool // Derive attempts to explicitly derive a hierarchical deterministic account at
// the specified derivation path. If requested, the derived account will be added
// to the wallet's tracked account list.
// Derive 尝试在指定的派生路径上显式派生出分层确定性帐户。如果pin为true,派生帐户将被添加到钱包的跟踪帐户列表中。
Derive(path DerivationPath, pin bool) (Account, error) // SelfDerive sets a base account derivation path from which the wallet attempts
// to discover non zero accounts and automatically add them to list of tracked
// accounts.
//
// Note, self derivaton will increment the last component of the specified path
// opposed to decending into a child path to allow discovering accounts starting
// from non zero components.
//
// You can disable automatic account discovery by calling SelfDerive with a nil
// chain state reader.
// SelfDerive 设置一个基本帐户导出路径,从中钱包尝试发现非零帐户,并自动将其添加到跟踪帐户列表中。
// 注意,SelfDerive将递增指定路径的最后一个组件,而不是下降到子路径,以允许从非零组件开始发现帐户。
// 你可以通过传递一个nil的ChainStateReader来禁用自动账号发现。
SelfDerive(base DerivationPath, chain ethereum.ChainStateReader) // SignHash requests the wallet to sign the given hash.
//
// It looks up the account specified either solely via its address contained within,
// or optionally with the aid of any location metadata from the embedded URL field.
//
// If the wallet requires additional authentication to sign the request (e.g.
// a password to decrypt the account, or a PIN code o verify the transaction),
// an AuthNeededError instance will be returned, containing infos for the user
// about which fields or actions are needed. The user may retry by providing
// the needed details via SignHashWithPassphrase, or by other means (e.g. unlock
// the account in a keystore).
// SignHash 请求钱包来给传入的hash进行签名。
// 它可以通过其中包含的地址(或可选地借助嵌入式URL字段中的任何位置元数据)来查找指定的帐户。
// 如果钱包需要额外的验证才能签名(比如说需要密码来解锁账号,或者是需要一个PIN代码来验证交易),
// 会返回一个AuthNeededError的错误,里面包含了用户的信息,以及哪些字段或者操作需要提供。
// 用户可以通过SignHashWithPassphrase来签名或者通过其他手段(在keystore里面解锁账号)
SignHash(account Account, hash []byte) ([]byte, error) // SignTx requests the wallet to sign the given transaction.
//
// It looks up the account specified either solely via its address contained within,
// or optionally with the aid of any location metadata from the embedded URL field.
//
// If the wallet requires additional authentication to sign the request (e.g.
// a password to decrypt the account, or a PIN code to verify the transaction),
// an AuthNeededError instance will be returned, containing infos for the user
// about which fields or actions are needed. The user may retry by providing
// the needed details via SignTxWithPassphrase, or by other means (e.g. unlock
// the account in a keystore).
// SignTx 请求钱包对指定的交易进行签名。
SignTx(account Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) // SignHashWithPassphrase requests the wallet to sign the given hash with the
// given passphrase as extra authentication information.
//
// It looks up the account specified either solely via its address contained within,
// or optionally with the aid of any location metadata from the embedded URL field.
// SignHashWithPassphrase 请求钱包使用给定的passphrase来作为额外的认证信息去签名给定的hash
SignHashWithPassphrase(account Account, passphrase string, hash []byte) ([]byte, error) // SignTxWithPassphrase requests the wallet to sign the given transaction, with the
// given passphrase as extra authentication information.
//
// It looks up the account specified either solely via its address contained within,
// or optionally with the aid of any location metadata from the embedded URL field.
// SignHashWithPassphrase 请求钱包使用给定的passphrase来作为额外的认证信息去签名给定的transaction
SignTxWithPassphrase(account Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
}

三、Backend

// Backend is a "wallet provider" that may contain a batch of accounts they can
// sign transactions with and upon request, do so.
// Backend 是一个钱包提供器,包含一批账号。他们可以根据请求签署交易
type Backend interface {
// Wallets retrieves the list of wallets the backend is currently aware of.
//
// The returned wallets are not opened by default. For software HD wallets this
// means that no base seeds are decrypted, and for hardware wallets that no actual
// connection is established.
//
// The resulting wallet list will be sorted alphabetically based on its internal
// URL assigned by the backend. Since wallets (especially hardware) may come and
// go, the same wallet might appear at a different positions in the list during
// subsequent retrievals.
// 检索backend当前知道的一批钱包,返回的钱包默认是关闭的
// 所产生的钱包列表将根据后端分配的内部URL按字母顺序排序。由于钱包(特别是硬件钱包)可能会打开和关闭,
// 所以在随后的检索过程中,相同的钱包可能会出现在列表中的不同位置。
Wallets() []Wallet // Subscribe creates an async subscription to receive notifications when the
// backend detects the arrival or departure of a wallet.
// 创建异步订阅,以便在后端检测到钱包的到达或离开时接收通知。
Subscribe(sink chan<- WalletEvent) event.Subscription
}

Ethereum 源码分析之 accounts的更多相关文章

  1. [ethereum源码分析](3) ethereum初始化指令

    前言 在上一章介绍了关于区块链的一些基础知识,这一章会分析指令 geth --datadir dev/data/02 init private-geth/genesis.json 的源码,若你的eth ...

  2. go ethereum源码分析 PartIV Transaction相关

    核心数据结构: core.types.transaction.go type Transaction struct { data txdata // caches hash atomic.Value ...

  3. [ethereum源码分析](5) 创建新账号

    前言 在上一章我们介绍了 ethereum运行开启console 的过程,那么在这一章我们将会介绍如何在以太坊中创建一个新的账号.以下的理解可能存在错误,如果各位大虾发现错误,还望指正. 指令分析 指 ...

  4. [ethereum源码分析](4) ethereum运行开启console

    前言 在上一章我们介绍了  ethereum初始化指令 ,包括了系统是如何调用指令和指令的执行.在本章节我们将会介绍 geth --datadir dev/data/ --networkid cons ...

  5. Ethereum 源码分析之框架

    accounts 实现了一个高等级的以太坊账户管理     bmt          二进制的默克尔树的实现     build           主要是编译和构建的一些脚本和配置     cmd  ...

  6. [ethereum源码分析](2) ethereum基础知识

    前言 上一章我们介绍了如何搭建ethereum的debug环境.为了更深入的了解ethereum,我们需要了解一些ethereum的相关的知识,本章我们将介绍这些知识. ethereum相关知识 在学 ...

  7. [ethereum源码分析](1) dubug环境搭建

    前言 因为最近云小哥哥换了一份工作,新公司比较忙,所以一直没有更新新的博客.云小哥哥新的公司是做区块链的,最近在学习区块链相关的东西(也算是乘坐上了区块链这艘大船).本博客是记录我搭建ethereum ...

  8. Android7.0 Phone应用源码分析(一) phone拨号流程分析

    1.1 dialer拨号 拨号盘点击拨号DialpadFragment的onClick方法会被调用 public void onClick(View view) { int resId = view. ...

  9. 【精】EOS智能合约:system系统合约源码分析

    系统合约在链启动阶段就会被部署,是因为系统合约赋予了EOS链资源.命名拍卖.基础数据准备.生产者信息.投票等能力.本篇文章将会从源码角度详细研究system合约. 关键字:EOS,eosio.syst ...

随机推荐

  1. svn服务器快速搭建及简单配置

    http://www.360doc.com/content/11/0711/19/5131531_132950891.shtml 简介Svn已经不容质疑的成为了一款流行的代码控制工具,但是你是否还在为 ...

  2. 动态载入DLL所需要的三个函数详解(LoadLibrary,GetProcAddress,FreeLibrary)

    动态载入 DLL 动态载入方式是指在编译之前并不知道将会调用哪些 DLL 函数, 完全是在运行过程中根据需要决定应调用哪些函数. 方法是:用 LoadLibrary 函数加载动态链接库到内存,用 Ge ...

  3. C++显式转换

    标准C++包含一个显式的转换语法: --static_cast:用于“良性”和“适度良性”的转换,包括不用强制转换 --const_cast:用于“const”和/或“volatile”进行转换 -- ...

  4. eclipse/myeclipse介绍

    eclipse更加纯净,比较简洁,需要某些插件的时候,需要自己去配置才可以,而myeclipse自带了很多的插件功能更为强大. 在eclipse于myeclipse创建的项目是有差异的,eclipse ...

  5. .NET 4中的多线程编程之一:使用Task(转载)

    原文地址:http://www.cnblogs.com/yinzixin/archive/2011/11/04/2235233.html .NET 4为了简化多线程编程,提供了System.Threa ...

  6. 项目笔记---事半功倍之StyleCop(一)

    前言 曾几何时,你是否在看别人代码的时候总是在抱怨代码没有注释,命名不规范,代码风格不统一,代码可读性差?是否有一个适合团队开发规范的检查工具? 答案就是大名鼎鼎的StyleCop代码检查插件,有了这 ...

  7. PYQT5实现 关闭 提示弹框

    当关闭窗口时,要实现如下功能: def closeEvent(self, event): reply = QtWidgets.QMessageBox.question(self, '警告', '退出后 ...

  8. python 检索一个目录下所有的txt文件,并把文件改为.log

    检索一个目录及子目录下所有的txt文件,并把txt文件后缀改为log: import os f_path = r'C:\Users\PycharmProjects\mystudy\Testfolder ...

  9. 《ASP.NET MVC 5 破境之道》:第一境 ASP.Net MVC5项目初探 — 第一节:运行第一个MVC5项目

    第一境 ASP.Net MVC5项目初探 — 第一节:运行第一个MVC5项目 创建一个MVC项目,是很容易的,大部分工作,VS都帮我们完成了.只需要按照如下步骤按部就班就可以了. 打开VS2017,选 ...

  10. hdu 4325 Flowers(区间离散化)

    http://acm.hdu.edu.cn/showproblem.php?pid=4325 Flowers Time Limit: 4000/2000 MS (Java/Others)    Mem ...