main.go 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. // Copyright 2018 The go-ethereum Authors
  2. // This file is part of go-ethereum.
  3. //
  4. // go-ethereum is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // go-ethereum is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
  16. package main
  17. import (
  18. "bufio"
  19. "context"
  20. "crypto/rand"
  21. "crypto/sha256"
  22. "encoding/hex"
  23. "encoding/json"
  24. "fmt"
  25. "io"
  26. "math/big"
  27. "os"
  28. "os/signal"
  29. "path/filepath"
  30. "runtime"
  31. "strings"
  32. "time"
  33. "github.com/ethereum/go-ethereum/accounts"
  34. "github.com/ethereum/go-ethereum/accounts/keystore"
  35. "github.com/ethereum/go-ethereum/cmd/utils"
  36. "github.com/ethereum/go-ethereum/common"
  37. "github.com/ethereum/go-ethereum/common/hexutil"
  38. "github.com/ethereum/go-ethereum/core/types"
  39. "github.com/ethereum/go-ethereum/crypto"
  40. "github.com/ethereum/go-ethereum/internal/ethapi"
  41. "github.com/ethereum/go-ethereum/internal/flags"
  42. "github.com/ethereum/go-ethereum/log"
  43. "github.com/ethereum/go-ethereum/node"
  44. "github.com/ethereum/go-ethereum/params"
  45. "github.com/ethereum/go-ethereum/rlp"
  46. "github.com/ethereum/go-ethereum/rpc"
  47. "github.com/ethereum/go-ethereum/signer/core"
  48. "github.com/ethereum/go-ethereum/signer/core/apitypes"
  49. "github.com/ethereum/go-ethereum/signer/fourbyte"
  50. "github.com/ethereum/go-ethereum/signer/rules"
  51. "github.com/ethereum/go-ethereum/signer/storage"
  52. "github.com/mattn/go-colorable"
  53. "github.com/mattn/go-isatty"
  54. "github.com/urfave/cli/v2"
  55. )
  56. const legalWarning = `
  57. WARNING!
  58. Clef is an account management tool. It may, like any software, contain bugs.
  59. Please take care to
  60. - backup your keystore files,
  61. - verify that the keystore(s) can be opened with your password.
  62. Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  63. without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  64. PURPOSE. See the GNU General Public License for more details.
  65. `
  66. var (
  67. logLevelFlag = &cli.IntFlag{
  68. Name: "loglevel",
  69. Value: 4,
  70. Usage: "log level to emit to the screen",
  71. }
  72. advancedMode = &cli.BoolFlag{
  73. Name: "advanced",
  74. Usage: "If enabled, issues warnings instead of rejections for suspicious requests. Default off",
  75. }
  76. acceptFlag = &cli.BoolFlag{
  77. Name: "suppress-bootwarn",
  78. Usage: "If set, does not show the warning during boot",
  79. }
  80. keystoreFlag = &cli.StringFlag{
  81. Name: "keystore",
  82. Value: filepath.Join(node.DefaultDataDir(), "keystore"),
  83. Usage: "Directory for the keystore",
  84. }
  85. configdirFlag = &cli.StringFlag{
  86. Name: "configdir",
  87. Value: DefaultConfigDir(),
  88. Usage: "Directory for Clef configuration",
  89. }
  90. chainIdFlag = &cli.Int64Flag{
  91. Name: "chainid",
  92. Value: params.MainnetChainConfig.ChainID.Int64(),
  93. Usage: "Chain id to use for signing (1=mainnet, 3=Ropsten, 4=Rinkeby, 5=Goerli)",
  94. }
  95. rpcPortFlag = &cli.IntFlag{
  96. Name: "http.port",
  97. Usage: "HTTP-RPC server listening port",
  98. Value: node.DefaultHTTPPort + 5,
  99. Category: flags.APICategory,
  100. }
  101. signerSecretFlag = &cli.StringFlag{
  102. Name: "signersecret",
  103. Usage: "A file containing the (encrypted) master seed to encrypt Clef data, e.g. keystore credentials and ruleset hash",
  104. }
  105. customDBFlag = &cli.StringFlag{
  106. Name: "4bytedb-custom",
  107. Usage: "File used for writing new 4byte-identifiers submitted via API",
  108. Value: "./4byte-custom.json",
  109. }
  110. auditLogFlag = &cli.StringFlag{
  111. Name: "auditlog",
  112. Usage: "File used to emit audit logs. Set to \"\" to disable",
  113. Value: "audit.log",
  114. }
  115. ruleFlag = &cli.StringFlag{
  116. Name: "rules",
  117. Usage: "Path to the rule file to auto-authorize requests with",
  118. }
  119. stdiouiFlag = &cli.BoolFlag{
  120. Name: "stdio-ui",
  121. Usage: "Use STDIN/STDOUT as a channel for an external UI. " +
  122. "This means that an STDIN/STDOUT is used for RPC-communication with a e.g. a graphical user " +
  123. "interface, and can be used when Clef is started by an external process.",
  124. }
  125. testFlag = &cli.BoolFlag{
  126. Name: "stdio-ui-test",
  127. Usage: "Mechanism to test interface between Clef and UI. Requires 'stdio-ui'.",
  128. }
  129. initCommand = &cli.Command{
  130. Action: initializeSecrets,
  131. Name: "init",
  132. Usage: "Initialize the signer, generate secret storage",
  133. ArgsUsage: "",
  134. Flags: []cli.Flag{
  135. logLevelFlag,
  136. configdirFlag,
  137. },
  138. Description: `
  139. The init command generates a master seed which Clef can use to store credentials and data needed for
  140. the rule-engine to work.`,
  141. }
  142. attestCommand = &cli.Command{
  143. Action: attestFile,
  144. Name: "attest",
  145. Usage: "Attest that a js-file is to be used",
  146. ArgsUsage: "<sha256sum>",
  147. Flags: []cli.Flag{
  148. logLevelFlag,
  149. configdirFlag,
  150. signerSecretFlag,
  151. },
  152. Description: `
  153. The attest command stores the sha256 of the rule.js-file that you want to use for automatic processing of
  154. incoming requests.
  155. Whenever you make an edit to the rule file, you need to use attestation to tell
  156. Clef that the file is 'safe' to execute.`,
  157. }
  158. setCredentialCommand = &cli.Command{
  159. Action: setCredential,
  160. Name: "setpw",
  161. Usage: "Store a credential for a keystore file",
  162. ArgsUsage: "<address>",
  163. Flags: []cli.Flag{
  164. logLevelFlag,
  165. configdirFlag,
  166. signerSecretFlag,
  167. },
  168. Description: `
  169. The setpw command stores a password for a given address (keyfile).
  170. `}
  171. delCredentialCommand = &cli.Command{
  172. Action: removeCredential,
  173. Name: "delpw",
  174. Usage: "Remove a credential for a keystore file",
  175. ArgsUsage: "<address>",
  176. Flags: []cli.Flag{
  177. logLevelFlag,
  178. configdirFlag,
  179. signerSecretFlag,
  180. },
  181. Description: `
  182. The delpw command removes a password for a given address (keyfile).
  183. `}
  184. newAccountCommand = &cli.Command{
  185. Action: newAccount,
  186. Name: "newaccount",
  187. Usage: "Create a new account",
  188. ArgsUsage: "",
  189. Flags: []cli.Flag{
  190. logLevelFlag,
  191. keystoreFlag,
  192. utils.LightKDFFlag,
  193. acceptFlag,
  194. },
  195. Description: `
  196. The newaccount command creates a new keystore-backed account. It is a convenience-method
  197. which can be used in lieu of an external UI.`,
  198. }
  199. gendocCommand = &cli.Command{
  200. Action: GenDoc,
  201. Name: "gendoc",
  202. Usage: "Generate documentation about json-rpc format",
  203. Description: `
  204. The gendoc generates example structures of the json-rpc communication types.
  205. `}
  206. )
  207. var (
  208. // Git SHA1 commit hash of the release (set via linker flags)
  209. gitCommit = ""
  210. gitDate = ""
  211. app = flags.NewApp(gitCommit, gitDate, "Manage Ethereum account operations")
  212. )
  213. func init() {
  214. app.Name = "Clef"
  215. app.Flags = []cli.Flag{
  216. logLevelFlag,
  217. keystoreFlag,
  218. configdirFlag,
  219. chainIdFlag,
  220. utils.LightKDFFlag,
  221. utils.NoUSBFlag,
  222. utils.SmartCardDaemonPathFlag,
  223. utils.HTTPListenAddrFlag,
  224. utils.HTTPVirtualHostsFlag,
  225. utils.IPCDisabledFlag,
  226. utils.IPCPathFlag,
  227. utils.HTTPEnabledFlag,
  228. rpcPortFlag,
  229. signerSecretFlag,
  230. customDBFlag,
  231. auditLogFlag,
  232. ruleFlag,
  233. stdiouiFlag,
  234. testFlag,
  235. advancedMode,
  236. acceptFlag,
  237. }
  238. app.Action = signer
  239. app.Commands = []*cli.Command{initCommand,
  240. attestCommand,
  241. setCredentialCommand,
  242. delCredentialCommand,
  243. newAccountCommand,
  244. gendocCommand,
  245. }
  246. }
  247. func main() {
  248. if err := app.Run(os.Args); err != nil {
  249. fmt.Fprintln(os.Stderr, err)
  250. os.Exit(1)
  251. }
  252. }
  253. func initializeSecrets(c *cli.Context) error {
  254. // Get past the legal message
  255. if err := initialize(c); err != nil {
  256. return err
  257. }
  258. // Ensure the master key does not yet exist, we're not willing to overwrite
  259. configDir := c.String(configdirFlag.Name)
  260. if err := os.Mkdir(configDir, 0700); err != nil && !os.IsExist(err) {
  261. return err
  262. }
  263. location := filepath.Join(configDir, "masterseed.json")
  264. if _, err := os.Stat(location); err == nil {
  265. return fmt.Errorf("master key %v already exists, will not overwrite", location)
  266. }
  267. // Key file does not exist yet, generate a new one and encrypt it
  268. masterSeed := make([]byte, 256)
  269. num, err := io.ReadFull(rand.Reader, masterSeed)
  270. if err != nil {
  271. return err
  272. }
  273. if num != len(masterSeed) {
  274. return fmt.Errorf("failed to read enough random")
  275. }
  276. n, p := keystore.StandardScryptN, keystore.StandardScryptP
  277. if c.Bool(utils.LightKDFFlag.Name) {
  278. n, p = keystore.LightScryptN, keystore.LightScryptP
  279. }
  280. text := "The master seed of clef will be locked with a password.\nPlease specify a password. Do not forget this password!"
  281. var password string
  282. for {
  283. password = utils.GetPassPhrase(text, true)
  284. if err := core.ValidatePasswordFormat(password); err != nil {
  285. fmt.Printf("invalid password: %v\n", err)
  286. } else {
  287. fmt.Println()
  288. break
  289. }
  290. }
  291. cipherSeed, err := encryptSeed(masterSeed, []byte(password), n, p)
  292. if err != nil {
  293. return fmt.Errorf("failed to encrypt master seed: %v", err)
  294. }
  295. // Double check the master key path to ensure nothing wrote there in between
  296. if err = os.Mkdir(configDir, 0700); err != nil && !os.IsExist(err) {
  297. return err
  298. }
  299. if _, err := os.Stat(location); err == nil {
  300. return fmt.Errorf("master key %v already exists, will not overwrite", location)
  301. }
  302. // Write the file and print the usual warning message
  303. if err = os.WriteFile(location, cipherSeed, 0400); err != nil {
  304. return err
  305. }
  306. fmt.Printf("A master seed has been generated into %s\n", location)
  307. fmt.Printf(`
  308. This is required to be able to store credentials, such as:
  309. * Passwords for keystores (used by rule engine)
  310. * Storage for JavaScript auto-signing rules
  311. * Hash of JavaScript rule-file
  312. You should treat 'masterseed.json' with utmost secrecy and make a backup of it!
  313. * The password is necessary but not enough, you need to back up the master seed too!
  314. * The master seed does not contain your accounts, those need to be backed up separately!
  315. `)
  316. return nil
  317. }
  318. func attestFile(ctx *cli.Context) error {
  319. if ctx.NArg() < 1 {
  320. utils.Fatalf("This command requires an argument.")
  321. }
  322. if err := initialize(ctx); err != nil {
  323. return err
  324. }
  325. stretchedKey, err := readMasterKey(ctx, nil)
  326. if err != nil {
  327. utils.Fatalf(err.Error())
  328. }
  329. configDir := ctx.String(configdirFlag.Name)
  330. vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
  331. confKey := crypto.Keccak256([]byte("config"), stretchedKey)
  332. // Initialize the encrypted storages
  333. configStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "config.json"), confKey)
  334. val := ctx.Args().First()
  335. configStorage.Put("ruleset_sha256", val)
  336. log.Info("Ruleset attestation updated", "sha256", val)
  337. return nil
  338. }
  339. func setCredential(ctx *cli.Context) error {
  340. if ctx.NArg() < 1 {
  341. utils.Fatalf("This command requires an address to be passed as an argument")
  342. }
  343. if err := initialize(ctx); err != nil {
  344. return err
  345. }
  346. addr := ctx.Args().First()
  347. if !common.IsHexAddress(addr) {
  348. utils.Fatalf("Invalid address specified: %s", addr)
  349. }
  350. address := common.HexToAddress(addr)
  351. password := utils.GetPassPhrase("Please enter a password to store for this address:", true)
  352. fmt.Println()
  353. stretchedKey, err := readMasterKey(ctx, nil)
  354. if err != nil {
  355. utils.Fatalf(err.Error())
  356. }
  357. configDir := ctx.String(configdirFlag.Name)
  358. vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
  359. pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)
  360. pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
  361. pwStorage.Put(address.Hex(), password)
  362. log.Info("Credential store updated", "set", address)
  363. return nil
  364. }
  365. func removeCredential(ctx *cli.Context) error {
  366. if ctx.NArg() < 1 {
  367. utils.Fatalf("This command requires an address to be passed as an argument")
  368. }
  369. if err := initialize(ctx); err != nil {
  370. return err
  371. }
  372. addr := ctx.Args().First()
  373. if !common.IsHexAddress(addr) {
  374. utils.Fatalf("Invalid address specified: %s", addr)
  375. }
  376. address := common.HexToAddress(addr)
  377. stretchedKey, err := readMasterKey(ctx, nil)
  378. if err != nil {
  379. utils.Fatalf(err.Error())
  380. }
  381. configDir := ctx.String(configdirFlag.Name)
  382. vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
  383. pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)
  384. pwStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
  385. pwStorage.Del(address.Hex())
  386. log.Info("Credential store updated", "unset", address)
  387. return nil
  388. }
  389. func newAccount(c *cli.Context) error {
  390. if err := initialize(c); err != nil {
  391. return err
  392. }
  393. // The newaccount is meant for users using the CLI, since 'real' external
  394. // UIs can use the UI-api instead. So we'll just use the native CLI UI here.
  395. var (
  396. ui = core.NewCommandlineUI()
  397. pwStorage storage.Storage = &storage.NoStorage{}
  398. ksLoc = c.String(keystoreFlag.Name)
  399. lightKdf = c.Bool(utils.LightKDFFlag.Name)
  400. )
  401. log.Info("Starting clef", "keystore", ksLoc, "light-kdf", lightKdf)
  402. am := core.StartClefAccountManager(ksLoc, true, lightKdf, "")
  403. // This gives is us access to the external API
  404. apiImpl := core.NewSignerAPI(am, 0, true, ui, nil, false, pwStorage)
  405. // This gives us access to the internal API
  406. internalApi := core.NewUIServerAPI(apiImpl)
  407. addr, err := internalApi.New(context.Background())
  408. if err == nil {
  409. fmt.Printf("Generated account %v\n", addr.String())
  410. }
  411. return err
  412. }
  413. func initialize(c *cli.Context) error {
  414. // Set up the logger to print everything
  415. logOutput := os.Stdout
  416. if c.Bool(stdiouiFlag.Name) {
  417. logOutput = os.Stderr
  418. // If using the stdioui, we can't do the 'confirm'-flow
  419. if !c.Bool(acceptFlag.Name) {
  420. fmt.Fprint(logOutput, legalWarning)
  421. }
  422. } else if !c.Bool(acceptFlag.Name) {
  423. if !confirm(legalWarning) {
  424. return fmt.Errorf("aborted by user")
  425. }
  426. fmt.Println()
  427. }
  428. usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
  429. output := io.Writer(logOutput)
  430. if usecolor {
  431. output = colorable.NewColorable(logOutput)
  432. }
  433. log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int(logLevelFlag.Name)), log.StreamHandler(output, log.TerminalFormat(usecolor))))
  434. return nil
  435. }
  436. // ipcEndpoint resolves an IPC endpoint based on a configured value, taking into
  437. // account the set data folders as well as the designated platform we're currently
  438. // running on.
  439. func ipcEndpoint(ipcPath, datadir string) string {
  440. // On windows we can only use plain top-level pipes
  441. if runtime.GOOS == "windows" {
  442. if strings.HasPrefix(ipcPath, `\\.\pipe\`) {
  443. return ipcPath
  444. }
  445. return `\\.\pipe\` + ipcPath
  446. }
  447. // Resolve names into the data directory full paths otherwise
  448. if filepath.Base(ipcPath) == ipcPath {
  449. if datadir == "" {
  450. return filepath.Join(os.TempDir(), ipcPath)
  451. }
  452. return filepath.Join(datadir, ipcPath)
  453. }
  454. return ipcPath
  455. }
  456. func signer(c *cli.Context) error {
  457. // If we have some unrecognized command, bail out
  458. if c.NArg() > 0 {
  459. return fmt.Errorf("invalid command: %q", c.Args().First())
  460. }
  461. if err := initialize(c); err != nil {
  462. return err
  463. }
  464. var (
  465. ui core.UIClientAPI
  466. )
  467. if c.Bool(stdiouiFlag.Name) {
  468. log.Info("Using stdin/stdout as UI-channel")
  469. ui = core.NewStdIOUI()
  470. } else {
  471. log.Info("Using CLI as UI-channel")
  472. ui = core.NewCommandlineUI()
  473. }
  474. // 4bytedb data
  475. fourByteLocal := c.String(customDBFlag.Name)
  476. db, err := fourbyte.NewWithFile(fourByteLocal)
  477. if err != nil {
  478. utils.Fatalf(err.Error())
  479. }
  480. embeds, locals := db.Size()
  481. log.Info("Loaded 4byte database", "embeds", embeds, "locals", locals, "local", fourByteLocal)
  482. var (
  483. api core.ExternalAPI
  484. pwStorage storage.Storage = &storage.NoStorage{}
  485. )
  486. configDir := c.String(configdirFlag.Name)
  487. if stretchedKey, err := readMasterKey(c, ui); err != nil {
  488. log.Warn("Failed to open master, rules disabled", "err", err)
  489. } else {
  490. vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), stretchedKey)[:10]))
  491. // Generate domain specific keys
  492. pwkey := crypto.Keccak256([]byte("credentials"), stretchedKey)
  493. jskey := crypto.Keccak256([]byte("jsstorage"), stretchedKey)
  494. confkey := crypto.Keccak256([]byte("config"), stretchedKey)
  495. // Initialize the encrypted storages
  496. pwStorage = storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "credentials.json"), pwkey)
  497. jsStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "jsstorage.json"), jskey)
  498. configStorage := storage.NewAESEncryptedStorage(filepath.Join(vaultLocation, "config.json"), confkey)
  499. // Do we have a rule-file?
  500. if ruleFile := c.String(ruleFlag.Name); ruleFile != "" {
  501. ruleJS, err := os.ReadFile(ruleFile)
  502. if err != nil {
  503. log.Warn("Could not load rules, disabling", "file", ruleFile, "err", err)
  504. } else {
  505. shasum := sha256.Sum256(ruleJS)
  506. foundShaSum := hex.EncodeToString(shasum[:])
  507. storedShasum, _ := configStorage.Get("ruleset_sha256")
  508. if storedShasum != foundShaSum {
  509. log.Warn("Rule hash not attested, disabling", "hash", foundShaSum, "attested", storedShasum)
  510. } else {
  511. // Initialize rules
  512. ruleEngine, err := rules.NewRuleEvaluator(ui, jsStorage)
  513. if err != nil {
  514. utils.Fatalf(err.Error())
  515. }
  516. ruleEngine.Init(string(ruleJS))
  517. ui = ruleEngine
  518. log.Info("Rule engine configured", "file", c.String(ruleFlag.Name))
  519. }
  520. }
  521. }
  522. }
  523. var (
  524. chainId = c.Int64(chainIdFlag.Name)
  525. ksLoc = c.String(keystoreFlag.Name)
  526. lightKdf = c.Bool(utils.LightKDFFlag.Name)
  527. advanced = c.Bool(advancedMode.Name)
  528. nousb = c.Bool(utils.NoUSBFlag.Name)
  529. scpath = c.String(utils.SmartCardDaemonPathFlag.Name)
  530. )
  531. log.Info("Starting signer", "chainid", chainId, "keystore", ksLoc,
  532. "light-kdf", lightKdf, "advanced", advanced)
  533. am := core.StartClefAccountManager(ksLoc, nousb, lightKdf, scpath)
  534. apiImpl := core.NewSignerAPI(am, chainId, nousb, ui, db, advanced, pwStorage)
  535. // Establish the bidirectional communication, by creating a new UI backend and registering
  536. // it with the UI.
  537. ui.RegisterUIServer(core.NewUIServerAPI(apiImpl))
  538. api = apiImpl
  539. // Audit logging
  540. if logfile := c.String(auditLogFlag.Name); logfile != "" {
  541. api, err = core.NewAuditLogger(logfile, api)
  542. if err != nil {
  543. utils.Fatalf(err.Error())
  544. }
  545. log.Info("Audit logs configured", "file", logfile)
  546. }
  547. // register signer API with server
  548. var (
  549. extapiURL = "n/a"
  550. ipcapiURL = "n/a"
  551. )
  552. rpcAPI := []rpc.API{
  553. {
  554. Namespace: "account",
  555. Service: api,
  556. },
  557. }
  558. if c.Bool(utils.HTTPEnabledFlag.Name) {
  559. vhosts := utils.SplitAndTrim(c.String(utils.HTTPVirtualHostsFlag.Name))
  560. cors := utils.SplitAndTrim(c.String(utils.HTTPCORSDomainFlag.Name))
  561. srv := rpc.NewServer()
  562. err := node.RegisterApis(rpcAPI, []string{"account"}, srv)
  563. if err != nil {
  564. utils.Fatalf("Could not register API: %w", err)
  565. }
  566. handler := node.NewHTTPHandlerStack(srv, cors, vhosts, nil)
  567. // set port
  568. port := c.Int(rpcPortFlag.Name)
  569. // start http server
  570. httpEndpoint := fmt.Sprintf("%s:%d", c.String(utils.HTTPListenAddrFlag.Name), port)
  571. httpServer, addr, err := node.StartHTTPEndpoint(httpEndpoint, rpc.DefaultHTTPTimeouts, handler)
  572. if err != nil {
  573. utils.Fatalf("Could not start RPC api: %v", err)
  574. }
  575. extapiURL = fmt.Sprintf("http://%v/", addr)
  576. log.Info("HTTP endpoint opened", "url", extapiURL)
  577. defer func() {
  578. // Don't bother imposing a timeout here.
  579. httpServer.Shutdown(context.Background())
  580. log.Info("HTTP endpoint closed", "url", extapiURL)
  581. }()
  582. }
  583. if !c.Bool(utils.IPCDisabledFlag.Name) {
  584. givenPath := c.String(utils.IPCPathFlag.Name)
  585. ipcapiURL = ipcEndpoint(filepath.Join(givenPath, "clef.ipc"), configDir)
  586. listener, _, err := rpc.StartIPCEndpoint(ipcapiURL, rpcAPI)
  587. if err != nil {
  588. utils.Fatalf("Could not start IPC api: %v", err)
  589. }
  590. log.Info("IPC endpoint opened", "url", ipcapiURL)
  591. defer func() {
  592. listener.Close()
  593. log.Info("IPC endpoint closed", "url", ipcapiURL)
  594. }()
  595. }
  596. if c.Bool(testFlag.Name) {
  597. log.Info("Performing UI test")
  598. go testExternalUI(apiImpl)
  599. }
  600. ui.OnSignerStartup(core.StartupInfo{
  601. Info: map[string]interface{}{
  602. "intapi_version": core.InternalAPIVersion,
  603. "extapi_version": core.ExternalAPIVersion,
  604. "extapi_http": extapiURL,
  605. "extapi_ipc": ipcapiURL,
  606. },
  607. })
  608. abortChan := make(chan os.Signal, 1)
  609. signal.Notify(abortChan, os.Interrupt)
  610. sig := <-abortChan
  611. log.Info("Exiting...", "signal", sig)
  612. return nil
  613. }
  614. // DefaultConfigDir is the default config directory to use for the vaults and other
  615. // persistence requirements.
  616. func DefaultConfigDir() string {
  617. // Try to place the data folder in the user's home dir
  618. home := flags.HomeDir()
  619. if home != "" {
  620. if runtime.GOOS == "darwin" {
  621. return filepath.Join(home, "Library", "Signer")
  622. } else if runtime.GOOS == "windows" {
  623. appdata := os.Getenv("APPDATA")
  624. if appdata != "" {
  625. return filepath.Join(appdata, "Signer")
  626. }
  627. return filepath.Join(home, "AppData", "Roaming", "Signer")
  628. }
  629. return filepath.Join(home, ".clef")
  630. }
  631. // As we cannot guess a stable location, return empty and handle later
  632. return ""
  633. }
  634. func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
  635. var (
  636. file string
  637. configDir = ctx.String(configdirFlag.Name)
  638. )
  639. if ctx.IsSet(signerSecretFlag.Name) {
  640. file = ctx.String(signerSecretFlag.Name)
  641. } else {
  642. file = filepath.Join(configDir, "masterseed.json")
  643. }
  644. if err := checkFile(file); err != nil {
  645. return nil, err
  646. }
  647. cipherKey, err := os.ReadFile(file)
  648. if err != nil {
  649. return nil, err
  650. }
  651. var password string
  652. // If ui is not nil, get the password from ui.
  653. if ui != nil {
  654. resp, err := ui.OnInputRequired(core.UserInputRequest{
  655. Title: "Master Password",
  656. Prompt: "Please enter the password to decrypt the master seed",
  657. IsPassword: true})
  658. if err != nil {
  659. return nil, err
  660. }
  661. password = resp.Text
  662. } else {
  663. password = utils.GetPassPhrase("Decrypt master seed of clef", false)
  664. }
  665. masterSeed, err := decryptSeed(cipherKey, password)
  666. if err != nil {
  667. return nil, fmt.Errorf("failed to decrypt the master seed of clef")
  668. }
  669. if len(masterSeed) < 256 {
  670. return nil, fmt.Errorf("master seed of insufficient length, expected >255 bytes, got %d", len(masterSeed))
  671. }
  672. // Create vault location
  673. vaultLocation := filepath.Join(configDir, common.Bytes2Hex(crypto.Keccak256([]byte("vault"), masterSeed)[:10]))
  674. err = os.Mkdir(vaultLocation, 0700)
  675. if err != nil && !os.IsExist(err) {
  676. return nil, err
  677. }
  678. return masterSeed, nil
  679. }
  680. // checkFile is a convenience function to check if a file
  681. // * exists
  682. // * is mode 0400 (unix only)
  683. func checkFile(filename string) error {
  684. info, err := os.Stat(filename)
  685. if err != nil {
  686. return fmt.Errorf("failed stat on %s: %v", filename, err)
  687. }
  688. // Check the unix permission bits
  689. // However, on windows, we cannot use the unix perm-bits, see
  690. // https://github.com/ethereum/go-ethereum/issues/20123
  691. if runtime.GOOS != "windows" && info.Mode().Perm()&0377 != 0 {
  692. return fmt.Errorf("file (%v) has insecure file permissions (%v)", filename, info.Mode().String())
  693. }
  694. return nil
  695. }
  696. // confirm displays a text and asks for user confirmation
  697. func confirm(text string) bool {
  698. fmt.Print(text)
  699. fmt.Printf("\nEnter 'ok' to proceed:\n> ")
  700. text, err := bufio.NewReader(os.Stdin).ReadString('\n')
  701. if err != nil {
  702. log.Crit("Failed to read user input", "err", err)
  703. }
  704. if text := strings.TrimSpace(text); text == "ok" {
  705. return true
  706. }
  707. return false
  708. }
  709. func testExternalUI(api *core.SignerAPI) {
  710. ctx := context.WithValue(context.Background(), "remote", "clef binary")
  711. ctx = context.WithValue(ctx, "scheme", "in-proc")
  712. ctx = context.WithValue(ctx, "local", "main")
  713. errs := make([]string, 0)
  714. a := common.HexToAddress("0xdeadbeef000000000000000000000000deadbeef")
  715. addErr := func(errStr string) {
  716. log.Info("Test error", "err", errStr)
  717. errs = append(errs, errStr)
  718. }
  719. queryUser := func(q string) string {
  720. resp, err := api.UI.OnInputRequired(core.UserInputRequest{
  721. Title: "Testing",
  722. Prompt: q,
  723. })
  724. if err != nil {
  725. addErr(err.Error())
  726. }
  727. return resp.Text
  728. }
  729. expectResponse := func(testcase, question, expect string) {
  730. if got := queryUser(question); got != expect {
  731. addErr(fmt.Sprintf("%s: got %v, expected %v", testcase, got, expect))
  732. }
  733. }
  734. expectApprove := func(testcase string, err error) {
  735. if err == nil || err == accounts.ErrUnknownAccount {
  736. return
  737. }
  738. addErr(fmt.Sprintf("%v: expected no error, got %v", testcase, err.Error()))
  739. }
  740. expectDeny := func(testcase string, err error) {
  741. if err == nil || err != core.ErrRequestDenied {
  742. addErr(fmt.Sprintf("%v: expected ErrRequestDenied, got %v", testcase, err))
  743. }
  744. }
  745. var delay = 1 * time.Second
  746. // Test display of info and error
  747. {
  748. api.UI.ShowInfo("If you see this message, enter 'yes' to next question")
  749. time.Sleep(delay)
  750. expectResponse("showinfo", "Did you see the message? [yes/no]", "yes")
  751. api.UI.ShowError("If you see this message, enter 'yes' to the next question")
  752. time.Sleep(delay)
  753. expectResponse("showerror", "Did you see the message? [yes/no]", "yes")
  754. }
  755. { // Sign data test - clique header
  756. api.UI.ShowInfo("Please approve the next request for signing a clique header")
  757. time.Sleep(delay)
  758. cliqueHeader := types.Header{
  759. ParentHash: common.HexToHash("0000H45H"),
  760. UncleHash: common.HexToHash("0000H45H"),
  761. Coinbase: common.HexToAddress("0000H45H"),
  762. Root: common.HexToHash("0000H00H"),
  763. TxHash: common.HexToHash("0000H45H"),
  764. ReceiptHash: common.HexToHash("0000H45H"),
  765. Difficulty: big.NewInt(1337),
  766. Number: big.NewInt(1337),
  767. GasLimit: 1338,
  768. GasUsed: 1338,
  769. Time: 1338,
  770. Extra: []byte("Extra data Extra data Extra data Extra data Extra data Extra data Extra data Extra data"),
  771. MixDigest: common.HexToHash("0x0000H45H"),
  772. }
  773. cliqueRlp, err := rlp.EncodeToBytes(cliqueHeader)
  774. if err != nil {
  775. utils.Fatalf("Should not error: %v", err)
  776. }
  777. addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
  778. _, err = api.SignData(ctx, accounts.MimetypeClique, *addr, hexutil.Encode(cliqueRlp))
  779. expectApprove("signdata - clique header", err)
  780. }
  781. { // Sign data test - typed data
  782. api.UI.ShowInfo("Please approve the next request for signing EIP-712 typed data")
  783. time.Sleep(delay)
  784. addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
  785. data := `{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"test","type":"uint8"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"1","verifyingContract":"0xCCCcccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","test":"3","wallet":"0xcD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB","test":"2"},"contents":"Hello, Bob!"}}`
  786. //_, err := api.SignData(ctx, accounts.MimetypeTypedData, *addr, hexutil.Encode([]byte(data)))
  787. var typedData apitypes.TypedData
  788. json.Unmarshal([]byte(data), &typedData)
  789. _, err := api.SignTypedData(ctx, *addr, typedData)
  790. expectApprove("sign 712 typed data", err)
  791. }
  792. { // Sign data test - plain text
  793. api.UI.ShowInfo("Please approve the next request for signing text")
  794. time.Sleep(delay)
  795. addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
  796. _, err := api.SignData(ctx, accounts.MimetypeTextPlain, *addr, hexutil.Encode([]byte("hello world")))
  797. expectApprove("signdata - text", err)
  798. }
  799. { // Sign data test - plain text reject
  800. api.UI.ShowInfo("Please deny the next request for signing text")
  801. time.Sleep(delay)
  802. addr, _ := common.NewMixedcaseAddressFromString("0x0011223344556677889900112233445566778899")
  803. _, err := api.SignData(ctx, accounts.MimetypeTextPlain, *addr, hexutil.Encode([]byte("hello world")))
  804. expectDeny("signdata - text", err)
  805. }
  806. { // Sign transaction
  807. api.UI.ShowInfo("Please reject next transaction")
  808. time.Sleep(delay)
  809. data := hexutil.Bytes([]byte{})
  810. to := common.NewMixedcaseAddress(a)
  811. tx := apitypes.SendTxArgs{
  812. Data: &data,
  813. Nonce: 0x1,
  814. Value: hexutil.Big(*big.NewInt(6)),
  815. From: common.NewMixedcaseAddress(a),
  816. To: &to,
  817. GasPrice: (*hexutil.Big)(big.NewInt(5)),
  818. Gas: 1000,
  819. Input: nil,
  820. }
  821. _, err := api.SignTransaction(ctx, tx, nil)
  822. expectDeny("signtransaction [1]", err)
  823. expectResponse("signtransaction [2]", "Did you see any warnings for the last transaction? (yes/no)", "no")
  824. }
  825. { // Listing
  826. api.UI.ShowInfo("Please reject listing-request")
  827. time.Sleep(delay)
  828. _, err := api.List(ctx)
  829. expectDeny("list", err)
  830. }
  831. { // Import
  832. api.UI.ShowInfo("Please reject new account-request")
  833. time.Sleep(delay)
  834. _, err := api.New(ctx)
  835. expectDeny("newaccount", err)
  836. }
  837. { // Metadata
  838. api.UI.ShowInfo("Please check if you see the Origin in next listing (approve or deny)")
  839. time.Sleep(delay)
  840. api.List(context.WithValue(ctx, "Origin", "origin.com"))
  841. expectResponse("metadata - origin", "Did you see origin (origin.com)? [yes/no] ", "yes")
  842. }
  843. for _, e := range errs {
  844. log.Error(e)
  845. }
  846. result := fmt.Sprintf("Tests completed. %d errors:\n%s\n", len(errs), strings.Join(errs, "\n"))
  847. api.UI.ShowInfo(result)
  848. }
  849. type encryptedSeedStorage struct {
  850. Description string `json:"description"`
  851. Version int `json:"version"`
  852. Params keystore.CryptoJSON `json:"params"`
  853. }
  854. // encryptSeed uses a similar scheme as the keystore uses, but with a different wrapping,
  855. // to encrypt the master seed
  856. func encryptSeed(seed []byte, auth []byte, scryptN, scryptP int) ([]byte, error) {
  857. cryptoStruct, err := keystore.EncryptDataV3(seed, auth, scryptN, scryptP)
  858. if err != nil {
  859. return nil, err
  860. }
  861. return json.Marshal(&encryptedSeedStorage{"Clef seed", 1, cryptoStruct})
  862. }
  863. // decryptSeed decrypts the master seed
  864. func decryptSeed(keyjson []byte, auth string) ([]byte, error) {
  865. var encSeed encryptedSeedStorage
  866. if err := json.Unmarshal(keyjson, &encSeed); err != nil {
  867. return nil, err
  868. }
  869. if encSeed.Version != 1 {
  870. log.Warn(fmt.Sprintf("unsupported encryption format of seed: %d, operation will likely fail", encSeed.Version))
  871. }
  872. seed, err := keystore.DecryptDataV3(encSeed.Params, auth)
  873. if err != nil {
  874. return nil, err
  875. }
  876. return seed, err
  877. }
  878. // GenDoc outputs examples of all structures used in json-rpc communication
  879. func GenDoc(ctx *cli.Context) error {
  880. var (
  881. a = common.HexToAddress("0xdeadbeef000000000000000000000000deadbeef")
  882. b = common.HexToAddress("0x1111111122222222222233333333334444444444")
  883. meta = core.Metadata{
  884. Scheme: "http",
  885. Local: "localhost:8545",
  886. Origin: "www.malicious.ru",
  887. Remote: "localhost:9999",
  888. UserAgent: "Firefox 3.2",
  889. }
  890. output []string
  891. add = func(name, desc string, v interface{}) {
  892. if data, err := json.MarshalIndent(v, "", " "); err == nil {
  893. output = append(output, fmt.Sprintf("### %s\n\n%s\n\nExample:\n```json\n%s\n```", name, desc, data))
  894. } else {
  895. log.Error("Error generating output", "err", err)
  896. }
  897. }
  898. )
  899. { // Sign plain text request
  900. desc := "SignDataRequest contains information about a pending request to sign some data. " +
  901. "The data to be signed can be of various types, defined by content-type. Clef has done most " +
  902. "of the work in canonicalizing and making sense of the data, and it's up to the UI to present" +
  903. "the user with the contents of the `message`"
  904. sighash, msg := accounts.TextAndHash([]byte("hello world"))
  905. messages := []*apitypes.NameValueType{{Name: "message", Value: msg, Typ: accounts.MimetypeTextPlain}}
  906. add("SignDataRequest", desc, &core.SignDataRequest{
  907. Address: common.NewMixedcaseAddress(a),
  908. Meta: meta,
  909. ContentType: accounts.MimetypeTextPlain,
  910. Rawdata: []byte(msg),
  911. Messages: messages,
  912. Hash: sighash})
  913. }
  914. { // Sign plain text response
  915. add("SignDataResponse - approve", "Response to SignDataRequest",
  916. &core.SignDataResponse{Approved: true})
  917. add("SignDataResponse - deny", "Response to SignDataRequest",
  918. &core.SignDataResponse{})
  919. }
  920. { // Sign transaction request
  921. desc := "SignTxRequest contains information about a pending request to sign a transaction. " +
  922. "Aside from the transaction itself, there is also a `call_info`-struct. That struct contains " +
  923. "messages of various types, that the user should be informed of." +
  924. "\n\n" +
  925. "As in any request, it's important to consider that the `meta` info also contains untrusted data." +
  926. "\n\n" +
  927. "The `transaction` (on input into clef) can have either `data` or `input` -- if both are set, " +
  928. "they must be identical, otherwise an error is generated. " +
  929. "However, Clef will always use `data` when passing this struct on (if Clef does otherwise, please file a ticket)"
  930. data := hexutil.Bytes([]byte{0x01, 0x02, 0x03, 0x04})
  931. add("SignTxRequest", desc, &core.SignTxRequest{
  932. Meta: meta,
  933. Callinfo: []apitypes.ValidationInfo{
  934. {Typ: "Warning", Message: "Something looks odd, show this message as a warning"},
  935. {Typ: "Info", Message: "User should see this as well"},
  936. },
  937. Transaction: apitypes.SendTxArgs{
  938. Data: &data,
  939. Nonce: 0x1,
  940. Value: hexutil.Big(*big.NewInt(6)),
  941. From: common.NewMixedcaseAddress(a),
  942. To: nil,
  943. GasPrice: (*hexutil.Big)(big.NewInt(5)),
  944. Gas: 1000,
  945. Input: nil,
  946. }})
  947. }
  948. { // Sign tx response
  949. data := hexutil.Bytes([]byte{0x04, 0x03, 0x02, 0x01})
  950. add("SignTxResponse - approve", "Response to request to sign a transaction. This response needs to contain the `transaction`"+
  951. ", because the UI is free to make modifications to the transaction.",
  952. &core.SignTxResponse{Approved: true,
  953. Transaction: apitypes.SendTxArgs{
  954. Data: &data,
  955. Nonce: 0x4,
  956. Value: hexutil.Big(*big.NewInt(6)),
  957. From: common.NewMixedcaseAddress(a),
  958. To: nil,
  959. GasPrice: (*hexutil.Big)(big.NewInt(5)),
  960. Gas: 1000,
  961. Input: nil,
  962. }})
  963. add("SignTxResponse - deny", "Response to SignTxRequest. When denying a request, there's no need to "+
  964. "provide the transaction in return",
  965. &core.SignTxResponse{})
  966. }
  967. { // WHen a signed tx is ready to go out
  968. desc := "SignTransactionResult is used in the call `clef` -> `OnApprovedTx(result)`" +
  969. "\n\n" +
  970. "This occurs _after_ successful completion of the entire signing procedure, but right before the signed " +
  971. "transaction is passed to the external caller. This method (and data) can be used by the UI to signal " +
  972. "to the user that the transaction was signed, but it is primarily useful for ruleset implementations." +
  973. "\n\n" +
  974. "A ruleset that implements a rate limitation needs to know what transactions are sent out to the external " +
  975. "interface. By hooking into this methods, the ruleset can maintain track of that count." +
  976. "\n\n" +
  977. "**OBS:** Note that if an attacker can restore your `clef` data to a previous point in time" +
  978. " (e.g through a backup), the attacker can reset such windows, even if he/she is unable to decrypt the content. " +
  979. "\n\n" +
  980. "The `OnApproved` method cannot be responded to, it's purely informative"
  981. rlpdata := common.FromHex("0xf85d640101948a8eafb1cf62bfbeb1741769dae1a9dd47996192018026a0716bd90515acb1e68e5ac5867aa11a1e65399c3349d479f5fb698554ebc6f293a04e8a4ebfff434e971e0ef12c5bf3a881b06fd04fc3f8b8a7291fb67a26a1d4ed")
  982. var tx types.Transaction
  983. tx.UnmarshalBinary(rlpdata)
  984. add("OnApproved - SignTransactionResult", desc, &ethapi.SignTransactionResult{Raw: rlpdata, Tx: &tx})
  985. }
  986. { // User input
  987. add("UserInputRequest", "Sent when clef needs the user to provide data. If 'password' is true, the input field should be treated accordingly (echo-free)",
  988. &core.UserInputRequest{IsPassword: true, Title: "The title here", Prompt: "The question to ask the user"})
  989. add("UserInputResponse", "Response to UserInputRequest",
  990. &core.UserInputResponse{Text: "The textual response from user"})
  991. }
  992. { // List request
  993. add("ListRequest", "Sent when a request has been made to list addresses. The UI is provided with the "+
  994. "full `account`s, including local directory names. Note: this information is not passed back to the external caller, "+
  995. "who only sees the `address`es. ",
  996. &core.ListRequest{
  997. Meta: meta,
  998. Accounts: []accounts.Account{
  999. {Address: a, URL: accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/a"}},
  1000. {Address: b, URL: accounts.URL{Scheme: "keystore", Path: "/path/to/keyfile/b"}}},
  1001. })
  1002. add("ListResponse", "Response to list request. The response contains a list of all addresses to show to the caller. "+
  1003. "Note: the UI is free to respond with any address the caller, regardless of whether it exists or not",
  1004. &core.ListResponse{
  1005. Accounts: []accounts.Account{
  1006. {
  1007. Address: common.HexToAddress("0xcowbeef000000cowbeef00000000000000000c0w"),
  1008. URL: accounts.URL{Path: ".. ignored .."},
  1009. },
  1010. {
  1011. Address: common.HexToAddress("0xffffffffffffffffffffffffffffffffffffffff"),
  1012. },
  1013. }})
  1014. }
  1015. fmt.Println(`## UI Client interface
  1016. These data types are defined in the channel between clef and the UI`)
  1017. for _, elem := range output {
  1018. fmt.Println(elem)
  1019. }
  1020. return nil
  1021. }