Skip to content

Instantly share code, notes, and snippets.

@bitmeme
Last active March 9, 2024 22:30
Show Gist options
  • Save bitmeme/9c6f76eef1f4991e5f2f737156f62cca to your computer and use it in GitHub Desktop.
Save bitmeme/9c6f76eef1f4991e5f2f737156f62cca to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index d280741c6..000000000
--- a/.dockerignore
+++ /dev/null
@@ -1,9 +0,0 @@
-**/.git
-.git
-!.git/HEAD
-!.git/refs/heads
-**/*_test.go
-
-build/_workspace
-build/_bin
-tests/testdata
diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index dfe077042..000000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
deleted file mode 100644
index 6076fe46a..000000000
--- a/.github/CODEOWNERS
+++ /dev/null
@@ -1,9 +0,0 @@
-# Lines starting with '#' are comments.
-# Each line is a file pattern followed by one or more owners.
-
-accounts/usbwallet @karalabe
-consensus @karalabe
-core/ @karalabe @holiman
-eth/ @karalabe
-mobile/ @karalabe
-p2p/ @fjl @zsfelfoldi
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
deleted file mode 100644
index a332b815d..000000000
--- a/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,16 +0,0 @@
-## Can I have feature X
-
-Before you do a feature request please check and make sure that it isn't possible
-through some other means. The JavaScript enabled console is a powerful feature
-in the right hands. Please check our [Bitchin' tricks](https://github.com/ethereum/go-ethereum/wiki/bitchin-tricks) wiki page for more info
-and help.
-
-## Contributing
-
-If you'd like to contribute to go-ethereum please fork, fix, commit and
-send a pull request. Commits which do not comply with the coding standards
-are ignored (use gofmt!).
-
-See [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
-for more details on configuring your environment, testing, and
-dependency management.
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index 7d80659b0..000000000
--- a/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,26 +0,0 @@
-Hi there,
-
-please note that this is an issue tracker reserved for bug reports and feature requests.
-
-For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.
-
-#### System information
-
-Geth version: `geth version`
-OS & Version: Windows/Linux/OSX
-Commit hash : (if `develop`)
-
-#### Expected behaviour
-
-
-#### Actual behaviour
-
-
-#### Steps to reproduce the behaviour
-
-
-#### Backtrace
-
-````
-[backtrace]
-````
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 3a5acef9f..000000000
--- a/.gitignore
+++ /dev/null
@@ -1,40 +0,0 @@
-# See http://help.github.com/ignore-files/ for more about ignoring files.
-#
-# If you find yourself ignoring temporary files generated by your text editor
-# or operating system, you probably want to add a global ignore instead:
-# git config --global core.excludesfile ~/.gitignore_global
-
-/tmp
-*/**/*un~
-*/**/*.test
-*un~
-.DS_Store
-*/**/.DS_Store
-.ethtest
-*/**/*tx_database*
-*/**/*dapps*
-build/_vendor/pkg
-
-#*
-.#*
-*#
-*~
-.project
-.settings
-
-# used by the Makefile
-/build/_workspace/
-/build/bin/
-/geth*.zip
-
-# travis
-profile.tmp
-profile.cov
-
-# IdeaIDE
-.idea
-
-# dashboard
-/dashboard/assets/node_modules
-/dashboard/assets/stats.json
-/dashboard/assets/public/bundle.js
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index 32bdb3b6e..000000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "tests"]
- path = tests/testdata
- url = https://github.com/ethereum/tests
diff --git a/.mailmap b/.mailmap
deleted file mode 100644
index d51c7b609..000000000
--- a/.mailmap
+++ /dev/null
@@ -1,111 +0,0 @@
-Jeffrey Wilcke <jeffrey@ethereum.org>
-Jeffrey Wilcke <jeffrey@ethereum.org> <geffobscura@gmail.com>
-Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@obscura.com>
-Jeffrey Wilcke <jeffrey@ethereum.org> <obscuren@users.noreply.github.com>
-
-Viktor Trón <viktor.tron@gmail.com>
-
-Joseph Goulden <joegoulden@gmail.com>
-
-Nick Savers <nicksavers@gmail.com>
-
-Maran Hidskes <maran.hidskes@gmail.com>
-
-Taylor Gerring <taylor.gerring@gmail.com>
-Taylor Gerring <taylor.gerring@gmail.com> <taylor.gerring@ethereum.org>
-
-Bas van Kervel <bas@ethdev.com>
-Bas van Kervel <bas@ethdev.com> <basvankervel@ziggo.nl>
-Bas van Kervel <bas@ethdev.com> <basvankervel@gmail.com>
-Bas van Kervel <bas@ethdev.com> <bas-vk@users.noreply.github.com>
-
-Sven Ehlert <sven@ethdev.com>
-
-Vitalik Buterin <v@buterin.com>
-
-Marian Oancea <contact@siteshop.ro>
-
-Christoph Jentzsch <jentzsch.software@gmail.com>
-
-Heiko Hees <heiko@heiko.org>
-
-Alex Leverington <alex@ethdev.com>
-Alex Leverington <alex@ethdev.com> <subtly@users.noreply.github.com>
-
-Zsolt Felföldi <zsfelfoldi@gmail.com>
-
-Gavin Wood <i@gavwood.com>
-
-Martin Becze <mjbecze@gmail.com>
-Martin Becze <mjbecze@gmail.com> <wanderer@users.noreply.github.com>
-
-Dimitry Khokhlov <winsvega@mail.ru>
-
-Roman Mandeleil <roman.mandeleil@gmail.com>
-
-Alec Perseghin <aperseghin@gmail.com>
-
-Alon Muroch <alonmuroch@gmail.com>
-
-Arkadiy Paronyan <arkadiy@ethdev.com>
-
-Jae Kwon <jkwon.work@gmail.com>
-
-Aaron Kumavis <kumavis@users.noreply.github.com>
-
-Nick Dodson <silentcicero@outlook.com>
-
-Jason Carver <jacarver@linkedin.com>
-Jason Carver <jacarver@linkedin.com> <ut96caarrs@snkmail.com>
-
-Joseph Chow <ethereum@outlook.com>
-Joseph Chow <ethereum@outlook.com> ethers <TODO>
-
-Enrique Fynn <enriquefynn@gmail.com>
-
-Vincent G <caktux@gmail.com>
-
-RJ Catalano <rj@erisindustries.com>
-
-Nchinda Nchinda <nchinda2@gmail.com>
-
-Aron Fischer <github@aron.guru> <homotopycolimit@users.noreply.github.com>
-
-Vlad Gluhovsky <gluk256@users.noreply.github.com>
-
-Ville Sundell <github@solarius.fi>
-
-Elliot Shepherd <elliot@identitii.com>
-
-Yohann Léon <sybiload@gmail.com>
-
-Gregg Dourgarian <greggd@tempworks.com>
-
-Casey Detrio <cdetrio@gmail.com>
-
-Jens Agerberg <github@agerberg.me>
-
-Nick Johnson <arachnid@notdot.net>
-
-Henning Diedrich <hd@eonblast.com>
-Henning Diedrich <hd@eonblast.com> Drake Burroughs <wildfyre@hotmail.com>
-
-Felix Lange <fjl@twurst.com>
-Felix Lange <fjl@twurst.com> <fjl@users.noreply.github.com>
-
-Максим Чусовлянов <mchusovlianov@gmail.com>
-
-Louis Holbrook <dev@holbrook.no>
-Louis Holbrook <dev@holbrook.no> <nolash@users.noreply.github.com>
-
-Thomas Bocek <tom@tomp2p.net>
-
-Victor Tran <vu.tran54@gmail.com>
-
-Justin Drake <drakefjustin@gmail.com>
-
-Frank Wang <eternnoir@gmail.com>
-
-Gary Rong <garyrong0905@gmail.com>
-
-Guillaume Nicolas <guin56@gmail.com>
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1bd69da34..000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,210 +0,0 @@
-language: go
-go_import_path: github.com/ethereum/go-ethereum
-sudo: false
-matrix:
- include:
- - os: linux
- dist: trusty
- sudo: required
- go: 1.7.x
- script:
- - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install fuse
- - sudo modprobe fuse
- - sudo chmod 666 /dev/fuse
- - sudo chown root:$USER /etc/fuse.conf
- - go run build/ci.go install
- - go run build/ci.go test -coverage
-
- - os: linux
- dist: trusty
- sudo: required
- go: 1.8.x
- script:
- - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install fuse
- - sudo modprobe fuse
- - sudo chmod 666 /dev/fuse
- - sudo chown root:$USER /etc/fuse.conf
- - go run build/ci.go install
- - go run build/ci.go test -coverage
-
- # These are the latest Go versions.
- - os: linux
- dist: trusty
- sudo: required
- go: 1.9.x
- script:
- - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install fuse
- - sudo modprobe fuse
- - sudo chmod 666 /dev/fuse
- - sudo chown root:$USER /etc/fuse.conf
- - go run build/ci.go install
- - go run build/ci.go test -coverage
-
- - os: osx
- go: 1.9.x
- sudo: required
- script:
- - brew update
- - brew install caskroom/cask/brew-cask
- - brew cask install osxfuse
- - go run build/ci.go install
- - go run build/ci.go test -coverage
-
- # This builder only tests code linters on latest version of Go
- - os: linux
- dist: trusty
- sudo: required
- go: 1.9.x
- env:
- - lint
- script:
- - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install fuse
- - sudo modprobe fuse
- - sudo chmod 666 /dev/fuse
- - sudo chown root:$USER /etc/fuse.conf
- - go run build/ci.go lint
-
- # This builder does the Ubuntu PPA and Linux Azure uploads
- - os: linux
- dist: trusty
- sudo: required
- go: 1.9.x
- env:
- - ubuntu-ppa
- - azure-linux
- addons:
- apt:
- packages:
- - devscripts
- - debhelper
- - dput
- - gcc-multilib
- - fakeroot
- script:
- # Build for the primary platforms that Trusty can manage
- - go run build/ci.go debsrc -signer "Go Ethereum Linux Builder <geth-ci@ethereum.org>" -upload ppa:ethereum/ethereum
- - go run build/ci.go install
- - go run build/ci.go archive -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- - go run build/ci.go install -arch 386
- - go run build/ci.go archive -arch 386 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- # Switch over GCC to cross compilation (breaks 386, hence why do it here only)
- - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install gcc-arm-linux-gnueabi libc6-dev-armel-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
- - sudo ln -s /usr/include/asm-generic /usr/include/asm
-
- - GOARM=5 CC=arm-linux-gnueabi-gcc go run build/ci.go install -arch arm
- - GOARM=5 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- - GOARM=6 CC=arm-linux-gnueabi-gcc go run build/ci.go install -arch arm
- - GOARM=6 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- - GOARM=7 CC=arm-linux-gnueabihf-gcc go run build/ci.go install -arch arm
- - GOARM=7 go run build/ci.go archive -arch arm -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
- - CC=aarch64-linux-gnu-gcc go run build/ci.go install -arch arm64
- - go run build/ci.go archive -arch arm64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- # This builder does the Linux Azure MIPS xgo uploads
- - os: linux
- dist: trusty
- sudo: required
- services:
- - docker
- go: 1.9.x
- env:
- - azure-linux-mips
- script:
- - go run build/ci.go xgo --alltools -- --targets=linux/mips --ldflags '-extldflags "-static"' -v
- - for bin in build/bin/*-linux-mips; do mv -f "${bin}" "${bin/-linux-mips/}"; done
- - go run build/ci.go archive -arch mips -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- - go run build/ci.go xgo --alltools -- --targets=linux/mipsle --ldflags '-extldflags "-static"' -v
- - for bin in build/bin/*-linux-mipsle; do mv -f "${bin}" "${bin/-linux-mipsle/}"; done
- - go run build/ci.go archive -arch mipsle -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- - go run build/ci.go xgo --alltools -- --targets=linux/mips64 --ldflags '-extldflags "-static"' -v
- - for bin in build/bin/*-linux-mips64; do mv -f "${bin}" "${bin/-linux-mips64/}"; done
- - go run build/ci.go archive -arch mips64 -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- - go run build/ci.go xgo --alltools -- --targets=linux/mips64le --ldflags '-extldflags "-static"' -v
- - for bin in build/bin/*-linux-mips64le; do mv -f "${bin}" "${bin/-linux-mips64le/}"; done
- - go run build/ci.go archive -arch mips64le -type tar -signer LINUX_SIGNING_KEY -upload gethstore/builds
-
- # This builder does the Android Maven and Azure uploads
- - os: linux
- dist: precise # Needed for the android tools
- addons:
- apt:
- packages:
- - oracle-java8-installer
- - oracle-java8-set-default
- language: android
- android:
- components:
- - platform-tools
- - tools
- - android-15
- - android-19
- - android-24
- env:
- - azure-android
- - maven-android
- before_install:
- - curl https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz | tar -xz
- - export PATH=`pwd`/go/bin:$PATH
- - export GOROOT=`pwd`/go
- - export GOPATH=$HOME/go
- script:
- # Build the Android archive and upload it to Maven Central and Azure
- - curl https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip -o android-ndk-r15c.zip
- - unzip -q android-ndk-r15c.zip && rm android-ndk-r15c.zip
- - mv android-ndk-r15c $HOME
- - export ANDROID_NDK=$HOME/android-ndk-r15c
-
- - mkdir -p $GOPATH/src/github.com/ethereum
- - ln -s `pwd` $GOPATH/src/github.com/ethereum
- - go run build/ci.go aar -signer ANDROID_SIGNING_KEY -deploy https://oss.sonatype.org -upload gethstore/builds
-
- # This builder does the OSX Azure, iOS CocoaPods and iOS Azure uploads
- - os: osx
- go: 1.9.x
- env:
- - azure-osx
- - azure-ios
- - cocoapods-ios
- script:
- - go run build/ci.go install
- - go run build/ci.go archive -type tar -signer OSX_SIGNING_KEY -upload gethstore/builds
-
- # Build the iOS framework and upload it to CocoaPods and Azure
- - gem uninstall cocoapods -a -x
- - gem install cocoapods
-
- - mv ~/.cocoapods/repos/master ~/.cocoapods/repos/master.bak
- - sed -i '.bak' 's/repo.join/!repo.join/g' $(dirname `gem which cocoapods`)/cocoapods/sources_manager.rb
- - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git clone --depth=1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master && pod setup --verbose; fi
-
- - xctool -version
- - xcrun simctl list
-
- - go run build/ci.go xcode -signer IOS_SIGNING_KEY -deploy trunk -upload gethstore/builds
-
- # This builder does the Azure archive purges to avoid accumulating junk
- - os: linux
- dist: trusty
- sudo: required
- go: 1.9.x
- env:
- - azure-purge
- script:
- - go run build/ci.go purge -store gethstore/builds -days 14
-
-install:
- - go get golang.org/x/tools/cmd/cover
-script:
- - go run build/ci.go install
- - go run build/ci.go test -coverage
-
-notifications:
- webhooks:
- urls:
- - https://webhooks.gitter.im/e/e09ccdce1048c5e03445
- on_success: change
- on_failure: always
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index faa19d281..000000000
--- a/AUTHORS
+++ /dev/null
@@ -1,85 +0,0 @@
-# This is the official list of go-ethereum authors for copyright purposes.
-
-Ales Katona <ales@coinbase.com>
-Alex Leverington <alex@ethdev.com>
-Alexandre Van de Sande <alex.vandesande@ethdev.com>
-Aron Fischer <github@aron.guru>
-Bas van Kervel <bas@ethdev.com>
-Benjamin Brent <benjamin@benjaminbrent.com>
-Brian Schroeder <bts@gmail.com>
-Casey Detrio <cdetrio@gmail.com>
-Christoph Jentzsch <jentzsch.software@gmail.com>
-Daniel A. Nagy <nagy.da@gmail.com>
-Diego Siqueira <DiSiqueira@users.noreply.github.com>
-Elliot Shepherd <elliot@identitii.com>
-Enrique Fynn <enriquefynn@gmail.com>
-Ethan Buchman <ethan@coinculture.info>
-Fabian Vogelsteller <fabian@frozeman.de>
-Fabio Berger <fabioberger1991@gmail.com>
-Felix Lange <fjl@twurst.com>
-Frank Wang <eternnoir@gmail.com>
-Gary Rong <garyrong0905@gmail.com>
-Gregg Dourgarian <greggd@tempworks.com>
-Guillaume Nicolas <guin56@gmail.com>
-Gustav Simonsson <gustav.simonsson@gmail.com>
-Hao Bryan Cheng <haobcheng@gmail.com>
-Henning Diedrich <hd@eonblast.com>
-Isidoro Ghezzi <isidoro.ghezzi@icloud.com>
-Jae Kwon <jkwon.work@gmail.com>
-Jamie Pitts <james.pitts@gmail.com>
-Jason Carver <jacarver@linkedin.com>
-Jeff R. Allen <jra@nella.org>
-Jeffrey Wilcke <jeffrey@ethereum.org>
-Jens Agerberg <github@agerberg.me>
-Jonathan Brown <jbrown@bluedroplet.com>
-Joseph Chow <ethereum@outlook.com>
-Justin Clark-Casey <justincc@justincc.org>
-Justin Drake <drakefjustin@gmail.com>
-Kenji Siu <kenji@isuntv.com>
-Kobi Gurkan <kobigurk@gmail.com>
-Lefteris Karapetsas <lefteris@refu.co>
-Leif Jurvetson <leijurv@gmail.com>
-Lewis Marshall <lewis@lmars.net>
-Louis Holbrook <dev@holbrook.no>
-Luca Zeug <luclu@users.noreply.github.com>
-Maran Hidskes <maran.hidskes@gmail.com>
-Marek Kotewicz <marek.kotewicz@gmail.com>
-Martin Holst Swende <martin@swende.se>
-Matthew Di Ferrante <mattdf@users.noreply.github.com>
-Matthew Wampler-Doty <matthew.wampler.doty@gmail.com>
-Micah Zoltu <micah@zoltu.net>
-Nchinda Nchinda <nchinda2@gmail.com>
-Nick Dodson <silentcicero@outlook.com>
-Nick Johnson <arachnid@notdot.net>
-Paulo L F Casaretto <pcasaretto@gmail.com>
-Peter Pratscher <pratscher@gmail.com>
-Péter Szilágyi <peterke@gmail.com>
-RJ Catalano <rj@erisindustries.com>
-Ramesh Nair <ram@hiddentao.com>
-Ricardo Catalinas Jiménez <r@untroubled.be>
-Rémy Roy <remyroy@remyroy.com>
-Shintaro Kaneko <kaneshin0120@gmail.com>
-Stein Dekker <dekker.stein@gmail.com>
-Steven Roose <stevenroose@gmail.com>
-Taylor Gerring <taylor.gerring@gmail.com>
-Thomas Bocek <tom@tomp2p.net>
-Tosh Camille <tochecamille@gmail.com>
-Valentin Wüstholz <wuestholz@users.noreply.github.com>
-Victor Farazdagi <simple.square@gmail.com>
-Victor Tran <vu.tran54@gmail.com>
-Viktor Trón <viktor.tron@gmail.com>
-Ville Sundell <github@solarius.fi>
-Vincent G <caktux@gmail.com>
-Vitalik Buterin <v@buterin.com>
-Vivek Anand <vivekanand1101@users.noreply.github.com>
-Vlad Gluhovsky <gluk256@users.noreply.github.com>
-Yohann Léon <sybiload@gmail.com>
-Yoichi Hirai <i@yoichihirai.com>
-Zahoor Mohamed <zahoor@zahoor.in>
-Zsolt Felföldi <zsfelfoldi@gmail.com>
-holisticode <holistic.computing@gmail.com>
-ken10100147 <sunhongping@kanjian.com>
-ligi <ligi@ligi.de>
-xiekeyang <xiekeyang@users.noreply.github.com>
-ΞTHΞЯSPHΞЯΞ <{viktor.tron,nagydani,zsfelfoldi}@gmail.com>
-Максим Чусовлянов <mchusovlianov@gmail.com>
diff --git a/COPYING.LESSER b/COPYING.LESSER
deleted file mode 100644
index 65c5ca88a..000000000
--- a/COPYING.LESSER
+++ /dev/null
@@ -1,165 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index f4396fcf2..000000000
--- a/Dockerfile
+++ /dev/null
@@ -1,16 +0,0 @@
-# Build Geth in a stock Go builder container
-FROM golang:1.9-alpine as builder
-
-RUN apk add --no-cache make gcc musl-dev linux-headers
-
-ADD . /go-ethereum
-RUN cd /go-ethereum && make geth
-
-# Pull Geth into a second stage deploy alpine container
-FROM alpine:latest
-
-RUN apk add --no-cache ca-certificates
-COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/
-
-EXPOSE 8545 8546 30303 30303/udp 30304/udp
-ENTRYPOINT ["geth"]
diff --git a/Dockerfile.alltools b/Dockerfile.alltools
deleted file mode 100644
index 79bf0f8d5..000000000
--- a/Dockerfile.alltools
+++ /dev/null
@@ -1,15 +0,0 @@
-# Build Geth in a stock Go builder container
-FROM golang:1.9-alpine as builder
-
-RUN apk add --no-cache make gcc musl-dev linux-headers
-
-ADD . /go-ethereum
-RUN cd /go-ethereum && make all
-
-# Pull all binaries into a second stage deploy alpine container
-FROM alpine:latest
-
-RUN apk add --no-cache ca-certificates
-COPY --from=builder /go-ethereum/build/bin/* /usr/local/bin/
-
-EXPOSE 8545 8546 30303 30303/udp 30304/udp
diff --git a/COPYING b/LICENSE
similarity index 100%
rename from COPYING
rename to LICENSE
diff --git a/Makefile b/Makefile
old mode 100644
new mode 100755
index 2cfd1110e..57a4136c7
--- a/Makefile
+++ b/Makefile
@@ -2,19 +2,19 @@
# with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make.
-.PHONY: geth android ios geth-cross swarm evm all test clean
-.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
-.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
-.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
-.PHONY: geth-windows geth-windows-386 geth-windows-amd64
+.PHONY: gwtc android ios gwtc-cross swarm evm all test clean
+.PHONY: gwtc-linux gwtc-linux-386 gwtc-linux-amd64 gwtc-linux-mips64 gwtc-linux-mips64le
+.PHONY: gwtc-linux-arm gwtc-linux-arm-5 gwtc-linux-arm-6 gwtc-linux-arm-7 gwtc-linux-arm64
+.PHONY: gwtc-darwin gwtc-darwin-386 gwtc-darwin-amd64
+.PHONY: gwtc-windows gwtc-windows-386 gwtc-windows-amd64
GOBIN = $(shell pwd)/build/bin
GO ?= latest
-geth:
- build/env.sh go run build/ci.go install ./cmd/geth
+gwtc:
+ build/env.sh go run build/ci.go install ./cmd/gwtc
@echo "Done building."
- @echo "Run \"$(GOBIN)/geth\" to launch geth."
+ @echo "Run \"$(GOBIN)/gwtc\" to launch gwtc."
swarm:
build/env.sh go run build/ci.go install ./cmd/swarm
@@ -27,12 +27,12 @@ all:
android:
build/env.sh go run build/ci.go aar --local
@echo "Done building."
- @echo "Import \"$(GOBIN)/geth.aar\" to use the library."
+ @echo "Import \"$(GOBIN)/gwtc.aar\" to use the library."
ios:
build/env.sh go run build/ci.go xcode --local
@echo "Done building."
- @echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
+ @echo "Import \"$(GOBIN)/Gwtc.framework\" to use the library."
test: all
build/env.sh go run build/ci.go test
@@ -51,92 +51,92 @@ devtools:
# Cross Compilation Targets (xgo)
-geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
+gwtc-cross: gwtc-linux gwtc-darwin gwtc-windows gwtc-android gwtc-ios
@echo "Full cross compilation done:"
- @ls -ld $(GOBIN)/geth-*
+ @ls -ld $(GOBIN)/gwtc-*
-geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 geth-linux-mips64le
+gwtc-linux: gwtc-linux-386 gwtc-linux-amd64 gwtc-linux-arm gwtc-linux-mips64 gwtc-linux-mips64le
@echo "Linux cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-*
+ @ls -ld $(GOBIN)/gwtc-linux-*
-geth-linux-386:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
+gwtc-linux-386:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/gwtc
@echo "Linux 386 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep 386
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep 386
-geth-linux-amd64:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
+gwtc-linux-amd64:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/gwtc
@echo "Linux amd64 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep amd64
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep amd64
-geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
+gwtc-linux-arm: gwtc-linux-arm-5 gwtc-linux-arm-6 gwtc-linux-arm-7 gwtc-linux-arm64
@echo "Linux ARM cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep arm
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep arm
-geth-linux-arm-5:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
+gwtc-linux-arm-5:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/gwtc
@echo "Linux ARMv5 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep arm-5
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep arm-5
-geth-linux-arm-6:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
+gwtc-linux-arm-6:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/gwtc
@echo "Linux ARMv6 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep arm-6
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep arm-6
-geth-linux-arm-7:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/geth
+gwtc-linux-arm-7:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./cmd/gwtc
@echo "Linux ARMv7 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep arm-7
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep arm-7
-geth-linux-arm64:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
+gwtc-linux-arm64:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/gwtc
@echo "Linux ARM64 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep arm64
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep arm64
-geth-linux-mips:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
+gwtc-linux-mips:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/gwtc
@echo "Linux MIPS cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep mips
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep mips
-geth-linux-mipsle:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
+gwtc-linux-mipsle:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/gwtc
@echo "Linux MIPSle cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep mipsle
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep mipsle
-geth-linux-mips64:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
+gwtc-linux-mips64:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/gwtc
@echo "Linux MIPS64 cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep mips64
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep mips64
-geth-linux-mips64le:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
+gwtc-linux-mips64le:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/gwtc
@echo "Linux MIPS64le cross compilation done:"
- @ls -ld $(GOBIN)/geth-linux-* | grep mips64le
+ @ls -ld $(GOBIN)/gwtc-linux-* | grep mips64le
-geth-darwin: geth-darwin-386 geth-darwin-amd64
+gwtc-darwin: gwtc-darwin-386 gwtc-darwin-amd64
@echo "Darwin cross compilation done:"
- @ls -ld $(GOBIN)/geth-darwin-*
+ @ls -ld $(GOBIN)/gwtc-darwin-*
-geth-darwin-386:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
+gwtc-darwin-386:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/gwtc
@echo "Darwin 386 cross compilation done:"
- @ls -ld $(GOBIN)/geth-darwin-* | grep 386
+ @ls -ld $(GOBIN)/gwtc-darwin-* | grep 386
-geth-darwin-amd64:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
+gwtc-darwin-amd64:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/gwtc
@echo "Darwin amd64 cross compilation done:"
- @ls -ld $(GOBIN)/geth-darwin-* | grep amd64
+ @ls -ld $(GOBIN)/gwtc-darwin-* | grep amd64
-geth-windows: geth-windows-386 geth-windows-amd64
+gwtc-windows: gwtc-windows-386 gwtc-windows-amd64
@echo "Windows cross compilation done:"
- @ls -ld $(GOBIN)/geth-windows-*
+ @ls -ld $(GOBIN)/gwtc-windows-*
-geth-windows-386:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
+gwtc-windows-386:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/gwtc
@echo "Windows 386 cross compilation done:"
- @ls -ld $(GOBIN)/geth-windows-* | grep 386
+ @ls -ld $(GOBIN)/gwtc-windows-* | grep 386
-geth-windows-amd64:
- build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
+gwtc-windows-amd64:
+ build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/gwtc
@echo "Windows amd64 cross compilation done:"
- @ls -ld $(GOBIN)/geth-windows-* | grep amd64
+ @ls -ld $(GOBIN)/gwtc-windows-* | grep amd64
diff --git a/README.md b/README.md
index 61e36afec..0ec70ca30 100644
--- a/README.md
+++ b/README.md
@@ -1,304 +1,67 @@
-## Go Ethereum
-
-Official golang implementation of the Ethereum protocol.
-
-[![API Reference](
-https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
-)](https://godoc.org/github.com/ethereum/go-ethereum)
-[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ethereum/go-ethereum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
-
-Automated builds are available for stable releases and the unstable master branch.
-Binary archives are published at https://geth.ethereum.org/downloads/.
-
-## Building the source
-
-For prerequisites and detailed build instructions please read the
-[Installation Instructions](https://github.com/ethereum/go-ethereum/wiki/Building-Ethereum)
-on the wiki.
-
-Building geth requires both a Go (version 1.7 or later) and a C compiler.
-You can install them using your favourite package manager.
-Once the dependencies are installed, run
-
- make geth
-
-or, to build the full suite of utilities:
-
- make all
-
-## Executables
-
-The go-ethereum project comes with several wrappers/executables found in the `cmd` directory.
-
-| Command | Description |
-|:----------:|-------------|
-| **`geth`** | Our main Ethereum CLI client. It is the entry point into the Ethereum network (main-, test- or private net), capable of running as a full node (default) archive node (retaining all historical state) or a light node (retrieving data live). It can be used by other processes as a gateway into the Ethereum network via JSON RPC endpoints exposed on top of HTTP, WebSocket and/or IPC transports. `geth --help` and the [CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options) for command line options. |
-| `abigen` | Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages. It operates on plain [Ethereum contract ABIs](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI) with expanded functionality if the contract bytecode is also available. However it also accepts Solidity source files, making development much more streamlined. Please see our [Native DApps](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) wiki page for details. |
-| `bootnode` | Stripped down version of our Ethereum client implementation that only takes part in the network node discovery protocol, but does not run any of the higher level application protocols. It can be used as a lightweight bootstrap node to aid in finding peers in private networks. |
-| `evm` | Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode. Its purpose is to allow isolated, fine-grained debugging of EVM opcodes (e.g. `evm --code 60ff60ff --debug`). |
-| `gethrpctest` | Developer utility tool to support our [ethereum/rpc-test](https://github.com/ethereum/rpc-tests) test suite which validates baseline conformity to the [Ethereum JSON RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC) specs. Please see the [test suite's readme](https://github.com/ethereum/rpc-tests/blob/master/README.md) for details. |
-| `rlpdump` | Developer utility tool to convert binary RLP ([Recursive Length Prefix](https://github.com/ethereum/wiki/wiki/RLP)) dumps (data encoding used by the Ethereum protocol both network as well as consensus wise) to user friendlier hierarchical representation (e.g. `rlpdump --hex CE0183FFFFFFC4C304050583616263`). |
-| `swarm` | swarm daemon and tools. This is the entrypoint for the swarm network. `swarm --help` for command line options and subcommands. See https://swarm-guide.readthedocs.io for swarm documentation. |
-| `puppeth` | a CLI wizard that aids in creating a new Ethereum network. |
-
-## Running geth
-
-Going through all the possible command line flags is out of scope here (please consult our
-[CLI Wiki page](https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options)), but we've
-enumerated a few common parameter combos to get you up to speed quickly on how you can run your
-own Geth instance.
-
-### Full node on the main Ethereum network
-
-By far the most common scenario is people wanting to simply interact with the Ethereum network:
-create accounts; transfer funds; deploy and interact with contracts. For this particular use-case
-the user doesn't care about years-old historical data, so we can fast-sync quickly to the current
-state of the network. To do so:
-
-```
-$ geth --fast --cache=512 console
-```
-
-This command will:
-
- * Start geth in fast sync mode (`--fast`), causing it to download more data in exchange for avoiding
- processing the entire history of the Ethereum network, which is very CPU intensive.
- * Bump the memory allowance of the database to 512MB (`--cache=512`), which can help significantly in
- sync times especially for HDD users. This flag is optional and you can set it as high or as low as
- you'd like, though we'd recommend the 512MB - 2GB range.
- * Start up Geth's built-in interactive [JavaScript console](https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console),
- (via the trailing `console` subcommand) through which you can invoke all official [`web3` methods](https://github.com/ethereum/wiki/wiki/JavaScript-API)
- as well as Geth's own [management APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs).
- This too is optional and if you leave it out you can always attach to an already running Geth instance
- with `geth attach`.
-
-### Full node on the Ethereum test network
-
-Transitioning towards developers, if you'd like to play around with creating Ethereum contracts, you
-almost certainly would like to do that without any real money involved until you get the hang of the
-entire system. In other words, instead of attaching to the main network, you want to join the **test**
-network with your node, which is fully equivalent to the main network, but with play-Ether only.
-
-```
-$ geth --testnet --fast --cache=512 console
-```
-
-The `--fast`, `--cache` flags and `console` subcommand have the exact same meaning as above and they
-are equally useful on the testnet too. Please see above for their explanations if you've skipped to
-here.
-
-Specifying the `--testnet` flag however will reconfigure your Geth instance a bit:
-
- * Instead of using the default data directory (`~/.ethereum` on Linux for example), Geth will nest
- itself one level deeper into a `testnet` subfolder (`~/.ethereum/testnet` on Linux). Note, on OSX
- and Linux this also means that attaching to a running testnet node requires the use of a custom
- endpoint since `geth attach` will try to attach to a production node endpoint by default. E.g.
- `geth attach <datadir>/testnet/geth.ipc`. Windows users are not affected by this.
- * Instead of connecting the main Ethereum network, the client will connect to the test network,
- which uses different P2P bootnodes, different network IDs and genesis states.
-
-*Note: Although there are some internal protective measures to prevent transactions from crossing
-over between the main network and test network, you should make sure to always use separate accounts
-for play-money and real-money. Unless you manually move accounts, Geth will by default correctly
-separate the two networks and will not make any accounts available between them.*
-
-### Configuration
-
-As an alternative to passing the numerous flags to the `geth` binary, you can also pass a configuration file via:
-
-```
-$ geth --config /path/to/your_config.toml
-```
-
-To get an idea how the file should look like you can use the `dumpconfig` subcommand to export your existing configuration:
-
-```
-$ geth --your-favourite-flags dumpconfig
-```
-
-*Note: This works only with geth v1.6.0 and above.*
-
-#### Docker quick start
-
-One of the quickest ways to get Ethereum up and running on your machine is by using Docker:
-
-```
-docker run -d --name ethereum-node -v /Users/alice/ethereum:/root \
- -p 8545:8545 -p 30303:30303 \
- ethereum/client-go --fast --cache=512
-```
-
-This will start geth in fast sync mode with a DB memory allowance of 512MB just as the above command does. It will also create a persistent volume in your home directory for saving your blockchain as well as map the default ports. There is also an `alpine` tag available for a slim version of the image.
-
-Do not forget `--rpcaddr 0.0.0.0`, if you want to access RPC from other containers and/or hosts. By default, `geth` binds to the local interface and RPC endpoints is not accessible from the outside.
-
-### Programatically interfacing Geth nodes
-
-As a developer, sooner rather than later you'll want to start interacting with Geth and the Ethereum
-network via your own programs and not manually through the console. To aid this, Geth has built in
-support for a JSON-RPC based APIs ([standard APIs](https://github.com/ethereum/wiki/wiki/JSON-RPC) and
-[Geth specific APIs](https://github.com/ethereum/go-ethereum/wiki/Management-APIs)). These can be
-exposed via HTTP, WebSockets and IPC (unix sockets on unix based platforms, and named pipes on Windows).
-
-The IPC interface is enabled by default and exposes all the APIs supported by Geth, whereas the HTTP
-and WS interfaces need to manually be enabled and only expose a subset of APIs due to security reasons.
-These can be turned on/off and configured as you'd expect.
-
-HTTP based JSON-RPC API options:
-
- * `--rpc` Enable the HTTP-RPC server
- * `--rpcaddr` HTTP-RPC server listening interface (default: "localhost")
- * `--rpcport` HTTP-RPC server listening port (default: 8545)
- * `--rpcapi` API's offered over the HTTP-RPC interface (default: "eth,net,web3")
- * `--rpccorsdomain` Comma separated list of domains from which to accept cross origin requests (browser enforced)
- * `--ws` Enable the WS-RPC server
- * `--wsaddr` WS-RPC server listening interface (default: "localhost")
- * `--wsport` WS-RPC server listening port (default: 8546)
- * `--wsapi` API's offered over the WS-RPC interface (default: "eth,net,web3")
- * `--wsorigins` Origins from which to accept websockets requests
- * `--ipcdisable` Disable the IPC-RPC server
- * `--ipcapi` API's offered over the IPC-RPC interface (default: "admin,debug,eth,miner,net,personal,shh,txpool,web3")
- * `--ipcpath` Filename for IPC socket/pipe within the datadir (explicit paths escape it)
-
-You'll need to use your own programming environments' capabilities (libraries, tools, etc) to connect
-via HTTP, WS or IPC to a Geth node configured with the above flags and you'll need to speak [JSON-RPC](http://www.jsonrpc.org/specification)
-on all transports. You can reuse the same connection for multiple requests!
-
-**Note: Please understand the security implications of opening up an HTTP/WS based transport before
-doing so! Hackers on the internet are actively trying to subvert Ethereum nodes with exposed APIs!
-Further, all browser tabs can access locally running webservers, so malicious webpages could try to
-subvert locally available APIs!**
-
-### Operating a private network
-
-Maintaining your own private network is more involved as a lot of configurations taken for granted in
-the official networks need to be manually set up.
-
-#### Defining the private genesis state
-
-First, you'll need to create the genesis state of your networks, which all nodes need to be aware of
-and agree upon. This consists of a small JSON file (e.g. call it `genesis.json`):
-
-```json
-{
- "config": {
- "chainId": 0,
- "homesteadBlock": 0,
- "eip155Block": 0,
- "eip158Block": 0
- },
- "alloc" : {},
- "coinbase" : "0x0000000000000000000000000000000000000000",
- "difficulty" : "0x20000",
- "extraData" : "",
- "gasLimit" : "0x2fefd8",
- "nonce" : "0x0000000000000042",
- "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "timestamp" : "0x00"
-}
-```
-
-The above fields should be fine for most purposes, although we'd recommend changing the `nonce` to
-some random value so you prevent unknown remote nodes from being able to connect to you. If you'd
-like to pre-fund some accounts for easier testing, you can populate the `alloc` field with account
-configs:
-
-```json
-"alloc": {
- "0x0000000000000000000000000000000000000001": {"balance": "111111111"},
- "0x0000000000000000000000000000000000000002": {"balance": "222222222"}
-}
-```
-
-With the genesis state defined in the above JSON file, you'll need to initialize **every** Geth node
-with it prior to starting it up to ensure all blockchain parameters are correctly set:
-
-```
-$ geth init path/to/genesis.json
-```
-
-#### Creating the rendezvous point
-
-With all nodes that you want to run initialized to the desired genesis state, you'll need to start a
-bootstrap node that others can use to find each other in your network and/or over the internet. The
-clean way is to configure and run a dedicated bootnode:
-
-```
-$ bootnode --genkey=boot.key
-$ bootnode --nodekey=boot.key
-```
-
-With the bootnode online, it will display an [`enode` URL](https://github.com/ethereum/wiki/wiki/enode-url-format)
-that other nodes can use to connect to it and exchange peer information. Make sure to replace the
-displayed IP address information (most probably `[::]`) with your externally accessible IP to get the
-actual `enode` URL.
-
-*Note: You could also use a full fledged Geth node as a bootnode, but it's the less recommended way.*
-
-#### Starting up your member nodes
-
-With the bootnode operational and externally reachable (you can try `telnet <ip> <port>` to ensure
-it's indeed reachable), start every subsequent Geth node pointed to the bootnode for peer discovery
-via the `--bootnodes` flag. It will probably also be desirable to keep the data directory of your
-private network separated, so do also specify a custom `--datadir` flag.
-
-```
-$ geth --datadir=path/to/custom/data/folder --bootnodes=<bootnode-enode-url-from-above>
-```
-
-*Note: Since your network will be completely cut off from the main and test networks, you'll also
-need to configure a miner to process transactions and create new blocks for you.*
-
-#### Running a private miner
-
-Mining on the public Ethereum network is a complex task as it's only feasible using GPUs, requiring
-an OpenCL or CUDA enabled `ethminer` instance. For information on such a setup, please consult the
-[EtherMining subreddit](https://www.reddit.com/r/EtherMining/) and the [Genoil miner](https://github.com/Genoil/cpp-ethereum)
-repository.
-
-In a private network setting however, a single CPU miner instance is more than enough for practical
-purposes as it can produce a stable stream of blocks at the correct intervals without needing heavy
-resources (consider running on a single thread, no need for multiple ones either). To start a Geth
-instance for mining, run it with all your usual flags, extended by:
-
-```
-$ geth <usual-flags> --mine --minerthreads=1 --etherbase=0x0000000000000000000000000000000000000000
-```
-
-Which will start mining blocks and transactions on a single CPU thread, crediting all proceedings to
-the account specified by `--etherbase`. You can further tune the mining by changing the default gas
-limit blocks converge to (`--targetgaslimit`) and the price transactions are accepted at (`--gasprice`).
-
-## Contribution
-
-Thank you for considering to help out with the source code! We welcome contributions from
-anyone on the internet, and are grateful for even the smallest of fixes!
-
-If you'd like to contribute to go-ethereum, please fork, fix, commit and send a pull request
-for the maintainers to review and merge into the main code base. If you wish to submit more
-complex changes though, please check up with the core devs first on [our gitter channel](https://gitter.im/ethereum/go-ethereum)
-to ensure those changes are in line with the general philosophy of the project and/or get some
-early feedback which can make both your efforts much lighter as well as our review and merge
-procedures quick and simple.
-
-Please make sure your contributions adhere to our coding guidelines:
-
- * Code must adhere to the official Go [formatting](https://golang.org/doc/effective_go.html#formatting) guidelines (i.e. uses [gofmt](https://golang.org/cmd/gofmt/)).
- * Code must be documented adhering to the official Go [commentary](https://golang.org/doc/effective_go.html#commentary) guidelines.
- * Pull requests need to be based on and opened against the `master` branch.
- * Commit messages should be prefixed with the package(s) they modify.
- * E.g. "eth, rpc: make trace configs optional"
-
-Please see the [Developers' Guide](https://github.com/ethereum/go-ethereum/wiki/Developers'-Guide)
-for more details on configuring your environment, managing project dependencies and testing procedures.
-
-## License
-
-The go-ethereum library (i.e. all code outside of the `cmd` directory) is licensed under the
-[GNU Lesser General Public License v3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html), also
-included in our repository in the `COPYING.LESSER` file.
-
-The go-ethereum binaries (i.e. all code inside of the `cmd` directory) is licensed under the
-[GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html), also included
-in our repository in the `COPYING` file.
+![](images/wtc_logo.jpg)
+
+# GO WTC
+Waltonchain Mainnet User Manual
+
+
+## Steps
+
+### 1. Run docker container
+Install latest distribution of [Go](https://golang.org "Go") if you don't have it already.
+`# sudo apt-get install -y build-essential`
+
+### 2. Compile source code
+`# cd /usr/local/src`
+`# git clone https://github.com/WaltonChain/WaltonChain_Gwtc_Src.git`
+`# cd WaltonChain_Gwtc_Src`
+`# make gwtc`
+`# ./build/bin/gwtc version`
+
+### 3. Deploy
+`# cd /usr/local/src/WaltonChain_Gwtc_Src/gwtc_bin/`
+`# cp ../build/bin/gwtc ./bin/gwtc`
+`# ./backend.sh`
+
+### 4. Enter console
+`# cd /usr/local/src/WaltonChain_Gwtc_Src/gwtc_bin/`
+`# ./bin/gwtc attach ./data/gwtc.ipc`
+
+### 5. View information of the connected node
+`# admin.peers`
+
+### 6. Create account
+`# personal.newAccount()`
+`# ******` ---- Enter new account password
+`# ******` ---- Confirm the new account password
+
+### 7. Mine
+`# miner.start()`
+
+### 8. Query
+`# wtc.getBalance(wtc.coinbase)`
+
+### 9. Unlock account
+`# personal.unlockAccount(wtc.coinbase)`
+
+### 10. Transfer
+`# wtc.sendTransaction({from: wtc.accounts[0], to: wtc.accounts[1], value: web3.toWei(1)})`
+
+### 11. Exit console
+`# exit`
+
+### 12. View log
+`# cd /usr/local/src/WaltonChain_Gwtc_Src/gwtc_bin/`
+`# tail -f gwtc.log`
+
+### 13. Stop gwtc
+`# cd /usr/local/src/WaltonChain_Gwtc_Src/gwtc_bin/`
+`# ./stop.sh`
+
+
+## Acknowledgement
+We hereby thank:
+· [Ethereum](https://www.ethereum.org/ "Ethereum")
+
+
+
+
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 661e7aead..000000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.7.3
diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go
old mode 100644
new mode 100755
index 205dc300b..302ab6a28
--- a/accounts/abi/abi.go
+++ b/accounts/abi/abi.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,6 +20,10 @@ import (
"encoding/json"
"fmt"
"io"
+ "reflect"
+ "strings"
+
+ "github.com/wtc/go-wtc/common"
)
// The ABI holds information about a contract's context and available
@@ -72,27 +76,106 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
return append(method.Id(), arguments...), nil
}
+// these variable are used to determine certain types during type assertion for
+// assignment.
+var (
+ r_interSlice = reflect.TypeOf([]interface{}{})
+ r_hash = reflect.TypeOf(common.Hash{})
+ r_bytes = reflect.TypeOf([]byte{})
+ r_byte = reflect.TypeOf(byte(0))
+)
+
// Unpack output in v according to the abi specification
-func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
- if err = bytesAreProper(output); err != nil {
- return err
+func (abi ABI) Unpack(v interface{}, name string, output []byte) error {
+ var method = abi.Methods[name]
+
+ if len(output) == 0 {
+ return fmt.Errorf("abi: unmarshalling empty output")
}
- // since there can't be naming collisions with contracts and events,
- // we need to decide whether we're calling a method or an event
- var unpack unpacker
- if method, ok := abi.Methods[name]; ok {
- unpack = method
- } else if event, ok := abi.Events[name]; ok {
- unpack = event
- } else {
- return fmt.Errorf("abi: could not locate named method or event.")
+
+ // make sure the passed value is a pointer
+ valueOf := reflect.ValueOf(v)
+ if reflect.Ptr != valueOf.Kind() {
+ return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
}
- // requires a struct to unpack into for a tuple return...
- if unpack.isTupleReturn() {
- return unpack.tupleUnpack(v, output)
+ var (
+ value = valueOf.Elem()
+ typ = value.Type()
+ )
+
+ if len(method.Outputs) > 1 {
+ switch value.Kind() {
+ // struct will match named return values to the struct's field
+ // names
+ case reflect.Struct:
+ for i := 0; i < len(method.Outputs); i++ {
+ marshalledValue, err := toGoType(i, method.Outputs[i], output)
+ if err != nil {
+ return err
+ }
+ reflectValue := reflect.ValueOf(marshalledValue)
+
+ for j := 0; j < typ.NumField(); j++ {
+ field := typ.Field(j)
+ // TODO read tags: `abi:"fieldName"`
+ if field.Name == strings.ToUpper(method.Outputs[i].Name[:1])+method.Outputs[i].Name[1:] {
+ if err := set(value.Field(j), reflectValue, method.Outputs[i]); err != nil {
+ return err
+ }
+ }
+ }
+ }
+ case reflect.Slice:
+ if !value.Type().AssignableTo(r_interSlice) {
+ return fmt.Errorf("abi: cannot marshal tuple in to slice %T (only []interface{} is supported)", v)
+ }
+
+ // if the slice already contains values, set those instead of the interface slice itself.
+ if value.Len() > 0 {
+ if len(method.Outputs) > value.Len() {
+ return fmt.Errorf("abi: cannot marshal in to slices of unequal size (require: %v, got: %v)", len(method.Outputs), value.Len())
+ }
+
+ for i := 0; i < len(method.Outputs); i++ {
+ marshalledValue, err := toGoType(i, method.Outputs[i], output)
+ if err != nil {
+ return err
+ }
+ reflectValue := reflect.ValueOf(marshalledValue)
+ if err := set(value.Index(i).Elem(), reflectValue, method.Outputs[i]); err != nil {
+ return err
+ }
+ }
+ return nil
+ }
+
+ // create a new slice and start appending the unmarshalled
+ // values to the new interface slice.
+ z := reflect.MakeSlice(typ, 0, len(method.Outputs))
+ for i := 0; i < len(method.Outputs); i++ {
+ marshalledValue, err := toGoType(i, method.Outputs[i], output)
+ if err != nil {
+ return err
+ }
+ z = reflect.Append(z, reflect.ValueOf(marshalledValue))
+ }
+ value.Set(z)
+ default:
+ return fmt.Errorf("abi: cannot unmarshal tuple in to %v", typ)
+ }
+
+ } else {
+ marshalledValue, err := toGoType(0, method.Outputs[0], output)
+ if err != nil {
+ return err
+ }
+ if err := set(value, reflect.ValueOf(marshalledValue), method.Outputs[0]); err != nil {
+ return err
+ }
}
- return unpack.singleUnpack(v, output)
+
+ return nil
}
func (abi *ABI) UnmarshalJSON(data []byte) error {
diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go
old mode 100644
new mode 100755
index 79c4d4a16..91c68b234
--- a/accounts/abi/abi_test.go
+++ b/accounts/abi/abi_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,10 +25,29 @@ import (
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/crypto"
)
+// formatSilceOutput add padding to the value and adds a size
+func formatSliceOutput(v ...[]byte) []byte {
+ off := common.LeftPadBytes(big.NewInt(int64(len(v))).Bytes(), 32)
+ output := append(off, make([]byte, 0, len(v)*32)...)
+
+ for _, value := range v {
+ output = append(output, common.LeftPadBytes(value, 32)...)
+ }
+ return output
+}
+
+// quick helper padding
+func pad(input []byte, size int, left bool) []byte {
+ if left {
+ return common.LeftPadBytes(input, size)
+ }
+ return common.RightPadBytes(input, size)
+}
+
const jsondata = `
[
{ "type" : "function", "name" : "balance", "constant" : true },
@@ -172,7 +191,7 @@ func TestMethodSignature(t *testing.T) {
t.Errorf("expected ids to match %x != %x", m.Id(), idexp)
}
- uintt, _ := NewType("uint256")
+ uintt, _ := NewType("uint")
m = Method{"foo", false, []Argument{{"bar", uintt, false}}, nil}
exp = "foo(uint256)"
if m.Sig() != exp {
diff --git a/accounts/abi/argument.go b/accounts/abi/argument.go
old mode 100644
new mode 100755
index 4691318ce..3edfd0499
--- a/accounts/abi/argument.go
+++ b/accounts/abi/argument.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/abi/bind/auth.go b/accounts/abi/bind/auth.go
old mode 100644
new mode 100755
index e6bb0c3b5..ca6910104
--- a/accounts/abi/bind/auth.go
+++ b/accounts/abi/bind/auth.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,10 +22,10 @@ import (
"io"
"io/ioutil"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
)
// NewTransactor is a utility method to easily create a transaction signer from
diff --git a/accounts/abi/bind/backend.go b/accounts/abi/bind/backend.go
old mode 100644
new mode 100755
index 25b61928e..fd9a90878
--- a/accounts/abi/bind/backend.go
+++ b/accounts/abi/bind/backend.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,9 +21,9 @@ import (
"errors"
"math/big"
- "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
)
var (
@@ -47,9 +47,9 @@ type ContractCaller interface {
// CodeAt returns the code of the given account. This is needed to differentiate
// between contract internal errors and the local chain being out of sync.
CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- // ContractCall executes an Ethereum contract call with the specified data as the
+ // ContractCall executes an Wtc contract call with the specified data as the
// input.
- CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
+ CallContract(ctx context.Context, call wtc.CallMsg, blockNumber *big.Int) ([]byte, error)
}
// DeployBackend wraps the operations needed by WaitMined and WaitDeployed.
@@ -64,8 +64,8 @@ type DeployBackend interface {
type PendingContractCaller interface {
// PendingCodeAt returns the code of the given account in the pending state.
PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
- // PendingCallContract executes an Ethereum contract call against the pending state.
- PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
+ // PendingCallContract executes an Wtc contract call against the pending state.
+ PendingCallContract(ctx context.Context, call wtc.CallMsg) ([]byte, error)
}
// ContractTransactor defines the methods needed to allow operating with contract
@@ -85,7 +85,7 @@ type ContractTransactor interface {
// There is no guarantee that this is the true gas limit requirement as other
// transactions may be added or removed by miners, but it should provide a basis
// for setting a reasonable default.
- EstimateGas(ctx context.Context, call ethereum.CallMsg) (usedGas *big.Int, err error)
+ EstimateGas(ctx context.Context, call wtc.CallMsg) (usedGas *big.Int, err error)
// SendTransaction injects the transaction into the pending pool for execution.
SendTransaction(ctx context.Context, tx *types.Transaction) error
}
diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go
old mode 100644
new mode 100755
index 09288d401..8c3467b8f
--- a/accounts/abi/bind/backends/simulated.go
+++ b/accounts/abi/bind/backends/simulated.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,30 +24,29 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/params"
)
// This nil assignment ensures compile time that SimulatedBackend implements bind.ContractBackend.
var _ bind.ContractBackend = (*SimulatedBackend)(nil)
var errBlockNumberUnsupported = errors.New("SimulatedBackend cannot access blocks other than the latest block")
-var errGasEstimationFailed = errors.New("gas required exceeds allowance or always failing transaction")
// SimulatedBackend implements bind.ContractBackend, simulating a blockchain in
// the background. Its main purpose is to allow easily testing contract bindings.
type SimulatedBackend struct {
- database ethdb.Database // In memory database to store our testing data
- blockchain *core.BlockChain // Ethereum blockchain to handle the consensus
+ database wtcdb.Database // In memory database to store our testing data
+ blockchain *core.BlockChain // Wtc blockchain to handle the consensus
mu sync.Mutex
pendingBlock *types.Block // Currently pending block that will be imported on request
@@ -59,8 +58,8 @@ type SimulatedBackend struct {
// NewSimulatedBackend creates a new binding backend using a simulated blockchain
// for testing purposes.
func NewSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend {
- database, _ := ethdb.NewMemDatabase()
- genesis := core.Genesis{Config: params.AllEthashProtocolChanges, Alloc: alloc}
+ database, _ := wtcdb.NewMemDatabase()
+ genesis := core.Genesis{Config: params.AllProtocolChanges, Alloc: alloc}
genesis.MustCommit(database)
blockchain, _ := core.NewBlockChain(database, genesis.Config, ethash.NewFaker(), vm.Config{})
backend := &SimulatedBackend{database: database, blockchain: blockchain, config: genesis.Config}
@@ -102,7 +101,7 @@ func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address,
if blockNumber != nil && blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) != 0 {
return nil, errBlockNumberUnsupported
}
- statedb, _ := b.blockchain.State()
+ statedb, _, _, _ := b.blockchain.State()
return statedb.GetCode(contract), nil
}
@@ -114,7 +113,7 @@ func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Addres
if blockNumber != nil && blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) != 0 {
return nil, errBlockNumberUnsupported
}
- statedb, _ := b.blockchain.State()
+ statedb, _, _, _ := b.blockchain.State()
return statedb.GetBalance(contract), nil
}
@@ -126,7 +125,7 @@ func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address,
if blockNumber != nil && blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) != 0 {
return 0, errBlockNumberUnsupported
}
- statedb, _ := b.blockchain.State()
+ statedb, _, _, _ := b.blockchain.State()
return statedb.GetNonce(contract), nil
}
@@ -138,7 +137,7 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
if blockNumber != nil && blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) != 0 {
return nil, errBlockNumberUnsupported
}
- statedb, _ := b.blockchain.State()
+ statedb, _, _, _ := b.blockchain.State()
val := statedb.GetState(contract, key)
return val[:], nil
}
@@ -158,14 +157,14 @@ func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Ad
}
// CallContract executes a contract call.
-func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error) {
+func (b *SimulatedBackend) CallContract(ctx context.Context, call wtc.CallMsg, blockNumber *big.Int) ([]byte, error) {
b.mu.Lock()
defer b.mu.Unlock()
if blockNumber != nil && blockNumber.Cmp(b.blockchain.CurrentBlock().Number()) != 0 {
return nil, errBlockNumberUnsupported
}
- state, err := b.blockchain.State()
+ state, err, _, _ := b.blockchain.State()
if err != nil {
return nil, err
}
@@ -174,7 +173,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM
}
// PendingCallContract executes a contract call on the pending state.
-func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error) {
+func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call wtc.CallMsg) ([]byte, error) {
b.mu.Lock()
defer b.mu.Unlock()
defer b.pendingState.RevertToSnapshot(b.pendingState.Snapshot())
@@ -200,57 +199,43 @@ func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error
// EstimateGas executes the requested code against the currently pending block/state and
// returns the used amount of gas.
-func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (*big.Int, error) {
+func (b *SimulatedBackend) EstimateGas(ctx context.Context, call wtc.CallMsg) (*big.Int, error) {
b.mu.Lock()
defer b.mu.Unlock()
- // Determine the lowest and highest possible gas limits to binary search in between
+ // Binary search the gas requirement, as it may be higher than the amount used
var (
- lo uint64 = params.TxGas - 1
- hi uint64
- cap uint64
+ lo uint64 = params.TxGas - 1
+ hi uint64
)
if call.Gas != nil && call.Gas.Uint64() >= params.TxGas {
hi = call.Gas.Uint64()
} else {
hi = b.pendingBlock.GasLimit().Uint64()
}
- cap = hi
-
- // Create a helper to check if a gas allowance results in an executable transaction
- executable := func(gas uint64) bool {
- call.Gas = new(big.Int).SetUint64(gas)
+ for lo+1 < hi {
+ // Take a guess at the gas, and check transaction validity
+ mid := (hi + lo) / 2
+ call.Gas = new(big.Int).SetUint64(mid)
snapshot := b.pendingState.Snapshot()
_, _, failed, err := b.callContract(ctx, call, b.pendingBlock, b.pendingState)
b.pendingState.RevertToSnapshot(snapshot)
+ // If the transaction became invalid or execution failed, raise the gas limit
if err != nil || failed {
- return false
- }
- return true
- }
- // Execute the binary search and hone in on an executable gas limit
- for lo+1 < hi {
- mid := (hi + lo) / 2
- if !executable(mid) {
lo = mid
- } else {
- hi = mid
- }
- }
- // Reject the transaction as invalid if it still fails at the highest allowance
- if hi == cap {
- if !executable(hi) {
- return nil, errGasEstimationFailed
+ continue
}
+ // Otherwise assume the transaction succeeded, lower the gas limit
+ hi = mid
}
return new(big.Int).SetUint64(hi), nil
}
// callContract implemens common code between normal and pending contract calls.
// state is modified during execution, make sure to copy it if necessary.
-func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallMsg, block *types.Block, statedb *state.StateDB) ([]byte, *big.Int, bool, error) {
+func (b *SimulatedBackend) callContract(ctx context.Context, call wtc.CallMsg, block *types.Block, statedb *state.StateDB) ([]byte, *big.Int, bool, error) {
// Ensure message is initialized properly.
if call.GasPrice == nil {
call.GasPrice = big.NewInt(1)
@@ -263,7 +248,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
}
// Set infinite balance to the fake caller account.
from := statedb.GetOrNewStateObject(call.From)
- from.SetBalance(math.MaxBig256)
+ from.SetBalance(math.MaxBig256,new(big.Int),new(big.Int))
// Execute the call.
msg := callmsg{call}
@@ -320,7 +305,7 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
// callmsg implements core.Message to allow passing it as a transaction simulator.
type callmsg struct {
- ethereum.CallMsg
+ wtc.CallMsg
}
func (m callmsg) From() common.Address { return m.CallMsg.From }
diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go
old mode 100644
new mode 100755
index b40bd65e8..78878c8a5
--- a/accounts/abi/bind/base.go
+++ b/accounts/abi/bind/base.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,11 +22,11 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/accounts/abi"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/accounts/abi"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
)
// SignerFn is a signer function callback when a contract requires a method to
@@ -42,9 +42,9 @@ type CallOpts struct {
}
// TransactOpts is the collection of authorization data required to create a
-// valid Ethereum transaction.
+// valid Wtc transaction.
type TransactOpts struct {
- From common.Address // Ethereum account to send the transaction from
+ From common.Address // Wtc account to send the transaction from
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
Signer SignerFn // Method to use for signing the transaction (mandatory)
@@ -56,11 +56,11 @@ type TransactOpts struct {
}
// BoundContract is the base wrapper object that reflects a contract on the
-// Ethereum network. It contains a collection of methods that are used by the
+// Wtc network. It contains a collection of methods that are used by the
// higher level contract bindings to operate.
type BoundContract struct {
- address common.Address // Deployment address of the contract on the Ethereum blockchain
- abi abi.ABI // Reflect based ABI to access the correct Ethereum methods
+ address common.Address // Deployment address of the contract on the Wtc blockchain
+ abi abi.ABI // Reflect based ABI to access the correct Wtc methods
caller ContractCaller // Read interface to interact with the blockchain
transactor ContractTransactor // Write interface to interact with the blockchain
}
@@ -76,7 +76,7 @@ func NewBoundContract(address common.Address, abi abi.ABI, caller ContractCaller
}
}
-// DeployContract deploys a contract onto the Ethereum blockchain and binds the
+// DeployContract deploys a contract onto the Wtc blockchain and binds the
// deployment address with a Go wrapper.
func DeployContract(opts *TransactOpts, abi abi.ABI, bytecode []byte, backend ContractBackend, params ...interface{}) (common.Address, *types.Transaction, *BoundContract, error) {
// Otherwise try to deploy the contract
@@ -109,7 +109,7 @@ func (c *BoundContract) Call(opts *CallOpts, result interface{}, method string,
return err
}
var (
- msg = ethereum.CallMsg{From: opts.From, To: &c.address, Data: input}
+ msg = wtc.CallMsg{From: opts.From, To: &c.address, Data: input}
ctx = ensureContext(opts.Context)
code []byte
output []byte
@@ -199,7 +199,7 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
}
}
// If the contract surely has code (or code is not needed), estimate the transaction
- msg := ethereum.CallMsg{From: opts.From, To: contract, Value: value, Data: input}
+ msg := wtc.CallMsg{From: opts.From, To: contract, Value: value, Data: input}
gasLimit, err = c.transactor.EstimateGas(ensureContext(opts.Context), msg)
if err != nil {
return nil, fmt.Errorf("failed to estimate gas needed: %v", err)
diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go
old mode 100644
new mode 100755
index f58758088..f23fb470d
--- a/accounts/abi/bind/bind.go
+++ b/accounts/abi/bind/bind.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package bind generates Ethereum contract Go bindings.
+// Package bind generates Wtc contract Go bindings.
//
-// Detailed usage document and tutorial available on the go-ethereum Wiki page:
-// https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts
+// Detailed usage document and tutorial available on the go-wtc Wiki page:
+// https://github.com/wtc/go-wtc/wiki/Native-DApps:-Go-bindings-to-Wtc-contracts
package bind
import (
@@ -28,7 +28,7 @@ import (
"text/template"
"unicode"
- "github.com/ethereum/go-ethereum/accounts/abi"
+ "github.com/wtc/go-wtc/accounts/abi"
"golang.org/x/tools/imports"
)
diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go
old mode 100644
new mode 100755
index 43ed53b92..dcd949198
--- a/accounts/abi/bind/bind_test.go
+++ b/accounts/abi/bind/bind_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -26,7 +26,7 @@ import (
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
"golang.org/x/tools/imports"
)
@@ -58,7 +58,7 @@ var bindTests = []struct {
// Test that all the official sample contracts bind correctly
{
`Token`,
- `https://ethereum.org/token`,
+ `https://wtc.org/token`,
`60606040526040516107fd3803806107fd83398101604052805160805160a05160c051929391820192909101600160a060020a0333166000908152600360209081526040822086905581548551838052601f6002600019610100600186161502019093169290920482018390047f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56390810193919290918801908390106100e857805160ff19168380011785555b506101189291505b8082111561017157600081556001016100b4565b50506002805460ff19168317905550505050610658806101a56000396000f35b828001600101855582156100ac579182015b828111156100ac5782518260005055916020019190600101906100fa565b50508060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061017557805160ff19168380011785555b506100c89291506100b4565b5090565b82800160010185558215610165579182015b8281111561016557825182600050559160200191906001019061018756606060405236156100775760e060020a600035046306fdde03811461007f57806323b872dd146100dc578063313ce5671461010e57806370a082311461011a57806395d89b4114610132578063a9059cbb1461018e578063cae9ca51146101bd578063dc3080f21461031c578063dd62ed3e14610341575b610365610002565b61036760008054602060026001831615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b6103d5600435602435604435600160a060020a038316600090815260036020526040812054829010156104f357610002565b6103e760025460ff1681565b6103d560043560036020526000908152604090205481565b610367600180546020600282841615610100026000190190921691909104601f810182900490910260809081016040526060828152929190828280156104eb5780601f106104c0576101008083540402835291602001916104eb565b610365600435602435600160a060020a033316600090815260036020526040902054819010156103f157610002565b60806020604435600481810135601f8101849004909302840160405260608381526103d5948235946024803595606494939101919081908382808284375094965050505050505060006000836004600050600033600160a060020a03168152602001908152602001600020600050600087600160a060020a031681526020019081526020016000206000508190555084905080600160a060020a0316638f4ffcb1338630876040518560e060020a0281526004018085600160a060020a0316815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156102f25780820380516001836020036101000a031916815260200191505b50955050505050506000604051808303816000876161da5a03f11561000257505050509392505050565b6005602090815260043560009081526040808220909252602435815220546103d59081565b60046020818152903560009081526040808220909252602435815220546103d59081565b005b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156103c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60408051918252519081900360200190f35b6060908152602090f35b600160a060020a03821660009081526040902054808201101561041357610002565b806003600050600033600160a060020a03168152602001908152602001600020600082828250540392505081905550806003600050600084600160a060020a0316815260200190815260200160002060008282825054019250508190555081600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b820191906000526020600020905b8154815290600101906020018083116104ce57829003601f168201915b505050505081565b600160a060020a03831681526040812054808301101561051257610002565b600160a060020a0380851680835260046020908152604080852033949094168086529382528085205492855260058252808520938552929052908220548301111561055c57610002565b816003600050600086600160a060020a03168152602001908152602001600020600082828250540392505081905550816003600050600085600160a060020a03168152602001908152602001600020600082828250540192505081905550816005600050600086600160a060020a03168152602001908152602001600020600050600033600160a060020a0316815260200190815260200160002060008282825054019250508190555082600160a060020a031633600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a3939250505056`,
`[{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"spentAllowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"decimalUnits","type":"uint8"},{"name":"tokenSymbol","type":"string"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]`,
`
@@ -69,7 +69,7 @@ var bindTests = []struct {
},
{
`Crowdsale`,
- `https://ethereum.org/crowdsale`,
+ `https://wtc.org/crowdsale`,
`606060408190526007805460ff1916905560a0806105a883396101006040529051608051915160c05160e05160008054600160a060020a03199081169095178155670de0b6b3a7640000958602600155603c9093024201600355930260045560058054909216909217905561052f90819061007990396000f36060604052361561006c5760e060020a600035046301cb3b20811461008257806329dcb0cf1461014457806338af3eed1461014d5780636e66f6e91461015f5780637a3a0e84146101715780637b3e5e7b1461017a578063a035b1fe14610183578063dc0d3dff1461018c575b61020060075460009060ff161561032357610002565b61020060035460009042106103205760025460015490106103cb576002548154600160a060020a0316908290606082818181858883f150915460025460408051600160a060020a039390931683526020830191909152818101869052517fe842aea7a5f1b01049d752008c53c52890b1a6daf660cf39e8eec506112bbdf6945090819003909201919050a15b60405160008054600160a060020a039081169230909116319082818181858883f150506007805460ff1916600117905550505050565b6103a160035481565b6103ab600054600160a060020a031681565b6103ab600554600160a060020a031681565b6103a160015481565b6103a160025481565b6103a160045481565b6103be60043560068054829081101561000257506000526002027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f8101547ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d409190910154600160a060020a03919091169082565b005b505050815481101561000257906000526020600020906002020160005060008201518160000160006101000a815481600160a060020a030219169083021790555060208201518160010160005055905050806002600082828250540192505081905550600560009054906101000a9004600160a060020a0316600160a060020a031663a9059cbb3360046000505484046040518360e060020a0281526004018083600160a060020a03168152602001828152602001925050506000604051808303816000876161da5a03f11561000257505060408051600160a060020a03331681526020810184905260018183015290517fe842aea7a5f1b01049d752008c53c52890b1a6daf660cf39e8eec506112bbdf692509081900360600190a15b50565b5060a0604052336060908152346080819052600680546001810180835592939282908280158290116102025760020281600202836000526020600020918201910161020291905b8082111561039d57805473ffffffffffffffffffffffffffffffffffffffff19168155600060019190910190815561036a565b5090565b6060908152602090f35b600160a060020a03166060908152602090f35b6060918252608052604090f35b5b60065481101561010e576006805482908110156100025760009182526002027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f0190600680549254600160a060020a0316928490811015610002576002027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40015460405190915082818181858883f19350505050507fe842aea7a5f1b01049d752008c53c52890b1a6daf660cf39e8eec506112bbdf660066000508281548110156100025760008290526002027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f01548154600160a060020a039190911691908490811015610002576002027ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d40015460408051600160a060020a0394909416845260208401919091526000838201525191829003606001919050a16001016103cc56`,
`[{"constant":false,"inputs":[],"name":"checkGoalReached","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"deadline","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"tokenReward","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":true,"inputs":[],"name":"fundingGoal","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"amountRaised","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"price","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"funders","outputs":[{"name":"addr","type":"address"},{"name":"amount","type":"uint256"}],"type":"function"},{"inputs":[{"name":"ifSuccessfulSendTo","type":"address"},{"name":"fundingGoalInEthers","type":"uint256"},{"name":"durationInMinutes","type":"uint256"},{"name":"etherCostOfEachToken","type":"uint256"},{"name":"addressOfTokenUsedAsReward","type":"address"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"backer","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"isContribution","type":"bool"}],"name":"FundTransfer","type":"event"}]`,
`
@@ -80,7 +80,7 @@ var bindTests = []struct {
},
{
`DAO`,
- `https://ethereum.org/dao`,
+ `https://wtc.org/dao`,
`606060405260405160808061145f833960e06040529051905160a05160c05160008054600160a060020a03191633179055600184815560028490556003839055600780549182018082558280158290116100b8576003028160030283600052602060002091820191016100b891906101c8565b50506060919091015160029190910155600160a060020a0381166000146100a65760008054600160a060020a031916821790555b505050506111f18061026e6000396000f35b505060408051608081018252600080825260208281018290528351908101845281815292820192909252426060820152600780549194509250811015610002579081527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6889050815181546020848101517401000000000000000000000000000000000000000002600160a060020a03199290921690921760a060020a60ff021916178255604083015180516001848101805460008281528690209195600293821615610100026000190190911692909204601f9081018390048201949192919091019083901061023e57805160ff19168380011785555b50610072929150610226565b5050600060028201556001015b8082111561023a578054600160a860020a031916815560018181018054600080835592600290821615610100026000190190911604601f81901061020c57506101bb565b601f0160209004906000526020600020908101906101bb91905b8082111561023a5760008155600101610226565b5090565b828001600101855582156101af579182015b828111156101af57825182600050559160200191906001019061025056606060405236156100b95760e060020a6000350463013cf08b81146100bb578063237e9492146101285780633910682114610281578063400e3949146102995780635daf08ca146102a257806369bd34361461032f5780638160f0b5146103385780638da5cb5b146103415780639644fcbd14610353578063aa02a90f146103be578063b1050da5146103c7578063bcca1fd3146104b5578063d3c0715b146104dc578063eceb29451461058d578063f2fde38b1461067b575b005b61069c6004356004805482908110156100025790600052602060002090600a02016000506005810154815460018301546003840154600485015460068601546007870154600160a060020a03959095169750929560020194919360ff828116946101009093041692919089565b60408051602060248035600481810135601f81018590048502860185019096528585526107759581359591946044949293909201918190840183828082843750949650505050505050600060006004600050848154811015610002575090527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e600a8402908101547f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b909101904210806101e65750600481015460ff165b8061026757508060000160009054906101000a9004600160a060020a03168160010160005054846040518084600160a060020a0316606060020a0281526014018381526020018280519060200190808383829060006004602084601f0104600f02600301f15090500193505050506040518091039020816007016000505414155b8061027757506001546005820154105b1561109257610002565b61077560043560066020526000908152604090205481565b61077560055481565b61078760043560078054829081101561000257506000526003026000805160206111d18339815191528101547fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68a820154600160a060020a0382169260a060020a90920460ff16917fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c689019084565b61077560025481565b61077560015481565b610830600054600160a060020a031681565b604080516020604435600481810135601f81018490048402850184019095528484526100b9948135946024803595939460649492939101918190840183828082843750949650505050505050600080548190600160a060020a03908116339091161461084d57610002565b61077560035481565b604080516020604435600481810135601f8101849004840285018401909552848452610775948135946024803595939460649492939101918190840183828082843750506040805160209735808a0135601f81018a90048a0283018a019093528282529698976084979196506024909101945090925082915084018382808284375094965050505050505033600160a060020a031660009081526006602052604081205481908114806104ab5750604081205460078054909190811015610002579082526003026000805160206111d1833981519152015460a060020a900460ff16155b15610ce557610002565b6100b960043560243560443560005433600160a060020a03908116911614610b1857610002565b604080516020604435600481810135601f810184900484028501840190955284845261077594813594602480359593946064949293910191819084018382808284375094965050505050505033600160a060020a031660009081526006602052604081205481908114806105835750604081205460078054909190811015610002579082526003026000805160206111d18339815191520181505460a060020a900460ff16155b15610f1d57610002565b604080516020606435600481810135601f81018490048402850184019095528484526107759481359460248035956044359560849492019190819084018382808284375094965050505050505060006000600460005086815481101561000257908252600a027f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01815090508484846040518084600160a060020a0316606060020a0281526014018381526020018280519060200190808383829060006004602084601f0104600f02600301f150905001935050505060405180910390208160070160005054149150610cdc565b6100b960043560005433600160a060020a03908116911614610f0857610002565b604051808a600160a060020a031681526020018981526020018060200188815260200187815260200186815260200185815260200184815260200183815260200182810382528981815460018160011615610100020316600290048152602001915080546001816001161561010002031660029004801561075e5780601f106107335761010080835404028352916020019161075e565b820191906000526020600020905b81548152906001019060200180831161074157829003601f168201915b50509a505050505050505050505060405180910390f35b60408051918252519081900360200190f35b60408051600160a060020a038616815260208101859052606081018390526080918101828152845460026001821615610100026000190190911604928201839052909160a08301908590801561081e5780601f106107f35761010080835404028352916020019161081e565b820191906000526020600020905b81548152906001019060200180831161080157829003601f168201915b50509550505050505060405180910390f35b60408051600160a060020a03929092168252519081900360200190f35b600160a060020a03851660009081526006602052604081205414156108a957604060002060078054918290556001820180825582801582901161095c5760030281600302836000526020600020918201910161095c9190610a4f565b600160a060020a03851660009081526006602052604090205460078054919350908390811015610002575060005250600381026000805160206111d183398151915201805474ff0000000000000000000000000000000000000000191660a060020a85021781555b60408051600160a060020a03871681526020810186905281517f27b022af4a8347100c7a041ce5ccf8e14d644ff05de696315196faae8cd50c9b929181900390910190a15050505050565b505050915081506080604051908101604052808681526020018581526020018481526020014281526020015060076000508381548110156100025790600052602060002090600302016000508151815460208481015160a060020a02600160a060020a03199290921690921774ff00000000000000000000000000000000000000001916178255604083015180516001848101805460008281528690209195600293821615610100026000190190911692909204601f90810183900482019491929190910190839010610ad357805160ff19168380011785555b50610b03929150610abb565b5050600060028201556001015b80821115610acf57805474ffffffffffffffffffffffffffffffffffffffffff1916815560018181018054600080835592600290821615610100026000190190911604601f819010610aa15750610a42565b601f016020900490600052602060002090810190610a4291905b80821115610acf5760008155600101610abb565b5090565b82800160010185558215610a36579182015b82811115610a36578251826000505591602001919060010190610ae5565b50506060919091015160029190910155610911565b600183905560028290556003819055604080518481526020810184905280820183905290517fa439d3fa452be5e0e1e24a8145e715f4fd8b9c08c96a42fd82a855a85e5d57de9181900360600190a1505050565b50508585846040518084600160a060020a0316606060020a0281526014018381526020018280519060200190808383829060006004602084601f0104600f02600301f150905001935050505060405180910390208160070160005081905550600260005054603c024201816003016000508190555060008160040160006101000a81548160ff0219169083021790555060008160040160016101000a81548160ff02191690830217905550600081600501600050819055507f646fec02522b41e7125cfc859a64fd4f4cefd5dc3b6237ca0abe251ded1fa881828787876040518085815260200184600160a060020a03168152602001838152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f168015610cc45780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1600182016005555b50949350505050565b6004805460018101808355909190828015829011610d1c57600a0281600a028360005260206000209182019101610d1c9190610db8565b505060048054929450918491508110156100025790600052602060002090600a02016000508054600160a060020a031916871781556001818101879055855160028381018054600082815260209081902096975091959481161561010002600019011691909104601f90810182900484019391890190839010610ed857805160ff19168380011785555b50610b6c929150610abb565b50506001015b80821115610acf578054600160a060020a03191681556000600182810182905560028381018054848255909281161561010002600019011604601f819010610e9c57505b5060006003830181905560048301805461ffff191690556005830181905560068301819055600783018190556008830180548282559082526020909120610db2916002028101905b80821115610acf57805474ffffffffffffffffffffffffffffffffffffffffff1916815560018181018054600080835592600290821615610100026000190190911604601f819010610eba57505b5050600101610e44565b601f016020900490600052602060002090810190610dfc9190610abb565b601f016020900490600052602060002090810190610e929190610abb565b82800160010185558215610da6579182015b82811115610da6578251826000505591602001919060010190610eea565b60008054600160a060020a0319168217905550565b600480548690811015610002576000918252600a027f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b01905033600160a060020a0316600090815260098201602052604090205490915060ff1660011415610f8457610002565b33600160a060020a031660009081526009820160205260409020805460ff1916600190811790915560058201805490910190558315610fcd576006810180546001019055610fda565b6006810180546000190190555b7fc34f869b7ff431b034b7b9aea9822dac189a685e0b015c7d1be3add3f89128e8858533866040518085815260200184815260200183600160a060020a03168152602001806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f16801561107a5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1509392505050565b6006810154600354901315611158578060000160009054906101000a9004600160a060020a0316600160a060020a03168160010160005054670de0b6b3a76400000284604051808280519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156111225780820380516001836020036101000a031916815260200191505b5091505060006040518083038185876185025a03f15050505060048101805460ff191660011761ff00191661010017905561116d565b60048101805460ff191660011761ff00191690555b60068101546005820154600483015460408051888152602081019490945283810192909252610100900460ff166060830152517fd220b7272a8b6d0d7d6bcdace67b936a8f175e6d5c1b3ee438b72256b32ab3af9181900360800190a1509291505056a66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688`,
`[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"proposals","outputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"},{"name":"description","type":"string"},{"name":"votingDeadline","type":"uint256"},{"name":"executed","type":"bool"},{"name":"proposalPassed","type":"bool"},{"name":"numberOfVotes","type":"uint256"},{"name":"currentResult","type":"int256"},{"name":"proposalHash","type":"bytes32"}],"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"transactionBytecode","type":"bytes"}],"name":"executeProposal","outputs":[{"name":"result","type":"int256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"memberId","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"numProposals","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"members","outputs":[{"name":"member","type":"address"},{"name":"canVote","type":"bool"},{"name":"name","type":"string"},{"name":"memberSince","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"debatingPeriodInMinutes","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"minimumQuorum","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"targetMember","type":"address"},{"name":"canVote","type":"bool"},{"name":"memberName","type":"string"}],"name":"changeMembership","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"majorityMargin","outputs":[{"name":"","type":"int256"}],"type":"function"},{"constant":false,"inputs":[{"name":"beneficiary","type":"address"},{"name":"etherAmount","type":"uint256"},{"name":"JobDescription","type":"string"},{"name":"transactionBytecode","type":"bytes"}],"name":"newProposal","outputs":[{"name":"proposalID","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"minimumQuorumForProposals","type":"uint256"},{"name":"minutesForDebate","type":"uint256"},{"name":"marginOfVotesForMajority","type":"int256"}],"name":"changeVotingRules","outputs":[],"type":"function"},{"constant":false,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"supportsProposal","type":"bool"},{"name":"justificationText","type":"string"}],"name":"vote","outputs":[{"name":"voteID","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[{"name":"proposalNumber","type":"uint256"},{"name":"beneficiary","type":"address"},{"name":"etherAmount","type":"uint256"},{"name":"transactionBytecode","type":"bytes"}],"name":"checkProposalCode","outputs":[{"name":"codeChecksOut","type":"bool"}],"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"type":"function"},{"inputs":[{"name":"minimumQuorumForProposals","type":"uint256"},{"name":"minutesForDebate","type":"uint256"},{"name":"marginOfVotesForMajority","type":"int256"},{"name":"congressLeader","type":"address"}],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"recipient","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"description","type":"string"}],"name":"ProposalAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"position","type":"bool"},{"indexed":false,"name":"voter","type":"address"},{"indexed":false,"name":"justification","type":"string"}],"name":"Voted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"proposalID","type":"uint256"},{"indexed":false,"name":"result","type":"int256"},{"indexed":false,"name":"quorum","type":"uint256"},{"indexed":false,"name":"active","type":"bool"}],"name":"ProposalTallied","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"member","type":"address"},{"indexed":false,"name":"isMember","type":"bool"}],"name":"MembershipChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"minimumQuorum","type":"uint256"},{"indexed":false,"name":"debatingPeriodInMinutes","type":"uint256"},{"indexed":false,"name":"majorityMargin","type":"int256"}],"name":"ChangeOfRules","type":"event"}]`,
`
@@ -457,13 +457,13 @@ func TestBindings(t *testing.T) {
if !common.FileExist(gocmd) {
t.Skip("go sdk not found for testing")
}
- // Skip the test if the go-ethereum sources are symlinked (https://github.com/golang/go/issues/14845)
+ // Skip the test if the go-wtc sources are symlinked (https://github.com/golang/go/issues/14845)
linkTestCode := fmt.Sprintf("package linktest\nfunc CheckSymlinks(){\nfmt.Println(backends.NewSimulatedBackend(nil))\n}")
linkTestDeps, err := imports.Process(os.TempDir(), []byte(linkTestCode), nil)
if err != nil {
t.Fatalf("failed check for goimports symlink bug: %v", err)
}
- if !strings.Contains(string(linkTestDeps), "go-ethereum") {
+ if !strings.Contains(string(linkTestDeps), "go-wtc") {
t.Skip("symlinked environment doesn't support bind (https://github.com/golang/go/issues/14845)")
}
// Create a temporary workspace for the test suite
diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go
old mode 100644
new mode 100755
index d07610e7c..024fd8a47
--- a/accounts/abi/bind/template.go
+++ b/accounts/abi/bind/template.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -16,7 +16,7 @@
package bind
-import "github.com/ethereum/go-ethereum/accounts/abi"
+import "github.com/wtc/go-wtc/accounts/abi"
// tmplData is the data structure required to fill the binding template.
type tmplData struct {
@@ -65,7 +65,7 @@ package {{.Package}}
// {{.Type}}Bin is the compiled bytecode used for deploying new contracts.
const {{.Type}}Bin = ` + "`" + `{{.InputBin}}` + "`" + `
- // Deploy{{.Type}} deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
+ // Deploy{{.Type}} deploys a new Wtc contract, binding an instance of {{.Type}} to it.
func Deploy{{.Type}}(auth *bind.TransactOpts, backend bind.ContractBackend {{range .Constructor.Inputs}}, {{.Name}} {{bindtype .Type}}{{end}}) (common.Address, *types.Transaction, *{{.Type}}, error) {
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
if err != nil {
@@ -79,23 +79,23 @@ package {{.Package}}
}
{{end}}
- // {{.Type}} is an auto generated Go binding around an Ethereum contract.
+ // {{.Type}} is an auto generated Go binding around an Wtc contract.
type {{.Type}} struct {
{{.Type}}Caller // Read-only binding to the contract
{{.Type}}Transactor // Write-only binding to the contract
}
- // {{.Type}}Caller is an auto generated read-only Go binding around an Ethereum contract.
+ // {{.Type}}Caller is an auto generated read-only Go binding around an Wtc contract.
type {{.Type}}Caller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
- // {{.Type}}Transactor is an auto generated write-only Go binding around an Ethereum contract.
+ // {{.Type}}Transactor is an auto generated write-only Go binding around an Wtc contract.
type {{.Type}}Transactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
- // {{.Type}}Session is an auto generated Go binding around an Ethereum contract,
+ // {{.Type}}Session is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type {{.Type}}Session struct {
Contract *{{.Type}} // Generic contract binding to set the session for
@@ -103,31 +103,31 @@ package {{.Package}}
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
- // {{.Type}}CallerSession is an auto generated read-only Go binding around an Ethereum contract,
+ // {{.Type}}CallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type {{.Type}}CallerSession struct {
Contract *{{.Type}}Caller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
- // {{.Type}}TransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+ // {{.Type}}TransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type {{.Type}}TransactorSession struct {
Contract *{{.Type}}Transactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
- // {{.Type}}Raw is an auto generated low-level Go binding around an Ethereum contract.
+ // {{.Type}}Raw is an auto generated low-level Go binding around an Wtc contract.
type {{.Type}}Raw struct {
Contract *{{.Type}} // Generic contract binding to access the raw methods on
}
- // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+ // {{.Type}}CallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type {{.Type}}CallerRaw struct {
Contract *{{.Type}}Caller // Generic read-only contract binding to access the raw methods on
}
- // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+ // {{.Type}}TransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type {{.Type}}TransactorRaw struct {
Contract *{{.Type}}Transactor // Generic write-only contract binding to access the raw methods on
}
@@ -274,8 +274,8 @@ const tmplSourceJava = `
package {{.Package}};
-import org.ethereum.geth.*;
-import org.ethereum.geth.internal.*;
+import org.wtc.gwtc.*;
+import org.wtc.gwtc.internal.*;
{{range $contract := .Contracts}}
public class {{.Type}} {
@@ -286,13 +286,13 @@ import org.ethereum.geth.internal.*;
// BYTECODE is the compiled bytecode used for deploying new contracts.
public final static byte[] BYTECODE = "{{.InputBin}}".getBytes();
- // deploy deploys a new Ethereum contract, binding an instance of {{.Type}} to it.
- public static {{.Type}} deploy(TransactOpts auth, EthereumClient client{{range .Constructor.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
- Interfaces args = Geth.newInterfaces({{(len .Constructor.Inputs)}});
+ // deploy deploys a new Wtc contract, binding an instance of {{.Type}} to it.
+ public static {{.Type}} deploy(TransactOpts auth, WtcClient client{{range .Constructor.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
+ Interfaces args = Gwtc.newInterfaces({{(len .Constructor.Inputs)}});
{{range $index, $element := .Constructor.Inputs}}
- args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
+ args.set({{$index}}, Gwtc.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
{{end}}
- return new {{.Type}}(Geth.deployContract(auth, ABI, BYTECODE, client, args));
+ return new {{.Type}}(Gwtc.deployContract(auth, ABI, BYTECODE, client, args));
}
// Internal constructor used by contract deployment.
@@ -303,18 +303,18 @@ import org.ethereum.geth.internal.*;
}
{{end}}
- // Ethereum address where this contract is located at.
+ // Wtc address where this contract is located at.
public final Address Address;
- // Ethereum transaction in which this contract was deployed (if known!).
+ // Wtc transaction in which this contract was deployed (if known!).
public final Transaction Deployer;
// Contract instance bound to a blockchain address.
private final BoundContract Contract;
// Creates a new instance of {{.Type}}, bound to a specific deployed contract.
- public {{.Type}}(Address address, EthereumClient client) throws Exception {
- this(Geth.bindContract(address, ABI, client));
+ public {{.Type}}(Address address, WtcClient client) throws Exception {
+ this(Gwtc.bindContract(address, ABI, client));
}
{{range .Calls}}
@@ -330,16 +330,16 @@ import org.ethereum.geth.internal.*;
//
// Solidity: {{.Original.String}}
public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
- Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
- {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
+ Interfaces args = Gwtc.newInterfaces({{(len .Normalized.Inputs)}});
+ {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Gwtc.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
{{end}}
- Interfaces results = Geth.newInterfaces({{(len .Normalized.Outputs)}});
- {{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Geth.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type) .Type}}(); results.set({{$index}}, result{{$index}});
+ Interfaces results = Gwtc.newInterfaces({{(len .Normalized.Outputs)}});
+ {{range $index, $item := .Normalized.Outputs}}Interface result{{$index}} = Gwtc.newInterface(); result{{$index}}.setDefault{{namedtype (bindtype .Type) .Type}}(); results.set({{$index}}, result{{$index}});
{{end}}
if (opts == null) {
- opts = Geth.newCallOpts();
+ opts = Gwtc.newCallOpts();
}
this.Contract.call(opts, results, "{{.Original.Name}}", args);
{{if gt (len .Normalized.Outputs) 1}}
@@ -357,8 +357,8 @@ import org.ethereum.geth.internal.*;
//
// Solidity: {{.Original.String}}
public Transaction {{.Normalized.Name}}(TransactOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type}} {{.Name}}{{end}}) throws Exception {
- Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}});
- {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Geth.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
+ Interfaces args = Gwtc.newInterfaces({{(len .Normalized.Inputs)}});
+ {{range $index, $item := .Normalized.Inputs}}args.set({{$index}}, Gwtc.newInterface()); args.get({{$index}}).set{{namedtype (bindtype .Type) .Type}}({{.Name}});
{{end}}
return this.Contract.transact(opts, "{{.Original.Name}}" , args);
diff --git a/accounts/abi/bind/util.go b/accounts/abi/bind/util.go
old mode 100644
new mode 100755
index d129993ca..fc3224c7c
--- a/accounts/abi/bind/util.go
+++ b/accounts/abi/bind/util.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,9 +21,9 @@ import (
"fmt"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
)
// WaitMined waits for tx to be mined on the blockchain.
diff --git a/accounts/abi/bind/util_test.go b/accounts/abi/bind/util_test.go
old mode 100644
new mode 100755
index d24aa721e..9ca6543ac
--- a/accounts/abi/bind/util_test.go
+++ b/accounts/abi/bind/util_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,12 +22,12 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/accounts/abi/bind/backends"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
)
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
diff --git a/accounts/abi/doc.go b/accounts/abi/doc.go
old mode 100644
new mode 100755
index 824206858..cbcea4752
--- a/accounts/abi/doc.go
+++ b/accounts/abi/doc.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package abi implements the Ethereum ABI (Application Binary
+// Package abi implements the Wtc ABI (Application Binary
// Interface).
//
-// The Ethereum ABI is strongly typed, known at compile time
+// The Wtc ABI is strongly typed, known at compile time
// and static. This ABI will handle basic type casting; unsigned
// to signed and visa versa. It does not handle slice casting such
// as unsigned slice to signed slice. Bit size type casting is also
diff --git a/accounts/abi/error.go b/accounts/abi/error.go
old mode 100644
new mode 100755
index 9d8674ad0..25678113f
--- a/accounts/abi/error.go
+++ b/accounts/abi/error.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -39,23 +39,22 @@ func formatSliceString(kind reflect.Kind, sliceSize int) string {
// type in t.
func sliceTypeCheck(t Type, val reflect.Value) error {
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
- return typeErr(formatSliceString(t.Kind, t.Size), val.Type())
+ return typeErr(formatSliceString(t.Kind, t.SliceSize), val.Type())
}
-
- if t.T == ArrayTy && val.Len() != t.Size {
- return typeErr(formatSliceString(t.Elem.Kind, t.Size), formatSliceString(val.Type().Elem().Kind(), val.Len()))
+ if t.IsArray && val.Len() != t.SliceSize {
+ return typeErr(formatSliceString(t.Elem.Kind, t.SliceSize), formatSliceString(val.Type().Elem().Kind(), val.Len()))
}
- if t.Elem.T == SliceTy {
+ if t.Elem.IsSlice {
if val.Len() > 0 {
return sliceTypeCheck(*t.Elem, val.Index(0))
}
- } else if t.Elem.T == ArrayTy {
+ } else if t.Elem.IsArray {
return sliceTypeCheck(*t.Elem, val.Index(0))
}
if elemKind := val.Type().Elem().Kind(); elemKind != t.Elem.Kind {
- return typeErr(formatSliceString(t.Elem.Kind, t.Size), val.Type())
+ return typeErr(formatSliceString(t.Elem.Kind, t.SliceSize), val.Type())
}
return nil
}
@@ -63,19 +62,20 @@ func sliceTypeCheck(t Type, val reflect.Value) error {
// typeCheck checks that the given reflection value can be assigned to the reflection
// type in t.
func typeCheck(t Type, value reflect.Value) error {
- if t.T == SliceTy || t.T == ArrayTy {
+ if t.IsSlice || t.IsArray {
return sliceTypeCheck(t, value)
}
// Check base type validity. Element types will be checked later on.
if t.Kind != value.Kind() {
return typeErr(t.Kind, value.Kind())
- } else if t.T == FixedBytesTy && t.Size != value.Len() {
- return typeErr(t.Type, value.Type())
- } else {
- return nil
}
+ return nil
+}
+// varErr returns a formatted error.
+func varErr(expected, got reflect.Kind) error {
+ return typeErr(expected, got)
}
// typeErr returns a formatted type casting error.
diff --git a/accounts/abi/event.go b/accounts/abi/event.go
old mode 100644
new mode 100755
index 44ed7b8df..af6267184
--- a/accounts/abi/event.go
+++ b/accounts/abi/event.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -18,11 +18,10 @@ package abi
import (
"fmt"
- "reflect"
"strings"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/crypto"
)
// Event is an event potentially triggered by the EVM's LOG mechanism. The Event
@@ -45,93 +44,3 @@ func (e Event) Id() common.Hash {
}
return common.BytesToHash(crypto.Keccak256([]byte(fmt.Sprintf("%v(%v)", e.Name, strings.Join(types, ",")))))
}
-
-// unpacks an event return tuple into a struct of corresponding go types
-//
-// Unpacking can be done into a struct or a slice/array.
-func (e Event) tupleUnpack(v interface{}, output []byte) error {
- // make sure the passed value is a pointer
- valueOf := reflect.ValueOf(v)
- if reflect.Ptr != valueOf.Kind() {
- return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
- }
-
- var (
- value = valueOf.Elem()
- typ = value.Type()
- )
-
- if value.Kind() != reflect.Struct {
- return fmt.Errorf("abi: cannot unmarshal tuple in to %v", typ)
- }
-
- j := 0
- for i := 0; i < len(e.Inputs); i++ {
- input := e.Inputs[i]
- if input.Indexed {
- // can't read, continue
- continue
- } else if input.Type.T == ArrayTy {
- // need to move this up because they read sequentially
- j += input.Type.Size
- }
- marshalledValue, err := toGoType((i+j)*32, input.Type, output)
- if err != nil {
- return err
- }
- reflectValue := reflect.ValueOf(marshalledValue)
-
- switch value.Kind() {
- case reflect.Struct:
- for j := 0; j < typ.NumField(); j++ {
- field := typ.Field(j)
- // TODO read tags: `abi:"fieldName"`
- if field.Name == strings.ToUpper(e.Inputs[i].Name[:1])+e.Inputs[i].Name[1:] {
- if err := set(value.Field(j), reflectValue, e.Inputs[i]); err != nil {
- return err
- }
- }
- }
- case reflect.Slice, reflect.Array:
- if value.Len() < i {
- return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", len(e.Inputs), value.Len())
- }
- v := value.Index(i)
- if v.Kind() != reflect.Ptr && v.Kind() != reflect.Interface {
- return fmt.Errorf("abi: cannot unmarshal %v in to %v", v.Type(), reflectValue.Type())
- }
- reflectValue := reflect.ValueOf(marshalledValue)
- if err := set(v.Elem(), reflectValue, e.Inputs[i]); err != nil {
- return err
- }
- default:
- return fmt.Errorf("abi: cannot unmarshal tuple in to %v", typ)
- }
- }
- return nil
-}
-
-func (e Event) isTupleReturn() bool { return len(e.Inputs) > 1 }
-
-func (e Event) singleUnpack(v interface{}, output []byte) error {
- // make sure the passed value is a pointer
- valueOf := reflect.ValueOf(v)
- if reflect.Ptr != valueOf.Kind() {
- return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
- }
-
- if e.Inputs[0].Indexed {
- return fmt.Errorf("abi: attempting to unpack indexed variable into element.")
- }
-
- value := valueOf.Elem()
-
- marshalledValue, err := toGoType(0, e.Inputs[0].Type, output)
- if err != nil {
- return err
- }
- if err := set(value, reflect.ValueOf(marshalledValue), e.Inputs[0]); err != nil {
- return err
- }
- return nil
-}
diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go
old mode 100644
new mode 100755
index 7e2f13f76..e9c8e74c1
--- a/accounts/abi/event_test.go
+++ b/accounts/abi/event_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,8 +20,8 @@ import (
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/crypto"
)
func TestEventId(t *testing.T) {
@@ -31,7 +31,7 @@ func TestEventId(t *testing.T) {
}{
{
definition: `[
- { "type" : "event", "name" : "balance", "inputs": [{ "name" : "in", "type": "uint256" }] },
+ { "type" : "event", "name" : "balance", "inputs": [{ "name" : "in", "type": "uint" }] },
{ "type" : "event", "name" : "check", "inputs": [{ "name" : "t", "type": "address" }, { "name": "b", "type": "uint256" }] }
]`,
expectations: map[string]common.Hash{
diff --git a/accounts/abi/method.go b/accounts/abi/method.go
old mode 100644
new mode 100755
index d8838e9ed..9a4ec7e0a
--- a/accounts/abi/method.go
+++ b/accounts/abi/method.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,7 @@ import (
"reflect"
"strings"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/crypto"
)
// Callable method given a `Name` and whether the method is a constant.
@@ -77,85 +77,6 @@ func (method Method) pack(args ...interface{}) ([]byte, error) {
return ret, nil
}
-// unpacks a method return tuple into a struct of corresponding go types
-//
-// Unpacking can be done into a struct or a slice/array.
-func (method Method) tupleUnpack(v interface{}, output []byte) error {
- // make sure the passed value is a pointer
- valueOf := reflect.ValueOf(v)
- if reflect.Ptr != valueOf.Kind() {
- return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
- }
-
- var (
- value = valueOf.Elem()
- typ = value.Type()
- )
-
- j := 0
- for i := 0; i < len(method.Outputs); i++ {
- toUnpack := method.Outputs[i]
- if toUnpack.Type.T == ArrayTy {
- // need to move this up because they read sequentially
- j += toUnpack.Type.Size
- }
- marshalledValue, err := toGoType((i+j)*32, toUnpack.Type, output)
- if err != nil {
- return err
- }
- reflectValue := reflect.ValueOf(marshalledValue)
-
- switch value.Kind() {
- case reflect.Struct:
- for j := 0; j < typ.NumField(); j++ {
- field := typ.Field(j)
- // TODO read tags: `abi:"fieldName"`
- if field.Name == strings.ToUpper(method.Outputs[i].Name[:1])+method.Outputs[i].Name[1:] {
- if err := set(value.Field(j), reflectValue, method.Outputs[i]); err != nil {
- return err
- }
- }
- }
- case reflect.Slice, reflect.Array:
- if value.Len() < i {
- return fmt.Errorf("abi: insufficient number of arguments for unpack, want %d, got %d", len(method.Outputs), value.Len())
- }
- v := value.Index(i)
- if v.Kind() != reflect.Ptr && v.Kind() != reflect.Interface {
- return fmt.Errorf("abi: cannot unmarshal %v in to %v", v.Type(), reflectValue.Type())
- }
- reflectValue := reflect.ValueOf(marshalledValue)
- if err := set(v.Elem(), reflectValue, method.Outputs[i]); err != nil {
- return err
- }
- default:
- return fmt.Errorf("abi: cannot unmarshal tuple in to %v", typ)
- }
- }
- return nil
-}
-
-func (method Method) isTupleReturn() bool { return len(method.Outputs) > 1 }
-
-func (method Method) singleUnpack(v interface{}, output []byte) error {
- // make sure the passed value is a pointer
- valueOf := reflect.ValueOf(v)
- if reflect.Ptr != valueOf.Kind() {
- return fmt.Errorf("abi: Unpack(non-pointer %T)", v)
- }
-
- value := valueOf.Elem()
-
- marshalledValue, err := toGoType(0, method.Outputs[0].Type, output)
- if err != nil {
- return err
- }
- if err := set(value, reflect.ValueOf(marshalledValue), method.Outputs[0]); err != nil {
- return err
- }
- return nil
-}
-
// Sig returns the methods string signature according to the ABI spec.
//
// Example
diff --git a/accounts/abi/numbers.go b/accounts/abi/numbers.go
old mode 100644
new mode 100755
index 9ad99f90d..22a9cd911
--- a/accounts/abi/numbers.go
+++ b/accounts/abi/numbers.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,28 +20,41 @@ import (
"math/big"
"reflect"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
)
var (
- big_t = reflect.TypeOf(&big.Int{})
- derefbig_t = reflect.TypeOf(big.Int{})
- uint8_t = reflect.TypeOf(uint8(0))
- uint16_t = reflect.TypeOf(uint16(0))
- uint32_t = reflect.TypeOf(uint32(0))
- uint64_t = reflect.TypeOf(uint64(0))
- int_t = reflect.TypeOf(int(0))
- int8_t = reflect.TypeOf(int8(0))
- int16_t = reflect.TypeOf(int16(0))
- int32_t = reflect.TypeOf(int32(0))
- int64_t = reflect.TypeOf(int64(0))
- address_t = reflect.TypeOf(common.Address{})
- int_ts = reflect.TypeOf([]int(nil))
- int8_ts = reflect.TypeOf([]int8(nil))
- int16_ts = reflect.TypeOf([]int16(nil))
- int32_ts = reflect.TypeOf([]int32(nil))
- int64_ts = reflect.TypeOf([]int64(nil))
+ big_t = reflect.TypeOf(big.Int{})
+ ubig_t = reflect.TypeOf(big.Int{})
+ byte_t = reflect.TypeOf(byte(0))
+ byte_ts = reflect.TypeOf([]byte(nil))
+ uint_t = reflect.TypeOf(uint(0))
+ uint8_t = reflect.TypeOf(uint8(0))
+ uint16_t = reflect.TypeOf(uint16(0))
+ uint32_t = reflect.TypeOf(uint32(0))
+ uint64_t = reflect.TypeOf(uint64(0))
+ int_t = reflect.TypeOf(int(0))
+ int8_t = reflect.TypeOf(int8(0))
+ int16_t = reflect.TypeOf(int16(0))
+ int32_t = reflect.TypeOf(int32(0))
+ int64_t = reflect.TypeOf(int64(0))
+ hash_t = reflect.TypeOf(common.Hash{})
+ address_t = reflect.TypeOf(common.Address{})
+
+ uint_ts = reflect.TypeOf([]uint(nil))
+ uint8_ts = reflect.TypeOf([]uint8(nil))
+ uint16_ts = reflect.TypeOf([]uint16(nil))
+ uint32_ts = reflect.TypeOf([]uint32(nil))
+ uint64_ts = reflect.TypeOf([]uint64(nil))
+ ubig_ts = reflect.TypeOf([]*big.Int(nil))
+
+ int_ts = reflect.TypeOf([]int(nil))
+ int8_ts = reflect.TypeOf([]int8(nil))
+ int16_ts = reflect.TypeOf([]int16(nil))
+ int32_ts = reflect.TypeOf([]int32(nil))
+ int64_ts = reflect.TypeOf([]int64(nil))
+ big_ts = reflect.TypeOf([]*big.Int(nil))
)
// U256 converts a big Int into a 256bit EVM number.
diff --git a/accounts/abi/numbers_test.go b/accounts/abi/numbers_test.go
old mode 100644
new mode 100755
index b9ff5aef1..91671513f
--- a/accounts/abi/numbers_test.go
+++ b/accounts/abi/numbers_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/abi/pack.go b/accounts/abi/pack.go
old mode 100644
new mode 100755
index 072e80536..a1ea9f988
--- a/accounts/abi/pack.go
+++ b/accounts/abi/pack.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,8 +20,8 @@ import (
"math/big"
"reflect"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
)
// packBytesSlice packs the given bytes as [L, V] as the canonical representation
@@ -61,9 +61,8 @@ func packElement(t Type, reflectValue reflect.Value) []byte {
reflectValue = mustArrayToByteSlice(reflectValue)
}
return common.RightPadBytes(reflectValue.Bytes(), 32)
- default:
- panic("abi: fatal error")
}
+ panic("abi: fatal error")
}
// packNum packs the given number (using the reflect value) and will cast it to appropriate number representation
@@ -75,8 +74,6 @@ func packNum(value reflect.Value) []byte {
return U256(big.NewInt(value.Int()))
case reflect.Ptr:
return U256(value.Interface().(*big.Int))
- default:
- panic("abi: fatal error")
}
-
+ return nil
}
diff --git a/accounts/abi/pack_test.go b/accounts/abi/pack_test.go
old mode 100644
new mode 100755
index 36401ee67..a8a210bf6
--- a/accounts/abi/pack_test.go
+++ b/accounts/abi/pack_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,7 +24,7 @@ import (
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
func TestPack(t *testing.T) {
@@ -322,12 +322,12 @@ func TestPack(t *testing.T) {
} {
typ, err := NewType(test.typ)
if err != nil {
- t.Fatalf("%v failed. Unexpected parse error: %v", i, err)
+ t.Fatal("unexpected parse error:", err)
}
output, err := typ.pack(reflect.ValueOf(test.input))
if err != nil {
- t.Fatalf("%v failed. Unexpected pack error: %v", i, err)
+ t.Fatal("unexpected pack error:", err)
}
if !bytes.Equal(output, test.output) {
@@ -435,4 +435,7 @@ func TestPackNumber(t *testing.T) {
t.Errorf("test %d: pack mismatch: have %x, want %x", i, packed, tt.packed)
}
}
+ if packed := packNum(reflect.ValueOf("string")); packed != nil {
+ t.Errorf("expected 'string' to pack to nil. got %x instead", packed)
+ }
}
diff --git a/accounts/abi/reflect.go b/accounts/abi/reflect.go
old mode 100644
new mode 100755
index e953b77c1..d60fb19e9
--- a/accounts/abi/reflect.go
+++ b/accounts/abi/reflect.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,7 +24,7 @@ import (
// indirect recursively dereferences the value until it either gets the value
// or finds a big.Int
func indirect(v reflect.Value) reflect.Value {
- if v.Kind() == reflect.Ptr && v.Elem().Type() != derefbig_t {
+ if v.Kind() == reflect.Ptr && v.Elem().Type() != big_t {
return indirect(v.Elem())
}
return v
@@ -73,9 +73,15 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
func set(dst, src reflect.Value, output Argument) error {
dstType := dst.Type()
srcType := src.Type()
+
switch {
- case dstType.AssignableTo(srcType):
+ case dstType.AssignableTo(src.Type()):
dst.Set(src)
+ case dstType.Kind() == reflect.Array && srcType.Kind() == reflect.Slice:
+ if dst.Len() < output.Type.SliceSize {
+ return fmt.Errorf("abi: cannot unmarshal src (len=%d) in to dst (len=%d)", output.Type.SliceSize, dst.Len())
+ }
+ reflect.Copy(dst, src)
case dstType.Kind() == reflect.Interface:
dst.Set(src)
case dstType.Kind() == reflect.Ptr:
diff --git a/accounts/abi/type.go b/accounts/abi/type.go
old mode 100644
new mode 100755
index fba10b96d..371f4738f
--- a/accounts/abi/type.go
+++ b/accounts/abi/type.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,6 @@ import (
"reflect"
"regexp"
"strconv"
- "strings"
)
const (
@@ -30,7 +29,6 @@ const (
BoolTy
StringTy
SliceTy
- ArrayTy
AddressTy
FixedBytesTy
BytesTy
@@ -41,6 +39,9 @@ const (
// Type is the reflection of the supported argument type
type Type struct {
+ IsSlice, IsArray bool
+ SliceSize int
+
Elem *Type
Kind reflect.Kind
@@ -52,116 +53,118 @@ type Type struct {
}
var (
+ // fullTypeRegex parses the abi types
+ //
+ // Types can be in the format of:
+ //
+ // Input = Type [ "[" [ Number ] "]" ] Name .
+ // Type = [ "u" ] "int" [ Number ] [ x ] [ Number ].
+ //
+ // Examples:
+ //
+ // string int uint fixed
+ // string32 int8 uint8 uint[]
+ // address int256 uint256 fixed128x128[2]
+ fullTypeRegex = regexp.MustCompile(`([a-zA-Z0-9]+)(\[([0-9]*)\])?`)
// typeRegex parses the abi sub types
typeRegex = regexp.MustCompile("([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?")
)
// NewType creates a new reflection type of abi type given in t.
func NewType(t string) (typ Type, err error) {
- // check that array brackets are equal if they exist
- if strings.Count(t, "[") != strings.Count(t, "]") {
- return Type{}, fmt.Errorf("invalid arg type in abi")
+ res := fullTypeRegex.FindAllStringSubmatch(t, -1)[0]
+ // check if type is slice and parse type.
+ switch {
+ case res[3] != "":
+ // err is ignored. Already checked for number through the regexp
+ typ.SliceSize, _ = strconv.Atoi(res[3])
+ typ.IsArray = true
+ case res[2] != "":
+ typ.IsSlice, typ.SliceSize = true, -1
+ case res[0] == "":
+ return Type{}, fmt.Errorf("abi: type parse error: %s", t)
}
-
- typ.stringKind = t
-
- // if there are brackets, get ready to go into slice/array mode and
- // recursively create the type
- if strings.Count(t, "[") != 0 {
- i := strings.LastIndex(t, "[")
- // recursively embed the type
- embeddedType, err := NewType(t[:i])
+ if typ.IsArray || typ.IsSlice {
+ sliceType, err := NewType(res[1])
if err != nil {
return Type{}, err
}
- // grab the last cell and create a type from there
- sliced := t[i:]
- // grab the slice size with regexp
- re := regexp.MustCompile("[0-9]+")
- intz := re.FindAllString(sliced, -1)
-
- if len(intz) == 0 {
- // is a slice
- typ.T = SliceTy
- typ.Kind = reflect.Slice
- typ.Elem = &embeddedType
- typ.Type = reflect.SliceOf(embeddedType.Type)
- } else if len(intz) == 1 {
- // is a array
- typ.T = ArrayTy
- typ.Kind = reflect.Array
- typ.Elem = &embeddedType
- typ.Size, err = strconv.Atoi(intz[0])
- if err != nil {
- return Type{}, fmt.Errorf("abi: error parsing variable size: %v", err)
- }
- typ.Type = reflect.ArrayOf(typ.Size, embeddedType.Type)
- } else {
- return Type{}, fmt.Errorf("invalid formatting of array type")
+ typ.Elem = &sliceType
+ typ.stringKind = sliceType.stringKind + t[len(res[1]):]
+ // Although we know that this is an array, we cannot return
+ // as we don't know the type of the element, however, if it
+ // is still an array, then don't determine the type.
+ if typ.Elem.IsArray || typ.Elem.IsSlice {
+ return typ, nil
}
- return typ, err
- } else {
- // parse the type and size of the abi-type.
- parsedType := typeRegex.FindAllStringSubmatch(t, -1)[0]
- // varSize is the size of the variable
- var varSize int
- if len(parsedType[3]) > 0 {
- var err error
- varSize, err = strconv.Atoi(parsedType[2])
- if err != nil {
- return Type{}, fmt.Errorf("abi: error parsing variable size: %v", err)
- }
- } else {
- if parsedType[0] == "uint" || parsedType[0] == "int" {
- // this should fail because it means that there's something wrong with
- // the abi type (the compiler should always format it to the size...always)
- return Type{}, fmt.Errorf("unsupported arg type: %s", t)
- }
+ }
+
+ // parse the type and size of the abi-type.
+ parsedType := typeRegex.FindAllStringSubmatch(res[1], -1)[0]
+ // varSize is the size of the variable
+ var varSize int
+ if len(parsedType[3]) > 0 {
+ var err error
+ varSize, err = strconv.Atoi(parsedType[2])
+ if err != nil {
+ return Type{}, fmt.Errorf("abi: error parsing variable size: %v", err)
}
- // varType is the parsed abi type
- varType := parsedType[1]
-
- switch varType {
- case "int":
- typ.Kind, typ.Type = reflectIntKindAndType(false, varSize)
- typ.Size = varSize
- typ.T = IntTy
- case "uint":
- typ.Kind, typ.Type = reflectIntKindAndType(true, varSize)
- typ.Size = varSize
- typ.T = UintTy
- case "bool":
- typ.Kind = reflect.Bool
- typ.T = BoolTy
- typ.Type = reflect.TypeOf(bool(false))
- case "address":
- typ.Kind = reflect.Array
- typ.Type = address_t
- typ.Size = 20
- typ.T = AddressTy
- case "string":
- typ.Kind = reflect.String
- typ.Type = reflect.TypeOf("")
- typ.T = StringTy
- case "bytes":
- if varSize == 0 {
- typ.T = BytesTy
- typ.Kind = reflect.Slice
- typ.Type = reflect.SliceOf(reflect.TypeOf(byte(0)))
- } else {
- typ.T = FixedBytesTy
- typ.Kind = reflect.Array
- typ.Size = varSize
- typ.Type = reflect.ArrayOf(varSize, reflect.TypeOf(byte(0)))
- }
- case "function":
- typ.Kind = reflect.Array
- typ.T = FunctionTy
- typ.Size = 24
- typ.Type = reflect.ArrayOf(24, reflect.TypeOf(byte(0)))
- default:
- return Type{}, fmt.Errorf("unsupported arg type: %s", t)
+ }
+ // varType is the parsed abi type
+ varType := parsedType[1]
+ // substitute canonical integer
+ if varSize == 0 && (varType == "int" || varType == "uint") {
+ varSize = 256
+ t += "256"
+ }
+
+ // only set stringKind if not array or slice, as for those,
+ // the correct string type has been set
+ if !(typ.IsArray || typ.IsSlice) {
+ typ.stringKind = t
+ }
+
+ switch varType {
+ case "int":
+ typ.Kind, typ.Type = reflectIntKindAndType(false, varSize)
+ typ.Size = varSize
+ typ.T = IntTy
+ case "uint":
+ typ.Kind, typ.Type = reflectIntKindAndType(true, varSize)
+ typ.Size = varSize
+ typ.T = UintTy
+ case "bool":
+ typ.Kind = reflect.Bool
+ typ.T = BoolTy
+ case "address":
+ typ.Kind = reflect.Array
+ typ.Type = address_t
+ typ.Size = 20
+ typ.T = AddressTy
+ case "string":
+ typ.Kind = reflect.String
+ typ.Size = -1
+ typ.T = StringTy
+ case "bytes":
+ sliceType, _ := NewType("uint8")
+ typ.Elem = &sliceType
+ if varSize == 0 {
+ typ.IsSlice = true
+ typ.T = BytesTy
+ typ.SliceSize = -1
+ } else {
+ typ.IsArray = true
+ typ.T = FixedBytesTy
+ typ.SliceSize = varSize
}
+ case "function":
+ sliceType, _ := NewType("uint8")
+ typ.Elem = &sliceType
+ typ.IsArray = true
+ typ.T = FunctionTy
+ typ.SliceSize = 24
+ default:
+ return Type{}, fmt.Errorf("unsupported arg type: %s", t)
}
return
@@ -180,7 +183,7 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
return nil, err
}
- if t.T == SliceTy || t.T == ArrayTy {
+ if (t.IsSlice || t.IsArray) && t.T != BytesTy && t.T != FixedBytesTy && t.T != FunctionTy {
var packed []byte
for i := 0; i < v.Len(); i++ {
@@ -190,17 +193,18 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
}
packed = append(packed, val...)
}
- if t.T == SliceTy {
+ if t.IsSlice {
return packBytesSlice(packed, v.Len()), nil
- } else if t.T == ArrayTy {
+ } else if t.IsArray {
return packed, nil
}
}
+
return packElement(t, v), nil
}
// requireLengthPrefix returns whether the type requires any sort of length
// prefixing.
func (t Type) requiresLengthPrefix() bool {
- return t.T == StringTy || t.T == BytesTy || t.T == SliceTy
+ return t.T != FixedBytesTy && (t.T == StringTy || t.T == BytesTy || t.IsSlice)
}
diff --git a/accounts/abi/type_test.go b/accounts/abi/type_test.go
old mode 100644
new mode 100755
index e55af1293..0ceeb2f47
--- a/accounts/abi/type_test.go
+++ b/accounts/abi/type_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,8 +21,7 @@ import (
"reflect"
"testing"
- "github.com/davecgh/go-spew/spew"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
// typeWithoutStringer is a alias for the Type type which simply doesn't implement
@@ -35,58 +34,51 @@ func TestTypeRegexp(t *testing.T) {
blob string
kind Type
}{
- {"bool", Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}},
- {"bool[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]bool(nil)), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[]"}},
- {"bool[2]", Type{Size: 2, Kind: reflect.Array, T: ArrayTy, Type: reflect.TypeOf([2]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[2]"}},
- {"bool[2][]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([][2]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[2]"}, stringKind: "bool[2][]"}},
- {"bool[][]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([][]bool{}), Elem: &Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[]"}, stringKind: "bool[][]"}},
- {"bool[][2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][]bool{}), Elem: &Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[]"}, stringKind: "bool[][2]"}},
- {"bool[2][2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][2]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[2]"}, stringKind: "bool[2][2]"}},
- {"bool[2][][2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][][2]bool{}), Elem: &Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([][2]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[2]"}, stringKind: "bool[2][]"}, stringKind: "bool[2][][2]"}},
- {"bool[2][2][2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][2][2]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][2]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[2]"}, stringKind: "bool[2][2]"}, stringKind: "bool[2][2][2]"}},
- {"bool[][][]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([][][]bool{}), Elem: &Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([][]bool{}), Elem: &Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[]"}, stringKind: "bool[][]"}, stringKind: "bool[][][]"}},
- {"bool[][2][]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([][2][]bool{}), Elem: &Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][]bool{}), Elem: &Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]bool{}), Elem: &Type{Kind: reflect.Bool, T: BoolTy, Type: reflect.TypeOf(bool(false)), stringKind: "bool"}, stringKind: "bool[]"}, stringKind: "bool[][2]"}, stringKind: "bool[][2][]"}},
+ {"bool", Type{Kind: reflect.Bool, T: BoolTy, stringKind: "bool"}},
+ {"bool[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Bool, T: BoolTy, Elem: &Type{Kind: reflect.Bool, T: BoolTy, stringKind: "bool"}, stringKind: "bool[]"}},
+ {"bool[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Bool, T: BoolTy, Elem: &Type{Kind: reflect.Bool, T: BoolTy, stringKind: "bool"}, stringKind: "bool[2]"}},
{"int8", Type{Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, stringKind: "int8"}},
{"int16", Type{Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, stringKind: "int16"}},
{"int32", Type{Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, stringKind: "int32"}},
{"int64", Type{Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, stringKind: "int64"}},
{"int256", Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, stringKind: "int256"}},
- {"int8[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]int8{}), Elem: &Type{Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, stringKind: "int8"}, stringKind: "int8[]"}},
- {"int8[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]int8{}), Elem: &Type{Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, stringKind: "int8"}, stringKind: "int8[2]"}},
- {"int16[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]int16{}), Elem: &Type{Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, stringKind: "int16"}, stringKind: "int16[]"}},
- {"int16[2]", Type{Size: 2, Kind: reflect.Array, T: ArrayTy, Type: reflect.TypeOf([2]int16{}), Elem: &Type{Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, stringKind: "int16"}, stringKind: "int16[2]"}},
- {"int32[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]int32{}), Elem: &Type{Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, stringKind: "int32"}, stringKind: "int32[]"}},
- {"int32[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]int32{}), Elem: &Type{Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, stringKind: "int32"}, stringKind: "int32[2]"}},
- {"int64[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]int64{}), Elem: &Type{Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, stringKind: "int64"}, stringKind: "int64[]"}},
- {"int64[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]int64{}), Elem: &Type{Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, stringKind: "int64"}, stringKind: "int64[2]"}},
- {"int256[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]*big.Int{}), Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, stringKind: "int256"}, stringKind: "int256[]"}},
- {"int256[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]*big.Int{}), Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, stringKind: "int256"}, stringKind: "int256[2]"}},
+ {"int8[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, Elem: &Type{Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, stringKind: "int8"}, stringKind: "int8[]"}},
+ {"int8[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, Elem: &Type{Kind: reflect.Int8, Type: int8_t, Size: 8, T: IntTy, stringKind: "int8"}, stringKind: "int8[2]"}},
+ {"int16[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, Elem: &Type{Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, stringKind: "int16"}, stringKind: "int16[]"}},
+ {"int16[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, Elem: &Type{Kind: reflect.Int16, Type: int16_t, Size: 16, T: IntTy, stringKind: "int16"}, stringKind: "int16[2]"}},
+ {"int32[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, Elem: &Type{Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, stringKind: "int32"}, stringKind: "int32[]"}},
+ {"int32[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, Elem: &Type{Kind: reflect.Int32, Type: int32_t, Size: 32, T: IntTy, stringKind: "int32"}, stringKind: "int32[2]"}},
+ {"int64[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, Elem: &Type{Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, stringKind: "int64"}, stringKind: "int64[]"}},
+ {"int64[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, Elem: &Type{Kind: reflect.Int64, Type: int64_t, Size: 64, T: IntTy, stringKind: "int64"}, stringKind: "int64[2]"}},
+ {"int256[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, stringKind: "int256"}, stringKind: "int256[]"}},
+ {"int256[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: IntTy, stringKind: "int256"}, stringKind: "int256[2]"}},
{"uint8", Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}},
{"uint16", Type{Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, stringKind: "uint16"}},
{"uint32", Type{Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, stringKind: "uint32"}},
{"uint64", Type{Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, stringKind: "uint64"}},
{"uint256", Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, stringKind: "uint256"}},
- {"uint8[]", Type{Kind: reflect.Slice, T: SliceTy, Type: reflect.TypeOf([]uint8{}), Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, stringKind: "uint8[]"}},
- {"uint8[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]uint8{}), Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, stringKind: "uint8[2]"}},
- {"uint16[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]uint16{}), Elem: &Type{Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, stringKind: "uint16"}, stringKind: "uint16[]"}},
- {"uint16[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]uint16{}), Elem: &Type{Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, stringKind: "uint16"}, stringKind: "uint16[2]"}},
- {"uint32[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]uint32{}), Elem: &Type{Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, stringKind: "uint32"}, stringKind: "uint32[]"}},
- {"uint32[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]uint32{}), Elem: &Type{Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, stringKind: "uint32"}, stringKind: "uint32[2]"}},
- {"uint64[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]uint64{}), Elem: &Type{Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, stringKind: "uint64"}, stringKind: "uint64[]"}},
- {"uint64[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]uint64{}), Elem: &Type{Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, stringKind: "uint64"}, stringKind: "uint64[2]"}},
- {"uint256[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]*big.Int{}), Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, stringKind: "uint256"}, stringKind: "uint256[]"}},
- {"uint256[2]", Type{Kind: reflect.Array, T: ArrayTy, Type: reflect.TypeOf([2]*big.Int{}), Size: 2, Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, stringKind: "uint256"}, stringKind: "uint256[2]"}},
- {"bytes32", Type{Kind: reflect.Array, T: FixedBytesTy, Size: 32, Type: reflect.TypeOf([32]byte{}), stringKind: "bytes32"}},
- {"bytes[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([][]byte{}), Elem: &Type{Kind: reflect.Slice, Type: reflect.TypeOf([]byte{}), T: BytesTy, stringKind: "bytes"}, stringKind: "bytes[]"}},
- {"bytes[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][]byte{}), Elem: &Type{T: BytesTy, Type: reflect.TypeOf([]byte{}), Kind: reflect.Slice, stringKind: "bytes"}, stringKind: "bytes[2]"}},
- {"bytes32[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([][32]byte{}), Elem: &Type{Kind: reflect.Array, Type: reflect.TypeOf([32]byte{}), T: FixedBytesTy, Size: 32, stringKind: "bytes32"}, stringKind: "bytes32[]"}},
- {"bytes32[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2][32]byte{}), Elem: &Type{Kind: reflect.Array, T: FixedBytesTy, Size: 32, Type: reflect.TypeOf([32]byte{}), stringKind: "bytes32"}, stringKind: "bytes32[2]"}},
- {"string", Type{Kind: reflect.String, T: StringTy, Type: reflect.TypeOf(""), stringKind: "string"}},
- {"string[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]string{}), Elem: &Type{Kind: reflect.String, Type: reflect.TypeOf(""), T: StringTy, stringKind: "string"}, stringKind: "string[]"}},
- {"string[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]string{}), Elem: &Type{Kind: reflect.String, T: StringTy, Type: reflect.TypeOf(""), stringKind: "string"}, stringKind: "string[2]"}},
+ {"uint8[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, stringKind: "uint8[]"}},
+ {"uint8[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, stringKind: "uint8[2]"}},
+ {"uint16[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, Elem: &Type{Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, stringKind: "uint16"}, stringKind: "uint16[]"}},
+ {"uint16[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, Elem: &Type{Kind: reflect.Uint16, Type: uint16_t, Size: 16, T: UintTy, stringKind: "uint16"}, stringKind: "uint16[2]"}},
+ {"uint32[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, Elem: &Type{Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, stringKind: "uint32"}, stringKind: "uint32[]"}},
+ {"uint32[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, Elem: &Type{Kind: reflect.Uint32, Type: uint32_t, Size: 32, T: UintTy, stringKind: "uint32"}, stringKind: "uint32[2]"}},
+ {"uint64[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, Elem: &Type{Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, stringKind: "uint64"}, stringKind: "uint64[]"}},
+ {"uint64[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, Elem: &Type{Kind: reflect.Uint64, Type: uint64_t, Size: 64, T: UintTy, stringKind: "uint64"}, stringKind: "uint64[2]"}},
+ {"uint256[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, stringKind: "uint256"}, stringKind: "uint256[]"}},
+ {"uint256[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, Elem: &Type{Kind: reflect.Ptr, Type: big_t, Size: 256, T: UintTy, stringKind: "uint256"}, stringKind: "uint256[2]"}},
+ {"bytes32", Type{IsArray: true, SliceSize: 32, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, T: FixedBytesTy, stringKind: "bytes32"}},
+ {"bytes[]", Type{IsSlice: true, SliceSize: -1, Elem: &Type{IsSlice: true, SliceSize: -1, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, T: BytesTy, stringKind: "bytes"}, stringKind: "bytes[]"}},
+ {"bytes[2]", Type{IsArray: true, SliceSize: 2, Elem: &Type{IsSlice: true, SliceSize: -1, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, T: BytesTy, stringKind: "bytes"}, stringKind: "bytes[2]"}},
+ {"bytes32[]", Type{IsSlice: true, SliceSize: -1, Elem: &Type{IsArray: true, SliceSize: 32, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, T: FixedBytesTy, stringKind: "bytes32"}, stringKind: "bytes32[]"}},
+ {"bytes32[2]", Type{IsArray: true, SliceSize: 2, Elem: &Type{IsArray: true, SliceSize: 32, Elem: &Type{Kind: reflect.Uint8, Type: uint8_t, Size: 8, T: UintTy, stringKind: "uint8"}, T: FixedBytesTy, stringKind: "bytes32"}, stringKind: "bytes32[2]"}},
+ {"string", Type{Kind: reflect.String, Size: -1, T: StringTy, stringKind: "string"}},
+ {"string[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.String, T: StringTy, Size: -1, Elem: &Type{Kind: reflect.String, T: StringTy, Size: -1, stringKind: "string"}, stringKind: "string[]"}},
+ {"string[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.String, T: StringTy, Size: -1, Elem: &Type{Kind: reflect.String, T: StringTy, Size: -1, stringKind: "string"}, stringKind: "string[2]"}},
{"address", Type{Kind: reflect.Array, Type: address_t, Size: 20, T: AddressTy, stringKind: "address"}},
- {"address[]", Type{T: SliceTy, Kind: reflect.Slice, Type: reflect.TypeOf([]common.Address{}), Elem: &Type{Kind: reflect.Array, Type: address_t, Size: 20, T: AddressTy, stringKind: "address"}, stringKind: "address[]"}},
- {"address[2]", Type{Kind: reflect.Array, T: ArrayTy, Size: 2, Type: reflect.TypeOf([2]common.Address{}), Elem: &Type{Kind: reflect.Array, Type: address_t, Size: 20, T: AddressTy, stringKind: "address"}, stringKind: "address[2]"}},
+ {"address[]", Type{IsSlice: true, SliceSize: -1, Kind: reflect.Array, Type: address_t, T: AddressTy, Size: 20, Elem: &Type{Kind: reflect.Array, Type: address_t, Size: 20, T: AddressTy, stringKind: "address"}, stringKind: "address[]"}},
+ {"address[2]", Type{IsArray: true, SliceSize: 2, Kind: reflect.Array, Type: address_t, T: AddressTy, Size: 20, Elem: &Type{Kind: reflect.Array, Type: address_t, Size: 20, T: AddressTy, stringKind: "address"}, stringKind: "address[2]"}},
+
// TODO when fixed types are implemented properly
// {"fixed", Type{}},
// {"fixed128x128", Type{}},
@@ -95,14 +87,13 @@ func TestTypeRegexp(t *testing.T) {
// {"fixed128x128[]", Type{}},
// {"fixed128x128[2]", Type{}},
}
-
- for _, tt := range tests {
+ for i, tt := range tests {
typ, err := NewType(tt.blob)
if err != nil {
- t.Errorf("type %q: failed to parse type string: %v", tt.blob, err)
+ t.Errorf("type %d: failed to parse type string: %v", i, err)
}
if !reflect.DeepEqual(typ, tt.kind) {
- t.Errorf("type %q: parsed type mismatch:\nGOT %s\nWANT %s ", tt.blob, spew.Sdump(typeWithoutStringer(typ)), spew.Sdump(typeWithoutStringer(tt.kind)))
+ t.Errorf("type %d: parsed type mismatch:\n have %+v\n want %+v", i, typeWithoutStringer(typ), typeWithoutStringer(tt.kind))
}
}
}
@@ -113,90 +104,15 @@ func TestTypeCheck(t *testing.T) {
input interface{}
err string
}{
- {"uint", big.NewInt(1), "unsupported arg type: uint"},
- {"int", big.NewInt(1), "unsupported arg type: int"},
- {"uint256", big.NewInt(1), ""},
- {"uint256[][3][]", [][3][]*big.Int{{{}}}, ""},
- {"uint256[][][3]", [3][][]*big.Int{{{}}}, ""},
- {"uint256[3][][]", [][][3]*big.Int{{{}}}, ""},
- {"uint256[3][3][3]", [3][3][3]*big.Int{{{}}}, ""},
- {"uint8[][]", [][]uint8{}, ""},
- {"int256", big.NewInt(1), ""},
- {"uint8", uint8(1), ""},
- {"uint16", uint16(1), ""},
- {"uint32", uint32(1), ""},
- {"uint64", uint64(1), ""},
- {"int8", int8(1), ""},
- {"int16", int16(1), ""},
- {"int32", int32(1), ""},
- {"int64", int64(1), ""},
- {"uint24", big.NewInt(1), ""},
- {"uint40", big.NewInt(1), ""},
- {"uint48", big.NewInt(1), ""},
- {"uint56", big.NewInt(1), ""},
- {"uint72", big.NewInt(1), ""},
- {"uint80", big.NewInt(1), ""},
- {"uint88", big.NewInt(1), ""},
- {"uint96", big.NewInt(1), ""},
- {"uint104", big.NewInt(1), ""},
- {"uint112", big.NewInt(1), ""},
- {"uint120", big.NewInt(1), ""},
- {"uint128", big.NewInt(1), ""},
- {"uint136", big.NewInt(1), ""},
- {"uint144", big.NewInt(1), ""},
- {"uint152", big.NewInt(1), ""},
- {"uint160", big.NewInt(1), ""},
- {"uint168", big.NewInt(1), ""},
- {"uint176", big.NewInt(1), ""},
- {"uint184", big.NewInt(1), ""},
- {"uint192", big.NewInt(1), ""},
- {"uint200", big.NewInt(1), ""},
- {"uint208", big.NewInt(1), ""},
- {"uint216", big.NewInt(1), ""},
- {"uint224", big.NewInt(1), ""},
- {"uint232", big.NewInt(1), ""},
- {"uint240", big.NewInt(1), ""},
- {"uint248", big.NewInt(1), ""},
- {"int24", big.NewInt(1), ""},
- {"int40", big.NewInt(1), ""},
- {"int48", big.NewInt(1), ""},
- {"int56", big.NewInt(1), ""},
- {"int72", big.NewInt(1), ""},
- {"int80", big.NewInt(1), ""},
- {"int88", big.NewInt(1), ""},
- {"int96", big.NewInt(1), ""},
- {"int104", big.NewInt(1), ""},
- {"int112", big.NewInt(1), ""},
- {"int120", big.NewInt(1), ""},
- {"int128", big.NewInt(1), ""},
- {"int136", big.NewInt(1), ""},
- {"int144", big.NewInt(1), ""},
- {"int152", big.NewInt(1), ""},
- {"int160", big.NewInt(1), ""},
- {"int168", big.NewInt(1), ""},
- {"int176", big.NewInt(1), ""},
- {"int184", big.NewInt(1), ""},
- {"int192", big.NewInt(1), ""},
- {"int200", big.NewInt(1), ""},
- {"int208", big.NewInt(1), ""},
- {"int216", big.NewInt(1), ""},
- {"int224", big.NewInt(1), ""},
- {"int232", big.NewInt(1), ""},
- {"int240", big.NewInt(1), ""},
- {"int248", big.NewInt(1), ""},
+ {"uint", big.NewInt(1), ""},
+ {"int", big.NewInt(1), ""},
+ {"uint30", big.NewInt(1), ""},
{"uint30", uint8(1), "abi: cannot use uint8 as type ptr as argument"},
- {"uint8", uint16(1), "abi: cannot use uint16 as type uint8 as argument"},
- {"uint8", uint32(1), "abi: cannot use uint32 as type uint8 as argument"},
- {"uint8", uint64(1), "abi: cannot use uint64 as type uint8 as argument"},
- {"uint8", int8(1), "abi: cannot use int8 as type uint8 as argument"},
- {"uint8", int16(1), "abi: cannot use int16 as type uint8 as argument"},
- {"uint8", int32(1), "abi: cannot use int32 as type uint8 as argument"},
- {"uint8", int64(1), "abi: cannot use int64 as type uint8 as argument"},
{"uint16", uint16(1), ""},
{"uint16", uint8(1), "abi: cannot use uint8 as type uint16 as argument"},
{"uint16[]", []uint16{1, 2, 3}, ""},
{"uint16[]", [3]uint16{1, 2, 3}, ""},
- {"uint16[]", []uint32{1, 2, 3}, "abi: cannot use []uint32 as type [0]uint16 as argument"},
+ {"uint16[]", []uint32{1, 2, 3}, "abi: cannot use []uint32 as type []uint16 as argument"},
{"uint16[3]", [3]uint32{1, 2, 3}, "abi: cannot use [3]uint32 as type [3]uint16 as argument"},
{"uint16[3]", [4]uint16{1, 2, 3}, "abi: cannot use [4]uint16 as type [3]uint16 as argument"},
{"uint16[3]", []uint16{1, 2, 3}, ""},
@@ -206,61 +122,20 @@ func TestTypeCheck(t *testing.T) {
{"address[1]", [1]common.Address{{1}}, ""},
{"address[2]", [1]common.Address{{1}}, "abi: cannot use [1]array as type [2]array as argument"},
{"bytes32", [32]byte{}, ""},
- {"bytes31", [31]byte{}, ""},
- {"bytes30", [30]byte{}, ""},
- {"bytes29", [29]byte{}, ""},
- {"bytes28", [28]byte{}, ""},
- {"bytes27", [27]byte{}, ""},
- {"bytes26", [26]byte{}, ""},
- {"bytes25", [25]byte{}, ""},
- {"bytes24", [24]byte{}, ""},
- {"bytes23", [23]byte{}, ""},
- {"bytes22", [22]byte{}, ""},
- {"bytes21", [21]byte{}, ""},
- {"bytes20", [20]byte{}, ""},
- {"bytes19", [19]byte{}, ""},
- {"bytes18", [18]byte{}, ""},
- {"bytes17", [17]byte{}, ""},
- {"bytes16", [16]byte{}, ""},
- {"bytes15", [15]byte{}, ""},
- {"bytes14", [14]byte{}, ""},
- {"bytes13", [13]byte{}, ""},
- {"bytes12", [12]byte{}, ""},
- {"bytes11", [11]byte{}, ""},
- {"bytes10", [10]byte{}, ""},
- {"bytes9", [9]byte{}, ""},
- {"bytes8", [8]byte{}, ""},
- {"bytes7", [7]byte{}, ""},
- {"bytes6", [6]byte{}, ""},
- {"bytes5", [5]byte{}, ""},
- {"bytes4", [4]byte{}, ""},
- {"bytes3", [3]byte{}, ""},
- {"bytes2", [2]byte{}, ""},
- {"bytes1", [1]byte{}, ""},
{"bytes32", [33]byte{}, "abi: cannot use [33]uint8 as type [32]uint8 as argument"},
{"bytes32", common.Hash{1}, ""},
- {"bytes31", common.Hash{1}, "abi: cannot use common.Hash as type [31]uint8 as argument"},
+ {"bytes31", [31]byte{}, ""},
{"bytes31", [32]byte{}, "abi: cannot use [32]uint8 as type [31]uint8 as argument"},
{"bytes", []byte{0, 1}, ""},
- {"bytes", [2]byte{0, 1}, "abi: cannot use array as type slice as argument"},
- {"bytes", common.Hash{1}, "abi: cannot use array as type slice as argument"},
+ {"bytes", [2]byte{0, 1}, ""},
+ {"bytes", common.Hash{1}, ""},
{"string", "hello world", ""},
- {"string", string(""), ""},
- {"string", []byte{}, "abi: cannot use slice as type string as argument"},
{"bytes32[]", [][32]byte{{}}, ""},
{"function", [24]byte{}, ""},
- {"bytes20", common.Address{}, ""},
- {"address", [20]byte{}, ""},
- {"address", common.Address{}, ""},
} {
typ, err := NewType(test.typ)
- if err != nil && len(test.err) == 0 {
+ if err != nil {
t.Fatal("unexpected parse error:", err)
- } else if err != nil && len(test.err) != 0 {
- if err.Error() != test.err {
- t.Errorf("%d failed. Expected err: '%v' got err: '%v'", i, test.err, err)
- }
- continue
}
err = typeCheck(typ, reflect.ValueOf(test.input))
diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go
old mode 100644
new mode 100755
index 57732797b..7fba5cddf
--- a/accounts/abi/unpack.go
+++ b/accounts/abi/unpack.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,23 +22,125 @@ import (
"math/big"
"reflect"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
-// unpacker is a utility interface that enables us to have
-// abstraction between events and methods and also to properly
-// "unpack" them; e.g. events use Inputs, methods use Outputs.
-type unpacker interface {
- tupleUnpack(v interface{}, output []byte) error
- singleUnpack(v interface{}, output []byte) error
- isTupleReturn() bool
+// toGoSliceType parses the input and casts it to the proper slice defined by the ABI
+// argument in T.
+func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
+ index := i * 32
+ // The slice must, at very least be large enough for the index+32 which is exactly the size required
+ // for the [offset in output, size of offset].
+ if index+32 > len(output) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go slice: insufficient size output %d require %d", len(output), index+32)
+ }
+ elem := t.Type.Elem
+
+ // first we need to create a slice of the type
+ var refSlice reflect.Value
+ switch elem.T {
+ case IntTy, UintTy, BoolTy:
+ // create a new reference slice matching the element type
+ switch t.Type.Kind {
+ case reflect.Bool:
+ refSlice = reflect.ValueOf([]bool(nil))
+ case reflect.Uint8:
+ refSlice = reflect.ValueOf([]uint8(nil))
+ case reflect.Uint16:
+ refSlice = reflect.ValueOf([]uint16(nil))
+ case reflect.Uint32:
+ refSlice = reflect.ValueOf([]uint32(nil))
+ case reflect.Uint64:
+ refSlice = reflect.ValueOf([]uint64(nil))
+ case reflect.Int8:
+ refSlice = reflect.ValueOf([]int8(nil))
+ case reflect.Int16:
+ refSlice = reflect.ValueOf([]int16(nil))
+ case reflect.Int32:
+ refSlice = reflect.ValueOf([]int32(nil))
+ case reflect.Int64:
+ refSlice = reflect.ValueOf([]int64(nil))
+ default:
+ refSlice = reflect.ValueOf([]*big.Int(nil))
+ }
+ case AddressTy: // address must be of slice Address
+ refSlice = reflect.ValueOf([]common.Address(nil))
+ case HashTy: // hash must be of slice hash
+ refSlice = reflect.ValueOf([]common.Hash(nil))
+ case FixedBytesTy:
+ refSlice = reflect.ValueOf([][]byte(nil))
+ default: // no other types are supported
+ return nil, fmt.Errorf("abi: unsupported slice type %v", elem.T)
+ }
+
+ var slice []byte
+ var size int
+ var offset int
+ if t.Type.IsSlice {
+ // get the offset which determines the start of this array ...
+ offset = int(binary.BigEndian.Uint64(output[index+24 : index+32]))
+ if offset+32 > len(output) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go slice: offset %d would go over slice boundary (len=%d)", len(output), offset+32)
+ }
+
+ slice = output[offset:]
+ // ... starting with the size of the array in elements ...
+ size = int(binary.BigEndian.Uint64(slice[24:32]))
+ slice = slice[32:]
+ // ... and make sure that we've at the very least the amount of bytes
+ // available in the buffer.
+ if size*32 > len(slice) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go slice: insufficient size output %d require %d", len(output), offset+32+size*32)
+ }
+
+ // reslice to match the required size
+ slice = slice[:size*32]
+ } else if t.Type.IsArray {
+ //get the number of elements in the array
+ size = t.Type.SliceSize
+
+ //check to make sure array size matches up
+ if index+32*size > len(output) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go array: offset %d would go over slice boundary (len=%d)", len(output), index+32*size)
+ }
+ //slice is there for a fixed amount of times
+ slice = output[index : index+size*32]
+ }
+
+ for i := 0; i < size; i++ {
+ var (
+ inter interface{} // interface type
+ returnOutput = slice[i*32 : i*32+32] // the return output
+ err error
+ )
+ // set inter to the correct type (cast)
+ switch elem.T {
+ case IntTy, UintTy:
+ inter = readInteger(t.Type.Kind, returnOutput)
+ case BoolTy:
+ inter, err = readBool(returnOutput)
+ if err != nil {
+ return nil, err
+ }
+ case AddressTy:
+ inter = common.BytesToAddress(returnOutput)
+ case HashTy:
+ inter = common.BytesToHash(returnOutput)
+ case FixedBytesTy:
+ inter = returnOutput
+ }
+ // append the item to our reflect slice
+ refSlice = reflect.Append(refSlice, reflect.ValueOf(inter))
+ }
+
+ // return the interface
+ return refSlice.Interface(), nil
}
-// reads the integer based on its kind
func readInteger(kind reflect.Kind, b []byte) interface{} {
switch kind {
case reflect.Uint8:
- return b[len(b)-1]
+ return uint8(b[len(b)-1])
case reflect.Uint16:
return binary.BigEndian.Uint16(b[len(b)-2:])
case reflect.Uint32:
@@ -58,10 +160,13 @@ func readInteger(kind reflect.Kind, b []byte) interface{} {
}
}
-// reads a bool
func readBool(word []byte) (bool, error) {
- for _, b := range word[:31] {
- if b != 0 {
+ if len(word) != 32 {
+ return false, fmt.Errorf("abi: fatal error: incorrect word length")
+ }
+
+ for i, b := range word {
+ if b != 0 && i != 31 {
return false, errBadBool
}
}
@@ -73,144 +178,58 @@ func readBool(word []byte) (bool, error) {
default:
return false, errBadBool
}
-}
-// A function type is simply the address with the function selection signature at the end.
-// This enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes)
-func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
- if t.T != FunctionTy {
- return [24]byte{}, fmt.Errorf("abi: invalid type in call to make function type byte array.")
- }
- if garbage := binary.BigEndian.Uint64(word[24:32]); garbage != 0 {
- err = fmt.Errorf("abi: got improperly encoded function type, got %v", word)
- } else {
- copy(funcTy[:], word[0:24])
- }
- return
}
-// through reflection, creates a fixed array to be read from
-func readFixedBytes(t Type, word []byte) (interface{}, error) {
- if t.T != FixedBytesTy {
- return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array.")
+// toGoType parses the input and casts it to the proper type defined by the ABI
+// argument in T.
+func toGoType(i int, t Argument, output []byte) (interface{}, error) {
+ // we need to treat slices differently
+ if (t.Type.IsSlice || t.Type.IsArray) && t.Type.T != BytesTy && t.Type.T != StringTy && t.Type.T != FixedBytesTy && t.Type.T != FunctionTy {
+ return toGoSlice(i, t, output)
}
- // convert
- array := reflect.New(t.Type).Elem()
-
- reflect.Copy(array, reflect.ValueOf(word[0:t.Size]))
- return array.Interface(), nil
-}
-
-// iteratively unpack elements
-func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error) {
- if start+32*size > len(output) {
- return nil, fmt.Errorf("abi: cannot marshal in to go array: offset %d would go over slice boundary (len=%d)", len(output), start+32*size)
- }
-
- // this value will become our slice or our array, depending on the type
- var refSlice reflect.Value
- slice := output[start : start+size*32]
-
- if t.T == SliceTy {
- // declare our slice
- refSlice = reflect.MakeSlice(t.Type, size, size)
- } else if t.T == ArrayTy {
- // declare our array
- refSlice = reflect.New(t.Type).Elem()
- } else {
- return nil, fmt.Errorf("abi: invalid type in array/slice unpacking stage")
- }
-
- for i, j := start, 0; j*32 < len(slice); i, j = i+32, j+1 {
- // this corrects the arrangement so that we get all the underlying array values
- if t.Elem.T == ArrayTy && j != 0 {
- i = start + t.Elem.Size*32*j
- }
- inter, err := toGoType(i, *t.Elem, output)
- if err != nil {
- return nil, err
- }
- // append the item to our reflect slice
- refSlice.Index(j).Set(reflect.ValueOf(inter))
- }
-
- // return the interface
- return refSlice.Interface(), nil
-}
-
-// toGoType parses the output bytes and recursively assigns the value of these bytes
-// into a go type with accordance with the ABI spec.
-func toGoType(index int, t Type, output []byte) (interface{}, error) {
+ index := i * 32
if index+32 > len(output) {
return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), index+32)
}
- var (
- returnOutput []byte
- begin, end int
- err error
- )
-
- // if we require a length prefix, find the beginning word and size returned.
- if t.requiresLengthPrefix() {
- begin, end, err = lengthPrefixPointsTo(index, output)
- if err != nil {
- return nil, err
+ // Parse the given index output and check whether we need to read
+ // a different offset and length based on the type (i.e. string, bytes)
+ var returnOutput []byte
+ switch t.Type.T {
+ case StringTy, BytesTy: // variable arrays are written at the end of the return bytes
+ // parse offset from which we should start reading
+ offset := int(binary.BigEndian.Uint64(output[index+24 : index+32]))
+ if offset+32 > len(output) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), offset+32)
+ }
+ // parse the size up until we should be reading
+ size := int(binary.BigEndian.Uint64(output[offset+24 : offset+32]))
+ if offset+32+size > len(output) {
+ return nil, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), offset+32+size)
}
- } else {
+
+ // get the bytes for this return value
+ returnOutput = output[offset+32 : offset+32+size]
+ default:
returnOutput = output[index : index+32]
}
- switch t.T {
- case SliceTy:
- return forEachUnpack(t, output, begin, end)
- case ArrayTy:
- return forEachUnpack(t, output, index, t.Size)
- case StringTy: // variable arrays are written at the end of the return bytes
- return string(output[begin : begin+end]), nil
+ // convert the bytes to whatever is specified by the ABI.
+ switch t.Type.T {
case IntTy, UintTy:
- return readInteger(t.Kind, returnOutput), nil
+ return readInteger(t.Type.Kind, returnOutput), nil
case BoolTy:
return readBool(returnOutput)
case AddressTy:
return common.BytesToAddress(returnOutput), nil
case HashTy:
return common.BytesToHash(returnOutput), nil
- case BytesTy:
- return output[begin : begin+end], nil
- case FixedBytesTy:
- return readFixedBytes(t, returnOutput)
- case FunctionTy:
- return readFunctionType(t, returnOutput)
- default:
- return nil, fmt.Errorf("abi: unknown type %v", t.T)
- }
-}
-
-// interprets a 32 byte slice as an offset and then determines which indice to look to decode the type.
-func lengthPrefixPointsTo(index int, output []byte) (start int, length int, err error) {
- offset := int(binary.BigEndian.Uint64(output[index+24 : index+32]))
- if offset+32 > len(output) {
- return 0, 0, fmt.Errorf("abi: cannot marshal in to go slice: offset %d would go over slice boundary (len=%d)", len(output), offset+32)
- }
- length = int(binary.BigEndian.Uint64(output[offset+24 : offset+32]))
- if offset+32+length > len(output) {
- return 0, 0, fmt.Errorf("abi: cannot marshal in to go type: length insufficient %d require %d", len(output), offset+32+length)
- }
- start = offset + 32
-
- //fmt.Printf("LENGTH PREFIX INFO: \nsize: %v\noffset: %v\nstart: %v\n", length, offset, start)
- return
-}
-
-// checks for proper formatting of byte output
-func bytesAreProper(output []byte) error {
- if len(output) == 0 {
- return fmt.Errorf("abi: unmarshalling empty output")
- } else if len(output)%32 != 0 {
- return fmt.Errorf("abi: improperly formatted output")
- } else {
- return nil
+ case BytesTy, FixedBytesTy, FunctionTy:
+ return returnOutput, nil
+ case StringTy:
+ return string(returnOutput), nil
}
+ return nil, fmt.Errorf("abi: unknown type %v", t.Type.T)
}
diff --git a/accounts/abi/unpack_test.go b/accounts/abi/unpack_test.go
old mode 100644
new mode 100755
index 294908378..754241769
--- a/accounts/abi/unpack_test.go
+++ b/accounts/abi/unpack_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -18,271 +18,272 @@ package abi
import (
"bytes"
- "encoding/hex"
"fmt"
"math/big"
"reflect"
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
-type unpackTest struct {
- def string // ABI definition JSON
- enc string // evm return data
- want interface{} // the expected output
- err string // empty or error if expected
-}
-
-func (test unpackTest) checkError(err error) error {
- if err != nil {
- if len(test.err) == 0 {
- return fmt.Errorf("expected no err but got: %v", err)
- } else if err.Error() != test.err {
- return fmt.Errorf("expected err: '%v' got err: %q", test.err, err)
+func TestSimpleMethodUnpack(t *testing.T) {
+ for i, test := range []struct {
+ def string // definition of the **output** ABI params
+ marshalledOutput []byte // evm return data
+ expectedOut interface{} // the expected output
+ outVar string // the output variable (e.g. uint32, *big.Int, etc)
+ err string // empty or error if expected
+ }{
+ {
+ `[ { "type": "bool" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ bool(true),
+ "bool",
+ "",
+ },
+ {
+ `[ { "type": "uint32" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ uint32(1),
+ "uint32",
+ "",
+ },
+ {
+ `[ { "type": "uint32" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ nil,
+ "uint16",
+ "abi: cannot unmarshal uint32 in to uint16",
+ },
+ {
+ `[ { "type": "uint17" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ nil,
+ "uint16",
+ "abi: cannot unmarshal *big.Int in to uint16",
+ },
+ {
+ `[ { "type": "uint17" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ big.NewInt(1),
+ "*big.Int",
+ "",
+ },
+
+ {
+ `[ { "type": "int32" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ int32(1),
+ "int32",
+ "",
+ },
+ {
+ `[ { "type": "int32" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ nil,
+ "int16",
+ "abi: cannot unmarshal int32 in to int16",
+ },
+ {
+ `[ { "type": "int17" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ nil,
+ "int16",
+ "abi: cannot unmarshal *big.Int in to int16",
+ },
+ {
+ `[ { "type": "int17" } ]`,
+ common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"),
+ big.NewInt(1),
+ "*big.Int",
+ "",
+ },
+
+ {
+ `[ { "type": "address" } ]`,
+ common.Hex2Bytes("0000000000000000000000000100000000000000000000000000000000000000"),
+ common.Address{1},
+ "address",
+ "",
+ },
+ {
+ `[ { "type": "bytes32" } ]`,
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ "bytes",
+ "",
+ },
+ {
+ `[ { "type": "bytes32" } ]`,
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ "hash",
+ "",
+ },
+ {
+ `[ { "type": "bytes32" } ]`,
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ "interface",
+ "",
+ },
+ {
+ `[ { "type": "function" } ]`,
+ common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
+ [24]byte{1},
+ "function",
+ "",
+ },
+ } {
+ abiDefinition := fmt.Sprintf(`[{ "name" : "method", "outputs": %s}]`, test.def)
+ abi, err := JSON(strings.NewReader(abiDefinition))
+ if err != nil {
+ t.Errorf("%d failed. %v", i, err)
+ continue
}
- } else if len(test.err) > 0 {
- return fmt.Errorf("expected err: %v but got none", test.err)
- }
- return nil
-}
-var unpackTests = []unpackTest{
- {
- def: `[{ "type": "bool" }]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: true,
- },
- {
- def: `[{"type": "uint32"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: uint32(1),
- },
- {
- def: `[{"type": "uint32"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: uint16(0),
- err: "abi: cannot unmarshal uint32 in to uint16",
- },
- {
- def: `[{"type": "uint17"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: uint16(0),
- err: "abi: cannot unmarshal *big.Int in to uint16",
- },
- {
- def: `[{"type": "uint17"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: big.NewInt(1),
- },
- {
- def: `[{"type": "int32"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: int32(1),
- },
- {
- def: `[{"type": "int32"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: int16(0),
- err: "abi: cannot unmarshal int32 in to int16",
- },
- {
- def: `[{"type": "int17"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: int16(0),
- err: "abi: cannot unmarshal *big.Int in to int16",
- },
- {
- def: `[{"type": "int17"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001",
- want: big.NewInt(1),
- },
- {
- def: `[{"type": "address"}]`,
- enc: "0000000000000000000000000100000000000000000000000000000000000000",
- want: common.Address{1},
- },
- {
- def: `[{"type": "bytes32"}]`,
- enc: "0100000000000000000000000000000000000000000000000000000000000000",
- want: [32]byte{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
- },
- {
- def: `[{"type": "bytes"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000000000000000000000000000000000000000000000",
- want: common.Hex2Bytes("0100000000000000000000000000000000000000000000000000000000000000"),
- },
- {
- def: `[{"type": "bytes"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000000000000000000000000000000000000000000000",
- want: [32]byte{},
- err: "abi: cannot unmarshal []uint8 in to [32]uint8",
- },
- {
- def: `[{"type": "bytes32"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200100000000000000000000000000000000000000000000000000000000000000",
- want: []byte(nil),
- err: "abi: cannot unmarshal [32]uint8 in to []uint8",
- },
- {
- def: `[{"type": "bytes32"}]`,
- enc: "0100000000000000000000000000000000000000000000000000000000000000",
- want: common.HexToHash("0100000000000000000000000000000000000000000000000000000000000000"),
- },
- {
- def: `[{"type": "function"}]`,
- enc: "0100000000000000000000000000000000000000000000000000000000000000",
- want: [24]byte{1},
- },
- // slices
- {
- def: `[{"type": "uint8[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []uint8{1, 2},
- },
- {
- def: `[{"type": "uint8[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]uint8{1, 2},
- },
- // multi dimensional, if these pass, all types that don't require length prefix should pass
- {
- def: `[{"type": "uint8[][]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000E0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [][]uint8{{1, 2}, {1, 2}},
- },
- {
- def: `[{"type": "uint8[2][2]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2][2]uint8{{1, 2}, {1, 2}},
- },
- {
- def: `[{"type": "uint8[][2]"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
- want: [2][]uint8{{1}, {1}},
- },
- {
- def: `[{"type": "uint8[2][]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [][2]uint8{{1, 2}},
- },
- {
- def: `[{"type": "uint16[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []uint16{1, 2},
- },
- {
- def: `[{"type": "uint16[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]uint16{1, 2},
- },
- {
- def: `[{"type": "uint32[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []uint32{1, 2},
- },
- {
- def: `[{"type": "uint32[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]uint32{1, 2},
- },
- {
- def: `[{"type": "uint64[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []uint64{1, 2},
- },
- {
- def: `[{"type": "uint64[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]uint64{1, 2},
- },
- {
- def: `[{"type": "uint256[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []*big.Int{big.NewInt(1), big.NewInt(2)},
- },
- {
- def: `[{"type": "uint256[3]"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003",
- want: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
- },
- {
- def: `[{"type": "int8[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []int8{1, 2},
- },
- {
- def: `[{"type": "int8[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]int8{1, 2},
- },
- {
- def: `[{"type": "int16[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []int16{1, 2},
- },
- {
- def: `[{"type": "int16[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]int16{1, 2},
- },
- {
- def: `[{"type": "int32[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []int32{1, 2},
- },
- {
- def: `[{"type": "int32[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]int32{1, 2},
- },
- {
- def: `[{"type": "int64[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []int64{1, 2},
- },
- {
- def: `[{"type": "int64[2]"}]`,
- enc: "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: [2]int64{1, 2},
- },
- {
- def: `[{"type": "int256[]"}]`,
- enc: "0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002",
- want: []*big.Int{big.NewInt(1), big.NewInt(2)},
- },
- {
- def: `[{"type": "int256[3]"}]`,
- enc: "000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003",
- want: [3]*big.Int{big.NewInt(1), big.NewInt(2), big.NewInt(3)},
- },
-}
+ var outvar interface{}
+ switch test.outVar {
+ case "bool":
+ var v bool
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "uint8":
+ var v uint8
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "uint16":
+ var v uint16
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "uint32":
+ var v uint32
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "uint64":
+ var v uint64
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "int8":
+ var v int8
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "int16":
+ var v int16
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "int32":
+ var v int32
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "int64":
+ var v int64
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "*big.Int":
+ var v *big.Int
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "address":
+ var v common.Address
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "bytes":
+ var v []byte
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "hash":
+ var v common.Hash
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v.Bytes()[:]
+ case "function":
+ var v [24]byte
+ err = abi.Unpack(&v, "method", test.marshalledOutput)
+ outvar = v
+ case "interface":
+ err = abi.Unpack(&outvar, "method", test.marshalledOutput)
+ default:
+ t.Errorf("unsupported type '%v' please add it to the switch statement in this test", test.outVar)
+ continue
+ }
-func TestUnpack(t *testing.T) {
- for i, test := range unpackTests {
- def := fmt.Sprintf(`[{ "name" : "method", "outputs": %s}]`, test.def)
- abi, err := JSON(strings.NewReader(def))
- if err != nil {
- t.Fatalf("invalid ABI definition %s: %v", def, err)
+ if err != nil && len(test.err) == 0 {
+ t.Errorf("%d failed. Expected no err but got: %v", i, err)
+ continue
}
- encb, err := hex.DecodeString(test.enc)
- if err != nil {
- t.Fatalf("invalid hex: %s" + test.enc)
+ if err == nil && len(test.err) != 0 {
+ t.Errorf("%d failed. Expected err: %v but got none", i, test.err)
+ continue
}
- outptr := reflect.New(reflect.TypeOf(test.want))
- err = abi.Unpack(outptr.Interface(), "method", encb)
- if err := test.checkError(err); err != nil {
- t.Errorf("test %d (%v) failed: %v", i, test.def, err)
+ if err != nil && len(test.err) != 0 && err.Error() != test.err {
+ t.Errorf("%d failed. Expected err: '%v' got err: '%v'", i, test.err, err)
continue
}
- out := outptr.Elem().Interface()
- if !reflect.DeepEqual(test.want, out) {
- t.Errorf("test %d (%v) failed: expected %v, got %v", i, test.def, test.want, out)
+
+ if err == nil {
+ if !reflect.DeepEqual(test.expectedOut, outvar) {
+ t.Errorf("%d failed. Output error: expected %v, got %v", i, test.expectedOut, outvar)
+ }
}
}
}
+func TestUnpackSetInterfaceSlice(t *testing.T) {
+ var (
+ var1 = new(uint8)
+ var2 = new(uint8)
+ )
+ out := []interface{}{var1, var2}
+ abi, err := JSON(strings.NewReader(`[{"type":"function", "name":"ints", "outputs":[{"type":"uint8"}, {"type":"uint8"}]}]`))
+ if err != nil {
+ t.Fatal(err)
+ }
+ marshalledReturn := append(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"), common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002")...)
+ err = abi.Unpack(&out, "ints", marshalledReturn)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if *var1 != 1 {
+ t.Error("expected var1 to be 1, got", *var1)
+ }
+ if *var2 != 2 {
+ t.Error("expected var2 to be 2, got", *var2)
+ }
+
+ out = []interface{}{var1}
+ err = abi.Unpack(&out, "ints", marshalledReturn)
+
+ expErr := "abi: cannot marshal in to slices of unequal size (require: 2, got: 1)"
+ if err == nil || err.Error() != expErr {
+ t.Error("expected err:", expErr, "Got:", err)
+ }
+}
+
+func TestUnpackSetInterfaceArrayOutput(t *testing.T) {
+ var (
+ var1 = new([1]uint32)
+ var2 = new([1]uint32)
+ )
+ out := []interface{}{var1, var2}
+ abi, err := JSON(strings.NewReader(`[{"type":"function", "name":"ints", "outputs":[{"type":"uint32[1]"}, {"type":"uint32[1]"}]}]`))
+ if err != nil {
+ t.Fatal(err)
+ }
+ marshalledReturn := append(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"), common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002")...)
+ err = abi.Unpack(&out, "ints", marshalledReturn)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if *var1 != [1]uint32{1} {
+ t.Error("expected var1 to be [1], got", *var1)
+ }
+ if *var2 != [1]uint32{2} {
+ t.Error("expected var2 to be [2], got", *var2)
+ }
+}
+
func TestMultiReturnWithStruct(t *testing.T) {
const definition = `[
{ "name" : "multi", "constant" : false, "outputs": [ { "name": "Int", "type": "uint256" }, { "name": "String", "type": "string" } ] }]`
@@ -336,6 +337,101 @@ func TestMultiReturnWithStruct(t *testing.T) {
}
}
+func TestMultiReturnWithSlice(t *testing.T) {
+ const definition = `[
+ { "name" : "multi", "constant" : false, "outputs": [ { "name": "Int", "type": "uint256" }, { "name": "String", "type": "string" } ] }]`
+
+ abi, err := JSON(strings.NewReader(definition))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ // using buff to make the code readable
+ buff := new(bytes.Buffer)
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000005"))
+ stringOut := "hello"
+ buff.Write(common.RightPadBytes([]byte(stringOut), 32))
+
+ var inter []interface{}
+ err = abi.Unpack(&inter, "multi", buff.Bytes())
+ if err != nil {
+ t.Error(err)
+ }
+
+ if len(inter) != 2 {
+ t.Fatal("expected 2 results got", len(inter))
+ }
+
+ if num, ok := inter[0].(*big.Int); !ok || num.Cmp(big.NewInt(1)) != 0 {
+ t.Error("expected index 0 to be 1 got", num)
+ }
+
+ if str, ok := inter[1].(string); !ok || str != stringOut {
+ t.Error("expected index 1 to be", stringOut, "got", str)
+ }
+}
+
+func TestMarshalArrays(t *testing.T) {
+ const definition = `[
+ { "name" : "bytes32", "constant" : false, "outputs": [ { "type": "bytes32" } ] },
+ { "name" : "bytes10", "constant" : false, "outputs": [ { "type": "bytes10" } ] }
+ ]`
+
+ abi, err := JSON(strings.NewReader(definition))
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ output := common.LeftPadBytes([]byte{1}, 32)
+
+ var bytes10 [10]byte
+ err = abi.Unpack(&bytes10, "bytes32", output)
+ if err == nil || err.Error() != "abi: cannot unmarshal src (len=32) in to dst (len=10)" {
+ t.Error("expected error or bytes32 not be assignable to bytes10:", err)
+ }
+
+ var bytes32 [32]byte
+ err = abi.Unpack(&bytes32, "bytes32", output)
+ if err != nil {
+ t.Error("didn't expect error:", err)
+ }
+ if !bytes.Equal(bytes32[:], output) {
+ t.Error("expected bytes32[31] to be 1 got", bytes32[31])
+ }
+
+ type (
+ B10 [10]byte
+ B32 [32]byte
+ )
+
+ var b10 B10
+ err = abi.Unpack(&b10, "bytes32", output)
+ if err == nil || err.Error() != "abi: cannot unmarshal src (len=32) in to dst (len=10)" {
+ t.Error("expected error or bytes32 not be assignable to bytes10:", err)
+ }
+
+ var b32 B32
+ err = abi.Unpack(&b32, "bytes32", output)
+ if err != nil {
+ t.Error("didn't expect error:", err)
+ }
+ if !bytes.Equal(b32[:], output) {
+ t.Error("expected bytes32[31] to be 1 got", bytes32[31])
+ }
+
+ output[10] = 1
+ var shortAssignLong [32]byte
+ err = abi.Unpack(&shortAssignLong, "bytes10", output)
+ if err != nil {
+ t.Error("didn't expect error:", err)
+ }
+ if !bytes.Equal(output, shortAssignLong[:]) {
+ t.Errorf("expected %x to be %x", shortAssignLong, output)
+ }
+}
+
func TestUnmarshal(t *testing.T) {
const definition = `[
{ "name" : "int", "constant" : false, "outputs": [ { "type": "uint256" } ] },
@@ -354,29 +450,6 @@ func TestUnmarshal(t *testing.T) {
}
buff := new(bytes.Buffer)
- // marshall mixed bytes (mixedBytes)
- p0, p0Exp := []byte{}, common.Hex2Bytes("01020000000000000000")
- p1, p1Exp := [32]byte{}, common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff")
- mixedBytes := []interface{}{&p0, &p1}
-
- buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
- buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000ddeeff"))
- buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000000000000a"))
- buff.Write(common.Hex2Bytes("0102000000000000000000000000000000000000000000000000000000000000"))
-
- err = abi.Unpack(&mixedBytes, "mixedBytes", buff.Bytes())
- if err != nil {
- t.Error(err)
- } else {
- if bytes.Compare(p0, p0Exp) != 0 {
- t.Errorf("unexpected value unpacked: want %x, got %x", p0Exp, p0)
- }
-
- if bytes.Compare(p1[:], p1Exp) != 0 {
- t.Errorf("unexpected value unpacked: want %x, got %x", p1Exp, p1)
- }
- }
-
// marshal int
var Int *big.Int
err = abi.Unpack(&Int, "int", common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
@@ -400,7 +473,6 @@ func TestUnmarshal(t *testing.T) {
}
// marshal dynamic bytes max length 32
- buff.Reset()
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
bytesOut := common.RightPadBytes([]byte("hello"), 32)
@@ -432,11 +504,11 @@ func TestUnmarshal(t *testing.T) {
t.Errorf("expected %x got %x", bytesOut, Bytes)
}
- // marshall dynamic bytes max length 64
+ // marshall dynamic bytes max length 63
buff.Reset()
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
buff.Write(common.Hex2Bytes("000000000000000000000000000000000000000000000000000000000000003f"))
- bytesOut = common.RightPadBytes([]byte("hello"), 64)
+ bytesOut = common.RightPadBytes([]byte("hello"), 63)
buff.Write(bytesOut)
err = abi.Unpack(&Bytes, "bytes", buff.Bytes())
@@ -444,8 +516,8 @@ func TestUnmarshal(t *testing.T) {
t.Error(err)
}
- if !bytes.Equal(Bytes, bytesOut[:len(bytesOut)-1]) {
- t.Errorf("expected %x got %x", bytesOut[:len(bytesOut)-1], Bytes)
+ if !bytes.Equal(Bytes, bytesOut) {
+ t.Errorf("expected %x got %x", bytesOut, Bytes)
}
// marshal dynamic bytes output empty
@@ -497,6 +569,29 @@ func TestUnmarshal(t *testing.T) {
t.Error("expected error")
}
+ // marshal mixed bytes
+ buff.Reset()
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000040"))
+ fixed := common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001")
+ buff.Write(fixed)
+ buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000020"))
+ bytesOut = common.RightPadBytes([]byte("hello"), 32)
+ buff.Write(bytesOut)
+
+ var out []interface{}
+ err = abi.Unpack(&out, "mixedBytes", buff.Bytes())
+ if err != nil {
+ t.Fatal("didn't expect error:", err)
+ }
+
+ if !bytes.Equal(bytesOut, out[0].([]byte)) {
+ t.Errorf("expected %x, got %x", bytesOut, out[0])
+ }
+
+ if !bytes.Equal(fixed, out[1].([]byte)) {
+ t.Errorf("expected %x, got %x", fixed, out[1])
+ }
+
buff.Reset()
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000001"))
buff.Write(common.Hex2Bytes("0000000000000000000000000000000000000000000000000000000000000002"))
diff --git a/accounts/accounts.go b/accounts/accounts.go
old mode 100644
new mode 100755
index 76951e1a4..c2bc010ec
--- a/accounts/accounts.go
+++ b/accounts/accounts.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,22 +14,22 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package accounts implements high level Ethereum account management.
+// Package accounts implements high level Wtc account management.
package accounts
import (
"math/big"
- ethereum "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/event"
+ wtc "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/event"
)
-// Account represents an Ethereum account located at a specific location defined
+// Account represents an Wtc account located at a specific location defined
// by the optional URL field.
type Account struct {
- Address common.Address `json:"address"` // Ethereum account address derived from the key
+ Address common.Address `json:"address"` // Wtc account address derived from the key
URL URL `json:"url"` // Optional resource locator within a backend
}
@@ -85,7 +85,7 @@ type Wallet interface {
//
// You can disable automatic account discovery by calling SelfDerive with a nil
// chain state reader.
- SelfDerive(base DerivationPath, chain ethereum.ChainStateReader)
+ SelfDerive(base DerivationPath, chain wtc.ChainStateReader)
// SignHash requests the wallet to sign the given hash.
//
diff --git a/accounts/errors.go b/accounts/errors.go
old mode 100644
new mode 100755
index 64da8821c..b4f89775d
--- a/accounts/errors.go
+++ b/accounts/errors.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/hd.go b/accounts/hd.go
old mode 100644
new mode 100755
index 277f688e4..520fdb27b
--- a/accounts/hd.go
+++ b/accounts/hd.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -50,10 +50,10 @@ var DefaultLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000
// The BIP-44 spec https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// defines that the `purpose` be 44' (or 0x8000002C) for crypto currencies, and
// SLIP-44 https://github.com/satoshilabs/slips/blob/master/slip-0044.md assigns
-// the `coin_type` 60' (or 0x8000003C) to Ethereum.
+// the `coin_type` 60' (or 0x8000003C) to Wtc.
//
-// The root path for Ethereum is m/44'/60'/0'/0 according to the specification
-// from https://github.com/ethereum/EIPs/issues/84, albeit it's not set in stone
+// The root path for Wtc is m/44'/60'/0'/0 according to the specification
+// from https://github.com/wtc/EIPs/issues/84, albeit it's not set in stone
// yet whether accounts should increment the last component or the children of
// that. We will go with the simpler approach of incrementing the last component.
type DerivationPath []uint32
diff --git a/accounts/hd_test.go b/accounts/hd_test.go
old mode 100644
new mode 100755
index b6b23230d..9e301c9e7
--- a/accounts/hd_test.go
+++ b/accounts/hd_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go
old mode 100644
new mode 100755
index 71f698ece..171aacff3
--- a/accounts/keystore/account_cache.go
+++ b/accounts/keystore/account_cache.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,6 +20,7 @@ import (
"bufio"
"encoding/json"
"fmt"
+ "io/ioutil"
"os"
"path/filepath"
"sort"
@@ -27,10 +28,9 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
- "gopkg.in/fatih/set.v0"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/log"
)
// Minimum amount of time between cache reloads. This limit applies if the platform does
@@ -71,7 +71,6 @@ type accountCache struct {
byAddr map[common.Address][]accounts.Account
throttle *time.Timer
notify chan struct{}
- fileC fileCache
}
func newAccountCache(keydir string) (*accountCache, chan struct{}) {
@@ -79,7 +78,6 @@ func newAccountCache(keydir string) (*accountCache, chan struct{}) {
keydir: keydir,
byAddr: make(map[common.Address][]accounts.Account),
notify: make(chan struct{}, 1),
- fileC: fileCache{all: set.NewNonTS()},
}
ac.watcher = newWatcher(ac)
return ac, ac.notify
@@ -129,23 +127,6 @@ func (ac *accountCache) delete(removed accounts.Account) {
}
}
-// deleteByFile removes an account referenced by the given path.
-func (ac *accountCache) deleteByFile(path string) {
- ac.mu.Lock()
- defer ac.mu.Unlock()
- i := sort.Search(len(ac.all), func(i int) bool { return ac.all[i].URL.Path >= path })
-
- if i < len(ac.all) && ac.all[i].URL.Path == path {
- removed := ac.all[i]
- ac.all = append(ac.all[:i], ac.all[i+1:]...)
- if ba := removeAccount(ac.byAddr[removed.Address], removed); len(ba) == 0 {
- delete(ac.byAddr, removed.Address)
- } else {
- ac.byAddr[removed.Address] = ba
- }
- }
-}
-
func removeAccount(slice []accounts.Account, elem accounts.Account) []accounts.Account {
for i := range slice {
if slice[i] == elem {
@@ -186,16 +167,15 @@ func (ac *accountCache) find(a accounts.Account) (accounts.Account, error) {
default:
err := &AmbiguousAddrError{Addr: a.Address, Matches: make([]accounts.Account, len(matches))}
copy(err.Matches, matches)
- sort.Sort(accountsByURL(err.Matches))
return accounts.Account{}, err
}
}
func (ac *accountCache) maybeReload() {
ac.mu.Lock()
+ defer ac.mu.Unlock()
if ac.watcher.running {
- ac.mu.Unlock()
return // A watcher is running and will keep the cache up-to-date.
}
if ac.throttle == nil {
@@ -204,15 +184,12 @@ func (ac *accountCache) maybeReload() {
select {
case <-ac.throttle.C:
default:
- ac.mu.Unlock()
return // The cache was reloaded recently.
}
}
- // No watcher running, start it.
ac.watcher.start()
+ ac.reload()
ac.throttle.Reset(minReloadInterval)
- ac.mu.Unlock()
- ac.scanAccounts()
}
func (ac *accountCache) close() {
@@ -228,71 +205,80 @@ func (ac *accountCache) close() {
ac.mu.Unlock()
}
-// scanAccounts checks if any changes have occurred on the filesystem, and
-// updates the account cache accordingly
-func (ac *accountCache) scanAccounts() error {
- // Scan the entire folder metadata for file changes
- creates, deletes, updates, err := ac.fileC.scan(ac.keydir)
+// reload caches addresses of existing accounts.
+// Callers must hold ac.mu.
+func (ac *accountCache) reload() {
+ accounts, err := ac.scan()
if err != nil {
log.Debug("Failed to reload keystore contents", "err", err)
- return err
}
- if creates.Size() == 0 && deletes.Size() == 0 && updates.Size() == 0 {
- return nil
+ ac.all = accounts
+ sort.Sort(ac.all)
+ for k := range ac.byAddr {
+ delete(ac.byAddr, k)
+ }
+ for _, a := range accounts {
+ ac.byAddr[a.Address] = append(ac.byAddr[a.Address], a)
+ }
+ select {
+ case ac.notify <- struct{}{}:
+ default:
}
- // Create a helper method to scan the contents of the key files
+ log.Debug("Reloaded keystore contents", "accounts", len(ac.all))
+}
+
+func (ac *accountCache) scan() ([]accounts.Account, error) {
+ files, err := ioutil.ReadDir(ac.keydir)
+ if err != nil {
+ return nil, err
+ }
+
var (
- buf = new(bufio.Reader)
- key struct {
+ buf = new(bufio.Reader)
+ addrs []accounts.Account
+ keyJSON struct {
Address string `json:"address"`
}
)
- readAccount := func(path string) *accounts.Account {
+ for _, fi := range files {
+ path := filepath.Join(ac.keydir, fi.Name())
+ if skipKeyFile(fi) {
+ log.Trace("Ignoring file on account scan", "path", path)
+ continue
+ }
+ logger := log.New("path", path)
+
fd, err := os.Open(path)
if err != nil {
- log.Trace("Failed to open keystore file", "path", path, "err", err)
- return nil
+ logger.Trace("Failed to open keystore file", "err", err)
+ continue
}
- defer fd.Close()
buf.Reset(fd)
// Parse the address.
- key.Address = ""
- err = json.NewDecoder(buf).Decode(&key)
- addr := common.HexToAddress(key.Address)
+ keyJSON.Address = ""
+ err = json.NewDecoder(buf).Decode(&keyJSON)
+ addr := common.HexToAddress(keyJSON.Address)
switch {
case err != nil:
- log.Debug("Failed to decode keystore key", "path", path, "err", err)
+ logger.Debug("Failed to decode keystore key", "err", err)
case (addr == common.Address{}):
- log.Debug("Failed to decode keystore key", "path", path, "err", "missing or zero address")
+ logger.Debug("Failed to decode keystore key", "err", "missing or zero address")
default:
- return &accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}}
+ addrs = append(addrs, accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}})
}
- return nil
+ fd.Close()
}
- // Process all the file diffs
- start := time.Now()
+ return addrs, err
+}
- for _, p := range creates.List() {
- if a := readAccount(p.(string)); a != nil {
- ac.add(*a)
- }
+func skipKeyFile(fi os.FileInfo) bool {
+ // Skip editor backups and UNIX-style hidden files.
+ if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
+ return true
}
- for _, p := range deletes.List() {
- ac.deleteByFile(p.(string))
- }
- for _, p := range updates.List() {
- path := p.(string)
- ac.deleteByFile(path)
- if a := readAccount(path); a != nil {
- ac.add(*a)
- }
- }
- end := time.Now()
-
- select {
- case ac.notify <- struct{}{}:
- default:
+ // Skip misc special files, directories (yes, symlinks too).
+ if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
+ return true
}
- log.Trace("Handled keystore changes", "time", end.Sub(start))
- return nil
+ return false
}
diff --git a/accounts/keystore/account_cache_test.go b/accounts/keystore/account_cache_test.go
old mode 100644
new mode 100755
index e3dc31065..a953958ad
--- a/accounts/keystore/account_cache_test.go
+++ b/accounts/keystore/account_cache_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -18,7 +18,6 @@ package keystore
import (
"fmt"
- "io/ioutil"
"math/rand"
"os"
"path/filepath"
@@ -29,8 +28,8 @@ import (
"github.com/cespare/cp"
"github.com/davecgh/go-spew/spew"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
)
var (
@@ -296,101 +295,3 @@ func TestCacheFind(t *testing.T) {
}
}
}
-
-func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
- var list []accounts.Account
- for d := 200 * time.Millisecond; d < 8*time.Second; d *= 2 {
- list = ks.Accounts()
- if reflect.DeepEqual(list, wantAccounts) {
- // ks should have also received change notifications
- select {
- case <-ks.changes:
- default:
- return fmt.Errorf("wasn't notified of new accounts")
- }
- return nil
- }
- time.Sleep(d)
- }
- return fmt.Errorf("\ngot %v\nwant %v", list, wantAccounts)
-}
-
-// TestUpdatedKeyfileContents tests that updating the contents of a keystore file
-// is noticed by the watcher, and the account cache is updated accordingly
-func TestUpdatedKeyfileContents(t *testing.T) {
- t.Parallel()
-
- // Create a temporary kesytore to test with
- rand.Seed(time.Now().UnixNano())
- dir := filepath.Join(os.TempDir(), fmt.Sprintf("eth-keystore-watch-test-%d-%d", os.Getpid(), rand.Int()))
- ks := NewKeyStore(dir, LightScryptN, LightScryptP)
-
- list := ks.Accounts()
- if len(list) > 0 {
- t.Error("initial account list not empty:", list)
- }
- time.Sleep(100 * time.Millisecond)
-
- // Create the directory and copy a key file into it.
- os.MkdirAll(dir, 0700)
- defer os.RemoveAll(dir)
- file := filepath.Join(dir, "aaa")
-
- // Place one of our testfiles in there
- if err := cp.CopyFile(file, cachetestAccounts[0].URL.Path); err != nil {
- t.Fatal(err)
- }
-
- // ks should see the account.
- wantAccounts := []accounts.Account{cachetestAccounts[0]}
- wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
- if err := waitForAccounts(wantAccounts, ks); err != nil {
- t.Error(err)
- return
- }
-
- // Now replace file contents
- if err := forceCopyFile(file, cachetestAccounts[1].URL.Path); err != nil {
- t.Fatal(err)
- return
- }
- wantAccounts = []accounts.Account{cachetestAccounts[1]}
- wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
- if err := waitForAccounts(wantAccounts, ks); err != nil {
- t.Errorf("First replacement failed")
- t.Error(err)
- return
- }
-
- // Now replace file contents again
- if err := forceCopyFile(file, cachetestAccounts[2].URL.Path); err != nil {
- t.Fatal(err)
- return
- }
- wantAccounts = []accounts.Account{cachetestAccounts[2]}
- wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
- if err := waitForAccounts(wantAccounts, ks); err != nil {
- t.Errorf("Second replacement failed")
- t.Error(err)
- return
- }
- // Now replace file contents with crap
- if err := ioutil.WriteFile(file, []byte("foo"), 0644); err != nil {
- t.Fatal(err)
- return
- }
- if err := waitForAccounts([]accounts.Account{}, ks); err != nil {
- t.Errorf("Emptying account file failed")
- t.Error(err)
- return
- }
-}
-
-// forceCopyFile is like cp.CopyFile, but doesn't complain if the destination exists.
-func forceCopyFile(dst, src string) error {
- data, err := ioutil.ReadFile(src)
- if err != nil {
- return err
- }
- return ioutil.WriteFile(dst, data, 0644)
-}
diff --git a/accounts/keystore/file_cache.go b/accounts/keystore/file_cache.go
deleted file mode 100644
index c91b7b7b6..000000000
--- a/accounts/keystore/file_cache.go
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright 2017 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package keystore
-
-import (
- "io/ioutil"
- "os"
- "path/filepath"
- "strings"
- "sync"
- "time"
-
- "github.com/ethereum/go-ethereum/log"
- set "gopkg.in/fatih/set.v0"
-)
-
-// fileCache is a cache of files seen during scan of keystore.
-type fileCache struct {
- all *set.SetNonTS // Set of all files from the keystore folder
- lastMod time.Time // Last time instance when a file was modified
- mu sync.RWMutex
-}
-
-// scan performs a new scan on the given directory, compares against the already
-// cached filenames, and returns file sets: creates, deletes, updates.
-func (fc *fileCache) scan(keyDir string) (set.Interface, set.Interface, set.Interface, error) {
- t0 := time.Now()
-
- // List all the failes from the keystore folder
- files, err := ioutil.ReadDir(keyDir)
- if err != nil {
- return nil, nil, nil, err
- }
- t1 := time.Now()
-
- fc.mu.Lock()
- defer fc.mu.Unlock()
-
- // Iterate all the files and gather their metadata
- all := set.NewNonTS()
- mods := set.NewNonTS()
-
- var newLastMod time.Time
- for _, fi := range files {
- // Skip any non-key files from the folder
- path := filepath.Join(keyDir, fi.Name())
- if skipKeyFile(fi) {
- log.Trace("Ignoring file on account scan", "path", path)
- continue
- }
- // Gather the set of all and fresly modified files
- all.Add(path)
-
- modified := fi.ModTime()
- if modified.After(fc.lastMod) {
- mods.Add(path)
- }
- if modified.After(newLastMod) {
- newLastMod = modified
- }
- }
- t2 := time.Now()
-
- // Update the tracked files and return the three sets
- deletes := set.Difference(fc.all, all) // Deletes = previous - current
- creates := set.Difference(all, fc.all) // Creates = current - previous
- updates := set.Difference(mods, creates) // Updates = modified - creates
-
- fc.all, fc.lastMod = all, newLastMod
- t3 := time.Now()
-
- // Report on the scanning stats and return
- log.Debug("FS scan times", "list", t1.Sub(t0), "set", t2.Sub(t1), "diff", t3.Sub(t2))
- return creates, deletes, updates, nil
-}
-
-// skipKeyFile ignores editor backups, hidden files and folders/symlinks.
-func skipKeyFile(fi os.FileInfo) bool {
- // Skip editor backups and UNIX-style hidden files.
- if strings.HasSuffix(fi.Name(), "~") || strings.HasPrefix(fi.Name(), ".") {
- return true
- }
- // Skip misc special files, directories (yes, symlinks too).
- if fi.IsDir() || fi.Mode()&os.ModeType != 0 {
- return true
- }
- return false
-}
diff --git a/accounts/keystore/key.go b/accounts/keystore/key.go
old mode 100644
new mode 100755
index 211fa863d..b3f9bc722
--- a/accounts/keystore/key.go
+++ b/accounts/keystore/key.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -29,9 +29,9 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/crypto"
"github.com/pborman/uuid"
)
@@ -204,8 +204,9 @@ func writeKeyFile(file string, content []byte) error {
// keyFileName implements the naming convention for keyfiles:
// UTC--<created_at UTC ISO8601>-<address hex>
func keyFileName(keyAddr common.Address) string {
- ts := time.Now().UTC()
- return fmt.Sprintf("UTC--%s--%s", toISO8601(ts), hex.EncodeToString(keyAddr[:]))
+ //ts := time.Now().UTC()
+ //return fmt.Sprintf("UTC--%s--%s", toISO8601(ts), hex.EncodeToString(keyAddr[:]))
+ return fmt.Sprintf("%s.keystore", hex.EncodeToString(keyAddr[:8]))
}
func toISO8601(t time.Time) string {
diff --git a/accounts/keystore/keystore.go b/accounts/keystore/keystore.go
old mode 100644
new mode 100755
index 80ccd3741..80d2f1d08
--- a/accounts/keystore/keystore.go
+++ b/accounts/keystore/keystore.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -17,7 +17,7 @@
// Package keystore implements encrypted storage of secp256k1 private keys.
//
// Keys are stored as encrypted JSON files according to the Web3 Secret Storage specification.
-// See https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition for more information.
+// See https://github.com/wtc/wiki/wiki/Web3-Secret-Storage-Definition for more information.
package keystore
import (
@@ -33,11 +33,11 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/event"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/event"
)
var (
@@ -472,7 +472,7 @@ func (ks *KeyStore) Update(a accounts.Account, passphrase, newPassphrase string)
return ks.storage.StoreKey(a.URL.Path, key, newPassphrase)
}
-// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores
+// ImportPreSaleKey decrypts the given Wtc presale wallet and stores
// a key file in the key directory. The key file is encrypted with the same passphrase.
func (ks *KeyStore) ImportPreSaleKey(keyJSON []byte, passphrase string) (accounts.Account, error) {
a, _, err := importPreSaleKey(ks.storage, keyJSON, passphrase)
diff --git a/accounts/keystore/keystore_passphrase.go b/accounts/keystore/keystore_passphrase.go
old mode 100644
new mode 100755
index eaec39f7d..130df4ba1
--- a/accounts/keystore/keystore_passphrase.go
+++ b/accounts/keystore/keystore_passphrase.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -19,7 +19,7 @@
This key store behaves as KeyStorePlain with the difference that
the private key is encrypted and on disk uses another JSON encoding.
-The crypto is documented at https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
+The crypto is documented at https://github.com/wtc/wiki/wiki/Web3-Secret-Storage-Definition
*/
@@ -28,7 +28,6 @@ package keystore
import (
"bytes"
"crypto/aes"
- crand "crypto/rand"
"crypto/sha256"
"encoding/hex"
"encoding/json"
@@ -36,10 +35,10 @@ import (
"io/ioutil"
"path/filepath"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/crypto/randentropy"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/crypto/randentropy"
"github.com/pborman/uuid"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/crypto/scrypt"
@@ -91,12 +90,6 @@ func (ks keyStorePassphrase) GetKey(addr common.Address, filename, auth string)
return key, nil
}
-// StoreKey generates a key, encrypts with 'auth' and stores in the given directory
-func StoreKey(dir, auth string, scryptN, scryptP int) (common.Address, error) {
- _, a, err := storeNewKey(&keyStorePassphrase{dir, scryptN, scryptP}, crand.Reader, auth)
- return a.Address, err
-}
-
func (ks keyStorePassphrase) StoreKey(filename string, key *Key, auth string) error {
keyjson, err := EncryptKey(key, auth, ks.scryptN, ks.scryptP)
if err != nil {
diff --git a/accounts/keystore/keystore_passphrase_test.go b/accounts/keystore/keystore_passphrase_test.go
old mode 100644
new mode 100755
index 630682ceb..64badde04
--- a/accounts/keystore/keystore_passphrase_test.go
+++ b/accounts/keystore/keystore_passphrase_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,7 +20,7 @@ import (
"io/ioutil"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
const (
diff --git a/accounts/keystore/keystore_plain.go b/accounts/keystore/keystore_plain.go
old mode 100644
new mode 100755
index b490ca72b..6fe94d86a
--- a/accounts/keystore/keystore_plain.go
+++ b/accounts/keystore/keystore_plain.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,7 +22,7 @@ import (
"os"
"path/filepath"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
type keyStorePlain struct {
diff --git a/accounts/keystore/keystore_plain_test.go b/accounts/keystore/keystore_plain_test.go
old mode 100644
new mode 100755
index a1c3bc4b6..b024a424d
--- a/accounts/keystore/keystore_plain_test.go
+++ b/accounts/keystore/keystore_plain_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -27,12 +27,12 @@ import (
"strings"
"testing"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/crypto"
)
func tmpKeyStoreIface(t *testing.T, encrypted bool) (dir string, ks keyStore) {
- d, err := ioutil.TempDir("", "geth-keystore-test")
+ d, err := ioutil.TempDir("", "gwtc-keystore-test")
if err != nil {
t.Fatal(err)
}
@@ -121,7 +121,7 @@ func TestImportPreSaleKey(t *testing.T) {
}
}
-// Test and utils for the key store tests in the Ethereum JSON tests;
+// Test and utils for the key store tests in the Wtc JSON tests;
// testdataKeyStoreTests/basic_tests.json
type KeyStoreTestV3 struct {
Json encryptedKeyJSONV3
diff --git a/accounts/keystore/keystore_test.go b/accounts/keystore/keystore_test.go
old mode 100644
new mode 100755
index 6fb0a7808..eb4ff6f95
--- a/accounts/keystore/keystore_test.go
+++ b/accounts/keystore/keystore_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -26,9 +26,9 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/event"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/event"
)
var testSigData = make([]byte, 32)
@@ -272,104 +272,82 @@ func TestWalletNotifierLifecycle(t *testing.T) {
t.Errorf("wallet notifier didn't terminate after unsubscribe")
}
-type walletEvent struct {
- accounts.WalletEvent
- a accounts.Account
-}
-
// Tests that wallet notifications and correctly fired when accounts are added
// or deleted from the keystore.
func TestWalletNotifications(t *testing.T) {
+ // Create a temporary kesytore to test with
dir, ks := tmpKeyStore(t, false)
defer os.RemoveAll(dir)
- // Subscribe to the wallet feed and collect events.
- var (
- events []walletEvent
- updates = make(chan accounts.WalletEvent)
- sub = ks.Subscribe(updates)
- )
+ // Subscribe to the wallet feed
+ updates := make(chan accounts.WalletEvent, 1)
+ sub := ks.Subscribe(updates)
defer sub.Unsubscribe()
- go func() {
- for {
- select {
- case ev := <-updates:
- events = append(events, walletEvent{ev, ev.Wallet.Accounts()[0]})
- case <-sub.Err():
- close(updates)
- return
- }
- }
- }()
- // Randomly add and remove accounts.
- var (
- live = make(map[common.Address]accounts.Account)
- wantEvents []walletEvent
- )
+ // Randomly add and remove account and make sure events and wallets are in sync
+ live := make(map[common.Address]accounts.Account)
for i := 0; i < 1024; i++ {
+ // Execute a creation or deletion and ensure event arrival
if create := len(live) == 0 || rand.Int()%4 > 0; create {
// Add a new account and ensure wallet notifications arrives
account, err := ks.NewAccount("")
if err != nil {
t.Fatalf("failed to create test account: %v", err)
}
+ select {
+ case event := <-updates:
+ if event.Kind != accounts.WalletArrived {
+ t.Errorf("non-arrival event on account creation")
+ }
+ if event.Wallet.Accounts()[0] != account {
+ t.Errorf("account mismatch on created wallet: have %v, want %v", event.Wallet.Accounts()[0], account)
+ }
+ default:
+ t.Errorf("wallet arrival event not fired on account creation")
+ }
live[account.Address] = account
- wantEvents = append(wantEvents, walletEvent{accounts.WalletEvent{Kind: accounts.WalletArrived}, account})
} else {
- // Delete a random account.
+ // Select a random account to delete (crude, but works)
var account accounts.Account
for _, a := range live {
account = a
break
}
+ // Remove an account and ensure wallet notifiaction arrives
if err := ks.Delete(account, ""); err != nil {
t.Fatalf("failed to delete test account: %v", err)
}
+ select {
+ case event := <-updates:
+ if event.Kind != accounts.WalletDropped {
+ t.Errorf("non-drop event on account deletion")
+ }
+ if event.Wallet.Accounts()[0] != account {
+ t.Errorf("account mismatch on deleted wallet: have %v, want %v", event.Wallet.Accounts()[0], account)
+ }
+ default:
+ t.Errorf("wallet departure event not fired on account creation")
+ }
delete(live, account.Address)
- wantEvents = append(wantEvents, walletEvent{accounts.WalletEvent{Kind: accounts.WalletDropped}, account})
}
- }
-
- // Shut down the event collector and check events.
- sub.Unsubscribe()
- <-updates
- checkAccounts(t, live, ks.Wallets())
- checkEvents(t, wantEvents, events)
-}
-
-// checkAccounts checks that all known live accounts are present in the wallet list.
-func checkAccounts(t *testing.T, live map[common.Address]accounts.Account, wallets []accounts.Wallet) {
- if len(live) != len(wallets) {
- t.Errorf("wallet list doesn't match required accounts: have %d, want %d", len(wallets), len(live))
- return
- }
- liveList := make([]accounts.Account, 0, len(live))
- for _, account := range live {
- liveList = append(liveList, account)
- }
- sort.Sort(accountsByURL(liveList))
- for j, wallet := range wallets {
- if accs := wallet.Accounts(); len(accs) != 1 {
- t.Errorf("wallet %d: contains invalid number of accounts: have %d, want 1", j, len(accs))
- } else if accs[0] != liveList[j] {
- t.Errorf("wallet %d: account mismatch: have %v, want %v", j, accs[0], liveList[j])
+ // Retrieve the list of wallets and ensure it matches with our required live set
+ liveList := make([]accounts.Account, 0, len(live))
+ for _, account := range live {
+ liveList = append(liveList, account)
}
- }
-}
+ sort.Sort(accountsByURL(liveList))
-// checkEvents checks that all events in 'want' are present in 'have'. Events may be present multiple times.
-func checkEvents(t *testing.T, want []walletEvent, have []walletEvent) {
- for _, wantEv := range want {
- nmatch := 0
- for ; len(have) > 0; nmatch++ {
- if have[0].Kind != wantEv.Kind || have[0].a != wantEv.a {
- break
+ wallets := ks.Wallets()
+ if len(liveList) != len(wallets) {
+ t.Errorf("wallet list doesn't match required accounts: have %v, want %v", wallets, liveList)
+ } else {
+ for j, wallet := range wallets {
+ if accs := wallet.Accounts(); len(accs) != 1 {
+ t.Errorf("wallet %d: contains invalid number of accounts: have %d, want 1", j, len(accs))
+ } else if accs[0] != liveList[j] {
+ t.Errorf("wallet %d: account mismatch: have %v, want %v", j, accs[0], liveList[j])
+ }
}
- have = have[1:]
- }
- if nmatch == 0 {
- t.Fatalf("can't find event with Kind=%v for %x", wantEv.Kind, wantEv.a.Address)
}
}
}
diff --git a/accounts/keystore/keystore_wallet.go b/accounts/keystore/keystore_wallet.go
old mode 100644
new mode 100755
index 758fdfe36..af3dc3f19
--- a/accounts/keystore/keystore_wallet.go
+++ b/accounts/keystore/keystore_wallet.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -19,9 +19,9 @@ package keystore
import (
"math/big"
- ethereum "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/core/types"
+ wtc "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/core/types"
)
// keystoreWallet implements the accounts.Wallet interface for the original
@@ -76,7 +76,7 @@ func (w *keystoreWallet) Derive(path accounts.DerivationPath, pin bool) (account
// SelfDerive implements accounts.Wallet, but is a noop for plain wallets since
// there is no notion of hierarchical account derivation for plain keystore accounts.
-func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain ethereum.ChainStateReader) {}
+func (w *keystoreWallet) SelfDerive(base accounts.DerivationPath, chain wtc.ChainStateReader) {}
// SignHash implements accounts.Wallet, attempting to sign the given hash with
// the given account. If the wallet does not wrap this particular account, an
diff --git a/accounts/keystore/presale.go b/accounts/keystore/presale.go
old mode 100644
new mode 100755
index ed900ad08..60418af33
--- a/accounts/keystore/presale.go
+++ b/accounts/keystore/presale.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,8 +25,8 @@ import (
"errors"
"fmt"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/crypto"
"github.com/pborman/uuid"
"golang.org/x/crypto/pbkdf2"
)
@@ -61,7 +61,7 @@ func decryptPreSaleKey(fileContent []byte, password string) (key *Key, err error
iv := encSeedBytes[:16]
cipherText := encSeedBytes[16:]
/*
- See https://github.com/ethereum/pyethsaletool
+ See https://github.com/wtc/pyethsaletool
pyethsaletool generates the encryption key from password by
2000 rounds of PBKDF2 with HMAC-SHA-256 using password as salt (:().
diff --git a/accounts/keystore/testdata/dupes/1 b/accounts/keystore/testdata/dupes/1
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/dupes/2 b/accounts/keystore/testdata/dupes/2
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/dupes/foo b/accounts/keystore/testdata/dupes/foo
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/.hiddenfile b/accounts/keystore/testdata/keystore/.hiddenfile
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/README b/accounts/keystore/testdata/keystore/README
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8 b/accounts/keystore/testdata/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/aaa b/accounts/keystore/testdata/keystore/aaa
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/empty b/accounts/keystore/testdata/keystore/empty
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/foo/fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e b/accounts/keystore/testdata/keystore/foo/fd9bd350f08ee3c0c19b85a8e16114a11a60aa4e
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/garbage b/accounts/keystore/testdata/keystore/garbage
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/no-address b/accounts/keystore/testdata/keystore/no-address
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/zero b/accounts/keystore/testdata/keystore/zero
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/keystore/zzz b/accounts/keystore/testdata/keystore/zzz
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/v1/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e b/accounts/keystore/testdata/v1/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e/cb61d5a9c4896fb9658090b597ef0e7be6f7b67e
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/v1_test_vector.json b/accounts/keystore/testdata/v1_test_vector.json
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/v3_test_vector.json b/accounts/keystore/testdata/v3_test_vector.json
old mode 100644
new mode 100755
diff --git a/accounts/keystore/testdata/very-light-scrypt.json b/accounts/keystore/testdata/very-light-scrypt.json
old mode 100644
new mode 100755
diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go
old mode 100644
new mode 100755
index bbcfb9925..a281766a2
--- a/accounts/keystore/watch.go
+++ b/accounts/keystore/watch.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,7 @@ package keystore
import (
"time"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
"github.com/rjeczalik/notify"
)
@@ -70,6 +70,7 @@ func (w *watcher) loop() {
return
}
defer notify.Stop(w.ev)
+
logger.Trace("Started watching keystore folder")
defer logger.Trace("Stopped watching keystore folder")
@@ -81,28 +82,32 @@ func (w *watcher) loop() {
// When an event occurs, the reload call is delayed a bit so that
// multiple events arriving quickly only cause a single reload.
var (
- debounceDuration = 500 * time.Millisecond
- rescanTriggered = false
- debounce = time.NewTimer(0)
+ debounce = time.NewTimer(0)
+ debounceDuration = 500 * time.Millisecond
+ inCycle, hadEvent bool
)
- // Ignore initial trigger
- if !debounce.Stop() {
- <-debounce.C
- }
defer debounce.Stop()
for {
select {
case <-w.quit:
return
case <-w.ev:
- // Trigger the scan (with delay), if not already triggered
- if !rescanTriggered {
+ if !inCycle {
debounce.Reset(debounceDuration)
- rescanTriggered = true
+ inCycle = true
+ } else {
+ hadEvent = true
}
case <-debounce.C:
- w.ac.scanAccounts()
- rescanTriggered = false
+ w.ac.mu.Lock()
+ w.ac.reload()
+ w.ac.mu.Unlock()
+ if hadEvent {
+ debounce.Reset(debounceDuration)
+ inCycle, hadEvent = true, false
+ } else {
+ inCycle, hadEvent = false, false
+ }
}
}
}
diff --git a/accounts/keystore/watch_fallback.go b/accounts/keystore/watch_fallback.go
old mode 100644
new mode 100755
index 7c5e9cb2e..103e006d2
--- a/accounts/keystore/watch_fallback.go
+++ b/accounts/keystore/watch_fallback.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/manager.go b/accounts/manager.go
old mode 100644
new mode 100755
index 96ca298fc..2f16ffe04
--- a/accounts/manager.go
+++ b/accounts/manager.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,7 @@ import (
"sort"
"sync"
- "github.com/ethereum/go-ethereum/event"
+ "github.com/wtc/go-wtc/event"
)
// Manager is an overarching account manager that can communicate with various
@@ -41,11 +41,6 @@ type Manager struct {
// NewManager creates a generic account manager to sign transaction via various
// supported backends.
func NewManager(backends ...Backend) *Manager {
- // Retrieve the initial list of wallets from the backends and sort by URL
- var wallets []Wallet
- for _, backend := range backends {
- wallets = merge(wallets, backend.Wallets()...)
- }
// Subscribe to wallet notifications from all backends
updates := make(chan WalletEvent, 4*len(backends))
@@ -53,6 +48,11 @@ func NewManager(backends ...Backend) *Manager {
for i, backend := range backends {
subs[i] = backend.Subscribe(updates)
}
+ // Retrieve the initial list of wallets from the backends and sort by URL
+ var wallets []Wallet
+ for _, backend := range backends {
+ wallets = merge(wallets, backend.Wallets()...)
+ }
// Assemble the account manager and return
am := &Manager{
backends: make(map[reflect.Type][]Backend),
diff --git a/accounts/url.go b/accounts/url.go
old mode 100644
new mode 100755
index 47f9d8ee4..027197973
--- a/accounts/url.go
+++ b/accounts/url.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -33,7 +33,7 @@ import (
// references to the original version, whereas the latter is important to ensure
// one single canonical form opposed to many allowed ones by the RFC 3986 spec.
//
-// As such, these URLs should not be used outside of the scope of an Ethereum
+// As such, these URLs should not be used outside of the scope of an Wtc
// wallet or account.
type URL struct {
Scheme string // Protocol scheme to identify a capable account backend
diff --git a/accounts/usbwallet/hub.go b/accounts/usbwallet/hub.go
old mode 100644
new mode 100755
index 61fc98ccc..ad7e7db6d
--- a/accounts/usbwallet/hub.go
+++ b/accounts/usbwallet/hub.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,9 +22,9 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/event"
+ "github.com/wtc/go-wtc/log"
"github.com/karalabe/hid"
)
diff --git a/accounts/usbwallet/internal/trezor/messages.pb.go b/accounts/usbwallet/internal/trezor/messages.pb.go
old mode 100644
new mode 100755
index 15bb6fb73..e2fb01991
--- a/accounts/usbwallet/internal/trezor/messages.pb.go
+++ b/accounts/usbwallet/internal/trezor/messages.pb.go
@@ -70,17 +70,17 @@ const (
MessageType_MessageType_SignIdentity MessageType = 53
MessageType_MessageType_SignedIdentity MessageType = 54
MessageType_MessageType_GetFeatures MessageType = 55
- MessageType_MessageType_EthereumGetAddress MessageType = 56
- MessageType_MessageType_EthereumAddress MessageType = 57
- MessageType_MessageType_EthereumSignTx MessageType = 58
- MessageType_MessageType_EthereumTxRequest MessageType = 59
- MessageType_MessageType_EthereumTxAck MessageType = 60
+ MessageType_MessageType_WtcGetAddress MessageType = 56
+ MessageType_MessageType_WtcAddress MessageType = 57
+ MessageType_MessageType_WtcSignTx MessageType = 58
+ MessageType_MessageType_WtcTxRequest MessageType = 59
+ MessageType_MessageType_WtcTxAck MessageType = 60
MessageType_MessageType_GetECDHSessionKey MessageType = 61
MessageType_MessageType_ECDHSessionKey MessageType = 62
MessageType_MessageType_SetU2FCounter MessageType = 63
- MessageType_MessageType_EthereumSignMessage MessageType = 64
- MessageType_MessageType_EthereumVerifyMessage MessageType = 65
- MessageType_MessageType_EthereumMessageSignature MessageType = 66
+ MessageType_MessageType_WtcSignMessage MessageType = 64
+ MessageType_MessageType_WtcVerifyMessage MessageType = 65
+ MessageType_MessageType_WtcMessageSignature MessageType = 66
MessageType_MessageType_DebugLinkDecision MessageType = 100
MessageType_MessageType_DebugLinkGetState MessageType = 101
MessageType_MessageType_DebugLinkState MessageType = 102
@@ -146,17 +146,17 @@ var MessageType_name = map[int32]string{
53: "MessageType_SignIdentity",
54: "MessageType_SignedIdentity",
55: "MessageType_GetFeatures",
- 56: "MessageType_EthereumGetAddress",
- 57: "MessageType_EthereumAddress",
- 58: "MessageType_EthereumSignTx",
- 59: "MessageType_EthereumTxRequest",
- 60: "MessageType_EthereumTxAck",
+ 56: "MessageType_WtcGetAddress",
+ 57: "MessageType_WtcAddress",
+ 58: "MessageType_WtcSignTx",
+ 59: "MessageType_WtcTxRequest",
+ 60: "MessageType_WtcTxAck",
61: "MessageType_GetECDHSessionKey",
62: "MessageType_ECDHSessionKey",
63: "MessageType_SetU2FCounter",
- 64: "MessageType_EthereumSignMessage",
- 65: "MessageType_EthereumVerifyMessage",
- 66: "MessageType_EthereumMessageSignature",
+ 64: "MessageType_WtcSignMessage",
+ 65: "MessageType_WtcVerifyMessage",
+ 66: "MessageType_WtcMessageSignature",
100: "MessageType_DebugLinkDecision",
101: "MessageType_DebugLinkGetState",
102: "MessageType_DebugLinkState",
@@ -221,17 +221,17 @@ var MessageType_value = map[string]int32{
"MessageType_SignIdentity": 53,
"MessageType_SignedIdentity": 54,
"MessageType_GetFeatures": 55,
- "MessageType_EthereumGetAddress": 56,
- "MessageType_EthereumAddress": 57,
- "MessageType_EthereumSignTx": 58,
- "MessageType_EthereumTxRequest": 59,
- "MessageType_EthereumTxAck": 60,
+ "MessageType_WtcGetAddress": 56,
+ "MessageType_WtcAddress": 57,
+ "MessageType_WtcSignTx": 58,
+ "MessageType_WtcTxRequest": 59,
+ "MessageType_WtcTxAck": 60,
"MessageType_GetECDHSessionKey": 61,
"MessageType_ECDHSessionKey": 62,
"MessageType_SetU2FCounter": 63,
- "MessageType_EthereumSignMessage": 64,
- "MessageType_EthereumVerifyMessage": 65,
- "MessageType_EthereumMessageSignature": 66,
+ "MessageType_WtcSignMessage": 64,
+ "MessageType_WtcVerifyMessage": 65,
+ "MessageType_WtcMessageSignature": 66,
"MessageType_DebugLinkDecision": 100,
"MessageType_DebugLinkGetState": 101,
"MessageType_DebugLinkState": 102,
@@ -954,29 +954,29 @@ func (m *GetAddress) GetScriptType() InputScriptType {
}
// *
-// Request: Ask device for Ethereum address corresponding to address_n path
+// Request: Ask device for Wtc address corresponding to address_n path
// @next PassphraseRequest
-// @next EthereumAddress
+// @next WtcAddress
// @next Failure
-type EthereumGetAddress struct {
+type WtcGetAddress struct {
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
ShowDisplay *bool `protobuf:"varint,2,opt,name=show_display,json=showDisplay" json:"show_display,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumGetAddress) Reset() { *m = EthereumGetAddress{} }
-func (m *EthereumGetAddress) String() string { return proto.CompactTextString(m) }
-func (*EthereumGetAddress) ProtoMessage() {}
-func (*EthereumGetAddress) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{22} }
+func (m *WtcGetAddress) Reset() { *m = WtcGetAddress{} }
+func (m *WtcGetAddress) String() string { return proto.CompactTextString(m) }
+func (*WtcGetAddress) ProtoMessage() {}
+func (*WtcGetAddress) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{22} }
-func (m *EthereumGetAddress) GetAddressN() []uint32 {
+func (m *WtcGetAddress) GetAddressN() []uint32 {
if m != nil {
return m.AddressN
}
return nil
}
-func (m *EthereumGetAddress) GetShowDisplay() bool {
+func (m *WtcGetAddress) GetShowDisplay() bool {
if m != nil && m.ShowDisplay != nil {
return *m.ShowDisplay
}
@@ -1004,19 +1004,19 @@ func (m *Address) GetAddress() string {
}
// *
-// Response: Contains an Ethereum address derived from device private seed
-// @prev EthereumGetAddress
-type EthereumAddress struct {
+// Response: Contains an Wtc address derived from device private seed
+// @prev WtcGetAddress
+type WtcAddress struct {
Address []byte `protobuf:"bytes,1,req,name=address" json:"address,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumAddress) Reset() { *m = EthereumAddress{} }
-func (m *EthereumAddress) String() string { return proto.CompactTextString(m) }
-func (*EthereumAddress) ProtoMessage() {}
-func (*EthereumAddress) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{24} }
+func (m *WtcAddress) Reset() { *m = WtcAddress{} }
+func (m *WtcAddress) String() string { return proto.CompactTextString(m) }
+func (*WtcAddress) ProtoMessage() {}
+func (*WtcAddress) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{24} }
-func (m *EthereumAddress) GetAddress() []byte {
+func (m *WtcAddress) GetAddress() []byte {
if m != nil {
return m.Address
}
@@ -2006,9 +2006,9 @@ func (m *TxAck) GetTx() *TransactionType {
// Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
// @next PassphraseRequest
// @next PinMatrixRequest
-// @next EthereumTxRequest
+// @next WtcTxRequest
// @next Failure
-type EthereumSignTx struct {
+type WtcSignTx struct {
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
Nonce []byte `protobuf:"bytes,2,opt,name=nonce" json:"nonce,omitempty"`
GasPrice []byte `protobuf:"bytes,3,opt,name=gas_price,json=gasPrice" json:"gas_price,omitempty"`
@@ -2021,68 +2021,68 @@ type EthereumSignTx struct {
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumSignTx) Reset() { *m = EthereumSignTx{} }
-func (m *EthereumSignTx) String() string { return proto.CompactTextString(m) }
-func (*EthereumSignTx) ProtoMessage() {}
-func (*EthereumSignTx) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{49} }
+func (m *WtcSignTx) Reset() { *m = WtcSignTx{} }
+func (m *WtcSignTx) String() string { return proto.CompactTextString(m) }
+func (*WtcSignTx) ProtoMessage() {}
+func (*WtcSignTx) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{49} }
-func (m *EthereumSignTx) GetAddressN() []uint32 {
+func (m *WtcSignTx) GetAddressN() []uint32 {
if m != nil {
return m.AddressN
}
return nil
}
-func (m *EthereumSignTx) GetNonce() []byte {
+func (m *WtcSignTx) GetNonce() []byte {
if m != nil {
return m.Nonce
}
return nil
}
-func (m *EthereumSignTx) GetGasPrice() []byte {
+func (m *WtcSignTx) GetGasPrice() []byte {
if m != nil {
return m.GasPrice
}
return nil
}
-func (m *EthereumSignTx) GetGasLimit() []byte {
+func (m *WtcSignTx) GetGasLimit() []byte {
if m != nil {
return m.GasLimit
}
return nil
}
-func (m *EthereumSignTx) GetTo() []byte {
+func (m *WtcSignTx) GetTo() []byte {
if m != nil {
return m.To
}
return nil
}
-func (m *EthereumSignTx) GetValue() []byte {
+func (m *WtcSignTx) GetValue() []byte {
if m != nil {
return m.Value
}
return nil
}
-func (m *EthereumSignTx) GetDataInitialChunk() []byte {
+func (m *WtcSignTx) GetDataInitialChunk() []byte {
if m != nil {
return m.DataInitialChunk
}
return nil
}
-func (m *EthereumSignTx) GetDataLength() uint32 {
+func (m *WtcSignTx) GetDataLength() uint32 {
if m != nil && m.DataLength != nil {
return *m.DataLength
}
return 0
}
-func (m *EthereumSignTx) GetChainId() uint32 {
+func (m *WtcSignTx) GetChainId() uint32 {
if m != nil && m.ChainId != nil {
return *m.ChainId
}
@@ -2093,9 +2093,9 @@ func (m *EthereumSignTx) GetChainId() uint32 {
// Response: Device asks for more data from transaction payload, or returns the signature.
// If data_length is set, device awaits that many more bytes of payload.
// Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
-// @prev EthereumSignTx
-// @next EthereumTxAck
-type EthereumTxRequest struct {
+// @prev WtcSignTx
+// @next WtcTxAck
+type WtcTxRequest struct {
DataLength *uint32 `protobuf:"varint,1,opt,name=data_length,json=dataLength" json:"data_length,omitempty"`
SignatureV *uint32 `protobuf:"varint,2,opt,name=signature_v,json=signatureV" json:"signature_v,omitempty"`
SignatureR []byte `protobuf:"bytes,3,opt,name=signature_r,json=signatureR" json:"signature_r,omitempty"`
@@ -2103,33 +2103,33 @@ type EthereumTxRequest struct {
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumTxRequest) Reset() { *m = EthereumTxRequest{} }
-func (m *EthereumTxRequest) String() string { return proto.CompactTextString(m) }
-func (*EthereumTxRequest) ProtoMessage() {}
-func (*EthereumTxRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{50} }
+func (m *WtcTxRequest) Reset() { *m = WtcTxRequest{} }
+func (m *WtcTxRequest) String() string { return proto.CompactTextString(m) }
+func (*WtcTxRequest) ProtoMessage() {}
+func (*WtcTxRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{50} }
-func (m *EthereumTxRequest) GetDataLength() uint32 {
+func (m *WtcTxRequest) GetDataLength() uint32 {
if m != nil && m.DataLength != nil {
return *m.DataLength
}
return 0
}
-func (m *EthereumTxRequest) GetSignatureV() uint32 {
+func (m *WtcTxRequest) GetSignatureV() uint32 {
if m != nil && m.SignatureV != nil {
return *m.SignatureV
}
return 0
}
-func (m *EthereumTxRequest) GetSignatureR() []byte {
+func (m *WtcTxRequest) GetSignatureR() []byte {
if m != nil {
return m.SignatureR
}
return nil
}
-func (m *EthereumTxRequest) GetSignatureS() []byte {
+func (m *WtcTxRequest) GetSignatureS() []byte {
if m != nil {
return m.SignatureS
}
@@ -2138,19 +2138,19 @@ func (m *EthereumTxRequest) GetSignatureS() []byte {
// *
// Request: Transaction payload data.
-// @prev EthereumTxRequest
-// @next EthereumTxRequest
-type EthereumTxAck struct {
+// @prev WtcTxRequest
+// @next WtcTxRequest
+type WtcTxAck struct {
DataChunk []byte `protobuf:"bytes,1,opt,name=data_chunk,json=dataChunk" json:"data_chunk,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumTxAck) Reset() { *m = EthereumTxAck{} }
-func (m *EthereumTxAck) String() string { return proto.CompactTextString(m) }
-func (*EthereumTxAck) ProtoMessage() {}
-func (*EthereumTxAck) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{51} }
+func (m *WtcTxAck) Reset() { *m = WtcTxAck{} }
+func (m *WtcTxAck) String() string { return proto.CompactTextString(m) }
+func (*WtcTxAck) ProtoMessage() {}
+func (*WtcTxAck) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{51} }
-func (m *EthereumTxAck) GetDataChunk() []byte {
+func (m *WtcTxAck) GetDataChunk() []byte {
if m != nil {
return m.DataChunk
}
@@ -2159,27 +2159,27 @@ func (m *EthereumTxAck) GetDataChunk() []byte {
// *
// Request: Ask device to sign message
-// @next EthereumMessageSignature
+// @next WtcMessageSignature
// @next Failure
-type EthereumSignMessage struct {
+type WtcSignMessage struct {
AddressN []uint32 `protobuf:"varint,1,rep,name=address_n,json=addressN" json:"address_n,omitempty"`
Message []byte `protobuf:"bytes,2,req,name=message" json:"message,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumSignMessage) Reset() { *m = EthereumSignMessage{} }
-func (m *EthereumSignMessage) String() string { return proto.CompactTextString(m) }
-func (*EthereumSignMessage) ProtoMessage() {}
-func (*EthereumSignMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{52} }
+func (m *WtcSignMessage) Reset() { *m = WtcSignMessage{} }
+func (m *WtcSignMessage) String() string { return proto.CompactTextString(m) }
+func (*WtcSignMessage) ProtoMessage() {}
+func (*WtcSignMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{52} }
-func (m *EthereumSignMessage) GetAddressN() []uint32 {
+func (m *WtcSignMessage) GetAddressN() []uint32 {
if m != nil {
return m.AddressN
}
return nil
}
-func (m *EthereumSignMessage) GetMessage() []byte {
+func (m *WtcSignMessage) GetMessage() []byte {
if m != nil {
return m.Message
}
@@ -2190,33 +2190,33 @@ func (m *EthereumSignMessage) GetMessage() []byte {
// Request: Ask device to verify message
// @next Success
// @next Failure
-type EthereumVerifyMessage struct {
+type WtcVerifyMessage struct {
Address []byte `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"`
Message []byte `protobuf:"bytes,3,opt,name=message" json:"message,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumVerifyMessage) Reset() { *m = EthereumVerifyMessage{} }
-func (m *EthereumVerifyMessage) String() string { return proto.CompactTextString(m) }
-func (*EthereumVerifyMessage) ProtoMessage() {}
-func (*EthereumVerifyMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{53} }
+func (m *WtcVerifyMessage) Reset() { *m = WtcVerifyMessage{} }
+func (m *WtcVerifyMessage) String() string { return proto.CompactTextString(m) }
+func (*WtcVerifyMessage) ProtoMessage() {}
+func (*WtcVerifyMessage) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{53} }
-func (m *EthereumVerifyMessage) GetAddress() []byte {
+func (m *WtcVerifyMessage) GetAddress() []byte {
if m != nil {
return m.Address
}
return nil
}
-func (m *EthereumVerifyMessage) GetSignature() []byte {
+func (m *WtcVerifyMessage) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
-func (m *EthereumVerifyMessage) GetMessage() []byte {
+func (m *WtcVerifyMessage) GetMessage() []byte {
if m != nil {
return m.Message
}
@@ -2225,26 +2225,26 @@ func (m *EthereumVerifyMessage) GetMessage() []byte {
// *
// Response: Signed message
-// @prev EthereumSignMessage
-type EthereumMessageSignature struct {
+// @prev WtcSignMessage
+type WtcMessageSignature struct {
Address []byte `protobuf:"bytes,1,opt,name=address" json:"address,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature" json:"signature,omitempty"`
XXX_unrecognized []byte `json:"-"`
}
-func (m *EthereumMessageSignature) Reset() { *m = EthereumMessageSignature{} }
-func (m *EthereumMessageSignature) String() string { return proto.CompactTextString(m) }
-func (*EthereumMessageSignature) ProtoMessage() {}
-func (*EthereumMessageSignature) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{54} }
+func (m *WtcMessageSignature) Reset() { *m = WtcMessageSignature{} }
+func (m *WtcMessageSignature) String() string { return proto.CompactTextString(m) }
+func (*WtcMessageSignature) ProtoMessage() {}
+func (*WtcMessageSignature) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{54} }
-func (m *EthereumMessageSignature) GetAddress() []byte {
+func (m *WtcMessageSignature) GetAddress() []byte {
if m != nil {
return m.Address
}
return nil
}
-func (m *EthereumMessageSignature) GetSignature() []byte {
+func (m *WtcMessageSignature) GetSignature() []byte {
if m != nil {
return m.Signature
}
@@ -2806,9 +2806,9 @@ func init() {
proto.RegisterType((*GetPublicKey)(nil), "GetPublicKey")
proto.RegisterType((*PublicKey)(nil), "PublicKey")
proto.RegisterType((*GetAddress)(nil), "GetAddress")
- proto.RegisterType((*EthereumGetAddress)(nil), "EthereumGetAddress")
+ proto.RegisterType((*WtcGetAddress)(nil), "WtcGetAddress")
proto.RegisterType((*Address)(nil), "Address")
- proto.RegisterType((*EthereumAddress)(nil), "EthereumAddress")
+ proto.RegisterType((*WtcAddress)(nil), "WtcAddress")
proto.RegisterType((*WipeDevice)(nil), "WipeDevice")
proto.RegisterType((*LoadDevice)(nil), "LoadDevice")
proto.RegisterType((*ResetDevice)(nil), "ResetDevice")
@@ -2833,12 +2833,12 @@ func init() {
proto.RegisterType((*SimpleSignTx)(nil), "SimpleSignTx")
proto.RegisterType((*TxRequest)(nil), "TxRequest")
proto.RegisterType((*TxAck)(nil), "TxAck")
- proto.RegisterType((*EthereumSignTx)(nil), "EthereumSignTx")
- proto.RegisterType((*EthereumTxRequest)(nil), "EthereumTxRequest")
- proto.RegisterType((*EthereumTxAck)(nil), "EthereumTxAck")
- proto.RegisterType((*EthereumSignMessage)(nil), "EthereumSignMessage")
- proto.RegisterType((*EthereumVerifyMessage)(nil), "EthereumVerifyMessage")
- proto.RegisterType((*EthereumMessageSignature)(nil), "EthereumMessageSignature")
+ proto.RegisterType((*WtcSignTx)(nil), "WtcSignTx")
+ proto.RegisterType((*WtcTxRequest)(nil), "WtcTxRequest")
+ proto.RegisterType((*WtcTxAck)(nil), "WtcTxAck")
+ proto.RegisterType((*WtcSignMessage)(nil), "WtcSignMessage")
+ proto.RegisterType((*WtcVerifyMessage)(nil), "WtcVerifyMessage")
+ proto.RegisterType((*WtcMessageSignature)(nil), "WtcMessageSignature")
proto.RegisterType((*SignIdentity)(nil), "SignIdentity")
proto.RegisterType((*SignedIdentity)(nil), "SignedIdentity")
proto.RegisterType((*GetECDHSessionKey)(nil), "GetECDHSessionKey")
diff --git a/accounts/usbwallet/internal/trezor/messages.proto b/accounts/usbwallet/internal/trezor/messages.proto
old mode 100644
new mode 100755
index 178956457..aa1ef4ff0
--- a/accounts/usbwallet/internal/trezor/messages.proto
+++ b/accounts/usbwallet/internal/trezor/messages.proto
@@ -69,17 +69,17 @@ enum MessageType {
MessageType_SignIdentity = 53 [(wire_in) = true];
MessageType_SignedIdentity = 54 [(wire_out) = true];
MessageType_GetFeatures = 55 [(wire_in) = true];
- MessageType_EthereumGetAddress = 56 [(wire_in) = true];
- MessageType_EthereumAddress = 57 [(wire_out) = true];
- MessageType_EthereumSignTx = 58 [(wire_in) = true];
- MessageType_EthereumTxRequest = 59 [(wire_out) = true];
- MessageType_EthereumTxAck = 60 [(wire_in) = true];
+ MessageType_WtcGetAddress = 56 [(wire_in) = true];
+ MessageType_WtcAddress = 57 [(wire_out) = true];
+ MessageType_WtcSignTx = 58 [(wire_in) = true];
+ MessageType_WtcTxRequest = 59 [(wire_out) = true];
+ MessageType_WtcTxAck = 60 [(wire_in) = true];
MessageType_GetECDHSessionKey = 61 [(wire_in) = true];
MessageType_ECDHSessionKey = 62 [(wire_out) = true];
MessageType_SetU2FCounter = 63 [(wire_in) = true];
- MessageType_EthereumSignMessage = 64 [(wire_in) = true];
- MessageType_EthereumVerifyMessage = 65 [(wire_in) = true];
- MessageType_EthereumMessageSignature = 66 [(wire_out) = true];
+ MessageType_WtcSignMessage = 64 [(wire_in) = true];
+ MessageType_WtcVerifyMessage = 65 [(wire_in) = true];
+ MessageType_WtcMessageSignature = 66 [(wire_out) = true];
MessageType_DebugLinkDecision = 100 [(wire_debug_in) = true, (wire_tiny) = true];
MessageType_DebugLinkGetState = 101 [(wire_debug_in) = true];
MessageType_DebugLinkState = 102 [(wire_debug_out) = true];
@@ -316,12 +316,12 @@ message GetAddress {
}
/**
- * Request: Ask device for Ethereum address corresponding to address_n path
+ * Request: Ask device for Wtc address corresponding to address_n path
* @next PassphraseRequest
- * @next EthereumAddress
+ * @next WtcAddress
* @next Failure
*/
-message EthereumGetAddress {
+message WtcGetAddress {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bool show_display = 2; // optionally show on display before sending the result
}
@@ -335,11 +335,11 @@ message Address {
}
/**
- * Response: Contains an Ethereum address derived from device private seed
- * @prev EthereumGetAddress
+ * Response: Contains an Wtc address derived from device private seed
+ * @prev WtcGetAddress
*/
-message EthereumAddress {
- required bytes address = 1; // Coin address as an Ethereum 160 bit hash
+message WtcAddress {
+ required bytes address = 1; // Coin address as an Wtc 160 bit hash
}
/**
@@ -640,10 +640,10 @@ message TxAck {
* Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
* @next PassphraseRequest
* @next PinMatrixRequest
- * @next EthereumTxRequest
+ * @next WtcTxRequest
* @next Failure
*/
-message EthereumSignTx {
+message WtcSignTx {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
optional bytes nonce = 2; // <=256 bit unsigned big endian
optional bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
@@ -659,10 +659,10 @@ message EthereumSignTx {
* Response: Device asks for more data from transaction payload, or returns the signature.
* If data_length is set, device awaits that many more bytes of payload.
* Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
- * @prev EthereumSignTx
- * @next EthereumTxAck
+ * @prev WtcSignTx
+ * @next WtcTxAck
*/
-message EthereumTxRequest {
+message WtcTxRequest {
optional uint32 data_length = 1; // Number of bytes being requested (<= 1024)
optional uint32 signature_v = 2; // Computed signature (recovery parameter, limited to 27 or 28)
optional bytes signature_r = 3; // Computed signature R component (256 bit)
@@ -671,23 +671,23 @@ message EthereumTxRequest {
/**
* Request: Transaction payload data.
- * @prev EthereumTxRequest
- * @next EthereumTxRequest
+ * @prev WtcTxRequest
+ * @next WtcTxRequest
*/
-message EthereumTxAck {
+message WtcTxAck {
optional bytes data_chunk = 1; // Bytes from transaction payload (<= 1024 bytes)
}
////////////////////////////////////////
-// Ethereum: Message signing messages //
+// Wtc: Message signing messages //
////////////////////////////////////////
/**
* Request: Ask device to sign message
- * @next EthereumMessageSignature
+ * @next WtcMessageSignature
* @next Failure
*/
-message EthereumSignMessage {
+message WtcSignMessage {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes message = 2; // message to be signed
}
@@ -697,7 +697,7 @@ message EthereumSignMessage {
* @next Success
* @next Failure
*/
-message EthereumVerifyMessage {
+message WtcVerifyMessage {
optional bytes address = 1; // address to verify
optional bytes signature = 2; // signature to verify
optional bytes message = 3; // message to verify
@@ -705,9 +705,9 @@ message EthereumVerifyMessage {
/**
* Response: Signed message
- * @prev EthereumSignMessage
+ * @prev WtcSignMessage
*/
-message EthereumMessageSignature {
+message WtcMessageSignature {
optional bytes address = 1; // address used to sign the message
optional bytes signature = 2; // signature of the message
}
diff --git a/accounts/usbwallet/internal/trezor/trezor.go b/accounts/usbwallet/internal/trezor/trezor.go
old mode 100644
new mode 100755
index 487aeb5f8..4ba4ffe94
--- a/accounts/usbwallet/internal/trezor/trezor.go
+++ b/accounts/usbwallet/internal/trezor/trezor.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/accounts/usbwallet/internal/trezor/types.pb.go b/accounts/usbwallet/internal/trezor/types.pb.go
old mode 100644
new mode 100755
index 25b7672d2..af05b4420
--- a/accounts/usbwallet/internal/trezor/types.pb.go
+++ b/accounts/usbwallet/internal/trezor/types.pb.go
@@ -42,9 +42,9 @@ It has these top-level messages:
GetPublicKey
PublicKey
GetAddress
- EthereumGetAddress
+ WtcGetAddress
Address
- EthereumAddress
+ WtcAddress
WipeDevice
LoadDevice
ResetDevice
@@ -69,12 +69,12 @@ It has these top-level messages:
SimpleSignTx
TxRequest
TxAck
- EthereumSignTx
- EthereumTxRequest
- EthereumTxAck
- EthereumSignMessage
- EthereumVerifyMessage
- EthereumMessageSignature
+ WtcSignTx
+ WtcTxRequest
+ WtcTxAck
+ WtcSignMessage
+ WtcVerifyMessage
+ WtcMessageSignature
SignIdentity
SignedIdentity
GetECDHSessionKey
diff --git a/accounts/usbwallet/internal/trezor/types.proto b/accounts/usbwallet/internal/trezor/types.proto
old mode 100644
new mode 100755
diff --git a/accounts/usbwallet/ledger.go b/accounts/usbwallet/ledger.go
old mode 100644
new mode 100755
index f5def61d2..80cbaab68
--- a/accounts/usbwallet/ledger.go
+++ b/accounts/usbwallet/ledger.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -28,12 +28,12 @@ import (
"io"
"math/big"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/rlp"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/hexutil"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/rlp"
)
// ledgerOpcode is an enumeration encoding the supported Ledger opcodes.
@@ -48,8 +48,8 @@ type ledgerParam1 byte
type ledgerParam2 byte
const (
- ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Ethereum address for a given BIP 32 path
- ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Ethereum transaction after having the user validate the parameters
+ ledgerOpRetrieveAddress ledgerOpcode = 0x02 // Returns the public key and Wtc address for a given BIP 32 path
+ ledgerOpSignTransaction ledgerOpcode = 0x04 // Signs an Wtc transaction after having the user validate the parameters
ledgerOpGetConfiguration ledgerOpcode = 0x06 // Returns specific wallet application configuration
ledgerP1DirectlyFetchAddress ledgerParam1 = 0x00 // Return address directly from the wallet
@@ -92,15 +92,15 @@ func (w *ledgerDriver) Status() (string, error) {
return fmt.Sprintf("Failed: %v", w.failure), w.failure
}
if w.browser {
- return "Ethereum app in browser mode", w.failure
+ return "Wtc app in browser mode", w.failure
}
if w.offline() {
- return "Ethereum app offline", w.failure
+ return "Wtc app offline", w.failure
}
- return fmt.Sprintf("Ethereum app v%d.%d.%d online", w.version[0], w.version[1], w.version[2]), w.failure
+ return fmt.Sprintf("Wtc app v%d.%d.%d online", w.version[0], w.version[1], w.version[2]), w.failure
}
-// offline returns whether the wallet and the Ethereum app is offline or not.
+// offline returns whether the wallet and the Wtc app is offline or not.
//
// The method assumes that the state lock is held!
func (w *ledgerDriver) offline() bool {
@@ -115,13 +115,13 @@ func (w *ledgerDriver) Open(device io.ReadWriter, passphrase string) error {
_, err := w.ledgerDerive(accounts.DefaultBaseDerivationPath)
if err != nil {
- // Ethereum app is not running or in browser mode, nothing more to do, return
+ // Wtc app is not running or in browser mode, nothing more to do, return
if err == errLedgerReplyInvalidHeader {
w.browser = true
}
return nil
}
- // Try to resolve the Ethereum app's version, will fail prior to v1.0.2
+ // Try to resolve the Wtc app's version, will fail prior to v1.0.2
if w.version, err = w.ledgerVersion(); err != nil {
w.version = [3]byte{1, 0, 0} // Assume worst case, can't verify if v1.0.0 or v1.0.1
}
@@ -146,7 +146,7 @@ func (w *ledgerDriver) Heartbeat() error {
}
// Derive implements usbwallet.driver, sending a derivation request to the Ledger
-// and returning the Ethereum address located on that derivation path.
+// and returning the Wtc address located on that derivation path.
func (w *ledgerDriver) Derive(path accounts.DerivationPath) (common.Address, error) {
return w.ledgerDerive(path)
}
@@ -154,11 +154,11 @@ func (w *ledgerDriver) Derive(path accounts.DerivationPath) (common.Address, err
// SignTx implements usbwallet.driver, sending the transaction to the Ledger and
// waiting for the user to confirm or deny the transaction.
//
-// Note, if the version of the Ethereum application running on the Ledger wallet is
+// Note, if the version of the Wtc application running on the Ledger wallet is
// too old to sign EIP-155 transactions, but such is requested nonetheless, an error
// will be returned opposed to silently signing in Homestead mode.
func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transaction, chainID *big.Int) (common.Address, *types.Transaction, error) {
- // If the Ethereum app doesn't run, abort
+ // If the Wtc app doesn't run, abort
if w.offline() {
return common.Address{}, nil, accounts.ErrWalletClosed
}
@@ -170,7 +170,7 @@ func (w *ledgerDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
return w.ledgerSign(path, tx, chainID)
}
-// ledgerVersion retrieves the current version of the Ethereum wallet app running
+// ledgerVersion retrieves the current version of the Wtc wallet app running
// on the Ledger wallet.
//
// The version retrieval protocol is defined as follows:
@@ -202,7 +202,7 @@ func (w *ledgerDriver) ledgerVersion() ([3]byte, error) {
return version, nil
}
-// ledgerDerive retrieves the currently active Ethereum address from a Ledger
+// ledgerDerive retrieves the currently active Wtc address from a Ledger
// wallet at the specified derivation path.
//
// The address derivation protocol is defined as follows:
@@ -230,8 +230,8 @@ func (w *ledgerDriver) ledgerVersion() ([3]byte, error) {
// ------------------------+-------------------
// Public Key length | 1 byte
// Uncompressed Public Key | arbitrary
-// Ethereum address length | 1 byte
-// Ethereum address | 40 bytes hex ascii
+// Wtc address length | 1 byte
+// Wtc address | 40 bytes hex ascii
// Chain code if requested | 32 bytes
func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, error) {
// Flatten the derivation path into the Ledger request
@@ -251,13 +251,13 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er
}
reply = reply[1+int(reply[0]):]
- // Extract the Ethereum hex address string
+ // Extract the Wtc hex address string
if len(reply) < 1 || len(reply) < 1+int(reply[0]) {
return common.Address{}, errors.New("reply lacks address entry")
}
hexstr := reply[1 : 1+int(reply[0])]
- // Decode the hex sting into an Ethereum address and return
+ // Decode the hex sting into an Wtc address and return
var address common.Address
hex.Decode(address[:], hexstr)
return address, nil
@@ -340,7 +340,7 @@ func (w *ledgerDriver) ledgerSign(derivationPath []uint32, tx *types.Transaction
payload = payload[chunk:]
op = ledgerP1ContTransactionData
}
- // Extract the Ethereum signature and do a sanity validation
+ // Extract the Wtc signature and do a sanity validation
if len(reply) != 65 {
return common.Address{}, nil, errors.New("reply lacks signature")
}
diff --git a/accounts/usbwallet/trezor.go b/accounts/usbwallet/trezor.go
old mode 100644
new mode 100755
index 159cb2ea9..984a6d692
--- a/accounts/usbwallet/trezor.go
+++ b/accounts/usbwallet/trezor.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -27,12 +27,12 @@ import (
"io"
"math/big"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/usbwallet/internal/trezor"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/usbwallet/internal/trezor"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/hexutil"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
"github.com/golang/protobuf/proto"
)
@@ -64,7 +64,7 @@ func newTrezorDriver(logger log.Logger) driver {
}
// Status implements accounts.Wallet, always whether the Trezor is opened, closed
-// or whether the Ethereum app was not started on it.
+// or whether the Wtc app was not started on it.
func (w *trezorDriver) Status() (string, error) {
if w.failure != nil {
return fmt.Sprintf("Failed: %v", w.failure), w.failure
@@ -145,7 +145,7 @@ func (w *trezorDriver) Heartbeat() error {
}
// Derive implements usbwallet.driver, sending a derivation request to the Trezor
-// and returning the Ethereum address located on that derivation path.
+// and returning the Wtc address located on that derivation path.
func (w *trezorDriver) Derive(path accounts.DerivationPath) (common.Address, error) {
return w.trezorDerive(path)
}
@@ -160,10 +160,10 @@ func (w *trezorDriver) SignTx(path accounts.DerivationPath, tx *types.Transactio
}
// trezorDerive sends a derivation request to the Trezor device and returns the
-// Ethereum address located on that path.
+// Wtc address located on that path.
func (w *trezorDriver) trezorDerive(derivationPath []uint32) (common.Address, error) {
- address := new(trezor.EthereumAddress)
- if _, err := w.trezorExchange(&trezor.EthereumGetAddress{AddressN: derivationPath}, address); err != nil {
+ address := new(trezor.WtcAddress)
+ if _, err := w.trezorExchange(&trezor.WtcGetAddress{AddressN: derivationPath}, address); err != nil {
return common.Address{}, err
}
return common.BytesToAddress(address.GetAddress()), nil
@@ -176,7 +176,7 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
data := tx.Data()
length := uint32(len(data))
- request := &trezor.EthereumSignTx{
+ request := &trezor.WtcSignTx{
AddressN: derivationPath,
Nonce: new(big.Int).SetUint64(tx.Nonce()).Bytes(),
GasPrice: tx.GasPrice().Bytes(),
@@ -197,7 +197,7 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
request.ChainId = &id
}
// Send the initiation message and stream content until a signature is returned
- response := new(trezor.EthereumTxRequest)
+ response := new(trezor.WtcTxRequest)
if _, err := w.trezorExchange(request, response); err != nil {
return common.Address{}, nil, err
}
@@ -205,11 +205,11 @@ func (w *trezorDriver) trezorSign(derivationPath []uint32, tx *types.Transaction
chunk := data[:*response.DataLength]
data = data[*response.DataLength:]
- if _, err := w.trezorExchange(&trezor.EthereumTxAck{DataChunk: chunk}, response); err != nil {
+ if _, err := w.trezorExchange(&trezor.WtcTxAck{DataChunk: chunk}, response); err != nil {
return common.Address{}, nil, err
}
}
- // Extract the Ethereum signature and do a sanity validation
+ // Extract the Wtc signature and do a sanity validation
if len(response.GetSignatureR()) == 0 || len(response.GetSignatureS()) == 0 || response.GetSignatureV() == 0 {
return common.Address{}, nil, errors.New("reply lacks signature")
}
diff --git a/accounts/usbwallet/wallet.go b/accounts/usbwallet/wallet.go
old mode 100644
new mode 100755
index 8b3b5a522..daf080769
--- a/accounts/usbwallet/wallet.go
+++ b/accounts/usbwallet/wallet.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,11 +25,11 @@ import (
"sync"
"time"
- ethereum "github.com/ethereum/go-ethereum"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/log"
+ wtc "github.com/wtc/go-wtc"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
"github.com/karalabe/hid"
)
@@ -59,7 +59,7 @@ type driver interface {
// is still online and healthy.
Heartbeat() error
- // Derive sends a derivation request to the USB device and returns the Ethereum
+ // Derive sends a derivation request to the USB device and returns the Wtc
// address located on that path.
Derive(path accounts.DerivationPath) (common.Address, error)
@@ -84,7 +84,7 @@ type wallet struct {
deriveNextPath accounts.DerivationPath // Next derivation path for account auto-discovery
deriveNextAddr common.Address // Next derived account address for auto-discovery
- deriveChain ethereum.ChainStateReader // Blockchain state reader to discover used account with
+ deriveChain wtc.ChainStateReader // Blockchain state reader to discover used account with
deriveReq chan chan struct{} // Channel to request a self-derivation on
deriveQuit chan chan error // Channel to terminate the self-deriver with
@@ -346,7 +346,7 @@ func (w *wallet) selfDerive() {
context = context.Background()
)
for empty := false; !empty; {
- // Retrieve the next derived Ethereum account
+ // Retrieve the next derived Wtc account
if nextAddr == (common.Address{}) {
if nextAddr, err = w.driver.Derive(nextPath); err != nil {
w.log.Warn("USB wallet account derivation failed", "err", err)
@@ -484,7 +484,7 @@ func (w *wallet) Derive(path accounts.DerivationPath, pin bool) (accounts.Accoun
// user used previously (based on the chain state), but ones that he/she did not
// explicitly pin to the wallet manually. To avoid chain head monitoring, self
// derivation only runs during account listing (and even then throttled).
-func (w *wallet) SelfDerive(base accounts.DerivationPath, chain ethereum.ChainStateReader) {
+func (w *wallet) SelfDerive(base accounts.DerivationPath, chain wtc.ChainStateReader) {
w.stateLock.Lock()
defer w.stateLock.Unlock()
@@ -505,7 +505,7 @@ func (w *wallet) SignHash(account accounts.Account, hash []byte) ([]byte, error)
// wallet to request a confirmation from the user. It returns either the signed
// transaction or a failure if the user denied the transaction.
//
-// Note, if the version of the Ethereum application running on the Ledger wallet is
+// Note, if the version of the Wtc application running on the Ledger wallet is
// too old to sign EIP-155 transactions, but such is requested nonetheless, an error
// will be returned opposed to silently signing in Homestead mode.
func (w *wallet) SignTx(account accounts.Account, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
diff --git a/appveyor.yml b/appveyor.yml
deleted file mode 100644
index 78b11fa9d..000000000
--- a/appveyor.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-os: Visual Studio 2015
-
-# Clone directly into GOPATH.
-clone_folder: C:\gopath\src\github.com\ethereum\go-ethereum
-clone_depth: 5
-version: "{branch}.{build}"
-environment:
- global:
- GOPATH: C:\gopath
- CC: gcc.exe
- matrix:
- - GETH_ARCH: amd64
- MSYS2_ARCH: x86_64
- MSYS2_BITS: 64
- MSYSTEM: MINGW64
- PATH: C:\msys64\mingw64\bin\;C:\Program Files (x86)\NSIS\;%PATH%
- - GETH_ARCH: 386
- MSYS2_ARCH: i686
- MSYS2_BITS: 32
- MSYSTEM: MINGW32
- PATH: C:\msys64\mingw32\bin\;C:\Program Files (x86)\NSIS\;%PATH%
-
-install:
- - git submodule update --init
- - rmdir C:\go /s /q
- - appveyor DownloadFile https://storage.googleapis.com/golang/go1.9.windows-%GETH_ARCH%.zip
- - 7z x go1.9.windows-%GETH_ARCH%.zip -y -oC:\ > NUL
- - go version
- - gcc --version
-
-build_script:
- - go run build\ci.go install
-
-after_build:
- - go run build\ci.go archive -type zip -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
- - go run build\ci.go nsis -signer WINDOWS_SIGNING_KEY -upload gethstore/builds
-
-test_script:
- - set CGO_ENABLED=1
- - go run build\ci.go test -coverage
diff --git a/bmt/bmt.go b/bmt/bmt.go
old mode 100644
new mode 100755
index d62365bb1..529797977
--- a/bmt/bmt.go
+++ b/bmt/bmt.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/bmt/bmt_r.go b/bmt/bmt_r.go
old mode 100644
new mode 100755
index 649093ee3..cf70bcdd0
--- a/bmt/bmt_r.go
+++ b/bmt/bmt_r.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/bmt/bmt_test.go b/bmt/bmt_test.go
old mode 100644
new mode 100755
index 57df83060..7087fe021
--- a/bmt/bmt_test.go
+++ b/bmt/bmt_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -28,7 +28,7 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/crypto/sha3"
+ "github.com/wtc/go-wtc/crypto/sha3"
)
const (
diff --git a/build/ci-notes.md b/build/ci-notes.md
old mode 100644
new mode 100755
index 78e9575c0..0b5d1325f
--- a/build/ci-notes.md
+++ b/build/ci-notes.md
@@ -18,11 +18,11 @@ and installs the new version into the PPA repository. Launchpad requires a valid
by a team member for source package uploads. The signing key is stored in an environment
variable which Travis CI makes available to certain builds.
-We want to build go-ethereum with the most recent version of Go, irrespective of the Go
+We want to build go-wtc with the most recent version of Go, irrespective of the Go
version that is available in the main Ubuntu repository. In order to make this possible,
our PPA depends on the ~gophers/ubuntu/archive PPA. Our source package build-depends on
golang-1.9, which is co-installable alongside the regular golang package. PPA dependencies
-can be edited at https://launchpad.net/%7Eethereum/+archive/ubuntu/ethereum/+edit-dependencies
+can be edited at https://launchpad.net/%7Ewtc/+archive/ubuntu/wtc/+edit-dependencies
## Building Packages Locally (for testing)
@@ -40,10 +40,10 @@ Create the source packages:
Then go into the source package directory for your running distribution and build the package:
- $ cd dist/ethereum-unstable-1.6.0+xenial
+ $ cd dist/wtc-unstable-1.6.0+xenial
$ dpkg-buildpackage
Built packages are placed in the dist/ directory.
$ cd ..
- $ dpkg-deb -c geth-unstable_1.6.0+xenial_amd64.deb
+ $ dpkg-deb -c gwtc-unstable_1.6.0+xenial_amd64.deb
diff --git a/build/ci.go b/build/ci.go
old mode 100644
new mode 100755
index 0c825ef31..133dc0162
--- a/build/ci.go
+++ b/build/ci.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,8 +24,7 @@ Usage: go run ci.go <command> <command flags/arguments>
Available commands are:
install [ -arch architecture ] [ packages... ] -- builds packages and executables
- test [ -coverage ] [ packages... ] -- runs the tests
- lint -- runs certain pre-selected linters
+ test [ -coverage ] [ -misspell ] [ packages... ] -- runs the tests
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
importkeys -- imports signing keys from env
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
@@ -55,26 +54,27 @@ import (
"path/filepath"
"regexp"
"runtime"
+ "strconv"
"strings"
"time"
- "github.com/ethereum/go-ethereum/internal/build"
+ "github.com/wtc/go-wtc/internal/build"
)
var (
- // Files that end up in the geth*.zip archive.
- gethArchiveFiles = []string{
+ // Files that end up in the gwtc*.zip archive.
+ gwtcArchiveFiles = []string{
"COPYING",
- executablePath("geth"),
+ executablePath("gwtc"),
}
- // Files that end up in the geth-alltools*.zip archive.
+ // Files that end up in the gwtc-alltools*.zip archive.
allToolsArchiveFiles = []string{
"COPYING",
executablePath("abigen"),
executablePath("bootnode"),
executablePath("evm"),
- executablePath("geth"),
+ executablePath("gwtc"),
executablePath("puppeth"),
executablePath("rlpdump"),
executablePath("swarm"),
@@ -85,23 +85,23 @@ var (
debExecutables = []debExecutable{
{
Name: "abigen",
- Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.",
+ Description: "Source code generator to convert Wtc contract definitions into easy to use, compile-time type-safe Go packages.",
},
{
Name: "bootnode",
- Description: "Ethereum bootnode.",
+ Description: "Wtc bootnode.",
},
{
Name: "evm",
- Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.",
+ Description: "Developer utility version of the EVM (Wtc Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.",
},
{
- Name: "geth",
- Description: "Ethereum CLI client.",
+ Name: "gwtc",
+ Description: "Wtc CLI client.",
},
{
Name: "puppeth",
- Description: "Ethereum private network manager.",
+ Description: "Wtc private network manager.",
},
{
Name: "rlpdump",
@@ -109,11 +109,11 @@ var (
},
{
Name: "swarm",
- Description: "Ethereum Swarm daemon and tools",
+ Description: "Wtc Swarm daemon and tools",
},
{
Name: "wnode",
- Description: "Ethereum Whisper diagnostic tool",
+ Description: "Wtc Whisper diagnostic tool",
},
}
@@ -121,7 +121,7 @@ var (
// Note: vivid is unsupported because there is no golang-1.6 package for it.
// Note: wily is unsupported because it was officially deprecated on lanchpad.
// Note: yakkety is unsupported because it was officially deprecated on lanchpad.
- debDistros = []string{"trusty", "xenial", "zesty", "artful"}
+ debDistros = []string{"trusty", "xenial", "zesty"}
)
var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin"))
@@ -147,8 +147,6 @@ func main() {
doInstall(os.Args[2:])
case "test":
doTest(os.Args[2:])
- case "lint":
- doLint(os.Args[2:])
case "archive":
doArchive(os.Args[2:])
case "debsrc":
@@ -179,12 +177,26 @@ func doInstall(cmdline []string) {
// Check Go version. People regularly open issues about compilation
// failure with outdated Go. This should save them the trouble.
- if runtime.Version() < "go1.7" && !strings.Contains(runtime.Version(), "devel") {
- log.Println("You have Go version", runtime.Version())
- log.Println("go-ethereum requires at least Go version 1.7 and cannot")
- log.Println("be compiled with an earlier version. Please upgrade your Go installation.")
+ majorGoVersion, err := strconv.Atoi(strings.Split(strings.Split(runtime.Version(), "go")[1], ".")[0])
+ if err != nil {
+ log.Println("Version returned does not correspond with supported 1.7+ version.")
+ log.Println("You are running version: ", runtime.Version())
os.Exit(1)
}
+ if majorGoVersion < 2 {
+ minorGoVersion, err := strconv.Atoi(strings.Split(runtime.Version(), ".")[1])
+ if err != nil {
+ log.Println("Version returned does not correspond with supported 1.7+ version.")
+ log.Println("You are running version: ", runtime.Version())
+ os.Exit(1)
+ }
+ if minorGoVersion < 7 && !strings.Contains(runtime.Version(), "devel") {
+ log.Println("You have Go version", runtime.Version())
+ log.Println("go-wtc requires at least Go version 1.7 and cannot")
+ log.Println("be compiled with an earlier version. Please upgrade your Go installation.")
+ os.Exit(1)
+ }
+ }
// Compile packages given as arguments, or everything if there are no arguments.
packages := []string{"./..."}
if flag.NArg() > 0 {
@@ -283,6 +295,7 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
func doTest(cmdline []string) {
var (
+ misspell = flag.Bool("misspell", false, "Whether to run the spell checker")
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
)
flag.CommandLine.Parse(cmdline)
@@ -296,7 +309,10 @@ func doTest(cmdline []string) {
// Run analysis tools before the tests.
build.MustRun(goTool("vet", packages...))
-
+ if *misspell {
+ // TODO(karalabe): Reenable after false detection is fixed: https://github.com/client9/misspell/issues/105
+ // spellcheck(packages)
+ }
// Run the actual tests.
gotest := goTool("test", buildFlags(env)...)
// Test a single package at a time. CI builders are slow
@@ -305,31 +321,35 @@ func doTest(cmdline []string) {
if *coverage {
gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover")
}
-
gotest.Args = append(gotest.Args, packages...)
build.MustRun(gotest)
}
-// runs gometalinter on requested packages
-func doLint(cmdline []string) {
- flag.CommandLine.Parse(cmdline)
+// spellcheck runs the client9/misspell spellchecker package on all Go, Cgo and
+// test files in the requested packages.
+func spellcheck(packages []string) {
+ // Ensure the spellchecker is available
+ build.MustRun(goTool("get", "github.com/client9/misspell/cmd/misspell"))
- packages := []string{"./..."}
- if len(flag.CommandLine.Args()) > 0 {
- packages = flag.CommandLine.Args()
- }
- // Get metalinter and install all supported linters
- build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v1"))
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), "--install")
-
- // Run fast linters batched together
- configs := []string{"--vendor", "--disable-all", "--enable=vet", "--enable=gofmt", "--enable=misspell"}
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
-
- // Run slow linters one by one
- for _, linter := range []string{"unconvert"} {
- configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter}
- build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v1"), append(configs, packages...)...)
+ // Windows chokes on long argument lists, check packages individually
+ for _, pkg := range packages {
+ // The spell checker doesn't work on packages, gather all .go files for it
+ out, err := goTool("list", "-f", "{{.Dir}}{{range .GoFiles}}\n{{.}}{{end}}{{range .CgoFiles}}\n{{.}}{{end}}{{range .TestGoFiles}}\n{{.}}{{end}}", pkg).CombinedOutput()
+ if err != nil {
+ log.Fatalf("source file listing failed: %v\n%s", err, string(out))
+ }
+ // Retrieve the folder and assemble the source list
+ lines := strings.Split(string(out), "\n")
+ root := lines[0]
+
+ sources := make([]string, 0, len(lines)-1)
+ for _, line := range lines[1:] {
+ if line = strings.TrimSpace(line); line != "" {
+ sources = append(sources, filepath.Join(root, line))
+ }
+ }
+ // Run the spell checker for this particular package
+ build.MustRunCommand(filepath.Join(GOBIN, "misspell"), append([]string{"-error"}, sources...)...)
}
}
@@ -340,7 +360,7 @@ func doArchive(cmdline []string) {
arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging")
atype = flag.String("type", "zip", "Type of archive to write (zip|tar)")
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`)
- upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
+ upload = flag.String("upload", "", `Destination to upload the archives (usually "gwtcstore/builds")`)
ext string
)
flag.CommandLine.Parse(cmdline)
@@ -356,17 +376,17 @@ func doArchive(cmdline []string) {
var (
env = build.Env()
base = archiveBasename(*arch, env)
- geth = "geth-" + base + ext
- alltools = "geth-alltools-" + base + ext
+ gwtc = "gwtc-" + base + ext
+ alltools = "gwtc-alltools-" + base + ext
)
maybeSkipArchive(env)
- if err := build.WriteArchive(geth, gethArchiveFiles); err != nil {
+ if err := build.WriteArchive(gwtc, gwtcArchiveFiles); err != nil {
log.Fatal(err)
}
if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil {
log.Fatal(err)
}
- for _, archive := range []string{geth, alltools} {
+ for _, archive := range []string{gwtc, alltools} {
if err := archiveUpload(archive, *upload, *signer); err != nil {
log.Fatal(err)
}
@@ -449,7 +469,7 @@ func maybeSkipArchive(env build.Environment) {
func doDebianSource(cmdline []string) {
var (
signer = flag.String("signer", "", `Signing key name, also used as package author`)
- upload = flag.String("upload", "", `Where to upload the source package (usually "ppa:ethereum/ethereum")`)
+ upload = flag.String("upload", "", `Where to upload the source package (usually "ppa:wtc/wtc")`)
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
now = time.Now()
)
@@ -493,7 +513,7 @@ func makeWorkdir(wdflag string) string {
if wdflag != "" {
err = os.MkdirAll(wdflag, 0744)
} else {
- wdflag, err = ioutil.TempDir("", "geth-build-")
+ wdflag, err = ioutil.TempDir("", "gwtc-build-")
}
if err != nil {
log.Fatal(err)
@@ -511,7 +531,7 @@ func isUnstableBuild(env build.Environment) bool {
type debMetadata struct {
Env build.Environment
- // go-ethereum version being built. Note that this
+ // go-wtc version being built. Note that this
// is not the debian package version. The package version
// is constructed by VersionString.
Version string
@@ -528,7 +548,7 @@ type debExecutable struct {
func newDebMetadata(distro, author string, env build.Environment, t time.Time) debMetadata {
if author == "" {
// No signing key, use default author.
- author = "Ethereum Builds <fjl@ethereum.org>"
+ author = "Wtc Builds <fjl@wtc.org>"
}
return debMetadata{
Env: env,
@@ -544,9 +564,9 @@ func newDebMetadata(distro, author string, env build.Environment, t time.Time) d
// on all executable packages.
func (meta debMetadata) Name() string {
if isUnstableBuild(meta.Env) {
- return "ethereum-unstable"
+ return "wtc-unstable"
}
- return "ethereum"
+ return "wtc"
}
// VersionString returns the debian version of the packages.
@@ -590,7 +610,7 @@ func (meta debMetadata) ExeConflicts(exe debExecutable) string {
// be preferred and the conflicting files should be handled via
// alternates. We might do this eventually but using a conflict is
// easier now.
- return "ethereum, " + exe.Name
+ return "wtc, " + exe.Name
}
return ""
}
@@ -630,7 +650,7 @@ func doWindowsInstaller(cmdline []string) {
var (
arch = flag.String("arch", runtime.GOARCH, "Architecture for cross build packaging")
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)`)
- upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
+ upload = flag.String("upload", "", `Destination to upload the archives (usually "gwtcstore/builds")`)
workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`)
)
flag.CommandLine.Parse(cmdline)
@@ -642,28 +662,28 @@ func doWindowsInstaller(cmdline []string) {
var (
devTools []string
allTools []string
- gethTool string
+ gwtcTool string
)
for _, file := range allToolsArchiveFiles {
if file == "COPYING" { // license, copied later
continue
}
allTools = append(allTools, filepath.Base(file))
- if filepath.Base(file) == "geth.exe" {
- gethTool = file
+ if filepath.Base(file) == "gwtc.exe" {
+ gwtcTool = file
} else {
devTools = append(devTools, file)
}
}
// Render NSIS scripts: Installer NSIS contains two installer sections,
- // first section contains the geth binary, second section holds the dev tools.
+ // first section contains the gwtc binary, second section holds the dev tools.
templateData := map[string]interface{}{
"License": "COPYING",
- "Geth": gethTool,
+ "Gwtc": gwtcTool,
"DevTools": devTools,
}
- build.Render("build/nsis.geth.nsi", filepath.Join(*workdir, "geth.nsi"), 0644, nil)
+ build.Render("build/nsis.gwtc.nsi", filepath.Join(*workdir, "gwtc.nsi"), 0644, nil)
build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData)
build.Render("build/nsis.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools)
build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil)
@@ -678,14 +698,14 @@ func doWindowsInstaller(cmdline []string) {
if env.Commit != "" {
version[2] += "-" + env.Commit[:8]
}
- installer, _ := filepath.Abs("geth-" + archiveBasename(*arch, env) + ".exe")
+ installer, _ := filepath.Abs("gwtc-" + archiveBasename(*arch, env) + ".exe")
build.MustRunCommand("makensis.exe",
"/DOUTPUTFILE="+installer,
"/DMAJORVERSION="+version[0],
"/DMINORVERSION="+version[1],
"/DBUILDVERSION="+version[2],
"/DARCH="+*arch,
- filepath.Join(*workdir, "geth.nsi"),
+ filepath.Join(*workdir, "gwtc.nsi"),
)
// Sign and publish installer.
@@ -701,7 +721,7 @@ func doAndroidArchive(cmdline []string) {
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. ANDROID_SIGNING_KEY)`)
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "https://oss.sonatype.org")`)
- upload = flag.String("upload", "", `Destination to upload the archive (usually "gethstore/builds")`)
+ upload = flag.String("upload", "", `Destination to upload the archive (usually "gwtcstore/builds")`)
)
flag.CommandLine.Parse(cmdline)
env := build.Env()
@@ -716,11 +736,11 @@ func doAndroidArchive(cmdline []string) {
// Build the Android archive and Maven resources
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile"))
build.MustRun(gomobileTool("init", "--ndk", os.Getenv("ANDROID_NDK")))
- build.MustRun(gomobileTool("bind", "--target", "android", "--javapkg", "org.ethereum", "-v", "github.com/ethereum/go-ethereum/mobile"))
+ build.MustRun(gomobileTool("bind", "--target", "android", "--javapkg", "org.wtc", "-v", "github.com/wtc/go-wtc/mobile"))
if *local {
// If we're building locally, copy bundle to build dir and skip Maven
- os.Rename("geth.aar", filepath.Join(GOBIN, "geth.aar"))
+ os.Rename("gwtc.aar", filepath.Join(GOBIN, "gwtc.aar"))
return
}
meta := newMavenMetadata(env)
@@ -730,8 +750,8 @@ func doAndroidArchive(cmdline []string) {
maybeSkipArchive(env)
// Sign and upload the archive to Azure
- archive := "geth-" + archiveBasename("android", env) + ".aar"
- os.Rename("geth.aar", archive)
+ archive := "gwtc-" + archiveBasename("android", env) + ".aar"
+ os.Rename("gwtc.aar", archive)
if err := archiveUpload(archive, *upload, *signer); err != nil {
log.Fatal(err)
@@ -815,7 +835,7 @@ func newMavenMetadata(env build.Environment) mavenMetadata {
}
return mavenMetadata{
Version: version,
- Package: "geth-" + version,
+ Package: "gwtc-" + version,
Develop: isUnstableBuild(env),
Contributors: contribs,
}
@@ -828,7 +848,7 @@ func doXCodeFramework(cmdline []string) {
local = flag.Bool("local", false, `Flag whether we're only doing a local build (skip Maven artifacts)`)
signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. IOS_SIGNING_KEY)`)
deploy = flag.String("deploy", "", `Destination to deploy the archive (usually "trunk")`)
- upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`)
+ upload = flag.String("upload", "", `Destination to upload the archives (usually "gwtcstore/builds")`)
)
flag.CommandLine.Parse(cmdline)
env := build.Env()
@@ -836,7 +856,7 @@ func doXCodeFramework(cmdline []string) {
// Build the iOS XCode framework
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile"))
build.MustRun(gomobileTool("init"))
- bind := gomobileTool("bind", "--target", "ios", "--tags", "ios", "-v", "github.com/ethereum/go-ethereum/mobile")
+ bind := gomobileTool("bind", "--target", "ios", "--tags", "ios", "-v", "github.com/wtc/go-wtc/mobile")
if *local {
// If we're building locally, use the build folder and stop afterwards
@@ -844,7 +864,7 @@ func doXCodeFramework(cmdline []string) {
build.MustRun(bind)
return
}
- archive := "geth-" + archiveBasename("ios", env)
+ archive := "gwtc-" + archiveBasename("ios", env)
if err := os.Mkdir(archive, os.ModePerm); err != nil {
log.Fatal(err)
}
@@ -862,8 +882,8 @@ func doXCodeFramework(cmdline []string) {
// Prepare and upload a PodSpec to CocoaPods
if *deploy != "" {
meta := newPodMetadata(env, archive)
- build.Render("build/pod.podspec", "Geth.podspec", 0755, meta)
- build.MustRunCommand("pod", *deploy, "push", "Geth.podspec", "--allow-warnings", "--verbose")
+ build.Render("build/pod.podspec", "Gwtc.podspec", 0755, meta)
+ build.MustRunCommand("pod", *deploy, "push", "Gwtc.podspec", "--allow-warnings", "--verbose")
}
}
@@ -968,7 +988,7 @@ func xgoTool(args []string) *exec.Cmd {
func doPurge(cmdline []string) {
var (
- store = flag.String("store", "", `Destination from where to purge archives (usually "gethstore/builds")`)
+ store = flag.String("store", "", `Destination from where to purge archives (usually "gwtcstore/builds")`)
limit = flag.Int("days", 30, `Age threshold above which to delete unstalbe archives`)
)
flag.CommandLine.Parse(cmdline)
diff --git a/build/deb.changelog b/build/deb.changelog
old mode 100644
new mode 100755
diff --git a/build/deb.control b/build/deb.control
old mode 100644
new mode 100755
index 5c9ce6705..6c1356f1a
--- a/build/deb.control
+++ b/build/deb.control
@@ -4,15 +4,15 @@ Priority: extra
Maintainer: {{.Author}}
Build-Depends: debhelper (>= 8.0.0), golang-1.9
Standards-Version: 3.9.5
-Homepage: https://ethereum.org
-Vcs-Git: git://github.com/ethereum/go-ethereum.git
-Vcs-Browser: https://github.com/ethereum/go-ethereum
+Homepage: https://wtc.org
+Vcs-Git: git://github.com/wtc/go-wtc.git
+Vcs-Browser: https://github.com/wtc/go-wtc
Package: {{.Name}}
Architecture: any
Depends: ${misc:Depends}, {{.ExeList}}
-Description: Meta-package to install geth and other tools
- Meta-package to install geth and other tools
+Description: Meta-package to install gwtc and other tools
+ Meta-package to install gwtc and other tools
{{range .Executables}}
Package: {{$.ExeName .}}
diff --git a/build/deb.copyright b/build/deb.copyright
old mode 100644
new mode 100755
index 513be45b1..feabe30cb
--- a/build/deb.copyright
+++ b/build/deb.copyright
@@ -1,14 +1,14 @@
Copyright 2016 The go-ethereum Authors
-go-ethereum is free software: you can redistribute it and/or modify
+go-wtc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-go-ethereum is distributed in the hope that it will be useful,
+go-wtc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
diff --git a/build/deb.docs b/build/deb.docs
old mode 100644
new mode 100755
diff --git a/build/deb.install b/build/deb.install
old mode 100644
new mode 100755
diff --git a/build/deb.rules b/build/deb.rules
old mode 100644
new mode 100755
diff --git a/build/env.sh b/build/env.sh
index 3914555d1..801007b4f 100755
--- a/build/env.sh
+++ b/build/env.sh
@@ -10,11 +10,11 @@ fi
# Create fake Go workspace if it doesn't exist yet.
workspace="$PWD/build/_workspace"
root="$PWD"
-ethdir="$workspace/src/github.com/ethereum"
-if [ ! -L "$ethdir/go-ethereum" ]; then
+ethdir="$workspace/src/github.com/wtc"
+if [ ! -L "$ethdir/go-wtc" ]; then
mkdir -p "$ethdir"
cd "$ethdir"
- ln -s ../../../../../. go-ethereum
+ ln -s ../../../../../. go-wtc
cd "$root"
fi
@@ -23,8 +23,8 @@ GOPATH="$workspace"
export GOPATH
# Run the command inside the workspace.
-cd "$ethdir/go-ethereum"
-PWD="$ethdir/go-ethereum"
+cd "$ethdir/go-wtc"
+PWD="$ethdir/go-wtc"
# Launch the arguments with the configured environment.
exec "$@"
diff --git a/build/mvn.pom b/build/mvn.pom
old mode 100644
new mode 100755
index 7670246ba..e2a23dd42
--- a/build/mvn.pom
+++ b/build/mvn.pom
@@ -4,14 +4,14 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.ethereum</groupId>
- <artifactId>geth</artifactId>
+ <groupId>org.wtc</groupId>
+ <artifactId>gwtc</artifactId>
<version>{{.Version}}</version>
<packaging>aar</packaging>
- <name>Android Ethereum Client</name>
- <description>Android port of the go-ethereum libraries and node</description>
- <url>https://github.com/ethereum/go-ethereum</url>
+ <name>Android Wtc Client</name>
+ <description>Android port of the go-wtc libraries and node</description>
+ <url>https://github.com/wtc/go-wtc</url>
<inceptionYear>2015</inceptionYear>
<licenses>
@@ -23,8 +23,8 @@
</licenses>
<organization>
- <name>Ethereum</name>
- <url>https://ethereum.org</url>
+ <name>Wtc</name>
+ <url>https://wtc.org</url>
</organization>
<developers>
@@ -48,10 +48,10 @@
<issueManagement>
<system>GitHub Issues</system>
- <url>https://github.com/ethereum/go-ethereum/issues/</url>
+ <url>https://github.com/wtc/go-wtc/issues/</url>
</issueManagement>
<scm>
- <url>https://github.com/ethereum/go-ethereum</url>
+ <url>https://github.com/wtc/go-wtc</url>
</scm>
</project>
diff --git a/build/mvn.settings b/build/mvn.settings
old mode 100644
new mode 100755
diff --git a/build/nsis.envvarupdate.nsh b/build/nsis.envvarupdate.nsh
old mode 100644
new mode 100755
diff --git a/build/nsis.geth.nsi b/build/nsis.geth.nsi
old mode 100644
new mode 100755
index 1034f3023..ab8a90d6b
--- a/build/nsis.geth.nsi
+++ b/build/nsis.geth.nsi
@@ -6,13 +6,13 @@
# - BUILDVERSION, build id version
#
# The created installer executes the following steps:
-# 1. install geth for all users
+# 1. install gwtc for all users
# 2. install optional development tools such as abigen
# 3. create an uninstaller
-# 4. configures the Windows firewall for geth
-# 5. create geth, attach and uninstall start menu entries
+# 4. configures the Windows firewall for gwtc
+# 5. create gwtc, attach and uninstall start menu entries
# 6. configures the registry that allows Windows to manage the package through its platform tools
-# 7. adds the environment system wide variable ETHEREUM_SOCKET
+# 7. adds the environment system wide variable WTC_SOCKET
# 8. adds the install directory to %PATH%
#
# Requirements:
@@ -29,9 +29,9 @@
# - sign installer
CRCCheck on
-!define GROUPNAME "Ethereum"
-!define APPNAME "Geth"
-!define DESCRIPTION "Official Go implementation of the Ethereum protocol"
+!define GROUPNAME "Wtc"
+!define APPNAME "Gwtc"
+!define DESCRIPTION "Official Go implementation of the Wtc protocol"
!addplugindir .\
# Require admin rights on NT6+ (When UAC is turned on)
@@ -55,7 +55,7 @@ ${EndIf}
!macroend
function .onInit
- # make vars are global for all users since geth is installed global
+ # make vars are global for all users since gwtc is installed global
setShellVarContext all
!insertmacro VerifyUserIsAdmin
diff --git a/build/nsis.install.nsh b/build/nsis.install.nsh
old mode 100644
new mode 100755
index 57ef5a37c..20d9e8880
--- a/build/nsis.install.nsh
+++ b/build/nsis.install.nsh
@@ -1,41 +1,41 @@
-Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments
+Name "gwtc ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments
InstallDir "$InstDir"
OutFile "${OUTPUTFILE}" # set through command line arguments
# Links for "Add/Remove Programs"
-!define HELPURL "https://github.com/ethereum/go-ethereum/issues"
-!define UPDATEURL "https://github.com/ethereum/go-ethereum/releases"
-!define ABOUTURL "https://github.com/ethereum/go-ethereum#ethereum-go"
+!define HELPURL "https://github.com/wtc/go-wtc/issues"
+!define UPDATEURL "https://github.com/wtc/go-wtc/releases"
+!define ABOUTURL "https://github.com/wtc/go-wtc#wtc-go"
!define /date NOW "%Y%m%d"
PageEx license
LicenseData {{.License}}
PageExEnd
-# Install geth binary
-Section "Geth" GETH_IDX
+# Install gwtc binary
+Section "Gwtc" GETH_IDX
SetOutPath $INSTDIR
- file {{.Geth}}
+ file {{.Gwtc}}
# Create start menu launcher
createDirectory "$SMPROGRAMS\${APPNAME}"
- createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" "--fast" "--cache=512"
- createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" "" ""
+ createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\gwtc.exe" "--fast" "--cache=512"
+ createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\gwtc.exe" "attach" "" ""
createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "" ""
# Firewall - remove rules (if exists)
- SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)"
- SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)"
- SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)"
+ SimpleFC::AdvRemoveRule "Gwtc incoming peers (TCP:10101)"
+ SimpleFC::AdvRemoveRule "Gwtc outgoing peers (TCP:10101)"
+ SimpleFC::AdvRemoveRule "Gwtc UDP discovery (UDP:10101)"
# Firewall - add rules
- SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" ""
- SimpleFC::AdvAddRule "Geth outgoing peers (TCP:30303)" "" 6 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" ""
- SimpleFC::AdvAddRule "Geth UDP discovery (UDP:30303)" "" 17 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" ""
+ SimpleFC::AdvAddRule "Gwtc incoming peers (TCP:10101)" "" 6 1 1 2147483647 1 "$INSTDIR\gwtc.exe" "" "" "Wtc" 10101 "" "" ""
+ SimpleFC::AdvAddRule "Gwtc outgoing peers (TCP:10101)" "" 6 2 1 2147483647 1 "$INSTDIR\gwtc.exe" "" "" "Wtc" "" 10101 "" ""
+ SimpleFC::AdvAddRule "Gwtc UDP discovery (UDP:10101)" "" 17 2 1 2147483647 1 "$INSTDIR\gwtc.exe" "" "" "Wtc" "" 10101 "" ""
- # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147)
- ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc"
- ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc"
+ # Set default IPC endpoint (https://github.com/wtc/EIPs/issues/147)
+ ${EnvVarUpdate} $0 "WTC_SOCKET" "R" "HKLM" "\\.\pipe\gwtc.ipc"
+ ${EnvVarUpdate} $0 "WTC_SOCKET" "A" "HKLM" "\\.\pipe\gwtc.ipc"
# Add instdir to PATH
Push "$INSTDIR"
diff --git a/build/nsis.pathupdate.nsh b/build/nsis.pathupdate.nsh
old mode 100644
new mode 100755
diff --git a/build/nsis.simplefc.dll b/build/nsis.simplefc.dll
deleted file mode 100644
index 73b7d9634..000000000
Binary files a/build/nsis.simplefc.dll and /dev/null differ
diff --git a/build/nsis.simplefc.source.zip b/build/nsis.simplefc.source.zip
old mode 100644
new mode 100755
diff --git a/build/nsis.uninstall.nsh b/build/nsis.uninstall.nsh
old mode 100644
new mode 100755
index 6358faa74..5504a71ed
--- a/build/nsis.uninstall.nsh
+++ b/build/nsis.uninstall.nsh
@@ -17,12 +17,12 @@ Section "Uninstall"
rmDir "$SMPROGRAMS\${APPNAME}"
# Firewall - remove rules if exists
- SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)"
- SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)"
- SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)"
+ SimpleFC::AdvRemoveRule "Gwtc incoming peers (TCP:10101)"
+ SimpleFC::AdvRemoveRule "Gwtc outgoing peers (TCP:10101)"
+ SimpleFC::AdvRemoveRule "Gwtc UDP discovery (UDP:10101)"
- # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147)
- ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc"
+ # Remove IPC endpoint (https://github.com/wtc/EIPs/issues/147)
+ ${un.EnvVarUpdate} $0 "WTC_SOCKET" "R" "HKLM" "\\.\pipe\gwtc.ipc"
# Remove install directory from PATH
Push "$INSTDIR"
diff --git a/build/pod.podspec b/build/pod.podspec
old mode 100644
new mode 100755
index 2c14c280c..e08e165c9
--- a/build/pod.podspec
+++ b/build/pod.podspec
@@ -1,22 +1,22 @@
Pod::Spec.new do |spec|
- spec.name = 'Geth'
+ spec.name = 'Gwtc'
spec.version = '{{.Version}}'
spec.license = { :type => 'GNU Lesser General Public License, Version 3.0' }
- spec.homepage = 'https://github.com/ethereum/go-ethereum'
+ spec.homepage = 'https://github.com/wtc/go-wtc'
spec.authors = { {{range .Contributors}}
'{{.Name}}' => '{{.Email}}',{{end}}
}
- spec.summary = 'iOS Ethereum Client'
- spec.source = { :git => 'https://github.com/ethereum/go-ethereum.git', :commit => '{{.Commit}}' }
+ spec.summary = 'iOS Wtc Client'
+ spec.source = { :git => 'https://github.com/wtc/go-wtc.git', :commit => '{{.Commit}}' }
spec.platform = :ios
spec.ios.deployment_target = '9.0'
- spec.ios.vendored_frameworks = 'Frameworks/Geth.framework'
+ spec.ios.vendored_frameworks = 'Frameworks/Gwtc.framework'
spec.prepare_command = <<-CMD
- curl https://gethstore.blob.core.windows.net/builds/{{.Archive}}.tar.gz | tar -xvz
+ curl https://gwtcstore.blob.core.windows.net/builds/{{.Archive}}.tar.gz | tar -xvz
mkdir Frameworks
- mv {{.Archive}}/Geth.framework Frameworks
+ mv {{.Archive}}/Gwtc.framework Frameworks
rm -rf {{.Archive}}
CMD
end
diff --git a/build/update-license.go b/build/update-license.go
old mode 100644
new mode 100755
index 3d69598b7..66d28d324
--- a/build/update-license.go
+++ b/build/update-license.go
@@ -69,7 +69,7 @@ var (
licenseCommentRE = regexp.MustCompile(`^//\s*(Copyright|This file is part of).*?\n(?://.*?\n)*\n*`)
// this text appears at the start of AUTHORS
- authorsFileHeader = "# This is the official list of go-ethereum authors for copyright purposes.\n\n"
+ authorsFileHeader = "# This is the official list of go-wtc authors for copyright purposes.\n\n"
)
// this template generates the license comment.
@@ -114,10 +114,10 @@ func (i info) ShortLicense() string {
func (i info) Whole(startOfSentence bool) string {
if i.gpl() {
- return "go-ethereum"
+ return "go-wtc"
}
if startOfSentence {
- return "The go-ethereum library"
+ return "The go-wtc library"
}
return "the go-ethereum library"
}
diff --git a/circle.yml b/circle.yml
deleted file mode 100644
index 39ff5d83c..000000000
--- a/circle.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-machine:
- services:
- - docker
-
-dependencies:
- cache_directories:
- - "~/.ethash" # Cache the ethash DAG generated by hive for consecutive builds
- - "~/.docker" # Cache all docker images manually to avoid lengthy rebuilds
- override:
- # Restore all previously cached docker images
- - mkdir -p ~/.docker
- - for img in `ls ~/.docker`; do docker load -i ~/.docker/$img; done
-
- # Pull in and hive, restore cached ethash DAGs and do a dry run
- - go get -u github.com/karalabe/hive
- - (cd ~/.go_workspace/src/github.com/karalabe/hive && mkdir -p workspace/ethash/ ~/.ethash)
- - (cd ~/.go_workspace/src/github.com/karalabe/hive && cp -r ~/.ethash/. workspace/ethash/)
- - (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=NONE --test=. --sim=. --loglevel=6)
-
- # Cache all the docker images and the ethash DAGs
- - for img in `docker images | grep -v "^<none>" | tail -n +2 | awk '{print $1}'`; do docker save $img > ~/.docker/`echo $img | tr '/' ':'`.tar; done
- - cp -r ~/.go_workspace/src/github.com/karalabe/hive/workspace/ethash/. ~/.ethash
-
-test:
- override:
- # Build Geth and move into a known folder
- - make geth
- - cp ./build/bin/geth $HOME/geth
-
- # Run hive and move all generated logs into the public artifacts folder
- - (cd ~/.go_workspace/src/github.com/karalabe/hive && hive --docker-noshell --client=go-ethereum:local --override=$HOME/geth --test=. --sim=.)
- - cp -r ~/.go_workspace/src/github.com/karalabe/hive/workspace/logs/* $CIRCLE_ARTIFACTS
diff --git a/cmd/abigen/main.go b/cmd/abigen/main.go
old mode 100644
new mode 100755
index 3a1ae6f4c..cc5eda505
--- a/cmd/abigen/main.go
+++ b/cmd/abigen/main.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -24,16 +24,16 @@ import (
"os"
"strings"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common/compiler"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common/compiler"
)
var (
- abiFlag = flag.String("abi", "", "Path to the Ethereum contract ABI json to bind")
- binFlag = flag.String("bin", "", "Path to the Ethereum contract bytecode (generate deploy method)")
+ abiFlag = flag.String("abi", "", "Path to the Wtc contract ABI json to bind")
+ binFlag = flag.String("bin", "", "Path to the Wtc contract bytecode (generate deploy method)")
typFlag = flag.String("type", "", "Struct name for the binding (default = package name)")
- solFlag = flag.String("sol", "", "Path to the Ethereum contract Solidity source to build and bind")
+ solFlag = flag.String("sol", "", "Path to the Wtc contract Solidity source to build and bind")
solcFlag = flag.String("solc", "solc", "Solidity compiler to use if source builds are requested")
excFlag = flag.String("exc", "", "Comma separated types to exclude from binding")
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go
old mode 100644
new mode 100755
index e1734d89a..aaf33badb
--- a/cmd/bootnode/main.go
+++ b/cmd/bootnode/main.go
@@ -1,20 +1,20 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
-// bootnode runs a bootstrap node for the Ethereum Discovery Protocol.
+// bootnode runs a bootstrap node for the Wtc Discovery Protocol.
package main
import (
@@ -23,18 +23,18 @@ import (
"fmt"
"os"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/p2p/discv5"
- "github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/p2p/netutil"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/p2p/discv5"
+ "github.com/wtc/go-wtc/p2p/nat"
+ "github.com/wtc/go-wtc/p2p/netutil"
)
func main() {
var (
- listenAddr = flag.String("addr", ":30301", "listen address")
+ listenAddr = flag.String("addr", ":10101", "listen address")
genKey = flag.String("genkey", "", "generate a node key")
writeAddr = flag.Bool("writeaddress", false, "write out the node's pubkey hash and quit")
nodeKeyFile = flag.String("nodekey", "", "private key filename")
diff --git a/cmd/evm/compiler.go b/cmd/evm/compiler.go
old mode 100644
new mode 100755
index c019a2fe7..6b5f6aaa3
--- a/cmd/evm/compiler.go
+++ b/cmd/evm/compiler.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -21,7 +21,7 @@ import (
"fmt"
"io/ioutil"
- "github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
+ "github.com/wtc/go-wtc/cmd/evm/internal/compiler"
cli "gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/evm/disasm.go b/cmd/evm/disasm.go
old mode 100644
new mode 100755
index 4a442cf78..bc04c164b
--- a/cmd/evm/disasm.go
+++ b/cmd/evm/disasm.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -22,7 +22,7 @@ import (
"io/ioutil"
"strings"
- "github.com/ethereum/go-ethereum/core/asm"
+ "github.com/wtc/go-wtc/core/asm"
cli "gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/evm/internal/compiler/compiler.go b/cmd/evm/internal/compiler/compiler.go
old mode 100644
new mode 100755
index 753ca6226..a3302ebf8
--- a/cmd/evm/internal/compiler/compiler.go
+++ b/cmd/evm/internal/compiler/compiler.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package compiler
@@ -20,7 +20,7 @@ import (
"errors"
"fmt"
- "github.com/ethereum/go-ethereum/core/asm"
+ "github.com/wtc/go-wtc/core/asm"
)
func Compile(fn string, src []byte, debug bool) (string, error) {
diff --git a/cmd/evm/json_logger.go b/cmd/evm/json_logger.go
old mode 100644
new mode 100755
index eb7b0c466..41803634f
--- a/cmd/evm/json_logger.go
+++ b/cmd/evm/json_logger.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,9 +21,9 @@ import (
"io"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/core/vm"
)
type JSONLogger struct {
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
old mode 100644
new mode 100755
index 6c39cf8b8..949fcffca
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -1,18 +1,18 @@
// Copyright 2014 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// evm executes EVM code snippets.
package main
@@ -22,7 +22,7 @@ import (
"math/big"
"os"
- "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/wtc/go-wtc/cmd/utils"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
old mode 100644
new mode 100755
index 96de0c76a..f8d6088dc
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -27,16 +27,16 @@ import (
goruntime "runtime"
- "github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/core/vm/runtime"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/cmd/evm/internal/compiler"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/core/vm/runtime"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/params"
cli "gopkg.in/urfave/cli.v1"
)
@@ -99,7 +99,7 @@ func runCmd(ctx *cli.Context) error {
_, statedb = gen.ToBlock()
chainConfig = gen.Config
} else {
- db, _ := ethdb.NewMemDatabase()
+ db, _ := wtcdb.NewMemDatabase()
statedb, _ = state.New(common.Hash{}, state.NewDatabase(db))
}
if ctx.GlobalString(SenderFlag.Name) != "" {
diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go
old mode 100644
new mode 100755
index 071ea94ad..2f4ee14d7
--- a/cmd/evm/staterunner.go
+++ b/cmd/evm/staterunner.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -23,10 +23,10 @@ import (
"io/ioutil"
"os"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/tests"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/tests"
cli "gopkg.in/urfave/cli.v1"
)
@@ -50,7 +50,7 @@ func stateTestCmd(ctx *cli.Context) error {
if len(ctx.Args().First()) == 0 {
return errors.New("path-to-test argument required")
}
- // Configure the go-ethereum logger
+ // Configure the go-wtc logger
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
log.Root().SetHandler(glogger)
@@ -94,8 +94,7 @@ func stateTestCmd(ctx *cli.Context) error {
for _, st := range test.Subtests() {
// Run the test and aggregate the result
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
- state, err := test.Run(st, cfg)
- if err != nil {
+ if state, err := test.Run(st, cfg); err != nil {
// Test failed, mark as so and dump any state to aid debugging
result.Pass, result.Error = false, err.Error()
if ctx.GlobalBool(DumpFlag.Name) && state != nil {
@@ -103,11 +102,6 @@ func stateTestCmd(ctx *cli.Context) error {
result.State = &dump
}
}
- // print state root for evmlab tracing (already committed above, so no need to delete objects again
- if ctx.GlobalBool(MachineFlag.Name) && state != nil {
- fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
- }
-
results = append(results, *result)
// Print any structured logs collected
diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go
old mode 100644
new mode 100755
index 72098e68d..80e95ad54
--- a/cmd/faucet/faucet.go
+++ b/cmd/faucet/faucet.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// faucet is a Ether faucet backed by a light client.
package main
@@ -21,10 +21,8 @@ package main
import (
"bytes"
- "compress/zlib"
"context"
"encoding/json"
- "errors"
"flag"
"fmt"
"html/template"
@@ -35,38 +33,37 @@ import (
"net/url"
"os"
"path/filepath"
- "regexp"
"strconv"
"strings"
"sync"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/eth/downloader"
- "github.com/ethereum/go-ethereum/ethclient"
- "github.com/ethereum/go-ethereum/ethstats"
- "github.com/ethereum/go-ethereum/les"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/p2p/discv5"
- "github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/wtc/downloader"
+ "github.com/wtc/go-wtc/wtcclient"
+ "github.com/wtc/go-wtc/wtcstats"
+ "github.com/wtc/go-wtc/les"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/p2p/discv5"
+ "github.com/wtc/go-wtc/p2p/nat"
+ "github.com/wtc/go-wtc/params"
"golang.org/x/net/websocket"
)
var (
genesisFlag = flag.String("genesis", "", "Genesis json file to seed the chain with")
apiPortFlag = flag.Int("apiport", 8080, "Listener port for the HTTP API connection")
- ethPortFlag = flag.Int("ethport", 30303, "Listener port for the devp2p connection")
+ ethPortFlag = flag.Int("ethport", 10101, "Listener port for the devp2p connection")
bootFlag = flag.String("bootnodes", "", "Comma separated bootnode enode URLs to seed with")
- netFlag = flag.Uint64("network", 0, "Network ID to use for the Ethereum protocol")
+ netFlag = flag.Uint64("network", 0, "Network ID to use for the Wtc protocol")
statsFlag = flag.String("ethstats", "", "Ethstats network monitoring auth string")
netnameFlag = flag.String("faucet.name", "", "Network name to assign to the faucet")
@@ -83,7 +80,7 @@ var (
captchaToken = flag.String("captcha.token", "", "Recaptcha site key to authenticate client side")
captchaSecret = flag.String("captcha.secret", "", "Recaptcha secret key to authenticate server side")
- logFlag = flag.Int("loglevel", 3, "Log level to use for Ethereum and the faucet")
+ logFlag = flag.Int("loglevel", 3, "Log level to use for Wtc and the faucet")
)
var (
@@ -184,17 +181,17 @@ func main() {
// request represents an accepted funding request.
type request struct {
- Avatar string `json:"avatar"` // Avatar URL to make the UI nicer
- Account common.Address `json:"account"` // Ethereum address being funded
- Time time.Time `json:"time"` // Timestamp when the request was accepted
- Tx *types.Transaction `json:"tx"` // Transaction funding the account
+ Username string `json:"username"` // GitHub user for displaying an avatar
+ Account common.Address `json:"account"` // Wtc address being funded
+ Time time.Time `json:"time"` // Timestamp when te request was accepted
+ Tx *types.Transaction `json:"tx"` // Transaction funding the account
}
-// faucet represents a crypto faucet backed by an Ethereum light client.
+// faucet represents a crypto faucet backed by an Wtc light client.
type faucet struct {
config *params.ChainConfig // Chain configurations for signing
- stack *node.Node // Ethereum protocol stack
- client *ethclient.Client // Client connection to the Ethereum chain
+ stack *node.Node // Wtc protocol stack
+ client *wtcclient.Client // Client connection to the Wtc chain
index []byte // Index page to serve up on the web
keystore *keystore.KeyStore // Keystore containing the single signer
@@ -213,7 +210,7 @@ type faucet struct {
func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network uint64, stats string, ks *keystore.KeyStore, index []byte) (*faucet, error) {
// Assemble the raw devp2p protocol stack
stack, err := node.New(&node.Config{
- Name: "geth",
+ Name: "gwtc",
Version: params.Version,
DataDir: filepath.Join(os.Getenv("HOME"), ".faucet"),
P2P: p2p.Config{
@@ -229,7 +226,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
if err != nil {
return nil, err
}
- // Assemble the Ethereum light client protocol
+ // Assemble the Wtc light client protocol
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
cfg := eth.DefaultConfig
cfg.SyncMode = downloader.LightSync
@@ -242,7 +239,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
// Assemble the ethstats monitoring and reporting service'
if stats != "" {
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- var serv *les.LightEthereum
+ var serv *les.LightWtc
ctx.Service(&serv)
return ethstats.New(stats, nil, serv)
}); err != nil {
@@ -263,7 +260,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
stack.Stop()
return nil, err
}
- client := ethclient.NewClient(api)
+ client := wtcclient.NewClient(api)
return &faucet{
config: genesis.Config,
@@ -277,7 +274,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network u
}, nil
}
-// close terminates the Ethereum connection and tears down the faucet.
+// close terminates the Wtc connection and tears down the faucet.
func (f *faucet) close() error {
return f.stack.Stop()
}
@@ -302,8 +299,6 @@ func (f *faucet) webHandler(w http.ResponseWriter, r *http.Request) {
// apiHandler handles requests for Ether grants and transaction statuses.
func (f *faucet) apiHandler(conn *websocket.Conn) {
// Start tracking the connection and drop at the end
- defer conn.Close()
-
f.lock.Lock()
f.conns = append(f.conns, conn)
f.lock.Unlock()
@@ -318,50 +313,25 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
}
f.lock.Unlock()
}()
- // Gather the initial stats from the network to report
- var (
- head *types.Header
- balance *big.Int
- nonce uint64
- err error
- )
- for {
- // Attempt to retrieve the stats, may error on no faucet connectivity
- ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
- head, err = f.client.HeaderByNumber(ctx, nil)
- if err == nil {
- balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number)
- if err == nil {
- nonce, err = f.client.NonceAt(ctx, f.account.Address, nil)
- }
- }
- cancel()
+ // Send a few initial stats to the client
+ balance, _ := f.client.BalanceAt(context.Background(), f.account.Address, nil)
+ nonce, _ := f.client.NonceAt(context.Background(), f.account.Address, nil)
- // If stats retrieval failed, wait a bit and retry
- if err != nil {
- if err = sendError(conn, errors.New("Faucet offline: "+err.Error())); err != nil {
- log.Warn("Failed to send faucet error to client", "err", err)
- return
- }
- time.Sleep(3 * time.Second)
- continue
- }
- // Initial stats reported successfully, proceed with user interaction
- break
- }
- // Send over the initial stats and the latest header
- if err = send(conn, map[string]interface{}{
+ websocket.JSON.Send(conn, map[string]interface{}{
"funds": balance.Div(balance, ether),
"funded": nonce,
"peers": f.stack.Server().PeerCount(),
"requests": f.reqs,
- }, 3*time.Second); err != nil {
- log.Warn("Failed to send initial stats to client", "err", err)
- return
- }
- if err = send(conn, head, 3*time.Second); err != nil {
- log.Warn("Failed to send initial header to client", "err", err)
- return
+ })
+ // Send the initial block to the client
+ ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+ header, err := f.client.HeaderByNumber(ctx, nil)
+ cancel()
+
+ if err != nil {
+ log.Error("Failed to retrieve latest header", "err", err)
+ } else {
+ websocket.JSON.Send(conn, header)
}
// Keep reading requests from the websocket until the connection breaks
for {
@@ -371,25 +341,18 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
Tier uint `json:"tier"`
Captcha string `json:"captcha"`
}
- if err = websocket.JSON.Receive(conn, &msg); err != nil {
+ if err := websocket.JSON.Receive(conn, &msg); err != nil {
return
}
- if !strings.HasPrefix(msg.URL, "https://gist.github.com/") && !strings.HasPrefix(msg.URL, "https://twitter.com/") &&
- !strings.HasPrefix(msg.URL, "https://plus.google.com/") && !strings.HasPrefix(msg.URL, "https://www.facebook.com/") {
- if err = sendError(conn, errors.New("URL doesn't link to supported services")); err != nil {
- log.Warn("Failed to send URL error to client", "err", err)
- return
- }
+ if !strings.HasPrefix(msg.URL, "https://gist.github.com/") {
+ websocket.JSON.Send(conn, map[string]string{"error": "URL doesn't link to GitHub Gists"})
continue
}
if msg.Tier >= uint(*tiersFlag) {
- if err = sendError(conn, errors.New("Invalid funding tier requested")); err != nil {
- log.Warn("Failed to send tier error to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"error": "Invalid funding tier requested"})
continue
}
- log.Info("Faucet funds requested", "url", msg.URL, "tier", msg.Tier)
+ log.Info("Faucet funds requested", "gist", msg.URL, "tier", msg.Tier)
// If captcha verifications are enabled, make sure we're not dealing with a robot
if *captchaToken != "" {
@@ -399,10 +362,7 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
res, err := http.PostForm("https://www.google.com/recaptcha/api/siteverify", form)
if err != nil {
- if err = sendError(conn, err); err != nil {
- log.Warn("Failed to send captcha post error to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
continue
}
var result struct {
@@ -412,55 +372,74 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
err = json.NewDecoder(res.Body).Decode(&result)
res.Body.Close()
if err != nil {
- if err = sendError(conn, err); err != nil {
- log.Warn("Failed to send captcha decode error to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
continue
}
if !result.Success {
log.Warn("Captcha verification failed", "err", string(result.Errors))
- if err = sendError(conn, errors.New("Beep-bop, you're a robot!")); err != nil {
- log.Warn("Failed to send captcha failure to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"error": "Beep-bop, you're a robot!"})
continue
}
}
- // Retrieve the Ethereum address to fund, the requesting user and a profile picture
- var (
- username string
- avatar string
- address common.Address
- )
- switch {
- case strings.HasPrefix(msg.URL, "https://gist.github.com/"):
- username, avatar, address, err = authGitHub(msg.URL)
- case strings.HasPrefix(msg.URL, "https://twitter.com/"):
- username, avatar, address, err = authTwitter(msg.URL)
- case strings.HasPrefix(msg.URL, "https://plus.google.com/"):
- username, avatar, address, err = authGooglePlus(msg.URL)
- case strings.HasPrefix(msg.URL, "https://www.facebook.com/"):
- username, avatar, address, err = authFacebook(msg.URL)
- default:
- err = errors.New("Something funky happened, please open an issue at https://github.com/ethereum/go-ethereum/issues")
+ // Retrieve the gist from the GitHub Gist APIs
+ parts := strings.Split(msg.URL, "/")
+ req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil)
+ if *githubUser != "" {
+ req.SetBasicAuth(*githubUser, *githubToken)
+ }
+ res, err := http.DefaultClient.Do(req)
+ if err != nil {
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
+ continue
+ }
+ var gist struct {
+ Owner struct {
+ Login string `json:"login"`
+ } `json:"owner"`
+ Files map[string]struct {
+ Content string `json:"content"`
+ } `json:"files"`
}
+ err = json.NewDecoder(res.Body).Decode(&gist)
+ res.Body.Close()
if err != nil {
- if err = sendError(conn, err); err != nil {
- log.Warn("Failed to send prefix error to client", "err", err)
- return
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
+ continue
+ }
+ if gist.Owner.Login == "" {
+ websocket.JSON.Send(conn, map[string]string{"error": "Anonymous Gists not allowed"})
+ continue
+ }
+ // Iterate over all the files and look for Wtc addresses
+ var address common.Address
+ for _, file := range gist.Files {
+ content := strings.TrimSpace(file.Content)
+ if len(content) == 2+common.AddressLength*2 {
+ address = common.HexToAddress(content)
}
+ }
+ if address == (common.Address{}) {
+ websocket.JSON.Send(conn, map[string]string{"error": "No Wtc address found to fund"})
continue
}
- log.Info("Faucet request valid", "url", msg.URL, "tier", msg.Tier, "user", username, "address", address)
+ // Validate the user's existence since the API is unhelpful here
+ if res, err = http.Head("https://github.com/" + gist.Owner.Login); err != nil {
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
+ continue
+ }
+ res.Body.Close()
+ if res.StatusCode != 200 {
+ websocket.JSON.Send(conn, map[string]string{"error": "Invalid user... boom!"})
+ continue
+ }
// Ensure the user didn't request funds too recently
f.lock.Lock()
var (
fund bool
timeout time.Time
)
- if timeout = f.timeouts[username]; time.Now().After(timeout) {
+ if timeout = f.timeouts[gist.Owner.Login]; time.Now().After(timeout) {
// User wasn't funded recently, create the funding transaction
amount := new(big.Int).Mul(big.NewInt(int64(*payoutFlag)), ether)
amount = new(big.Int).Mul(amount, new(big.Int).Exp(big.NewInt(5), big.NewInt(int64(msg.Tier)), nil))
@@ -469,45 +448,33 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
tx := types.NewTransaction(f.nonce+uint64(len(f.reqs)), address, amount, big.NewInt(21000), f.price, nil)
signed, err := f.keystore.SignTx(f.account, tx, f.config.ChainId)
if err != nil {
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
f.lock.Unlock()
- if err = sendError(conn, err); err != nil {
- log.Warn("Failed to send transaction creation error to client", "err", err)
- return
- }
continue
}
// Submit the transaction and mark as funded if successful
if err := f.client.SendTransaction(context.Background(), signed); err != nil {
+ websocket.JSON.Send(conn, map[string]string{"error": err.Error()})
f.lock.Unlock()
- if err = sendError(conn, err); err != nil {
- log.Warn("Failed to send transaction transmission error to client", "err", err)
- return
- }
continue
}
f.reqs = append(f.reqs, &request{
- Avatar: avatar,
- Account: address,
- Time: time.Now(),
- Tx: signed,
+ Username: gist.Owner.Login,
+ Account: address,
+ Time: time.Now(),
+ Tx: signed,
})
- f.timeouts[username] = time.Now().Add(time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))) * time.Minute)
+ f.timeouts[gist.Owner.Login] = time.Now().Add(time.Duration(*minutesFlag*int(math.Pow(3, float64(msg.Tier)))) * time.Minute)
fund = true
}
f.lock.Unlock()
// Send an error if too frequent funding, othewise a success
if !fund {
- if err = sendError(conn, fmt.Errorf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))); err != nil {
- log.Warn("Failed to send funding error to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"error": fmt.Sprintf("%s left until next allowance", common.PrettyDuration(timeout.Sub(time.Now())))})
continue
}
- if err = sendSuccess(conn, fmt.Sprintf("Funding request accepted for %s into %s", username, address.Hex())); err != nil {
- log.Warn("Failed to send funding success to client", "err", err)
- return
- }
+ websocket.JSON.Send(conn, map[string]string{"success": fmt.Sprintf("Funding request accepted for %s into %s", gist.Owner.Login, address.Hex())})
select {
case f.update <- struct{}{}:
default:
@@ -530,32 +497,12 @@ func (f *faucet) loop() {
select {
case head := <-heads:
// New chain head arrived, query the current stats and stream to clients
- var (
- balance *big.Int
- nonce uint64
- price *big.Int
- err error
- )
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- balance, err = f.client.BalanceAt(ctx, f.account.Address, head.Number)
- if err == nil {
- nonce, err = f.client.NonceAt(ctx, f.account.Address, nil)
- if err == nil {
- price, err = f.client.SuggestGasPrice(ctx)
- }
- }
- cancel()
-
- // If querying the data failed, try for the next block
- if err != nil {
- log.Warn("Failed to update faucet state", "block", head.Number, "hash", head.Hash(), "err", err)
- continue
- } else {
- log.Info("Updated faucet state", "block", head.Number, "hash", head.Hash(), "balance", balance, "nonce", nonce, "price", price)
- }
- // Faucet state retrieved, update locally and send to clients
+ balance, _ := f.client.BalanceAt(context.Background(), f.account.Address, nil)
balance = new(big.Int).Div(balance, ether)
+ price, _ := f.client.SuggestGasPrice(context.Background())
+ nonce, _ := f.client.NonceAt(context.Background(), f.account.Address, nil)
+
f.lock.Lock()
f.price, f.nonce = price, nonce
for len(f.reqs) > 0 && f.reqs[0].Tx.Nonce() < f.nonce {
@@ -565,17 +512,17 @@ func (f *faucet) loop() {
f.lock.RLock()
for _, conn := range f.conns {
- if err := send(conn, map[string]interface{}{
+ if err := websocket.JSON.Send(conn, map[string]interface{}{
"funds": balance,
"funded": f.nonce,
"peers": f.stack.Server().PeerCount(),
"requests": f.reqs,
- }, time.Second); err != nil {
+ }); err != nil {
log.Warn("Failed to send stats to client", "err", err)
conn.Close()
continue
}
- if err := send(conn, head, time.Second); err != nil {
+ if err := websocket.JSON.Send(conn, head); err != nil {
log.Warn("Failed to send header to client", "err", err)
conn.Close()
}
@@ -586,7 +533,7 @@ func (f *faucet) loop() {
// Pending requests updated, stream to clients
f.lock.RLock()
for _, conn := range f.conns {
- if err := send(conn, map[string]interface{}{"requests": f.reqs}, time.Second); err != nil {
+ if err := websocket.JSON.Send(conn, map[string]interface{}{"requests": f.reqs}); err != nil {
log.Warn("Failed to send requests to client", "err", err)
conn.Close()
}
@@ -595,184 +542,3 @@ func (f *faucet) loop() {
}
}
}
-
-// sends transmits a data packet to the remote end of the websocket, but also
-// setting a write deadline to prevent waiting forever on the node.
-func send(conn *websocket.Conn, value interface{}, timeout time.Duration) error {
- if timeout == 0 {
- timeout = 60 * time.Second
- }
- conn.SetWriteDeadline(time.Now().Add(timeout))
- return websocket.JSON.Send(conn, value)
-}
-
-// sendError transmits an error to the remote end of the websocket, also setting
-// the write deadline to 1 second to prevent waiting forever.
-func sendError(conn *websocket.Conn, err error) error {
- return send(conn, map[string]string{"error": err.Error()}, time.Second)
-}
-
-// sendSuccess transmits a success message to the remote end of the websocket, also
-// setting the write deadline to 1 second to prevent waiting forever.
-func sendSuccess(conn *websocket.Conn, msg string) error {
- return send(conn, map[string]string{"success": msg}, time.Second)
-}
-
-// authGitHub tries to authenticate a faucet request using GitHub gists, returning
-// the username, avatar URL and Ethereum address to fund on success.
-func authGitHub(url string) (string, string, common.Address, error) {
- // Retrieve the gist from the GitHub Gist APIs
- parts := strings.Split(url, "/")
- req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil)
- if *githubUser != "" {
- req.SetBasicAuth(*githubUser, *githubToken)
- }
- res, err := http.DefaultClient.Do(req)
- if err != nil {
- return "", "", common.Address{}, err
- }
- var gist struct {
- Owner struct {
- Login string `json:"login"`
- } `json:"owner"`
- Files map[string]struct {
- Content string `json:"content"`
- } `json:"files"`
- }
- err = json.NewDecoder(res.Body).Decode(&gist)
- res.Body.Close()
- if err != nil {
- return "", "", common.Address{}, err
- }
- if gist.Owner.Login == "" {
- return "", "", common.Address{}, errors.New("Anonymous Gists not allowed")
- }
- // Iterate over all the files and look for Ethereum addresses
- var address common.Address
- for _, file := range gist.Files {
- content := strings.TrimSpace(file.Content)
- if len(content) == 2+common.AddressLength*2 {
- address = common.HexToAddress(content)
- }
- }
- if address == (common.Address{}) {
- return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
- }
- // Validate the user's existence since the API is unhelpful here
- if res, err = http.Head("https://github.com/" + gist.Owner.Login); err != nil {
- return "", "", common.Address{}, err
- }
- res.Body.Close()
-
- if res.StatusCode != 200 {
- return "", "", common.Address{}, errors.New("Invalid user... boom!")
- }
- // Everything passed validation, return the gathered infos
- return gist.Owner.Login + "@github", fmt.Sprintf("https://github.com/%s.png?size=64", gist.Owner.Login), address, nil
-}
-
-// authTwitter tries to authenticate a faucet request using Twitter posts, returning
-// the username, avatar URL and Ethereum address to fund on success.
-func authTwitter(url string) (string, string, common.Address, error) {
- // Ensure the user specified a meaningful URL, no fancy nonsense
- parts := strings.Split(url, "/")
- if len(parts) < 4 || parts[len(parts)-2] != "status" {
- return "", "", common.Address{}, errors.New("Invalid Twitter status URL")
- }
- username := parts[len(parts)-3]
-
- // Twitter's API isn't really friendly with direct links. Still, we don't
- // want to do ask read permissions from users, so just load the public posts and
- // scrape it for the Ethereum address and profile URL.
- res, err := http.Get(url)
- if err != nil {
- return "", "", common.Address{}, err
- }
- defer res.Body.Close()
-
- reader, err := zlib.NewReader(res.Body)
- if err != nil {
- return "", "", common.Address{}, err
- }
- body, err := ioutil.ReadAll(reader)
- if err != nil {
- return "", "", common.Address{}, err
- }
- address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
- if address == (common.Address{}) {
- return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
- }
- var avatar string
- if parts = regexp.MustCompile("src=\"([^\"]+twimg.com/profile_images[^\"]+)\"").FindStringSubmatch(string(body)); len(parts) == 2 {
- avatar = parts[1]
- }
- return username + "@twitter", avatar, address, nil
-}
-
-// authGooglePlus tries to authenticate a faucet request using GooglePlus posts,
-// returning the username, avatar URL and Ethereum address to fund on success.
-func authGooglePlus(url string) (string, string, common.Address, error) {
- // Ensure the user specified a meaningful URL, no fancy nonsense
- parts := strings.Split(url, "/")
- if len(parts) < 4 || parts[len(parts)-2] != "posts" {
- return "", "", common.Address{}, errors.New("Invalid Google+ post URL")
- }
- username := parts[len(parts)-3]
-
- // Google's API isn't really friendly with direct links. Still, we don't
- // want to do ask read permissions from users, so just load the public posts and
- // scrape it for the Ethereum address and profile URL.
- res, err := http.Get(url)
- if err != nil {
- return "", "", common.Address{}, err
- }
- defer res.Body.Close()
-
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return "", "", common.Address{}, err
- }
- address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
- if address == (common.Address{}) {
- return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
- }
- var avatar string
- if parts = regexp.MustCompile("src=\"([^\"]+googleusercontent.com[^\"]+photo.jpg)\"").FindStringSubmatch(string(body)); len(parts) == 2 {
- avatar = parts[1]
- }
- return username + "@google+", avatar, address, nil
-}
-
-// authFacebook tries to authenticate a faucet request using Facebook posts,
-// returning the username, avatar URL and Ethereum address to fund on success.
-func authFacebook(url string) (string, string, common.Address, error) {
- // Ensure the user specified a meaningful URL, no fancy nonsense
- parts := strings.Split(url, "/")
- if len(parts) < 4 || parts[len(parts)-2] != "posts" {
- return "", "", common.Address{}, errors.New("Invalid Facebook post URL")
- }
- username := parts[len(parts)-3]
-
- // Facebook's Graph API isn't really friendly with direct links. Still, we don't
- // want to do ask read permissions from users, so just load the public posts and
- // scrape it for the Ethereum address and profile URL.
- res, err := http.Get(url)
- if err != nil {
- return "", "", common.Address{}, err
- }
- defer res.Body.Close()
-
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return "", "", common.Address{}, err
- }
- address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
- if address == (common.Address{}) {
- return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
- }
- var avatar string
- if parts = regexp.MustCompile("src=\"([^\"]+fbcdn.net[^\"]+)\"").FindStringSubmatch(string(body)); len(parts) == 2 {
- avatar = parts[1]
- }
- return username + "@facebook", avatar, address, nil
-}
diff --git a/cmd/faucet/faucet.html b/cmd/faucet/faucet.html
old mode 100644
new mode 100755
index 5d3b8741b..f08bd5365
--- a/cmd/faucet/faucet.html
+++ b/cmd/faucet/faucet.html
@@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>{{.Network}}: Authenticated Faucet</title>
+ <title>{{.Network}}: GitHub Faucet</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
@@ -43,13 +43,13 @@
<div class="container">
<div class="row" style="margin-bottom: 16px;">
<div class="col-lg-12">
- <h1 style="text-align: center;"><i class="fa fa-bath" aria-hidden="true"></i> {{.Network}} Authenticated Faucet</h1>
+ <h1 style="text-align: center;"><i class="fa fa-bath" aria-hidden="true"></i> {{.Network}} GitHub Authenticated Faucet <i class="fa fa-github-alt" aria-hidden="true"></i></h1>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<div class="input-group">
- <input id="url" name="url" type="text" class="form-control" placeholder="Social network URL containing your Ethereum address...">
+ <input id="gist" type="text" class="form-control" placeholder="GitHub Gist URL containing your Wtc address...">
<span class="input-group-btn">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Give me Ether <i class="fa fa-caret-down" aria-hidden="true"></i></button>
<ul class="dropdown-menu dropdown-menu-right">{{range $idx, $amount := .Amounts}}
@@ -80,21 +80,8 @@
<div class="row" style="margin-top: 32px;">
<div class="col-lg-12">
<h3>How does this work?</h3>
- <p>This Ether faucet is running on the {{.Network}} network. To prevent malicious actors from exhausting all available funds or accumulating enough Ether to mount long running spam attacks, requests are tied to certain common 3rd party accounts. Anyone having a GitHub, Twitter, Google+ or Facebook account may request funds within the permitted limits.</p>
- <dl class="dl-horizontal">
- <dt style="width: auto; margin-left: 40px;"><i class="fa fa-github-alt" aria-hidden="true" style="font-size: 36px;"></i></dt>
- <dd style="margin-left: 88px; margin-bottom: 10px;"></i> To request funds via GitHub, create a <a href="https://gist.github.com/" target="_about:blank">gist</a> with your Ethereum address embedded into the content (the file name doesn't matter).<br/>Copy-paste the gists URL into the above input box and fire away!</dd>
-
- <dt style="width: auto; margin-left: 40px;"><i class="fa fa-twitter" aria-hidden="true" style="font-size: 36px;"></i></dt>
- <dd style="margin-left: 88px; margin-bottom: 10px;"></i> To request funds via Twitter, make a <a href="https://twitter.com/intent/tweet?text=Requesting%20faucet%20funds%20into%200x0000000000000000000000000000000000000000%20on%20the%20%23{{.Network}}%20%23Ethereum%20test%20network." target="_about:blank">tweet</a> with your Ethereum address pasted into the contents (surrounding text doesn't matter).<br/>Copy-paste the <a href="https://support.twitter.com/articles/80586" target="_about:blank">tweets URL</a> into the above input box and fire away!</dd>
-
- <dt style="width: auto; margin-left: 40px;"><i class="fa fa-google-plus-official" aria-hidden="true" style="font-size: 36px;"></i></dt>
- <dd style="margin-left: 88px; margin-bottom: 10px;"></i> To request funds via Google Plus, publish a new <strong>public</strong> post with your Ethereum address embedded into the content (surrounding text doesn't matter).<br/>Copy-paste the posts URL into the above input box and fire away!</dd>
-
- <dt style="width: auto; margin-left: 40px;"><i class="fa fa-facebook" aria-hidden="true" style="font-size: 36px;"></i></dt>
- <dd style="margin-left: 88px; margin-bottom: 10px;"></i> To request funds via Facebook, publish a new <strong>public</strong> post with your Ethereum address embedded into the content (surrounding text doesn't matter).<br/>Copy-paste the <a href="https://www.facebook.com/help/community/question/?id=282662498552845" target="_about:blank">posts URL</a> into the above input box and fire away!</dd>
- </dl>
- <p>You can track the current pending requests below the input field to see how much you have to wait until your turn comes.</p>
+ <p>This Ether faucet is running on the {{.Network}} network. To prevent malicious actors from exhausting all available funds or accumulating enough Ether to mount long running spam attacks, requests are tied to GitHub accounts. Anyone having a GitHub account may request funds within the permitted limits.</p>
+ <p>To request funds, simply create a <a href="https://gist.github.com/" target="_about:blank">GitHub Gist</a> with your Wtc address pasted into the contents (the file name doesn't matter), copy paste the gists URL into the above input box and fire away! You can track the current pending requests below the input field to see how much you have to wait until your turn comes.</p>
{{if .Recaptcha}}<em>The faucet is running invisible reCaptcha protection against bots.</em>{{end}}
</div>
</div>
@@ -106,22 +93,10 @@
var attempt = 0;
var server;
var tier = 0;
- var requests = [];
- // Define a function that creates closures to drop old requests
- var dropper = function(hash) {
- return function() {
- for (var i=0; i<requests.length; i++) {
- if (requests[i].tx.hash == hash) {
- requests.splice(i, 1);
- break;
- }
- }
- }
- };
// Define the function that submits a gist url to the server
var submit = function({{if .Recaptcha}}captcha{{end}}) {
- server.send(JSON.stringify({url: $("#url")[0].value, tier: tier{{if .Recaptcha}}, captcha: captcha{{end}}}));{{if .Recaptcha}}
+ server.send(JSON.stringify({url: $("#gist")[0].value, tier: tier{{if .Recaptcha}}, captcha: captcha{{end}}}));{{if .Recaptcha}}
grecaptcha.reset();{{end}}
};
// Define a method to reconnect upon server loss
@@ -152,85 +127,21 @@
$("#block").text(parseInt(msg.number, 16));
}
if (msg.error !== undefined) {
- noty({layout: 'topCenter', text: msg.error, type: 'error', timeout: 5000, progressBar: true});
+ noty({layout: 'topCenter', text: msg.error, type: 'error'});
}
if (msg.success !== undefined) {
- noty({layout: 'topCenter', text: msg.success, type: 'success', timeout: 5000, progressBar: true});
+ noty({layout: 'topCenter', text: msg.success, type: 'success'});
}
if (msg.requests !== undefined && msg.requests !== null) {
- // Mark all previous requests missing as done
- for (var i=0; i<requests.length; i++) {
- if (msg.requests.length > 0 && msg.requests[0].tx.hash == requests[i].tx.hash) {
- break;
- }
- if (requests[i].time != "") {
- requests[i].time = "";
- setTimeout(dropper(requests[i].tx.hash), 3000);
- }
- }
- // Append any new requests into our local collection
- var common = -1;
- if (requests.length > 0) {
- for (var i=0; i<msg.requests.length; i++) {
- if (requests[requests.length-1].tx.hash == msg.requests[i].tx.hash) {
- common = i;
- break;
- }
- }
- }
- for (var i=common+1; i<msg.requests.length; i++) {
- requests.push(msg.requests[i]);
- }
- // Iterate over our entire local collection and re-render the funding table
var content = "";
- for (var i=0; i<requests.length; i++) {
- var done = requests[i].time == "";
- var elapsed = moment().unix()-moment(requests[i].time).unix();
-
- content += "<tr id='" + requests[i].tx.hash + "'>";
- content += " <td><div style=\"background: url('" + requests[i].avatar + "'); background-size: cover; width:32px; height: 32px; border-radius: 4px;\"></div></td>";
- content += " <td><pre>" + requests[i].account + "</pre></td>";
- content += " <td style=\"width: 100%; text-align: center; vertical-align: middle;\">";
- if (done) {
- content += " funded";
- } else {
- content += " <span id='time-" + i + "' class='timer'>" + moment.duration(-elapsed, 'seconds').humanize(true) + "</span>";
- }
- content += " <div class='progress' style='height: 4px; margin: 0;'>";
- if (done) {
- content += " <div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='30' style='width:100%;'></div>";
- } else if (elapsed > 30) {
- content += " <div class='progress-bar progress-bar-danger progress-bar-striped active' role='progressbar' aria-valuenow='30' style='width:100%;'></div>";
- } else {
- content += " <div class='progress-bar progress-bar-striped active' role='progressbar' aria-valuenow='" + elapsed + "' style='width:" + (elapsed * 100 / 30) + "%;'></div>";
- }
- content += " </div>";
- content += " </td>";
- content += "</tr>";
+ for (var i=0; i<msg.requests.length; i++) {
+ content += "<tr><td><div style=\"background: url('https://github.com/" + msg.requests[i].username + ".png?size=64'); background-size: cover; width:32px; height: 32px; border-radius: 4px;\"></div></td><td><pre>" + msg.requests[i].account + "</pre></td><td style=\"width: 100%; text-align: center; vertical-align: middle;\">" + moment.duration(moment(msg.requests[i].time).unix()-moment().unix(), 'seconds').humanize(true) + "</td></tr>";
}
$("#requests").html("<tbody>" + content + "</tbody>");
}
}
server.onclose = function() { setTimeout(reconnect, 3000); };
}
- // Start a UI updater to push the progress bars forward until they are done
- setInterval(function() {
- $('.progress-bar').each(function() {
- var progress = Number($(this).attr('aria-valuenow')) + 1;
- if (progress < 30) {
- $(this).attr('aria-valuenow', progress);
- $(this).css('width', (progress * 100 / 30) + '%');
- } else if (progress == 30) {
- $(this).css('width', '100%');
- $(this).addClass("progress-bar-danger");
- }
- })
- $('.timer').each(function() {
- var index = Number($(this).attr('id').substring(5));
- $(this).html(moment.duration(moment(requests[index].time).unix()-moment().unix(), 'seconds').humanize(true));
- })
- }, 1000);
-
// Establish a websocket connection to the API server
reconnect();
</script>{{if .Recaptcha}}
diff --git a/cmd/faucet/website.go b/cmd/faucet/website.go
old mode 100644
new mode 100755
index 6a99f8c6f..3151ab584
--- a/cmd/faucet/website.go
+++ b/cmd/faucet/website.go
@@ -68,7 +68,7 @@ func (fi bindataFileInfo) Sys() interface{} {
return nil
}
-var _faucetHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x3a\x7f\x73\xdb\xb6\x92\x7f\x3b\x9f\x62\xcb\x8b\x9f\xa4\xb3\x48\xca\x76\x92\xe7\x93\x48\x75\x72\x79\x7d\x7d\xb9\xb9\xeb\xeb\xb4\xe9\xdc\xbd\x69\x3b\x37\x20\xb1\x12\x11\x83\x00\x0b\x80\x92\x55\x8f\xbe\xfb\x0d\x00\x92\xa2\x7e\xd8\x71\x9a\xdc\x5d\xfc\x87\x4c\x00\x8b\xdd\xc5\xfe\xc6\x92\xc9\x57\x7f\xf9\xfb\x9b\x77\xff\xf8\xfe\x1b\x28\x4c\xc9\xe7\xcf\x12\xfb\x0f\x38\x11\xcb\x34\x40\x11\xcc\x9f\x9d\x25\x05\x12\x3a\x7f\x76\x76\x96\x94\x68\x08\xe4\x05\x51\x1a\x4d\x1a\xd4\x66\x11\xde\x04\xbb\x85\xc2\x98\x2a\xc4\xdf\x6a\xb6\x4a\x83\xff\x0a\x7f\x7a\x1d\xbe\x91\x65\x45\x0c\xcb\x38\x06\x90\x4b\x61\x50\x98\x34\x78\xfb\x4d\x8a\x74\x89\xbd\x7d\x82\x94\x98\x06\x2b\x86\xeb\x4a\x2a\xd3\x03\x5d\x33\x6a\x8a\x94\xe2\x8a\xe5\x18\xba\xc1\x18\x98\x60\x86\x11\x1e\xea\x9c\x70\x4c\x2f\x83\xf9\x33\x8b\xc7\x30\xc3\x71\x7e\x7f\x1f\x7d\x87\x66\x2d\xd5\xed\x76\x3b\x85\xd7\xb5\x29\x50\x18\x96\x13\x83\x14\xfe\x4a\xea\x1c\x4d\x12\x7b\x48\xb7\x89\x33\x71\x0b\x85\xc2\x45\x1a\x58\xd6\xf5\x34\x8e\x73\x2a\xde\xeb\x28\xe7\xb2\xa6\x0b\x4e\x14\x46\xb9\x2c\x63\xf2\x9e\xdc\xc5\x9c\x65\x3a\x36\x6b\x66\x0c\xaa\x30\x93\xd2\x68\xa3\x48\x15\x5f\x47\xd7\xd1\x9f\xe3\x5c\xeb\xb8\x9b\x8b\x4a\x26\xa2\x5c\xeb\x00\x14\xf2\x34\xd0\x66\xc3\x51\x17\x88\x26\x80\x78\xfe\xc7\xe8\x2e\xa4\x30\x21\x59\xa3\x96\x25\xc6\x2f\xa2\x3f\x47\x13\x47\xb2\x3f\xfd\x38\x55\x4b\x56\xe7\x8a\x55\x06\xb4\xca\x9f\x4c\xf7\xfd\x6f\x35\xaa\x4d\x7c\x1d\x5d\x46\x97\xcd\xc0\xd1\x79\xaf\x83\x79\x12\x7b\x84\xf3\x4f\xc2\x1d\x0a\x69\x36\xf1\x55\xf4\x22\xba\x8c\x2b\x92\xdf\x92\x25\xd2\x96\x92\x5d\x8a\xda\xc9\xcf\x46\xf7\x21\x1d\xbe\x3f\x54\xe1\xe7\x20\x56\xca\x12\x85\x89\xde\xeb\xf8\x2a\xba\xbc\x89\x26\xed\xc4\x31\x7e\x47\xc0\x2a\xcd\x92\x3a\x8b\x56\xa8\xac\xe5\xf2\x30\x47\x61\x50\xc1\xbd\x9d\x3d\x2b\x99\x08\x0b\x64\xcb\xc2\x4c\xe1\x72\x32\x39\x9f\x9d\x9a\x5d\x15\x7e\x9a\x32\x5d\x71\xb2\x99\xc2\x82\xe3\x9d\x9f\x22\x9c\x2d\x45\xc8\x0c\x96\x7a\x0a\x1e\xb3\x5b\xd8\x3a\x9a\x95\x92\x4b\x85\x5a\x37\xc4\x2a\xa9\x99\x61\x52\x4c\xad\x45\x11\xc3\x56\x78\x0a\x56\x57\x44\x1c\x6d\x20\x99\x96\xbc\x36\x78\xc0\x48\xc6\x65\x7e\xeb\xe7\x9c\x37\xf7\x0f\x91\x4b\x2e\xd5\x14\xd6\x05\x6b\xb6\x81\x23\x04\x95\xc2\x06\x3d\x54\x84\x52\x26\x96\x53\x78\x55\x35\xe7\x81\x92\xa8\x25\x13\x53\x98\xec\xb6\x24\x71\x2b\xc6\x24\xf6\x81\xeb\xd9\x59\x92\x49\xba\x71\x3a\xa4\x6c\x05\x39\x27\x5a\xa7\xc1\x81\x88\x5d\x40\xda\x03\xb0\x71\x88\x30\xd1\x2e\xed\xad\x29\xb9\x0e\xc0\x11\x4a\x03\xcf\x44\x98\x49\x63\x64\x39\x85\x4b\xcb\x5e\xb3\xe5\x00\x1f\x0f\xf9\x32\xbc\xbc\x6a\x17\xcf\x92\xe2\xb2\x45\x62\xf0\xce\x84\x4e\x3f\x9d\x66\x82\x79\xc2\xda\xbd\x0b\x02\x0b\x12\x66\xc4\x14\x01\x10\xc5\x48\x58\x30\x4a\x51\xa4\x81\x51\x35\x5a\x3b\x62\x73\xe8\x87\xbf\x07\xa2\x5f\x71\xd9\xf2\x15\x53\xb6\x6a\x8e\xd5\x7b\x3c\x38\xe1\xc3\x87\xb8\x81\xe6\x41\x2e\x16\x1a\x4d\xd8\x3b\x53\x0f\x98\x89\xaa\x36\xe1\x52\xc9\xba\xea\xd6\xcf\x12\x37\x0b\x8c\xa6\x41\xad\x78\xd0\x84\x7f\xf7\x68\x36\x55\x23\x8a\xa0\x3b\xb8\x54\x65\x68\x35\xa1\x24\x0f\xa0\xe2\x24\xc7\x42\x72\x8a\x2a\x0d\x7e\x94\x39\x23\x1c\x84\x3f\x33\xfc\xf4\xc3\xbf\x43\xa3\x32\x26\x96\xb0\x91\xb5\x82\x6f\x4c\x81\x0a\xeb\x12\x08\xa5\xd6\x5c\xa3\x28\xea\x31\xe2\x6c\xf7\x98\xd5\x30\x33\x62\x07\x75\x96\x64\xb5\x31\xb2\x03\xcc\x8c\x80\xcc\x88\x90\xe2\x82\xd4\xdc\x00\x55\xb2\xa2\x72\x2d\x42\x23\x97\x4b\x9b\xe9\xfc\x21\xfc\xa6\x00\x28\x31\xa4\x59\x4a\x83\x16\xb6\xd5\x21\xd1\x95\xac\xea\xaa\xd1\xa2\x9f\xc4\xbb\x8a\x08\x8a\xd4\xea\x9c\x6b\x0c\xe6\xdf\xb2\x15\x42\x89\xfe\x2c\x67\x87\x26\x91\x13\x85\x26\xec\x23\x3d\x32\x8c\x24\xf6\xcc\xf8\x23\x41\xf3\x97\xd4\xbc\xc5\xd4\x1d\xa1\x44\x51\xc3\xde\x28\x54\x36\xae\x04\xf3\xfb\x7b\x45\xc4\x12\xe1\x39\xa3\x77\x63\x78\x4e\x4a\x59\x0b\x03\xd3\x14\xa2\xd7\xee\x51\x6f\xb7\x7b\xd8\x01\x12\xce\xe6\x09\x79\xcc\xbc\x41\x8a\x9c\xb3\xfc\x36\x0d\x0c\x43\x95\xde\xdf\x5b\xe4\xdb\xed\x0c\xee\xef\xd9\x02\x9e\x47\x3f\x60\x4e\x2a\x93\x17\x64\xbb\x5d\xaa\xf6\x39\xc2\x3b\xcc\x6b\x83\xc3\xd1\xfd\x3d\x72\x8d\xdb\xad\xae\xb3\x92\x99\x61\xbb\xdd\xce\x0b\xba\xdd\x5a\x9e\x1b\x3e\xb7\x5b\x88\x2d\x52\x41\xf1\x0e\x9e\x47\xdf\xa3\x62\x92\x6a\xf0\xf0\x49\x4c\xe6\x49\xcc\xd9\xbc\xd9\xb7\x2f\xa4\xb8\xe6\x3b\x7b\x89\xad\xc1\x74\x76\xee\xdc\xc6\xb1\xda\xe7\xf4\x84\x17\x2c\xc3\x8e\xfb\xc6\x1e\x34\x33\x78\x8b\x9b\x34\xb8\xbf\xef\xef\x6d\x56\x73\xc2\x79\x46\xac\x5c\xfc\xd1\xba\x4d\xbf\xa3\xb5\xd3\x15\xd3\xae\xa4\x9a\xb7\x1c\xec\xd8\x7e\xa2\x5b\x1f\x04\x2e\x23\xab\x29\x5c\x5f\xf5\xa2\xd6\x29\x8f\x7f\x75\xe0\xf1\xd7\x27\x81\x2b\x22\x90\x83\xfb\x0d\x75\x49\x78\xfb\xdc\x78\x4b\xcf\xf9\x0e\x37\x85\x36\x46\x77\xac\x75\xb1\x7e\x32\x03\xb9\x42\xb5\xe0\x72\x3d\x05\x52\x1b\x39\x83\x92\xdc\x75\xf9\xee\x7a\x32\xe9\xf3\x6d\x4b\x41\x92\x71\x74\xd1\x45\xe1\x6f\x35\x6a\xa3\xbb\x58\xe2\x97\xdc\xaf\x0d\x29\x14\x85\x46\x7a\x20\x0d\x4b\xd1\x8a\xd6\x41\xf5\x54\xdf\x09\xf3\x24\xef\x0b\x29\xbb\x14\xd2\x67\xa3\x41\xdd\xcb\x76\xc1\x3c\x31\x6a\x07\x77\x96\x18\xfa\x51\x29\x40\xd9\x12\xef\xa1\x0c\xe0\x23\x9a\x3d\x7b\x85\xa8\x7c\x7d\x61\x4d\x16\xdc\x30\x89\x0d\xfd\x04\xca\xd6\x08\x33\xa2\xf1\x29\xe4\x5d\xa6\xdf\x91\x77\xc3\x4f\xa5\x5f\x20\x51\x26\x43\x62\x9e\xc2\xc0\xa2\x16\xb4\x77\x7e\x17\x3b\x3f\x95\x81\x5a\xb0\x15\x2a\xcd\xcc\xe6\xa9\x1c\x20\xdd\xb1\xe0\xc7\xfb\x2c\x24\xb1\x51\x8f\xdb\x5a\x7f\xf0\x99\x9c\xfb\x43\x25\xc9\xf5\xfc\x6f\x72\x0d\x54\xa2\x06\x53\x30\x0d\x36\xb9\x7e\x9d\xc4\xc5\x75\x07\x52\xcd\xdf\xd9\x05\x27\x54\x58\xb8\xd2\x02\x98\x06\x55\x0b\x97\x79\xa5\x00\x53\xe0\x7e\x39\xd2\x24\xe9\x08\xde\x49\x5b\xd2\xad\x50\x18\x28\x09\x67\x39\x93\xb5\x06\x92\x1b\xa9\x34\x2c\x94\x2c\x01\xef\x0a\x52\x6b\x63\x11\xd9\xf0\x41\x56\x84\x71\xe7\x4b\x4e\xa5\x20\x15\x90\x3c\xaf\xcb\xda\x96\xa4\x62\x09\x28\x64\xbd\x2c\x1a\x5e\x8c\x04\x9f\x98\xb8\x14\xcb\x8e\x1f\x5d\x91\x12\x88\x31\x24\xbf\xd5\x63\x68\xa3\x02\x10\x85\x60\x18\x52\xbb\x2b\x47\x65\xeb\x06\xc8\x65\x59\x4a\x01\xd7\x8a\x42\x45\x94\xd9\x58\x5a\x2e\xbd\x45\xf0\x5a\x6c\xa4\x40\x28\xc8\xca\xb1\x06\xdf\x32\xf3\xb7\x3a\x1b\xc3\x3b\x7f\x9f\x18\xc3\xb7\x52\x2e\x39\x5e\x58\x0e\xff\x4a\x72\xcc\xa4\xbc\x6d\xb7\x43\x49\x36\x2d\xe1\xe6\x1c\x6b\x66\x0a\xe6\x05\x55\xa1\x2a\x2d\x0e\x0a\x9c\x95\xcc\xe8\x28\x89\xab\x5d\x6c\xdd\x65\x69\x1e\x16\x52\xb1\xdf\x6d\x89\xc3\x3b\x7d\x01\x24\xd4\x1c\xc4\x99\x36\x4c\x3a\x03\xe0\xb8\x30\x53\x78\xe1\xc3\xe4\xa1\x49\x2f\x99\x29\xea\x2c\x24\xfc\xa4\x53\xb5\x68\xdd\x3d\xd3\xa6\x9f\x29\x5c\xfb\xe2\xd6\x97\x15\xd4\xf4\x42\x22\x3d\x30\x3c\x4f\xf7\xe6\xa6\xba\xeb\x58\xe9\x2a\xe4\x49\x87\xc4\xda\xc3\xbe\x60\x56\x6c\x27\xdb\x5c\x21\x31\x08\x04\x12\x72\x70\x61\x5e\x32\x6d\x22\xcf\xbd\xbb\x72\x05\x60\x88\x5a\xa2\x49\x83\xff\x26\x99\xac\xcd\x34\xe3\x44\xdc\x06\x73\x0b\x67\x33\xbc\x93\xf7\xe9\x9a\x10\xb0\xcc\x90\x52\xa4\xc0\x84\x91\x4e\x23\x4d\x07\x02\x86\x76\xb0\x60\x1c\x5d\x91\xea\x7c\x42\x0c\xac\x36\xad\xc6\x47\x51\x92\xa9\x78\xfe\x46\x56\x9b\xb0\x22\xda\xa0\xdb\x6a\x09\x6a\x57\x8b\x76\xd8\x48\x26\x57\x08\xbe\xea\xcd\xe4\x1d\x10\x41\x61\xc1\x14\x02\x59\x93\xcd\x57\x49\x4c\xdd\x1d\xa5\x95\xe3\x1f\x57\x66\x73\xb3\xfd\xa2\x34\xd9\x79\x47\x49\x6e\x4f\x2a\xb2\x61\xda\x29\x91\x39\xa9\xc7\x66\x8d\x68\xbe\xb6\x21\x39\xfd\xc1\x23\x64\x62\x79\x7e\x35\xf1\x91\xc6\x3e\x58\xf4\xe7\x57\x13\x2b\xe1\xf3\xab\xc9\xe4\x6e\xf2\xc4\xbf\xf3\xab\x89\x14\xe7\x57\x13\x53\xe0\xf9\xd5\xe4\xfc\xea\xba\x1f\xa3\xfc\x4c\x6b\x1d\x16\x0a\xb5\xa5\xd6\x86\xae\x87\x4c\xcc\xb1\xfb\x21\x1b\x73\x06\x72\x6c\x61\x1a\x86\xba\x56\x4a\xd6\xc2\x56\x3b\x60\xcf\xfc\x24\x2b\x3b\x12\xa3\xae\xab\x4a\x2a\x13\xf5\xc5\x49\xec\xfd\x96\xa3\x8e\x6f\x26\x2f\x6f\x5e\x3d\xca\xbe\xb3\x58\x77\x86\xff\x73\xab\x5d\xba\xb0\x19\x56\xbc\xd6\xb6\xb4\x64\xf6\x4e\xf7\x45\x99\xb0\x8f\xeb\xf0\x3d\xaf\xf5\x18\xaa\x3a\xe3\x4c\x17\x40\x40\xe0\x1a\x12\x6d\x94\x14\xcb\xb9\x9b\xcd\x93\xb8\x19\x42\x25\xb5\xf9\x83\x11\xe7\x0f\x99\x83\xa5\xf7\xff\x14\x74\x16\x4d\xaa\xfb\xa2\x54\xd6\xe6\xdf\x2f\x55\x5f\x47\xee\xbb\x5e\xaf\xa3\x56\x92\xce\x77\x0b\xe4\x55\x6c\xab\x91\x5a\x30\xb3\x89\x7d\x14\x94\x22\xfe\x9a\xd1\xf4\xea\xe6\xea\xd5\xab\xab\x17\xff\x72\xf3\xf2\xe5\xd5\xcd\x8b\x97\x0f\x39\x76\x67\x14\x1f\xef\xd7\x5d\xed\xc9\x7b\x35\xdf\x3f\x64\x0d\x39\x11\x60\x14\xc9\x6f\xbd\x10\x6a\xa5\xac\x10\x2a\xf4\xe7\xef\x4a\xab\x0c\xb9\x5c\x3b\x10\x4f\x67\xc1\x90\xbb\x3a\x4b\x23\x42\x21\xd7\x50\xd6\xb9\x93\xb5\x2d\xa7\xd0\x2e\xac\x09\x33\x50\x0b\xc3\xb8\x57\x81\xa9\x95\xab\xc6\x70\xaf\x1a\x3a\xba\x6d\x27\x58\xce\xdf\xd9\x1c\x7d\x54\x84\x76\xf7\x64\x50\xf8\xc6\x83\x43\xa5\xa4\xc1\xdc\xca\x11\xc8\x92\x30\xa1\xad\x04\x5c\xbd\x85\xe5\x13\xee\xd1\xdd\x53\xf3\xb0\xeb\x09\xbb\xe5\x38\x86\x6f\xb9\xcc\x08\x87\x95\x75\x85\x8c\xdb\x02\x5a\x42\x21\xed\xd1\x7b\xd2\xd2\x86\x98\x5a\x83\x5c\xb8\x59\xcf\xb9\xdd\xbf\x22\xca\x56\xa9\x58\x56\x06\xd2\xa6\xa3\x69\xe7\x34\xaa\x55\xd3\xa7\xb5\x43\xc3\x50\xed\xad\x77\x52\x4f\xe1\xe7\x5f\x67\xcf\x1a\x56\xfe\x82\x0b\x26\x6c\xc6\x5d\xd4\xc2\x1f\xd9\x14\xc4\x34\x15\x95\x86\x9c\x4b\x5d\x2b\xcf\x21\x55\xb2\x02\xcb\x65\x8b\xa9\xc5\x6c\x17\x2a\x47\xad\x45\x32\x2c\x88\x2e\x46\x4d\x43\x56\xa1\xd3\x52\xb7\xd6\xce\x9f\x2d\xa4\x82\xa1\x45\xc0\xd2\xc9\x0c\x58\xd2\xe2\x8d\x38\x8a\xa5\x29\x66\xc0\x2e\x2e\x3a\xe0\x33\xb6\x80\x61\x0b\xf1\x33\xfb\x35\x32\x77\x91\xa5\x02\x69\x0a\x7d\x6a\x8e\x60\x83\x47\x57\x9c\xe5\x38\x64\x63\xb8\x1c\xcd\xda\xd5\x4c\x21\xb9\x6d\x47\x8d\x1e\xfd\x3f\xf7\xbb\x9d\xed\x4b\xc6\x09\x7f\x4f\x36\xbe\xdb\xa2\x81\xb8\x22\x0e\x6a\xc5\xa1\xf1\x19\xaf\x82\x4e\x21\x0e\xae\x2f\x95\x23\xbb\x6c\x1e\x1a\x9b\x6a\x8f\xe0\xd1\x44\x1a\x05\x1d\xfe\xdb\x8f\x7f\xff\x2e\xd2\x46\x31\xb1\x64\x8b\xcd\xf0\xbe\x56\x7c\x0a\xcf\x87\xc1\x3f\xd5\x8a\x07\xa3\x9f\x27\xbf\x46\x2b\xc2\x6b\x1c\x3b\x7d\x4f\xdd\xef\x11\x95\x31\x34\x8f\x53\xd8\x27\xb8\x1d\x8d\x66\xa7\x3b\x53\xbd\x46\x9a\x42\x8d\x66\x68\x01\x3b\xc3\x3f\x94\x11\x81\x12\x4d\x21\x9d\xeb\x2a\xcc\xa5\x10\x98\x1b\xa8\x2b\x29\x1a\x91\x00\x97\x5a\xef\x0c\xb1\x85\x48\x8f\x8d\xc2\x6a\xb9\xb5\xee\x73\xb8\xb2\xda\x9d\x74\xaa\x6d\x90\xa5\x2e\x48\xff\x27\x66\x3f\xca\xfc\x16\xcd\x30\x58\x6b\x1b\x1c\x03\xb8\x00\x2e\x73\x62\xf1\x45\x85\x0d\xd5\x17\x10\xc4\xa4\x62\x41\xa3\xfc\x2d\x20\xd7\xf8\x61\x64\x4f\xc2\xe5\x5f\x94\x78\x4e\x2f\x2e\xbc\x3f\xb5\x9a\x93\xa2\x44\xad\xc9\x12\xfb\x27\x74\x97\xd9\xee\x28\x56\x10\xa5\x5e\x42\x0a\x4e\xc3\x15\x51\x1a\x3d\x48\x44\x89\x21\xad\xb9\x5a\x71\x38\xb0\x34\x05\x51\x73\xbe\xb3\x72\xef\x55\xb3\xd6\x7e\xf7\xc0\x23\x9f\xe2\xbe\x4a\x53\xa8\x05\x75\x3a\xa2\xbb\x9d\xd6\x7a\x7c\xdf\x63\x14\xd9\x54\xb4\xdb\x31\x9a\xf5\xdd\x61\x0f\x1b\xd2\x0f\xa1\x43\x7a\x88\x0f\xe9\x03\x08\x5d\x9b\xe9\x31\x7c\xbe\x2d\xd5\x43\xe7\x26\x1e\xc0\x26\xea\x32\x43\xf5\x18\x3a\xdf\x66\x6a\xd0\x39\x51\xbf\x15\xa6\xb7\x77\x0c\x97\xaf\x46\x0f\x60\x47\xa5\xe4\x83\xc8\x85\x34\x9b\xe1\x3d\x27\x1b\x9b\x4f\x61\x60\x64\xf5\xc6\x75\x85\x06\x63\x97\xe4\xa7\xd0\x61\x18\xbb\x7e\xff\x14\x06\x6e\x64\xd7\x59\x89\x6e\xd7\xcb\xc9\x64\x32\x86\xf6\x45\xd9\xbf\x12\xeb\xc5\xaa\xc6\xed\x03\xfc\xe8\x3a\xcf\x6d\xad\xf1\x29\x1c\x35\x38\x3a\x9e\x9a\xf1\x27\x70\xd5\x25\x97\x3d\xb6\xe0\x4f\x7f\x82\xa3\xd5\x7d\x33\x8e\x63\xf8\x0f\xa2\x6e\x5d\x0f\xa7\x52\xb8\x72\x7d\x9e\x0e\xbe\x64\x5a\xbb\x36\x8a\x06\x2a\x05\x36\x7b\x3e\x2e\x6f\x1c\xf1\xd8\x80\xc1\x1c\x26\x87\x0c\xda\x78\xda\xcb\x2b\x27\xd2\x4d\x0f\xef\x7e\x26\x69\x25\x72\x22\x51\xb1\x12\xe1\xab\x14\x82\xa0\xbf\xf9\x08\xc2\x02\x74\xc8\xce\x34\x9a\x77\x5e\x17\xc3\x26\xbd\x9e\x4a\x7e\xa3\x31\x5c\x4f\x26\x93\xd1\x11\x13\xdb\x9d\x78\x5f\x57\xb6\xee\x02\x22\x36\x2e\xd2\x75\xb2\x75\x95\x9e\xad\xa1\x6c\x9c\xe3\x90\x4b\xce\x7d\xd1\xd3\x6c\xb5\x02\x6e\xfa\x5c\x29\x84\x97\xb3\x13\x69\xb8\x27\xc9\xde\xd1\x0e\xd5\x73\x42\xf6\x87\x2a\xda\x97\xd9\x01\x70\x78\xb9\xa7\x94\x3d\x7d\x9d\x56\xcc\x59\xc7\x37\xdb\x49\xf4\x40\x5d\x3b\x7d\x1d\xca\xac\xc7\xbf\xc7\x73\x71\xf9\xc4\x63\x74\xcb\x55\xad\x8b\xe1\x01\xa3\xa3\xd9\xb1\x6e\xde\x1a\x54\xc4\xa0\x7b\x75\xe1\x74\x81\xc2\xd8\x1a\xfb\x50\x25\xae\xfa\x56\x18\x2a\x14\x14\x55\x5b\x93\xf8\xcb\x84\xad\x20\xf7\x54\xe6\x6f\x1c\x7d\x73\xfa\x48\x87\x71\x35\x9d\x14\x08\x00\x70\xe0\x04\xce\x50\xf7\x2c\xd5\x02\x23\x27\x95\x46\x0a\x29\xf8\xef\x16\x86\xa3\xa8\x16\xec\x6e\x38\x0a\x9b\xf1\x21\x8e\x76\x7d\xd6\xdd\x2d\x5b\xb6\x2f\x52\x08\x12\xa3\x80\xd1\x74\x60\x93\xf0\xa9\x8a\xef\x02\x82\xc1\x7c\xc7\x41\x7f\x2b\x40\x62\xe8\xdc\xb5\xae\xfd\x35\xf1\x97\x20\x23\xf9\xed\xd2\xdd\xbd\xa6\xb6\x56\x1b\x1e\xa1\x25\x2b\x62\x88\x72\x58\x47\x33\xd8\x81\x37\x57\xd1\xdc\x2a\x67\x06\xfe\xc6\xeb\x3a\xe4\xd0\xbd\x55\x72\xa3\x4c\x2a\x8a\x2a\x54\x84\xb2\x5a\x4f\xe1\x45\x75\x37\xfb\xa5\x7d\xeb\xe6\xfa\xf8\x8f\xb2\x5a\x29\x9c\x1f\x71\xd4\xb4\x83\x2f\x20\x48\x62\x0b\xf0\x21\x34\xdd\x61\xfb\xdf\x4b\xc0\x89\xb7\x15\xd0\x7d\xcd\xd0\xcc\x97\x8c\x52\x8e\x96\xe1\x1d\x7a\xeb\x8c\x56\xff\x7d\x97\xda\x27\x09\xcd\x6b\x8a\xdd\x9e\xfd\xda\xea\xc4\x86\xee\x8d\xc7\xc0\x1a\x40\x68\x8f\xcc\x9c\xcc\x9b\x3e\x81\x9b\x56\x03\x27\x8b\xe6\xeb\x17\x5a\x2b\x57\x80\x0d\xc3\xc6\xc0\xc6\x30\xd0\xb6\x78\xa4\x7a\x30\x8a\x8a\xba\x24\x82\xfd\x8e\x43\x9b\x97\x46\x5e\x56\xee\x15\x4a\x70\x1c\x92\x8f\x98\xd9\xbd\xdb\x18\xb4\x39\x6e\xd0\x08\x71\xd0\x6a\xf7\xc5\xae\xa5\x30\x85\xc9\x6c\xf0\x91\x12\x3a\x4d\x25\xcc\x88\x82\xfe\x20\x6c\x93\x2f\x28\x69\xa9\xb7\x6b\x19\x51\x03\xdf\x2b\x71\x05\xbe\x90\xeb\x74\x70\x3d\xe9\x98\xf4\x8a\x76\x7a\x1e\x34\xb6\x76\xa4\x0c\xcb\x65\xeb\x9a\x73\xb8\x9e\x7c\x0e\x6e\x29\x11\x4b\x3c\x3c\x81\x51\xac\x42\x0a\x24\x37\x6c\x85\xff\x0b\x07\xf9\x0c\x42\xfe\x68\x16\xad\x1d\xb6\xc2\x73\x66\xba\xc7\xaf\x5d\xed\x64\xfb\xcf\xd6\xdf\x20\x76\x12\xbe\x80\xe0\xe4\x41\x1e\xb4\xc4\x03\xc0\x03\xd7\x7e\xd8\xef\xdd\x3b\xc1\xe0\x30\xa7\xd8\x6a\xb7\x7b\x9f\x3d\x8a\x0a\x53\xf2\x61\x90\x18\xf7\x5d\x93\xe5\xb9\xc3\xe0\x10\xf8\xe9\xfd\x92\x6e\xbb\x7f\x91\xc9\xb9\xd4\x78\x70\x51\x83\x5e\x71\xd2\x5d\xe6\xda\x4a\x04\xb6\xbb\xcf\xbf\xe2\x18\x7e\x34\x44\x19\x20\xf0\xd3\x5b\xa8\x2b\x4a\x8c\x7f\xfb\x66\xf3\xa3\xef\x48\xb6\xdf\x87\x65\x44\x69\x58\x48\xb5\x26\x8a\x36\x0d\x1e\x53\xe0\xc6\xbd\x7d\x6b\x4b\x3f\x8d\xe6\xad\x8d\x62\x2b\xc2\x87\x47\x17\xc7\xe7\xc3\x41\xd4\x57\xf9\x60\x14\x21\xc9\x8b\x63\x40\x97\xb1\x3a\xba\x29\x7c\xe7\xae\x00\xc3\xe7\x43\x53\x30\x3d\x8a\x88\x31\x6a\x38\xd8\x33\x86\xc1\xc8\xea\xf5\xb2\x77\x25\xeb\xb6\x27\x7b\x6e\xf5\x18\x8e\x5d\x31\xdd\x15\x02\x2d\x78\xae\xf5\xd0\xdb\xd5\x60\xdc\xc3\xbd\x6f\x56\x83\xf3\x41\xa7\xa8\x9d\x7b\xef\xce\x91\x9e\xe4\x64\x0f\xf5\xc0\x7a\xd9\xe0\x88\x3c\xa1\xf4\x8d\xf5\x9f\x61\x70\xc2\xd3\x0f\xad\x63\xd4\x09\xdb\xc7\xeb\x47\xa5\xec\xbf\xa4\x79\x40\xc4\x8c\x0e\x46\x91\xae\x33\xdf\xdc\x18\xbe\xec\x2e\x60\x2d\x98\x33\xde\xc3\x54\x70\x54\x50\x58\x12\xfb\x45\x45\x78\x50\x84\x3c\x92\x35\xda\xcb\xbc\x3b\xd5\x76\x6c\x05\x3e\x19\x75\xbd\xb1\x6f\xb4\x2d\xae\x7c\x5b\x78\x8d\x99\x76\x0d\x02\x68\xec\xdd\xb5\x83\x7c\xdb\xe7\xf5\xf7\x6f\x7b\xad\x9f\xce\x23\x86\x0e\x7b\xf7\xe9\xe6\xa9\x46\xcb\xc9\x6f\x45\xd7\xeb\x75\xe4\xdf\x76\xb8\x16\x6f\xd7\x89\x89\x49\xc5\xa2\xf7\x3a\x00\xa2\x37\x22\x07\x8a\x0b\x54\xf3\x1e\xfa\xa6\x3d\x93\xc4\xfe\x2b\xc6\x24\xf6\x1f\x6a\xff\x4f\x00\x00\x00\xff\xff\xf1\xa6\xb6\xb8\xb9\x2d\x00\x00")
+var _faucetHtml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xac\x59\x6d\x6f\xdc\x36\x12\xfe\xec\xfc\x8a\xa9\x2e\xad\x77\x61\x4b\xb2\xe3\x20\x2d\xd6\xd2\x16\x41\x9a\x4b\x7b\x38\xb4\x45\x9b\xe2\xae\x68\x8b\x03\x25\xcd\x4a\x8c\x29\x52\x25\x87\xbb\xde\x1a\xfb\xdf\x0f\x24\x25\xad\x76\x6d\xa7\xb9\x4b\xf3\x61\x23\x92\x33\xcf\xbc\x51\xf3\x22\x67\x9f\x7c\xf5\xdd\xab\xb7\x3f\x7f\xff\x1a\x1a\x6a\xc5\xf2\x49\xe6\xfe\x03\xc1\x64\x9d\x47\x28\xa3\xe5\x93\x93\xac\x41\x56\x2d\x9f\x9c\x9c\x64\x2d\x12\x83\xb2\x61\xda\x20\xe5\x91\xa5\x55\xfc\x45\xb4\x3f\x68\x88\xba\x18\x7f\xb7\x7c\x9d\x47\xff\x8e\x7f\x7a\x19\xbf\x52\x6d\xc7\x88\x17\x02\x23\x28\x95\x24\x94\x94\x47\xdf\xbc\xce\xb1\xaa\x71\xc2\x27\x59\x8b\x79\xb4\xe6\xb8\xe9\x94\xa6\x09\xe9\x86\x57\xd4\xe4\x15\xae\x79\x89\xb1\x5f\x9c\x03\x97\x9c\x38\x13\xb1\x29\x99\xc0\xfc\x32\x5a\x3e\x71\x38\xc4\x49\xe0\xf2\xee\x2e\xf9\x16\x69\xa3\xf4\xcd\x6e\xb7\x80\x37\x9c\xbe\xb6\x05\xfc\x9d\xd9\x12\x29\x4b\x03\x89\xa7\x16\x5c\xde\x40\xa3\x71\x95\x47\x4e\x67\xb3\x48\xd3\xb2\x92\xef\x4c\x52\x0a\x65\xab\x95\x60\x1a\x93\x52\xb5\x29\x7b\xc7\x6e\x53\xc1\x0b\x93\xd2\x86\x13\xa1\x8e\x0b\xa5\xc8\x90\x66\x5d\x7a\x95\x5c\x25\x9f\xa7\xa5\x31\xe9\xb8\x97\xb4\x5c\x26\xa5\x31\x11\x68\x14\x79\x64\x68\x2b\xd0\x34\x88\x14\x41\xba\xfc\xff\xe4\xae\x94\xa4\x98\x6d\xd0\xa8\x16\xd3\xe7\xc9\xe7\xc9\x85\x17\x39\xdd\x7e\xbf\x54\x27\xd6\x94\x9a\x77\x04\x46\x97\x1f\x2c\xf7\xdd\xef\x16\xf5\x36\xbd\x4a\x2e\x93\xcb\x7e\xe1\xe5\xbc\x33\xd1\x32\x4b\x03\xe0\xf2\xa3\xb0\x63\xa9\x68\x9b\x3e\x4b\x9e\x27\x97\x69\xc7\xca\x1b\x56\x63\x35\x48\x72\x47\xc9\xb0\xf9\x97\xc9\x7d\x2c\x86\xef\x8e\x43\xf8\x57\x08\x6b\x55\x8b\x92\x92\x77\x26\x7d\x96\x5c\x7e\x91\x5c\x0c\x1b\xf7\xf1\xbd\x00\x17\x34\x27\xea\x24\x59\xa3\x26\x5e\x32\x11\x97\x28\x09\x35\xdc\xb9\xdd\x93\x96\xcb\xb8\x41\x5e\x37\xb4\x80\xcb\x8b\x8b\x4f\xaf\x1f\xda\x5d\x37\x61\xbb\xe2\xa6\x13\x6c\xbb\x80\x95\xc0\xdb\xb0\xc5\x04\xaf\x65\xcc\x09\x5b\xb3\x80\x80\xec\x0f\x76\x5e\x66\xa7\x55\xad\xd1\x98\x5e\x58\xa7\x0c\x27\xae\xe4\xc2\xdd\x28\x46\x7c\x8d\x0f\xd1\x9a\x8e\xc9\x7b\x0c\xac\x30\x4a\x58\xc2\x23\x45\x0a\xa1\xca\x9b\xb0\xe7\x5f\xe3\xa9\x11\xa5\x12\x4a\x2f\x60\xd3\xf0\x9e\x0d\xbc\x20\xe8\x34\xf6\xf0\xd0\xb1\xaa\xe2\xb2\x5e\xc0\x8b\xae\xb7\x07\x5a\xa6\x6b\x2e\x17\x70\xb1\x67\xc9\xd2\xc1\x8d\x59\x1a\x32\xd6\x93\x93\xac\x50\xd5\xd6\xc7\xb0\xe2\x6b\x28\x05\x33\x26\x8f\x8e\x5c\xec\x33\xd1\x01\x81\x4b\x40\x8c\xcb\xe1\xe8\xe0\x4c\xab\x4d\x04\x5e\x50\x1e\x05\x25\xe2\x42\x11\xa9\x76\x01\x97\x4e\xbd\x9e\xe5\x08\x4f\xc4\xa2\x8e\x2f\x9f\x0d\x87\x27\x59\x73\x39\x80\x10\xde\x52\xec\xe3\x33\x46\x26\x5a\x66\x7c\xe0\x5d\x31\x58\xb1\xb8\x60\xd4\x44\xc0\x34\x67\x71\xc3\xab\x0a\x65\x1e\x91\xb6\xe8\xee\x11\x5f\xc2\x34\xef\x0d\x69\xef\xa5\xa5\x06\xa5\xb3\x93\xb0\xea\x93\x20\x1c\xc3\xd6\x9c\x1a\x5b\xc4\x4c\xd0\xa3\xe0\x59\xda\x5c\x0e\x26\xa5\x15\x5f\xf7\x1e\x99\x3c\x1e\x39\xe7\x71\xfb\xbf\x80\xfe\x41\xad\x56\x06\x29\x9e\xb8\x63\x42\xcc\x65\x67\x29\xae\xb5\xb2\xdd\x78\x7e\x92\xf9\x5d\xe0\x55\x1e\xd5\xdc\x50\x04\xb4\xed\x7a\xdf\x45\xa3\x49\x4a\xb7\xb1\x0b\x9d\x56\x22\x82\x4e\xb0\x12\x1b\x25\x2a\xd4\x79\xd4\xfb\xe4\x0d\x37\x04\x3f\xfd\xf0\x4f\xe8\x03\xcc\x65\x0d\x5b\x65\x35\xbc\xa6\x06\x35\xda\x16\x58\x55\xb9\xcb\x9d\x24\xc9\x44\xb6\xbf\xe9\xf7\xb5\x8b\x0b\x92\x7b\xaa\x93\xac\xb0\x44\x6a\x24\x2c\x48\x42\x41\x32\xae\x70\xc5\xac\x20\xa8\xb4\xea\x2a\xb5\x91\x31\xa9\xba\x76\x05\x31\x58\x10\x98\x22\xa8\x18\xb1\xfe\x28\x8f\x06\xda\x21\x28\xcc\x74\xaa\xb3\x5d\x1f\x96\xb0\x89\xb7\x1d\x93\x15\x56\x2e\x94\xc2\x60\xb4\x7c\xc3\xd7\x08\x2d\x06\x5b\x4e\x8e\x23\x5d\x32\x8d\x14\x4f\x41\x1f\x88\x74\x50\x26\x98\x04\xfd\xbf\xcc\x8a\x01\x69\x34\xa1\x45\x69\xe1\x60\x15\x6b\x97\x85\xa2\xe5\xdd\x9d\x66\xb2\x46\x78\xca\xab\xdb\x73\x78\xca\x5a\x65\x25\xc1\x22\x87\xe4\xa5\x7f\x34\xbb\xdd\x01\x3a\x40\x26\xf8\x32\x63\xef\x7b\x19\x40\xc9\x52\xf0\xf2\x26\x8f\x88\xa3\xce\xef\xee\x1c\xf8\x6e\x77\x0d\x77\x77\x7c\x05\x4f\x93\x1f\xb0\x64\x1d\x95\x0d\xdb\xed\x6a\x3d\x3c\x27\x78\x8b\xa5\x25\x9c\xcd\xef\xee\x50\x18\xdc\xed\x8c\x2d\x5a\x4e\xb3\x81\xdd\xed\xcb\x6a\xb7\x73\x3a\xf7\x7a\xee\x76\x90\x3a\x50\x59\xe1\x2d\x3c\x4d\xbe\x47\xcd\x55\x65\x20\xd0\x67\x29\x5b\x66\xa9\xe0\xcb\x9e\xef\xd0\x49\xa9\x15\xfb\xfb\x92\xba\x0b\x33\x5e\x6d\xff\xa6\x78\x55\xa7\x9a\x3e\x70\xf1\xeb\x78\xd4\xbe\xbf\x0f\x86\x13\xde\xe0\x36\x8f\xee\xee\xa6\xbc\xfd\x69\xc9\x84\x28\x98\xf3\x4b\x30\x6d\x64\xfa\x03\xdd\x3d\x5d\x73\xe3\x3b\xaf\xe5\xa0\xc1\x5e\xed\x0f\x7c\x93\x8f\xd2\x1c\xa9\x6e\x01\x57\xcf\x26\x39\xee\xa1\x97\xfc\xc5\xd1\x4b\x7e\xf5\x20\x71\xc7\x24\x0a\xf0\xbf\xb1\x69\x99\x18\x9e\xfb\xb7\x65\xf2\xf2\x1d\x33\xc5\x2e\xa3\x8f\xaa\x8d\x95\xe1\xe2\x1a\xd4\x1a\xf5\x4a\xa8\xcd\x02\x98\x25\x75\x0d\x2d\xbb\x1d\xab\xe3\xd5\xc5\xc5\x54\x6f\xd7\x31\xb2\x42\xa0\x4f\x28\x1a\x7f\xb7\x68\xc8\x8c\x89\x24\x1c\xf9\x5f\x97\x4f\x2a\x94\x06\xab\x23\x6f\x38\x89\xce\xb5\x9e\x6a\x12\xfa\xd1\x99\x0f\xea\xbe\x52\x6a\x2c\x38\x53\x35\x7a\xe8\x49\x6d\x8c\x96\x19\xe9\x3d\xdd\x49\x46\xd5\xff\x54\x30\xb4\x6b\x08\x1f\xab\x17\x21\xa3\x39\xdb\x3b\x44\x1d\xba\x11\x77\x65\xc1\x2f\xb3\x94\xaa\x8f\x90\xec\x2e\x61\xc1\x0c\x7e\x88\x78\xdf\x17\xec\xc5\xfb\xe5\xc7\xca\x6f\x90\x69\x2a\x90\x3d\x5e\xd2\x26\x0a\xac\xac\xac\x26\xf6\xfb\xdc\xf9\xb1\x0a\x58\xc9\xd7\xa8\x0d\xa7\xed\x87\x6a\x80\xd5\x5e\x85\xb0\x3e\x54\x21\x4b\x49\xbf\xff\xae\x4d\x17\x7f\xd1\xcb\xfd\x67\x0d\xcc\xd5\xf2\x6b\xb5\x81\x4a\xa1\x01\x6a\xb8\x01\xd7\x7e\x7c\x99\xa5\xcd\xd5\x48\xd2\x2d\xdf\xba\x03\xef\x54\x58\x85\x0e\x84\x1b\xd0\x56\xfa\xca\xab\x24\x50\x83\x87\xcd\x8b\x0c\x4f\x09\xbc\x55\xae\x01\x5c\xa3\x24\x68\x99\xe0\x25\x57\xd6\x00\x2b\x49\x69\x03\x2b\xad\x5a\xc0\xdb\x86\x59\x43\x0e\xc8\xa5\x0f\xb6\x66\x5c\xf8\x77\xc9\x87\x14\x94\x06\x56\x96\xb6\xb5\xae\x81\x95\x35\xa0\x54\xb6\x6e\x7a\x5d\x48\x41\x28\x4c\x42\xc9\x7a\xd4\xc7\x74\xac\x05\x46\xc4\xca\x1b\x73\x0e\x43\x56\x00\xa6\x11\x88\x63\xe5\xb8\xfa\x3e\x82\x95\xa5\x2f\x66\x09\xbc\x94\x5b\x25\x11\x1a\xb6\xf6\x8a\x1c\x11\x40\xcb\xb6\x03\x50\xaf\xd7\x86\x53\xc3\x83\xe1\x1d\xea\xd6\x4d\x24\x15\x08\xde\x72\x32\x49\x96\x76\x53\xdf\xa9\x43\xd6\x73\x30\xbc\xed\xc4\x16\x4a\x8d\x8c\x10\x18\x64\xec\x68\x98\x74\xad\x51\x12\x7a\x3a\x3f\x8e\x44\x40\x4c\xd7\x6e\x54\xff\x0f\x2b\x94\xa5\x45\x21\x98\xbc\x71\xad\xc2\xd8\x0e\xb9\xb2\xe6\x95\x7a\xb8\x11\x82\x8e\x19\xa7\x21\x97\xa4\xbc\xd2\xfd\x6c\x6e\x60\xe6\x56\x2b\x2e\xd0\x8f\xef\xfe\x1e\xc8\x53\x67\xb1\x9b\xb1\xe6\xe7\x50\xaa\x6e\x1b\xb8\x3d\x9f\x53\xcd\xf8\xde\x6b\x84\x62\x85\x5a\x23\x84\xc6\xae\x50\xb7\xc0\x64\x05\x2b\xae\x11\xd8\x86\x6d\x3f\x81\x9f\x95\x85\x92\x49\x20\xcd\xca\x9b\x20\xdb\x6a\xed\x2e\x44\x87\xd2\x25\xfd\x7d\x88\x0a\x14\x6a\xe3\x49\x02\xda\x8a\xa3\xf0\xf1\x32\x88\xd0\xa8\x0d\xb4\xb6\xf4\x06\xba\x40\xa1\x3b\xd8\x30\x4e\x60\x25\x71\x11\xec\x26\xab\x25\x94\xaa\xc5\x83\x28\xdc\xab\xda\x19\xb6\xcb\xb7\xce\xee\x7b\x97\x79\xac\xb7\xa0\xf1\x55\x20\x87\x4e\x2b\xc2\xd2\x0d\x46\xc0\x6a\xc6\xa5\x71\x76\xfa\x38\x63\xfb\x01\xf5\x78\x7c\xea\x1f\xf6\x93\xa8\x3f\x4e\x53\x78\x23\x54\xc1\x04\xac\x5d\x96\x29\x84\x7b\x11\x15\xb8\x96\xf7\xc0\x5b\x86\x18\x59\x03\x6a\xe5\x77\x83\xe6\x8e\x7f\xcd\xb4\xbb\xed\xd8\x76\x04\x79\x3f\x47\xb9\x3d\x83\x7a\xdd\x4f\x87\x6e\xe9\x7a\xae\x70\xde\x0b\xfd\x0a\x57\x5c\x86\xa0\xae\xac\x0c\xe6\x51\xc3\x08\x42\x17\x62\x80\xf9\x60\x83\xd5\x02\xfa\x48\x07\xc8\x51\x80\xa7\x83\x7c\x64\x9f\xdd\xf3\x73\xff\xd0\xfb\x68\xde\xcf\x81\x01\x26\x31\x28\xab\xd9\x3f\x7e\xfc\xee\xdb\xc4\x90\xe6\xb2\xe6\xab\xed\xec\xce\x6a\xb1\x80\xa7\xb3\xe8\x6f\x7e\x3c\x98\xff\x72\xf1\x5b\xb2\x66\xc2\xe2\xb9\x37\x60\xe1\x7f\xef\x89\x39\x87\xfe\x71\x01\x87\x12\x77\xf3\xf9\xf5\xc3\x2d\xdb\xa4\xc3\xd4\x68\x90\x66\x8e\x70\x8c\xe4\xee\xfa\xd0\x49\x0c\x5a\xa4\x46\xf9\xbb\xa8\xb1\x54\x52\x62\x49\x60\x3b\x25\x7b\x9f\x80\x50\xc6\x0c\x8e\xd9\x53\x4c\x7c\x33\x18\xcf\x57\x30\x1b\xc2\xf5\x29\x3c\x83\x3c\x87\x8b\xe1\xac\xf7\x0c\xe4\x20\x71\x03\xff\xc2\xe2\x47\x55\xde\x20\xcd\xa2\x8d\x71\x69\x21\x82\x33\x10\xaa\x64\x0e\x2f\x69\x94\x21\x38\x83\x28\x65\x1d\x8f\xe6\x61\x9a\xde\x81\x6b\x91\xff\x1c\xec\x83\xb0\xc2\xf7\x86\xa0\xe9\xd9\x59\xb8\x36\x43\xe8\x94\x6c\xd1\x18\x56\xe3\xd4\x42\x9f\xe5\x47\x53\x9c\x23\x5a\x53\x43\x0e\x3e\xc4\x1d\xd3\x06\x03\x49\xe2\x3a\x8b\x5e\x8a\x77\x87\x27\xcb\x73\x90\x56\x88\x91\xff\x44\xa3\x7b\x99\x7b\xb2\xdd\x93\x03\xf2\x24\x24\xe1\x4f\xf2\x1c\x5c\x99\x75\x31\xaa\xf6\x9c\xee\xfa\x84\x86\x60\x9e\xb8\x4a\xbf\xe7\x98\x8f\x70\xf7\xd0\xb0\xfa\x33\x38\xac\x8e\xf1\xb0\x7a\x04\xd0\xf7\x5f\xef\xc3\x0b\xfd\xda\x04\xce\x6f\x3c\x82\x26\x6d\x5b\xa0\x7e\x1f\x5c\xe8\xbf\x7a\x38\xef\xea\x6f\x24\x4d\x78\xcf\xe1\xf2\xc5\xfc\x11\x74\xd4\x5a\x3d\x0a\x2e\x15\x6d\x67\x77\x82\x6d\x5d\xd5\x81\x53\x52\xdd\x2b\xdf\x2e\x9d\x9e\x83\x93\xb5\x80\x11\xe1\xdc\x0f\xc2\x0b\x38\xf5\xab\xd3\xdd\x23\xd2\x8c\x2d\x4b\x57\x8f\x3e\x46\x5e\x8f\x31\x4a\xec\xd7\x8f\xca\x1c\xeb\xcb\x81\x50\xf8\xec\x33\xb8\x77\x7a\x78\x05\xdd\x1d\xee\x0b\x25\xe4\x10\x45\x3d\xfc\xc9\x4a\x69\x98\xb9\x43\x9e\x5f\x5c\x03\xcf\xa6\x30\x89\x40\x59\x53\x73\x0d\xfc\xec\x6c\x8f\x74\x32\xc0\x9c\xe5\x10\xb9\x89\x20\xa3\x6a\xe9\x3b\xb3\xd0\xbe\xfd\x1a\xb9\x09\xb0\xd6\xca\xca\x6a\xe1\x52\xee\xec\x74\xdf\x0c\x4c\xfa\x80\xb3\x03\x95\x7f\xe1\xbf\x25\xd6\xa0\xf6\x95\xfb\x0c\xa2\xa4\x93\xf5\x97\x7e\x6e\x7c\xf1\xfc\x74\x7e\x0d\x7b\x4c\x3f\x4d\x2e\xa0\x74\xb3\xd5\x35\x84\xf9\xc4\x77\x89\x30\x4e\x56\x7e\x55\x28\x5d\xa1\x8e\x35\xab\xb8\x35\x0b\x78\xde\xdd\x5e\xff\x3a\x4c\x9e\xbe\x97\xf5\x7a\x77\x1a\x97\x0f\xe9\x32\xb4\x4b\x67\x10\x65\xa9\x23\x1a\x58\x46\x2b\xa7\x5f\x0d\xe1\x81\x2e\x1c\xc6\x6f\x7a\xfd\x7e\xcb\xab\x4a\xa0\x53\xc2\x0b\x0c\x1f\x5f\x2b\xab\x7d\xe2\x9a\x85\xf5\xec\x58\x0f\xe2\x2d\xce\x13\x2b\xf9\xed\x6c\x1e\xf7\x34\xc3\xfa\x1c\x4e\x8d\xcb\xcf\x95\x39\x9d\x27\x8d\x6d\x99\xe4\x7f\xe0\xcc\xb5\xf4\xf3\xa0\xb7\xd3\xd8\xf5\xe9\x63\xb4\x77\x93\x17\x6d\x9c\x31\xe7\x49\x43\xad\x98\x45\x19\xf9\x2f\x93\x4e\xb9\x31\xc4\x1e\x25\x6c\x1f\xde\xc8\xdd\x61\x0e\x2d\x85\x32\x78\x54\x23\xc0\x20\xbd\xe5\x2d\x2a\x4b\xb3\xb1\x8e\x9c\xbb\xb9\xf7\x62\x7e\x0d\xbb\xfd\x07\xdc\x34\x85\xd7\xc6\x4d\x12\xdc\x34\xc0\x60\x83\x85\xf1\xf9\x1d\x7a\x1e\x5f\xce\x43\xd9\x7e\xf9\xfd\x37\x93\xd2\x3d\xa2\xce\xbc\x72\xe3\x07\xec\x87\xea\xe4\x83\x5f\xcc\x37\x9b\x4d\x52\x2b\x55\x8b\xf0\xad\x7c\x2c\xa4\xae\x7a\x24\xef\xdc\xb8\x6a\xb6\xb2\x84\x0a\x57\xa8\x97\x13\xf8\xbe\xba\x66\x69\xf8\x96\x9b\xa5\xe1\xef\x54\xff\x0d\x00\x00\xff\xff\x71\x50\x77\xf3\xb8\x1a\x00\x00")
func faucetHtmlBytes() ([]byte, error) {
return bindataRead(
@@ -182,9 +182,8 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
-
var _bintree = &bintree{nil, map[string]*bintree{
- "faucet.html": {faucetHtml, map[string]*bintree{}},
+ "faucet.html": &bintree{faucetHtml, map[string]*bintree{}},
}}
// RestoreAsset restores an asset under the given directory
@@ -233,3 +232,4 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}
+
diff --git a/cmd/geth/dao_test.go b/cmd/geth/dao_test.go
deleted file mode 100644
index a8dbc5163..000000000
--- a/cmd/geth/dao_test.go
+++ /dev/null
@@ -1,152 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
-//
-// go-ethereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// go-ethereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
-
-package main
-
-import (
- "io/ioutil"
- "math/big"
- "os"
- "path/filepath"
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
-)
-
-// Genesis block for nodes which don't care about the DAO fork (i.e. not configured)
-var daoOldGenesis = `{
- "alloc" : {},
- "coinbase" : "0x0000000000000000000000000000000000000000",
- "difficulty" : "0x20000",
- "extraData" : "",
- "gasLimit" : "0x2fefd8",
- "nonce" : "0x0000000000000042",
- "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "timestamp" : "0x00",
- "config" : {}
-}`
-
-// Genesis block for nodes which actively oppose the DAO fork
-var daoNoForkGenesis = `{
- "alloc" : {},
- "coinbase" : "0x0000000000000000000000000000000000000000",
- "difficulty" : "0x20000",
- "extraData" : "",
- "gasLimit" : "0x2fefd8",
- "nonce" : "0x0000000000000042",
- "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "timestamp" : "0x00",
- "config" : {
- "daoForkBlock" : 314,
- "daoForkSupport" : false
- }
-}`
-
-// Genesis block for nodes which actively support the DAO fork
-var daoProForkGenesis = `{
- "alloc" : {},
- "coinbase" : "0x0000000000000000000000000000000000000000",
- "difficulty" : "0x20000",
- "extraData" : "",
- "gasLimit" : "0x2fefd8",
- "nonce" : "0x0000000000000042",
- "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
- "timestamp" : "0x00",
- "config" : {
- "daoForkBlock" : 314,
- "daoForkSupport" : true
- }
-}`
-
-var daoGenesisHash = common.HexToHash("5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0")
-var daoGenesisForkBlock = big.NewInt(314)
-
-// TestDAOForkBlockNewChain tests that the DAO hard-fork number and the nodes support/opposition is correctly
-// set in the database after various initialization procedures and invocations.
-func TestDAOForkBlockNewChain(t *testing.T) {
- for i, arg := range []struct {
- genesis string
- expectBlock *big.Int
- expectVote bool
- }{
- // Test DAO Default Mainnet
- {"", params.MainnetChainConfig.DAOForkBlock, true},
- // test DAO Init Old Privnet
- {daoOldGenesis, nil, false},
- // test DAO Default No Fork Privnet
- {daoNoForkGenesis, daoGenesisForkBlock, false},
- // test DAO Default Pro Fork Privnet
- {daoProForkGenesis, daoGenesisForkBlock, true},
- } {
- testDAOForkBlockNewChain(t, i, arg.genesis, arg.expectBlock, arg.expectVote)
- }
-}
-
-func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBlock *big.Int, expectVote bool) {
- // Create a temporary data directory to use and inspect later
- datadir := tmpdir(t)
- defer os.RemoveAll(datadir)
-
- // Start a Geth instance with the requested flags set and immediately terminate
- if genesis != "" {
- json := filepath.Join(datadir, "genesis.json")
- if err := ioutil.WriteFile(json, []byte(genesis), 0600); err != nil {
- t.Fatalf("test %d: failed to write genesis file: %v", test, err)
- }
- runGeth(t, "--datadir", datadir, "init", json).WaitExit()
- } else {
- // Force chain initialization
- args := []string{"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none", "--ipcdisable", "--datadir", datadir}
- geth := runGeth(t, append(args, []string{"--exec", "2+2", "console"}...)...)
- geth.WaitExit()
- }
- // Retrieve the DAO config flag from the database
- path := filepath.Join(datadir, "geth", "chaindata")
- db, err := ethdb.NewLDBDatabase(path, 0, 0)
- if err != nil {
- t.Fatalf("test %d: failed to open test database: %v", test, err)
- }
- defer db.Close()
-
- genesisHash := common.HexToHash("0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
- if genesis != "" {
- genesisHash = daoGenesisHash
- }
- config, err := core.GetChainConfig(db, genesisHash)
- if err != nil {
- t.Errorf("test %d: failed to retrieve chain config: %v", test, err)
- return // we want to return here, the other checks can't make it past this point (nil panic).
- }
- // Validate the DAO hard-fork block number against the expected value
- if config.DAOForkBlock == nil {
- if expectBlock != nil {
- t.Errorf("test %d: dao hard-fork block mismatch: have nil, want %v", test, expectBlock)
- }
- } else if expectBlock == nil {
- t.Errorf("test %d: dao hard-fork block mismatch: have %v, want nil", test, config.DAOForkBlock)
- } else if config.DAOForkBlock.Cmp(expectBlock) != 0 {
- t.Errorf("test %d: dao hard-fork block mismatch: have %v, want %v", test, config.DAOForkBlock, expectBlock)
- }
- if config.DAOForkSupport != expectVote {
- t.Errorf("test %d: dao hard-fork support mismatch: have %v, want %v", test, config.DAOForkSupport, expectVote)
- }
-}
diff --git a/cmd/geth/accountcmd.go b/cmd/gwtc/accountcmd.go
old mode 100644
new mode 100755
similarity index 87%
rename from cmd/geth/accountcmd.go
rename to cmd/gwtc/accountcmd.go
index 0db5c4ce0..52cf03ca4
--- a/cmd/geth/accountcmd.go
+++ b/cmd/gwtc/accountcmd.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -20,23 +20,23 @@ import (
"fmt"
"io/ioutil"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/log"
"gopkg.in/urfave/cli.v1"
)
var (
walletCommand = cli.Command{
Name: "wallet",
- Usage: "Manage Ethereum presale wallets",
+ Usage: "Manage Wtc presale wallets",
ArgsUsage: "",
Category: "ACCOUNT COMMANDS",
Description: `
- geth wallet import /path/to/my/presale.wallet
+ gwtc wallet import /path/to/my/presale.wallet
will prompt for your password and imports your ether presale account.
It can be used non-interactively with the --password option taking a
@@ -45,7 +45,7 @@ passwordfile as argument containing the wallet password in plaintext.`,
{
Name: "import",
- Usage: "Import Ethereum presale wallet",
+ Usage: "Import Wtc presale wallet",
ArgsUsage: "<keyFile>",
Action: utils.MigrateFlags(importWallet),
Category: "ACCOUNT COMMANDS",
@@ -56,7 +56,7 @@ passwordfile as argument containing the wallet password in plaintext.`,
utils.LightKDFFlag,
},
Description: `
- geth wallet [options] /path/to/my/presale.wallet
+ gwtc wallet [options] /path/to/my/presale.wallet
will prompt for your password and imports your ether presale account.
It can be used non-interactively with the --password option taking a
@@ -86,7 +86,7 @@ Note that exporting your key in unencrypted format is NOT supported.
Keys are stored under <DATADIR>/keystore.
It is safe to transfer the entire directory or the individual keys therein
-between ethereum nodes by simply copying.
+between wtc nodes by simply copying.
Make sure you backup your keys regularly.`,
Subcommands: []cli.Command{
@@ -112,7 +112,7 @@ Print a short summary of all accounts`,
utils.LightKDFFlag,
},
Description: `
- geth account new
+ gwtc account new
Creates a new account and prints the address.
@@ -137,7 +137,7 @@ password to file or expose in any other way.
utils.LightKDFFlag,
},
Description: `
- geth account update <address>
+ gwtc account update <address>
Update an existing account.
@@ -149,7 +149,7 @@ format to the newest format or change the password for an account.
For non-interactive use the passphrase can be specified with the --password flag:
- geth account update [options] <address>
+ gwtc account update [options] <address>
Since only one password can be given, only format update can be performed,
changing your password is only possible interactively.
@@ -167,7 +167,7 @@ changing your password is only possible interactively.
},
ArgsUsage: "<keyFile>",
Description: `
- geth account import <keyfile>
+ gwtc account import <keyfile>
Imports an unencrypted private key from <keyfile> and creates a new account.
Prints the address.
@@ -180,10 +180,10 @@ You must remember this passphrase to unlock your account in the future.
For non-interactive use the passphrase can be specified with the -password flag:
- geth account import [options] <keyfile>
+ gwtc account import [options] <keyfile>
Note:
-As you can directly copy your encrypted accounts to another ethereum instance,
+As you can directly copy your encrypted accounts to another wtc instance,
this import mechanism is not needed when you transfer an account between
nodes.
`,
@@ -291,28 +291,15 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
// accountCreate creates a new account into the keystore defined by the CLI flags.
func accountCreate(ctx *cli.Context) error {
- cfg := gethConfig{Node: defaultNodeConfig()}
- // Load config file.
- if file := ctx.GlobalString(configFileFlag.Name); file != "" {
- if err := loadConfig(file, &cfg); err != nil {
- utils.Fatalf("%v", err)
- }
- }
- utils.SetNodeConfig(ctx, &cfg.Node)
- scryptN, scryptP, keydir, err := cfg.Node.AccountConfig()
-
- if err != nil {
- utils.Fatalf("Failed to read configuration: %v", err)
- }
-
+ stack, _ := makeConfigNode(ctx)
password := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
- address, err := keystore.StoreKey(keydir, password, scryptN, scryptP)
-
+ ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
+ account, err := ks.NewAccount(password)
if err != nil {
utils.Fatalf("Failed to create account: %v", err)
}
- fmt.Printf("Address: {%x}\n", address)
+ fmt.Printf("Address: {%x}\n", account.Address)
return nil
}
diff --git a/cmd/geth/accountcmd_test.go b/cmd/gwtc/accountcmd_test.go
old mode 100644
new mode 100755
similarity index 76%
rename from cmd/geth/accountcmd_test.go
rename to cmd/gwtc/accountcmd_test.go
index 3ea22ccfa..ff6e15c87
--- a/cmd/geth/accountcmd_test.go
+++ b/cmd/gwtc/accountcmd_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -43,22 +43,22 @@ func tmpDatadirWithKeystore(t *testing.T) string {
}
func TestAccountListEmpty(t *testing.T) {
- geth := runGeth(t, "account", "list")
- geth.ExpectExit()
+ gwtc := runGwtc(t, "account", "list")
+ gwtc.ExpectExit()
}
func TestAccountList(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t, "account", "list", "--datadir", datadir)
- defer geth.ExpectExit()
+ gwtc := runGwtc(t, "account", "list", "--datadir", datadir)
+ defer gwtc.ExpectExit()
if runtime.GOOS == "windows" {
- geth.Expect(`
+ gwtc.Expect(`
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}\keystore\UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}\keystore\aaa
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\keystore\zzz
`)
} else {
- geth.Expect(`
+ gwtc.Expect(`
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
Account #1: {f466859ead1932d743d622cb74fc058882e8648a} keystore://{{.Datadir}}/keystore/aaa
Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/keystore/zzz
@@ -67,21 +67,21 @@ Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}/k
}
func TestAccountNew(t *testing.T) {
- geth := runGeth(t, "account", "new", "--lightkdf")
- defer geth.ExpectExit()
- geth.Expect(`
+ gwtc := runGwtc(t, "account", "new", "--lightkdf")
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
Your new account is locked with a password. Please give a password. Do not forget this password.
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foobar"}}
Repeat passphrase: {{.InputLine "foobar"}}
`)
- geth.ExpectRegexp(`Address: \{[0-9a-f]{40}\}\n`)
+ gwtc.ExpectRegexp(`Address: \{[0-9a-f]{40}\}\n`)
}
func TestAccountNewBadRepeat(t *testing.T) {
- geth := runGeth(t, "account", "new", "--lightkdf")
- defer geth.ExpectExit()
- geth.Expect(`
+ gwtc := runGwtc(t, "account", "new", "--lightkdf")
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
Your new account is locked with a password. Please give a password. Do not forget this password.
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "something"}}
@@ -92,11 +92,11 @@ Fatal: Passphrases do not match
func TestAccountUpdate(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t, "account", "update",
+ gwtc := runGwtc(t, "account", "update",
"--datadir", datadir, "--lightkdf",
"f466859ead1932d743d622cb74fc058882e8648a")
- defer geth.ExpectExit()
- geth.Expect(`
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foobar"}}
@@ -107,24 +107,24 @@ Repeat passphrase: {{.InputLine "foobar2"}}
}
func TestWalletImport(t *testing.T) {
- geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
- defer geth.ExpectExit()
- geth.Expect(`
+ gwtc := runGwtc(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foo"}}
Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f}
`)
- files, err := ioutil.ReadDir(filepath.Join(geth.Datadir, "keystore"))
+ files, err := ioutil.ReadDir(filepath.Join(gwtc.Datadir, "keystore"))
if len(files) != 1 {
t.Errorf("expected one key file in keystore directory, found %d files (error: %v)", len(files), err)
}
}
func TestWalletImportBadPassword(t *testing.T) {
- geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
- defer geth.ExpectExit()
- geth.Expect(`
+ gwtc := runGwtc(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "wrong"}}
Fatal: could not decrypt key with given passphrase
@@ -133,23 +133,23 @@ Fatal: could not decrypt key with given passphrase
func TestUnlockFlag(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t,
- "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
"js", "testdata/empty.js")
- geth.Expect(`
+ gwtc.Expect(`
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foobar"}}
`)
- geth.ExpectExit()
+ gwtc.ExpectExit()
wantMessages := []string{
"Unlocked account",
"=0xf466859eAD1932D743d622CB74FC058882E8648A",
}
for _, m := range wantMessages {
- if !strings.Contains(geth.StderrText(), m) {
+ if !strings.Contains(gwtc.StderrText(), m) {
t.Errorf("stderr text does not contain %q", m)
}
}
@@ -157,11 +157,11 @@ Passphrase: {{.InputLine "foobar"}}
func TestUnlockFlagWrongPassword(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t,
- "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
- defer geth.ExpectExit()
- geth.Expect(`
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "wrong1"}}
@@ -173,21 +173,21 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could
`)
}
-// https://github.com/ethereum/go-ethereum/issues/1785
+// https://github.com/wtc/go-wtc/issues/1785
func TestUnlockFlagMultiIndex(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t,
- "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
"--unlock", "0,2",
"js", "testdata/empty.js")
- geth.Expect(`
+ gwtc.Expect(`
Unlocking account 0 | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foobar"}}
Unlocking account 2 | Attempt 1/3
Passphrase: {{.InputLine "foobar"}}
`)
- geth.ExpectExit()
+ gwtc.ExpectExit()
wantMessages := []string{
"Unlocked account",
@@ -195,7 +195,7 @@ Passphrase: {{.InputLine "foobar"}}
"=0x289d485D9771714CCe91D3393D764E1311907ACc",
}
for _, m := range wantMessages {
- if !strings.Contains(geth.StderrText(), m) {
+ if !strings.Contains(gwtc.StderrText(), m) {
t.Errorf("stderr text does not contain %q", m)
}
}
@@ -203,11 +203,11 @@ Passphrase: {{.InputLine "foobar"}}
func TestUnlockFlagPasswordFile(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t,
- "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
"--password", "testdata/passwords.txt", "--unlock", "0,2",
"js", "testdata/empty.js")
- geth.ExpectExit()
+ gwtc.ExpectExit()
wantMessages := []string{
"Unlocked account",
@@ -215,7 +215,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
"=0x289d485D9771714CCe91D3393D764E1311907ACc",
}
for _, m := range wantMessages {
- if !strings.Contains(geth.StderrText(), m) {
+ if !strings.Contains(gwtc.StderrText(), m) {
t.Errorf("stderr text does not contain %q", m)
}
}
@@ -223,29 +223,29 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) {
datadir := tmpDatadirWithKeystore(t)
- geth := runGeth(t,
- "--datadir", datadir, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--datadir", datadir, "--nat", "none", "--nodiscover", "--dev",
"--password", "testdata/wrong-passwords.txt", "--unlock", "0,2")
- defer geth.ExpectExit()
- geth.Expect(`
+ defer gwtc.ExpectExit()
+ gwtc.Expect(`
Fatal: Failed to unlock account 0 (could not decrypt key with given passphrase)
`)
}
func TestUnlockFlagAmbiguous(t *testing.T) {
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
- geth := runGeth(t,
- "--keystore", store, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--keystore", store, "--nat", "none", "--nodiscover", "--dev",
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a",
"js", "testdata/empty.js")
- defer geth.ExpectExit()
+ defer gwtc.ExpectExit()
// Helper for the expect template, returns absolute keystore path.
- geth.SetTemplateFunc("keypath", func(file string) string {
+ gwtc.SetTemplateFunc("keypath", func(file string) string {
abs, _ := filepath.Abs(filepath.Join(store, file))
return abs
})
- geth.Expect(`
+ gwtc.Expect(`
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "foobar"}}
@@ -257,14 +257,14 @@ Your passphrase unlocked keystore://{{keypath "1"}}
In order to avoid this warning, you need to remove the following duplicate key files:
keystore://{{keypath "2"}}
`)
- geth.ExpectExit()
+ gwtc.ExpectExit()
wantMessages := []string{
"Unlocked account",
"=0xf466859eAD1932D743d622CB74FC058882E8648A",
}
for _, m := range wantMessages {
- if !strings.Contains(geth.StderrText(), m) {
+ if !strings.Contains(gwtc.StderrText(), m) {
t.Errorf("stderr text does not contain %q", m)
}
}
@@ -272,17 +272,17 @@ In order to avoid this warning, you need to remove the following duplicate key f
func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) {
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
- geth := runGeth(t,
- "--keystore", store, "--nat", "none", "--nodiscover", "--maxpeers", "0", "--port", "0",
+ gwtc := runGwtc(t,
+ "--keystore", store, "--nat", "none", "--nodiscover", "--dev",
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a")
- defer geth.ExpectExit()
+ defer gwtc.ExpectExit()
// Helper for the expect template, returns absolute keystore path.
- geth.SetTemplateFunc("keypath", func(file string) string {
+ gwtc.SetTemplateFunc("keypath", func(file string) string {
abs, _ := filepath.Abs(filepath.Join(store, file))
return abs
})
- geth.Expect(`
+ gwtc.Expect(`
Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3
!! Unsupported terminal, password will be echoed.
Passphrase: {{.InputLine "wrong"}}
@@ -292,5 +292,5 @@ Multiple key files exist for address f466859ead1932d743d622cb74fc058882e8648a:
Testing your passphrase against all of them...
Fatal: None of the listed files could be unlocked.
`)
- geth.ExpectExit()
+ gwtc.ExpectExit()
}
diff --git a/cmd/geth/bugcmd.go b/cmd/gwtc/bugcmd.go
old mode 100644
new mode 100755
similarity index 81%
rename from cmd/geth/bugcmd.go
rename to cmd/gwtc/bugcmd.go
index ce9dbe6c0..93f39ce0c
--- a/cmd/geth/bugcmd.go
+++ b/cmd/gwtc/bugcmd.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -26,24 +26,24 @@ import (
"runtime"
"strings"
- "github.com/ethereum/go-ethereum/cmd/internal/browser"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/cmd/internal/browser"
+ "github.com/wtc/go-wtc/params"
- "github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/wtc/go-wtc/cmd/utils"
cli "gopkg.in/urfave/cli.v1"
)
var bugCommand = cli.Command{
Action: utils.MigrateFlags(reportBug),
Name: "bug",
- Usage: "opens a window to report a bug on the geth repo",
+ Usage: "opens a window to report a bug on the gwtc repo",
ArgsUsage: " ",
Category: "MISCELLANEOUS COMMANDS",
}
-const issueUrl = "https://github.com/ethereum/go-ethereum/issues/new"
+const issueUrl = "https://github.com/wtc/go-wtc/issues/new"
-// reportBug reports a bug by opening a new URL to the go-ethereum GH issue
+// reportBug reports a bug by opening a new URL to the go-wtc GH issue
// tracker and setting default values as the issue body.
func reportBug(ctx *cli.Context) error {
// execute template and write contents to buff
diff --git a/cmd/geth/chaincmd.go b/cmd/gwtc/chaincmd.go
old mode 100644
new mode 100755
similarity index 74%
rename from cmd/geth/chaincmd.go
rename to cmd/gwtc/chaincmd.go
index 4a9a7b11b..440f1f720
--- a/cmd/geth/chaincmd.go
+++ b/cmd/gwtc/chaincmd.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,17 +25,15 @@ import (
"sync/atomic"
"time"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/eth/downloader"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/trie"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/trie"
"github.com/syndtr/goleveldb/leveldb/util"
"gopkg.in/urfave/cli.v1"
)
@@ -73,7 +71,7 @@ It expects the genesis file as argument.`,
The import command imports blocks from an RLP-encoded form. The form can be one file
with several RLP-encoded blocks, or several files can be used.
-If only one file is used, import error will result in failure. If several files are used,
+If only one file is used, import error will result in failure. If several files are used,
processing will proceed even if an individual RLP-file import failure occurs.`,
}
exportCommand = cli.Command{
@@ -92,23 +90,6 @@ Requires a first argument of the file to write to.
Optional second and third arguments control the first and
last block to write. In this mode, the file will be appended
if already existing.`,
- }
- copydbCommand = cli.Command{
- Action: utils.MigrateFlags(copyDb),
- Name: "copydb",
- Usage: "Create a local chain from a target chaindata folder",
- ArgsUsage: "<sourceChaindataDir>",
- Flags: []cli.Flag{
- utils.DataDirFlag,
- utils.CacheFlag,
- utils.SyncModeFlag,
- utils.FakePoWFlag,
- utils.TestnetFlag,
- utils.RinkebyFlag,
- },
- Category: "BLOCKCHAIN COMMANDS",
- Description: `
-The first argument must be the directory containing the blockchain to download from`,
}
removedbCommand = cli.Command{
Action: utils.MigrateFlags(removeDB),
@@ -136,7 +117,7 @@ Remove blockchain and state databases`,
Category: "BLOCKCHAIN COMMANDS",
Description: `
The arguments are interpreted as block numbers or hashes.
-Use "ethereum dump 0" to dump the genesis block.`,
+Use "wtc dump 0" to dump the genesis block.`,
}
)
@@ -169,7 +150,7 @@ func initGenesis(ctx *cli.Context) error {
if err != nil {
utils.Fatalf("Failed to write genesis block: %v", err)
}
- log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
+ log.Info("Genesis state update finish.", "database", name, "hash", hash)
}
return nil
}
@@ -215,7 +196,7 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("Import done in %v.\n\n", time.Since(start))
// Output pre-compaction stats mostly to see the import trashing
- db := chainDb.(*ethdb.LDBDatabase)
+ db := chainDb.(*wtcdb.LDBDatabase)
stats, err := db.LDB().GetProperty("leveldb.stats")
if err != nil {
@@ -287,54 +268,6 @@ func exportChain(ctx *cli.Context) error {
return nil
}
-func copyDb(ctx *cli.Context) error {
- // Ensure we have a source chain directory to copy
- if len(ctx.Args()) != 1 {
- utils.Fatalf("Source chaindata directory path argument missing")
- }
- // Initialize a new chain for the running node to sync into
- stack := makeFullNode(ctx)
- chain, chainDb := utils.MakeChain(ctx, stack)
-
- syncmode := *utils.GlobalTextMarshaler(ctx, utils.SyncModeFlag.Name).(*downloader.SyncMode)
- dl := downloader.New(syncmode, chainDb, new(event.TypeMux), chain, nil, nil)
-
- // Create a source peer to satisfy downloader requests from
- db, err := ethdb.NewLDBDatabase(ctx.Args().First(), ctx.GlobalInt(utils.CacheFlag.Name), 256)
- if err != nil {
- return err
- }
- hc, err := core.NewHeaderChain(db, chain.Config(), chain.Engine(), func() bool { return false })
- if err != nil {
- return err
- }
- peer := downloader.NewFakePeer("local", db, hc, dl)
- if err = dl.RegisterPeer("local", 63, peer); err != nil {
- return err
- }
- // Synchronise with the simulated peer
- start := time.Now()
-
- currentHeader := hc.CurrentHeader()
- if err = dl.Synchronise("local", currentHeader.Hash(), hc.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64()), syncmode); err != nil {
- return err
- }
- for dl.Synchronising() {
- time.Sleep(10 * time.Millisecond)
- }
- fmt.Printf("Database copy done in %v\n", time.Since(start))
-
- // Compact the entire database to remove any sync overhead
- start = time.Now()
- fmt.Println("Compacting entire database...")
- if err = chainDb.(*ethdb.LDBDatabase).LDB().CompactRange(util.Range{}); err != nil {
- utils.Fatalf("Compaction failed: %v", err)
- }
- fmt.Printf("Compaction done in %v.\n\n", time.Since(start))
-
- return nil
-}
-
func removeDB(ctx *cli.Context) error {
stack, _ := makeConfigNode(ctx)
diff --git a/cmd/geth/config.go b/cmd/gwtc/config.go
old mode 100644
new mode 100755
similarity index 78%
rename from cmd/geth/config.go
rename to cmd/gwtc/config.go
index 27490c404..510c2c88e
--- a/cmd/geth/config.go
+++ b/cmd/gwtc/config.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -28,13 +28,12 @@ import (
cli "gopkg.in/urfave/cli.v1"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/contracts/release"
- "github.com/ethereum/go-ethereum/dashboard"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/params"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/contracts/release"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/params"
+ whisper "github.com/wtc/go-wtc/whisper/whisperv5"
"github.com/naoina/toml"
)
@@ -76,15 +75,14 @@ type ethstatsConfig struct {
URL string `toml:",omitempty"`
}
-type gethConfig struct {
- Eth eth.Config
- Shh whisper.Config
- Node node.Config
- Ethstats ethstatsConfig
- Dashboard dashboard.Config
+type gwtcConfig struct {
+ Eth eth.Config
+ Shh whisper.Config
+ Node node.Config
+ Ethstats ethstatsConfig
}
-func loadConfig(file string, cfg *gethConfig) error {
+func loadConfig(file string, cfg *gwtcConfig) error {
f, err := os.Open(file)
if err != nil {
return err
@@ -105,17 +103,16 @@ func defaultNodeConfig() node.Config {
cfg.Version = params.VersionWithCommit(gitCommit)
cfg.HTTPModules = append(cfg.HTTPModules, "eth", "shh")
cfg.WSModules = append(cfg.WSModules, "eth", "shh")
- cfg.IPCPath = "geth.ipc"
+ cfg.IPCPath = "gwtc.ipc"
return cfg
}
-func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
+func makeConfigNode(ctx *cli.Context) (*node.Node, gwtcConfig) {
// Load defaults.
- cfg := gethConfig{
- Eth: eth.DefaultConfig,
- Shh: whisper.DefaultConfig,
- Node: defaultNodeConfig(),
- Dashboard: dashboard.DefaultConfig,
+ cfg := gwtcConfig{
+ Eth: eth.DefaultConfig,
+ Shh: whisper.DefaultConfig,
+ Node: defaultNodeConfig(),
}
// Load config file.
@@ -137,7 +134,6 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
}
utils.SetShhConfig(ctx, stack, &cfg.Shh)
- utils.SetDashboardConfig(ctx, &cfg.Dashboard)
return stack, cfg
}
@@ -157,12 +153,9 @@ func makeFullNode(ctx *cli.Context) *node.Node {
utils.RegisterEthService(stack, &cfg.Eth)
- if ctx.GlobalBool(utils.DashboardEnabledFlag.Name) {
- utils.RegisterDashboardService(stack, &cfg.Dashboard)
- }
// Whisper must be explicitly enabled by specifying at least 1 whisper flag or in dev mode
shhEnabled := enableWhisper(ctx)
- shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DeveloperFlag.Name)
+ shhAutoEnabled := !ctx.GlobalIsSet(utils.WhisperEnabledFlag.Name) && ctx.GlobalIsSet(utils.DevModeFlag.Name)
if shhEnabled || shhAutoEnabled {
if ctx.GlobalIsSet(utils.WhisperMaxMessageSizeFlag.Name) {
cfg.Shh.MaxMessageSize = uint32(ctx.Int(utils.WhisperMaxMessageSizeFlag.Name))
@@ -173,7 +166,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
utils.RegisterShhService(stack, &cfg.Shh)
}
- // Add the Ethereum Stats daemon if requested.
+ // Add the Wtc Stats daemon if requested.
if cfg.Ethstats.URL != "" {
utils.RegisterEthStatsService(stack, cfg.Ethstats.URL)
}
@@ -190,7 +183,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
copy(config.Commit[:], commit)
return release.NewReleaseService(ctx, config)
}); err != nil {
- utils.Fatalf("Failed to register the Geth release oracle service: %v", err)
+ utils.Fatalf("Failed to register the gwtc release oracle service: %v", err)
}
return stack
}
diff --git a/cmd/geth/consolecmd.go b/cmd/gwtc/consolecmd.go
old mode 100644
new mode 100755
similarity index 78%
rename from cmd/geth/consolecmd.go
rename to cmd/gwtc/consolecmd.go
index 2bb452d73..b6e49714a
--- a/cmd/geth/consolecmd.go
+++ b/cmd/gwtc/consolecmd.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -21,10 +21,10 @@ import (
"os/signal"
"strings"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/rpc"
"gopkg.in/urfave/cli.v1"
)
@@ -38,9 +38,9 @@ var (
Flags: append(append(append(nodeFlags, rpcFlags...), consoleFlags...), whisperFlags...),
Category: "CONSOLE COMMANDS",
Description: `
-The Geth console is an interactive shell for the JavaScript runtime environment
+The Gwtc console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
-See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.`,
+See https://github.com/wtc/go-wtc/wiki/Javascipt-Console.`,
}
attachCommand = cli.Command{
@@ -51,10 +51,10 @@ See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.`,
Flags: append(consoleFlags, utils.DataDirFlag),
Category: "CONSOLE COMMANDS",
Description: `
-The Geth console is an interactive shell for the JavaScript runtime environment
+The Gwtc console is an interactive shell for the JavaScript runtime environment
which exposes a node admin interface as well as the Ðapp JavaScript API.
-See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console.
-This command allows to open a console on a running geth node.`,
+See https://github.com/wtc/go-wtc/wiki/Javascipt-Console.
+This command allows to open a console on a running gwtc node.`,
}
javascriptCommand = cli.Command{
@@ -66,11 +66,11 @@ This command allows to open a console on a running geth node.`,
Category: "CONSOLE COMMANDS",
Description: `
The JavaScript VM exposes a node admin interface as well as the Ðapp
-JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Console`,
+JavaScript API. See https://github.com/wtc/go-wtc/wiki/Javascipt-Console`,
}
)
-// localConsole starts a new geth node, attaching a JavaScript console to it at the
+// localConsole starts a new gwtc node, attaching a JavaScript console to it at the
// same time.
func localConsole(ctx *cli.Context) error {
// Create and start the node based on the CLI flags
@@ -81,7 +81,7 @@ func localConsole(ctx *cli.Context) error {
// Attach to the newly started node and start the JavaScript console
client, err := node.Attach()
if err != nil {
- utils.Fatalf("Failed to attach to the inproc geth: %v", err)
+ utils.Fatalf("Failed to attach to the inproc gwtc: %v", err)
}
config := console.Config{
DataDir: utils.MakeDataDir(ctx),
@@ -108,13 +108,13 @@ func localConsole(ctx *cli.Context) error {
return nil
}
-// remoteConsole will connect to a remote geth instance, attaching a JavaScript
+// remoteConsole will connect to a remote gwtc instance, attaching a JavaScript
// console to it.
func remoteConsole(ctx *cli.Context) error {
- // Attach to a remotely running geth instance and start the JavaScript console
+ // Attach to a remotely running gwtc instance and start the JavaScript console
client, err := dialRPC(ctx.Args().First())
if err != nil {
- utils.Fatalf("Unable to attach to remote geth: %v", err)
+ utils.Fatalf("Unable to attach to remote gwtc: %v", err)
}
config := console.Config{
DataDir: utils.MakeDataDir(ctx),
@@ -143,19 +143,19 @@ func remoteConsole(ctx *cli.Context) error {
// dialRPC returns a RPC client which connects to the given endpoint.
// The check for empty endpoint implements the defaulting logic
-// for "geth attach" and "geth monitor" with no argument.
+// for "gwtc attach" and "gwtc monitor" with no argument.
func dialRPC(endpoint string) (*rpc.Client, error) {
if endpoint == "" {
endpoint = node.DefaultIPCEndpoint(clientIdentifier)
} else if strings.HasPrefix(endpoint, "rpc:") || strings.HasPrefix(endpoint, "ipc:") {
- // Backwards compatibility with geth < 1.5 which required
+ // Backwards compatibility with gwtc < 1.5 which required
// these prefixes.
endpoint = endpoint[4:]
}
return rpc.Dial(endpoint)
}
-// ephemeralConsole starts a new geth node, attaches an ephemeral JavaScript
+// ephemeralConsole starts a new gwtc node, attaches an ephemeral JavaScript
// console to it, executes each of the files specified as arguments and tears
// everything down.
func ephemeralConsole(ctx *cli.Context) error {
@@ -167,7 +167,7 @@ func ephemeralConsole(ctx *cli.Context) error {
// Attach to the newly started node and start the JavaScript console
client, err := node.Attach()
if err != nil {
- utils.Fatalf("Failed to attach to the inproc geth: %v", err)
+ utils.Fatalf("Failed to attach to the inproc gwtc: %v", err)
}
config := console.Config{
DataDir: utils.MakeDataDir(ctx),
diff --git a/cmd/geth/consolecmd_test.go b/cmd/gwtc/consolecmd_test.go
old mode 100644
new mode 100755
similarity index 69%
rename from cmd/geth/consolecmd_test.go
rename to cmd/gwtc/consolecmd_test.go
index 258b9e6dd..a0cbcf5d5
--- a/cmd/geth/consolecmd_test.go
+++ b/cmd/gwtc/consolecmd_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -27,7 +27,7 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/params"
)
const (
@@ -40,25 +40,25 @@ const (
func TestConsoleWelcome(t *testing.T) {
coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
- // Start a geth console, make sure it's cleaned up and terminate the console
- geth := runGeth(t,
+ // Start a gwtc console, make sure it's cleaned up and terminate the console
+ gwtc := runGwtc(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--shh",
"console")
// Gather all the infos the welcome message needs to contain
- geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
- geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
- geth.SetTemplateFunc("gover", runtime.Version)
- geth.SetTemplateFunc("gethver", func() string { return params.Version })
- geth.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
- geth.SetTemplateFunc("apis", func() string { return ipcAPIs })
+ gwtc.SetTemplateFunc("goos", func() string { return runtime.GOOS })
+ gwtc.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
+ gwtc.SetTemplateFunc("gover", runtime.Version)
+ gwtc.SetTemplateFunc("gwtcver", func() string { return params.Version })
+ gwtc.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
+ gwtc.SetTemplateFunc("apis", func() string { return ipcAPIs })
// Verify the actual welcome message to the required template
- geth.Expect(`
-Welcome to the Geth JavaScript console!
+ gwtc.Expect(`
+Welcome to the Gwtc JavaScript console!
-instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
+instance: Gwtc/v{{gwtcver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{.Etherbase}}
at block: 0 ({{niltime}})
datadir: {{.Datadir}}
@@ -66,7 +66,7 @@ at block: 0 ({{niltime}})
> {{.InputLine "exit"}}
`)
- geth.ExpectExit()
+ gwtc.ExpectExit()
}
// Tests that a console can be attached to a running node via various means.
@@ -75,57 +75,57 @@ func TestIPCAttachWelcome(t *testing.T) {
coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
var ipc string
if runtime.GOOS == "windows" {
- ipc = `\\.\pipe\geth` + strconv.Itoa(trulyRandInt(100000, 999999))
+ ipc = `\\.\pipe\gwtc` + strconv.Itoa(trulyRandInt(100000, 999999))
} else {
ws := tmpdir(t)
defer os.RemoveAll(ws)
- ipc = filepath.Join(ws, "geth.ipc")
+ ipc = filepath.Join(ws, "gwtc.ipc")
}
// Note: we need --shh because testAttachWelcome checks for default
// list of ipc modules and shh is included there.
- geth := runGeth(t,
+ gwtc := runGwtc(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--shh", "--ipcpath", ipc)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "ipc:"+ipc, ipcAPIs)
+ testAttachWelcome(t, gwtc, "ipc:"+ipc, ipcAPIs)
- geth.Interrupt()
- geth.ExpectExit()
+ gwtc.Interrupt()
+ gwtc.ExpectExit()
}
func TestHTTPAttachWelcome(t *testing.T) {
coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
- geth := runGeth(t,
+ gwtc := runGwtc(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--rpc", "--rpcport", port)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "http://localhost:"+port, httpAPIs)
+ testAttachWelcome(t, gwtc, "http://localhost:"+port, httpAPIs)
- geth.Interrupt()
- geth.ExpectExit()
+ gwtc.Interrupt()
+ gwtc.ExpectExit()
}
func TestWSAttachWelcome(t *testing.T) {
coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
port := strconv.Itoa(trulyRandInt(1024, 65536)) // Yeah, sometimes this will fail, sorry :P
- geth := runGeth(t,
+ gwtc := runGwtc(t,
"--port", "0", "--maxpeers", "0", "--nodiscover", "--nat", "none",
"--etherbase", coinbase, "--ws", "--wsport", port)
time.Sleep(2 * time.Second) // Simple way to wait for the RPC endpoint to open
- testAttachWelcome(t, geth, "ws://localhost:"+port, httpAPIs)
+ testAttachWelcome(t, gwtc, "ws://localhost:"+port, httpAPIs)
- geth.Interrupt()
- geth.ExpectExit()
+ gwtc.Interrupt()
+ gwtc.ExpectExit()
}
-func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
- // Attach to a running geth note and terminate immediately
- attach := runGeth(t, "attach", endpoint)
+func testAttachWelcome(t *testing.T, gwtc *testgwtc, endpoint, apis string) {
+ // Attach to a running gwtc note and terminate immediately
+ attach := runGwtc(t, "attach", endpoint)
defer attach.ExpectExit()
attach.CloseStdin()
@@ -133,18 +133,18 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
attach.SetTemplateFunc("gover", runtime.Version)
- attach.SetTemplateFunc("gethver", func() string { return params.Version })
- attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
+ attach.SetTemplateFunc("gwtcver", func() string { return params.Version })
+ attach.SetTemplateFunc("etherbase", func() string { return gwtc.Etherbase })
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })
- attach.SetTemplateFunc("datadir", func() string { return geth.Datadir })
+ attach.SetTemplateFunc("datadir", func() string { return gwtc.Datadir })
attach.SetTemplateFunc("apis", func() string { return apis })
// Verify the actual welcome message to the required template
attach.Expect(`
-Welcome to the Geth JavaScript console!
+Welcome to the Gwtc JavaScript console!
-instance: Geth/v{{gethver}}/{{goos}}-{{goarch}}/{{gover}}
+instance: Gwtc/v{{gwtcver}}/{{goos}}-{{goarch}}/{{gover}}
coinbase: {{etherbase}}
at block: 0 ({{niltime}}){{if ipc}}
datadir: {{datadir}}{{end}}
diff --git a/cmd/geth/genesis_test.go b/cmd/gwtc/genesis_test.go
old mode 100644
new mode 100755
similarity index 87%
rename from cmd/geth/genesis_test.go
rename to cmd/gwtc/genesis_test.go
index a00ae00c1..c6a5b9651
--- a/cmd/geth/genesis_test.go
+++ b/cmd/gwtc/genesis_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -84,7 +84,7 @@ var customGenesisTests = []struct {
},
}
-// Tests that initializing Geth with a custom genesis block and chain definitions
+// Tests that initializing Gwtc with a custom genesis block and chain definitions
// work properly.
func TestCustomGenesis(t *testing.T) {
for i, tt := range customGenesisTests {
@@ -97,14 +97,14 @@ func TestCustomGenesis(t *testing.T) {
if err := ioutil.WriteFile(json, []byte(tt.genesis), 0600); err != nil {
t.Fatalf("test %d: failed to write genesis file: %v", i, err)
}
- runGeth(t, "--datadir", datadir, "init", json).WaitExit()
+ runGwtc(t, "--datadir", datadir, "init", json).WaitExit()
// Query the custom genesis block
- geth := runGeth(t,
+ gwtc := runGwtc(t,
"--datadir", datadir, "--maxpeers", "0", "--port", "0",
"--nodiscover", "--nat", "none", "--ipcdisable",
"--exec", tt.query, "console")
- geth.ExpectRegexp(tt.result)
- geth.ExpectExit()
+ gwtc.ExpectRegexp(tt.result)
+ gwtc.ExpectExit()
}
}
diff --git a/cmd/geth/main.go b/cmd/gwtc/main.go
old mode 100644
new mode 100755
similarity index 77%
rename from cmd/geth/main.go
rename to cmd/gwtc/main.go
index bdb7fad62..816529c1e
--- a/cmd/geth/main.go
+++ b/cmd/gwtc/main.go
@@ -1,20 +1,20 @@
// Copyright 2014 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
-// geth is the official command-line client for Ethereum.
+// gwtc is the official command-line client for Wtc.
package main
import (
@@ -25,31 +25,31 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/ethclient"
- "github.com/ethereum/go-ethereum/internal/debug"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/metrics"
- "github.com/ethereum/go-ethereum/node"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/wtcclient"
+ "github.com/wtc/go-wtc/internal/debug"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/metrics"
+ "github.com/wtc/go-wtc/node"
"gopkg.in/urfave/cli.v1"
)
const (
- clientIdentifier = "geth" // Client identifier to advertise over the network
+ clientIdentifier = "gwtc" // Client identifier to advertise over the network
)
var (
// Git SHA1 commit hash of the release (set via linker flags)
gitCommit = ""
- // Ethereum address of the Geth release oracle.
+ // Wtc address of the Gwtc release oracle.
relOracle = common.HexToAddress("0xfa7b9770ca4cb04296cac84f37736d4041251cdf")
// The app that holds all commands and flags.
- app = utils.NewApp(gitCommit, "the go-ethereum command line interface")
+ app = utils.NewApp(gitCommit, "the go-wtc command line interface")
// flags that configure the node
nodeFlags = []cli.Flag{
utils.IdentityFlag,
@@ -61,11 +61,6 @@ var (
utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NoUSBFlag,
- utils.DashboardEnabledFlag,
- utils.DashboardAddrFlag,
- utils.DashboardPortFlag,
- utils.DashboardRefreshFlag,
- utils.DashboardAssetsFlag,
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
@@ -104,8 +99,7 @@ var (
utils.NetrestrictFlag,
utils.NodeKeyFileFlag,
utils.NodeKeyHexFlag,
- utils.DeveloperFlag,
- utils.DeveloperPeriodFlag,
+ utils.DevModeFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
utils.VMEnableDebugFlag,
@@ -114,6 +108,9 @@ var (
utils.EthStatsURLFlag,
utils.MetricsEnabledFlag,
utils.FakePoWFlag,
+ utils.GPUPowFlag,
+ utils.GPUPortFlag,
+ utils.GPUGetFlag,
utils.NoCompactionFlag,
utils.GpoBlocksFlag,
utils.GpoPercentileFlag,
@@ -143,16 +140,15 @@ var (
)
func init() {
- // Initialize the CLI app and start Geth
- app.Action = geth
+ // Initialize the CLI app and start Gwtc
+ app.Action = gwtc
app.HideVersion = true // we have a command to print the version
- app.Copyright = "Copyright 2013-2017 The go-ethereum Authors"
+ app.Copyright = "Copyright 2018-2019 The walton Authors"
app.Commands = []cli.Command{
// See chaincmd.go:
initCommand,
importCommand,
exportCommand,
- copydbCommand,
removedbCommand,
dumpCommand,
// See monitorcmd.go:
@@ -207,10 +203,10 @@ func main() {
}
}
-// geth is the main entry point into the system if no special subcommand is ran.
+// gwtc is the main entry point into the system if no special subcommand is ran.
// It creates a default node based on the command line arguments and runs it in
// blocking mode, waiting for it to be shut down.
-func geth(ctx *cli.Context) error {
+func gwtc(ctx *cli.Context) error {
node := makeFullNode(ctx)
startNode(ctx, node)
node.Wait()
@@ -244,7 +240,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
if err != nil {
utils.Fatalf("Failed to attach to self: %v", err)
}
- stateReader := ethclient.NewClient(rpcClient)
+ stateReader := wtcclient.NewClient(rpcClient)
// Open any wallets already attached
for _, wallet := range stack.AccountManager().Wallets() {
@@ -276,24 +272,24 @@ func startNode(ctx *cli.Context, stack *node.Node) {
}
}()
// Start auxiliary services if enabled
- if ctx.GlobalBool(utils.MiningEnabledFlag.Name) || ctx.GlobalBool(utils.DeveloperFlag.Name) {
- // Mining only makes sense if a full Ethereum node is running
- var ethereum *eth.Ethereum
- if err := stack.Service(&ethereum); err != nil {
- utils.Fatalf("ethereum service not running: %v", err)
+ if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
+ // Mining only makes sense if a full Wtc node is running
+ var wtc *eth.Wtc
+ if err := stack.Service(&wtc); err != nil {
+ utils.Fatalf("wtc service not running: %v", err)
}
// Use a reduced number of threads if requested
if threads := ctx.GlobalInt(utils.MinerThreadsFlag.Name); threads > 0 {
type threaded interface {
SetThreads(threads int)
}
- if th, ok := ethereum.Engine().(threaded); ok {
+ if th, ok := wtc.Engine().(threaded); ok {
th.SetThreads(threads)
}
}
// Set the gas price to the limits from the CLI and start mining
- ethereum.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name))
- if err := ethereum.StartMining(true); err != nil {
+ wtc.TxPool().SetGasPrice(utils.GlobalBig(ctx, utils.GasPriceFlag.Name))
+ if err := wtc.StartMining(true); err != nil {
utils.Fatalf("Failed to start mining: %v", err)
}
}
diff --git a/cmd/geth/misccmd.go b/cmd/gwtc/misccmd.go
old mode 100644
new mode 100755
similarity index 78%
rename from cmd/geth/misccmd.go
rename to cmd/gwtc/misccmd.go
index 2e68dcda3..4125a1022
--- a/cmd/geth/misccmd.go
+++ b/cmd/gwtc/misccmd.go
@@ -1,32 +1,30 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"fmt"
- "os"
"runtime"
"strconv"
"strings"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/params"
"gopkg.in/urfave/cli.v1"
)
@@ -80,7 +78,7 @@ The output of this command is supposed to be machine-readable.
func makecache(ctx *cli.Context) error {
args := ctx.Args()
if len(args) != 2 {
- utils.Fatalf(`Usage: geth makecache <block number> <outputdir>`)
+ utils.Fatalf(`Usage: gwtc makecache <block number> <outputdir>`)
}
block, err := strconv.ParseUint(args[0], 0, 64)
if err != nil {
@@ -95,7 +93,7 @@ func makecache(ctx *cli.Context) error {
func makedag(ctx *cli.Context) error {
args := ctx.Args()
if len(args) != 2 {
- utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`)
+ utils.Fatalf(`Usage: gwtc makedag <block number> <outputdir>`)
}
block, err := strconv.ParseUint(args[0], 0, 64)
if err != nil {
@@ -113,28 +111,24 @@ func version(ctx *cli.Context) error {
fmt.Println("Git Commit:", gitCommit)
}
fmt.Println("Architecture:", runtime.GOARCH)
- fmt.Println("Protocol Versions:", eth.ProtocolVersions)
- fmt.Println("Network Id:", eth.DefaultConfig.NetworkId)
fmt.Println("Go Version:", runtime.Version())
fmt.Println("Operating System:", runtime.GOOS)
- fmt.Printf("GOPATH=%s\n", os.Getenv("GOPATH"))
- fmt.Printf("GOROOT=%s\n", runtime.GOROOT())
return nil
}
func license(_ *cli.Context) error {
- fmt.Println(`Geth is free software: you can redistribute it and/or modify
+ fmt.Println(`Gwtc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
-Geth is distributed in the hope that it will be useful,
+Gwtc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with geth. If not, see <http://www.gnu.org/licenses/>.
+along with gwtc. If not, see <http://www.gnu.org/licenses/>.
`)
return nil
}
diff --git a/cmd/geth/monitorcmd.go b/cmd/gwtc/monitorcmd.go
old mode 100644
new mode 100755
similarity index 94%
rename from cmd/geth/monitorcmd.go
rename to cmd/gwtc/monitorcmd.go
index cd19caa27..975aa1b34
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/gwtc/monitorcmd.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,9 +25,9 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/rpc"
"github.com/gizak/termui"
"gopkg.in/urfave/cli.v1"
)
@@ -55,7 +55,7 @@ var (
ArgsUsage: " ",
Category: "MONITOR COMMANDS",
Description: `
-The Geth monitor is a tool to collect and visualize various internal metrics
+The Gwtc monitor is a tool to collect and visualize various internal metrics
gathered by the node, supporting different chart types as well as the capacity
to display multiple metrics simultaneously.
`,
@@ -73,10 +73,10 @@ func monitor(ctx *cli.Context) error {
client *rpc.Client
err error
)
- // Attach to an Ethereum node over IPC or RPC
+ // Attach to an Wtc node over IPC or RPC
endpoint := ctx.String(monitorCommandAttachFlag.Name)
if client, err = dialRPC(endpoint); err != nil {
- utils.Fatalf("Unable to attach to geth node: %v", err)
+ utils.Fatalf("Unable to attach to gwtc node: %v", err)
}
defer client.Close()
@@ -93,7 +93,7 @@ func monitor(ctx *cli.Context) error {
if len(list) > 0 {
utils.Fatalf("No metrics specified.\n\nAvailable:\n - %s", strings.Join(list, "\n - "))
} else {
- utils.Fatalf("No metrics collected by geth (--%s).\n", utils.MetricsEnabledFlag.Name)
+ utils.Fatalf("No metrics collected by gwtc (--%s).\n", utils.MetricsEnabledFlag.Name)
}
}
sort.Strings(monitored)
@@ -158,7 +158,7 @@ func monitor(ctx *cli.Context) error {
return nil
}
-// retrieveMetrics contacts the attached geth node and retrieves the entire set
+// retrieveMetrics contacts the attached gwtc node and retrieves the entire set
// of collected system metrics.
func retrieveMetrics(client *rpc.Client) (map[string]interface{}, error) {
var metrics map[string]interface{}
diff --git a/cmd/geth/run_test.go b/cmd/gwtc/run_test.go
old mode 100644
new mode 100755
similarity index 71%
rename from cmd/geth/run_test.go
rename to cmd/gwtc/run_test.go
index da82facac..48c917335
--- a/cmd/geth/run_test.go
+++ b/cmd/gwtc/run_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -23,18 +23,18 @@ import (
"testing"
"github.com/docker/docker/pkg/reexec"
- "github.com/ethereum/go-ethereum/internal/cmdtest"
+ "github.com/wtc/go-wtc/internal/cmdtest"
)
func tmpdir(t *testing.T) string {
- dir, err := ioutil.TempDir("", "geth-test")
+ dir, err := ioutil.TempDir("", "gwtc-test")
if err != nil {
t.Fatal(err)
}
return dir
}
-type testgeth struct {
+type testgwtc struct {
*cmdtest.TestCmd
// template variables for expect
@@ -43,8 +43,8 @@ type testgeth struct {
}
func init() {
- // Run the app if we've been exec'd as "geth-test" in runGeth.
- reexec.Register("geth-test", func() {
+ // Run the app if we've been exec'd as "gwtc-test" in runGwtc.
+ reexec.Register("gwtc-test", func() {
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
@@ -61,10 +61,10 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
-// spawns geth with the given command line args. If the args don't set --datadir, the
+// spawns gwtc with the given command line args. If the args don't set --datadir, the
// child g gets a temporary data directory.
-func runGeth(t *testing.T, args ...string) *testgeth {
- tt := &testgeth{}
+func runGwtc(t *testing.T, args ...string) *testgwtc {
+ tt := &testgwtc{}
tt.TestCmd = cmdtest.NewTestCmd(t, tt)
for i, arg := range args {
switch {
@@ -90,9 +90,9 @@ func runGeth(t *testing.T, args ...string) *testgeth {
}()
}
- // Boot "geth". This actually runs the test binary but the TestMain
+ // Boot "gwtc". This actually runs the test binary but the TestMain
// function will prevent any tests from running.
- tt.Run("geth-test", args...)
+ tt.Run("gwtc-test", args...)
return tt
}
diff --git a/cmd/geth/testdata/empty.js b/cmd/gwtc/testdata/empty.js
old mode 100644
new mode 100755
similarity index 100%
rename from cmd/geth/testdata/empty.js
rename to cmd/gwtc/testdata/empty.js
diff --git a/cmd/geth/testdata/guswallet.json b/cmd/gwtc/testdata/guswallet.json
old mode 100644
new mode 100755
similarity index 100%
rename from cmd/geth/testdata/guswallet.json
rename to cmd/gwtc/testdata/guswallet.json
diff --git a/cmd/geth/testdata/passwords.txt b/cmd/gwtc/testdata/passwords.txt
old mode 100644
new mode 100755
similarity index 100%
rename from cmd/geth/testdata/passwords.txt
rename to cmd/gwtc/testdata/passwords.txt
diff --git a/cmd/geth/testdata/wrong-passwords.txt b/cmd/gwtc/testdata/wrong-passwords.txt
old mode 100644
new mode 100755
similarity index 100%
rename from cmd/geth/testdata/wrong-passwords.txt
rename to cmd/gwtc/testdata/wrong-passwords.txt
diff --git a/cmd/geth/usage.go b/cmd/gwtc/usage.go
old mode 100644
new mode 100755
similarity index 89%
rename from cmd/geth/usage.go
rename to cmd/gwtc/usage.go
index a834d5b7a..2303664b6
--- a/cmd/geth/usage.go
+++ b/cmd/gwtc/usage.go
@@ -1,20 +1,20 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
-// Contains the geth command usage template and generator.
+// Contains the gwtc command usage template and generator.
package main
@@ -22,10 +22,9 @@ import (
"io"
"sort"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/internal/debug"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/internal/debug"
"gopkg.in/urfave/cli.v1"
- "strings"
)
// AppHelpTemplate is the test template for the default, global app help topic.
@@ -64,7 +63,7 @@ type flagGroup struct {
// AppHelpFlagGroups is the application flags, grouped by functionality.
var AppHelpFlagGroups = []flagGroup{
{
- Name: "ETHEREUM",
+ Name: "WTC",
Flags: []cli.Flag{
configFileFlag,
utils.DataDirFlag,
@@ -73,6 +72,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.NetworkIdFlag,
utils.TestnetFlag,
utils.RinkebyFlag,
+ utils.DevModeFlag,
utils.SyncModeFlag,
utils.EthStatsURLFlag,
utils.IdentityFlag,
@@ -81,12 +81,6 @@ var AppHelpFlagGroups = []flagGroup{
utils.LightKDFFlag,
},
},
- {Name: "DEVELOPER CHAIN",
- Flags: []cli.Flag{
- utils.DeveloperFlag,
- utils.DeveloperPeriodFlag,
- },
- },
{
Name: "ETHASH",
Flags: []cli.Flag{
@@ -96,18 +90,11 @@ var AppHelpFlagGroups = []flagGroup{
utils.EthashDatasetDirFlag,
utils.EthashDatasetsInMemoryFlag,
utils.EthashDatasetsOnDiskFlag,
+ utils.GPUPowFlag,
+ utils.GPUPortFlag,
+ utils.GPUGetFlag,
},
},
- //{
- // Name: "DASHBOARD",
- // Flags: []cli.Flag{
- // utils.DashboardEnabledFlag,
- // utils.DashboardAddrFlag,
- // utils.DashboardPortFlag,
- // utils.DashboardRefreshFlag,
- // utils.DashboardAssetsFlag,
- // },
- //},
{
Name: "TRANSACTION POOL",
Flags: []cli.Flag{
@@ -279,9 +266,6 @@ func init() {
uncategorized := []cli.Flag{}
for _, flag := range data.(*cli.App).Flags {
if _, ok := categorized[flag.String()]; !ok {
- if strings.HasPrefix(flag.GetName(), "dashboard") {
- continue
- }
uncategorized = append(uncategorized, flag)
}
}
diff --git a/cmd/internal/browser/browser.go b/cmd/internal/browser/browser.go
old mode 100644
new mode 100755
diff --git a/cmd/p2psim/main.go b/cmd/p2psim/main.go
old mode 100644
new mode 100755
index 56b74d135..50802d18b
--- a/cmd/p2psim/main.go
+++ b/cmd/p2psim/main.go
@@ -29,12 +29,12 @@ import (
"strings"
"text/tabwriter"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/p2p/simulations"
- "github.com/ethereum/go-ethereum/p2p/simulations/adapters"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/p2p/simulations"
+ "github.com/wtc/go-wtc/p2p/simulations/adapters"
+ "github.com/wtc/go-wtc/rpc"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/puppeth/module.go b/cmd/puppeth/module.go
old mode 100644
new mode 100755
index b6a029a01..27b556620
--- a/cmd/puppeth/module.go
+++ b/cmd/puppeth/module.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,7 +25,7 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
var (
diff --git a/cmd/puppeth/module_dashboard.go b/cmd/puppeth/module_dashboard.go
old mode 100644
new mode 100755
index 1cf6cab79..ef39a6183
--- a/cmd/puppeth/module_dashboard.go
+++ b/cmd/puppeth/module_dashboard.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -24,7 +24,7 @@ import (
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// dashboardContent is the actual dashboard HTML content to serve up when users
@@ -39,7 +39,7 @@ var dashboardContent = `
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>{{.NetworkTitle}}: Ethereum Testnet</title>
+ <title>{{.NetworkTitle}}: Wtc Testnet</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
@@ -82,9 +82,9 @@ var dashboardContent = `
{{if .FaucetPage}}<li><a onclick="load('//{{.FaucetPage}}')"><i class="fa fa-bath"></i> Crypto Faucet</a></li>{{end}}
<li id="connect"><a><i class="fa fa-plug"></i> Connect Yourself</a>
<ul id="connect_list" class="nav child_menu">
- <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-geth')">Go Ethereum: Geth</a></li>
- <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-mist')">Go Ethereum: Wallet & Mist</a></li>
- <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-ethereum-mobile')">Go Ethereum: Android & iOS</a></li>
+ <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-wtc-gwtc')">Go Wtc: Gwtc</a></li>
+ <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-wtc-mist')">Go Wtc: Wallet & Mist</a></li>
+ <li><a onclick="$('#connect').removeClass('active'); $('#connect_list').toggle(); load('#connect-go-wtc-mobile')">Go Wtc: Android & iOS</a></li>
</ul>
</li>
<li><a onclick="load('#about')"><i class="fa fa-heartbeat"></i> About Puppeth</a></li>
@@ -94,10 +94,10 @@ var dashboardContent = `
</div>
</div>
<div class="right_col" role="main" style="padding: 0">
- <div id="connect-go-ethereum-geth" hidden style="padding: 16px;">
+ <div id="connect-go-wtc-gwtc" hidden style="padding: 16px;">
<div class="page-title">
<div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Geth</h3>
+ <h3>Connect Yourself &ndash; Go Wtc: Gwtc</h3>
</div>
</div>
<div class="clearfix"></div>
@@ -112,12 +112,12 @@ var dashboardContent = `
<p>An archive node synchronizes the blockchain by downloading the full chain from the genesis block to the current head block, executing all the transactions contained within. As the node crunches through the transactions, all past historical state is stored on disk, and can be queried for each and every block.</p>
<p>Initial processing required to execute all transactions may require non-negligible time and disk capacity required to store all past state may be non-insignificant. High end machines with SSD storage, modern CPUs and 8GB+ RAM are recommended.</p>
<br/>
- <p>To run an archive node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024 --syncmode=full{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
+ <p>To run an archive node, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and start Gwtc with:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} init {{.GwtcGenesis}}</pre>
+ <pre>gwtc --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=1024 --syncmode=full{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
</p>
<br/>
- <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
+ <p>You can download Gwtc from <a href="https://gwtc.wtc.org/downloads/" target="about:blank">https://gwtc.wtc.org/downloads/</a>.</p>
</div>
</div>
</div>
@@ -131,12 +131,12 @@ var dashboardContent = `
<p>A full node synchronizes the blockchain by downloading the full chain from the genesis block to the current head block, but does not execute the transactions. Instead, it downloads all the transactions receipts along with the entire recent state. As the node downloads the recent state directly, historical data can only be queried from that block onward.</p>
<p>Initial processing required to synchronize is more bandwidth intensive, but is light on the CPU and has significantly reduced disk requirements. Mid range machines with HDD storage, decent CPUs and 4GB+ RAM should be enough.</p>
<br/>
- <p>To run a full node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
+ <p>To run a full node, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and start Gwtc with:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} init {{.GwtcGenesis}}</pre>
+ <pre>gwtc --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=512{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesFullFlat}}</pre>
</p>
<br/>
- <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
+ <p>You can download Gwtc from <a href="https://gwtc.wtc.org/downloads/" target="about:blank">https://gwtc.wtc.org/downloads/</a>.</p>
</div>
</div>
</div>
@@ -153,12 +153,12 @@ var dashboardContent = `
<p>A light node synchronizes the blockchain by downloading and verifying only the chain of headers from the genesis block to the current head, without executing any transactions or retrieving any associated state. As no state is available locally, any interaction with the blockchain relies on on-demand data retrievals from remote nodes.</p>
<p>Initial processing required to synchronize is light, as it only verifies the validity of the headers; similarly required disk capacity is small, tallying around 500 bytes per header. Low end machines with arbitrary storage, weak CPUs and 512MB+ RAM should cope well.</p>
<br/>
- <p>To run a light node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
+ <p>To run a light node, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and start Gwtc with:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} --light init {{.GwtcGenesis}}</pre>
+ <pre>gwtc --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
</p>
<br/>
- <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
+ <p>You can download Gwtc from <a href="https://gwtc.wtc.org/downloads/" target="about:blank">https://gwtc.wtc.org/downloads/</a>.</p>
</div>
</div>
</div>
@@ -172,21 +172,21 @@ var dashboardContent = `
<p>An embedded node is a variation of the light node with configuration parameters tuned towards low memory footprint. As such, it may sacrifice processing and disk IO performance to conserve memory. It should be considered an <strong>experimental</strong> direction for now without hard guarantees or bounds on the resources used.</p>
<p>Initial processing required to synchronize is light, as it only verifies the validity of the headers; similarly required disk capacity is small, tallying around 500 bytes per header. Embedded machines with arbitrary storage, low power CPUs and 128MB+ RAM may work.</p>
<br/>
- <p>To run an embedded node, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and start Geth with:
- <pre>geth --datadir=$HOME/.{{.Network}} --light init {{.GethGenesis}}</pre>
- <pre>geth --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=32 --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
+ <p>To run an embedded node, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and start Gwtc with:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} --light init {{.GwtcGenesis}}</pre>
+ <pre>gwtc --networkid={{.NetworkID}} --datadir=$HOME/.{{.Network}} --cache=32 --syncmode=light{{if .Ethstats}} --ethstats='{{.Ethstats}}'{{end}} --bootnodes={{.BootnodesLightFlat}}</pre>
</p>
<br/>
- <p>You can download Geth from <a href="https://geth.ethereum.org/downloads/" target="about:blank">https://geth.ethereum.org/downloads/</a>.</p>
+ <p>You can download Gwtc from <a href="https://gwtc.wtc.org/downloads/" target="about:blank">https://gwtc.wtc.org/downloads/</a>.</p>
</div>
</div>
</div>
</div>
</div>
- <div id="connect-go-ethereum-mist" hidden style="padding: 16px;">
+ <div id="connect-go-wtc-mist" hidden style="padding: 16px;">
<div class="page-title">
<div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Wallet &amp; Mist</h3>
+ <h3>Connect Yourself &ndash; Go Wtc: Wallet &amp; Mist</h3>
</div>
</div>
<div class="clearfix"></div>
@@ -198,17 +198,17 @@ var dashboardContent = `
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>The Ethereum Wallet is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to manage your Ethereum accounts and funds. Beside the usual account life-cycle operations you would expect to perform, the wallet also provides a means to send transactions from your accounts and to interact with smart contracts deployed on the network.</p>
- <p>Under the hood the wallet is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
+ <p>The Wtc Wallet is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to manage your Wtc accounts and funds. Beside the usual account life-cycle operations you would expect to perform, the wallet also provides a means to send transactions from your accounts and to interact with smart contracts deployed on the network.</p>
+ <p>Under the hood the wallet is backed by a go-wtc full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
<br/>
- <p>To connect with the Ethereum Wallet, you'll need to initialize your private network first via Geth as the wallet does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ <p>To connect with the Wtc Wallet, you'll need to initialize your private network first via Gwtc as the wallet does not currently support calling Gwtc directly. To initialize your local chain, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and run:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} init {{.GwtcGenesis}}</pre>
</p>
- <p>With your local chain initialized, you can start the Ethereum Wallet:
- <pre>ethereumwallet --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
+ <p>With your local chain initialized, you can start the Wtc Wallet:
+ <pre>wtcwallet --rpc $HOME/.{{.Network}}/gwtc.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
<p>
<br/>
- <p>You can download the Ethereum Wallet from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
+ <p>You can download the Wtc Wallet from <a href="https://github.com/wtc/mist/releases" target="about:blank">https://github.com/wtc/mist/releases</a>.</p>
</div>
</div>
</div>
@@ -219,26 +219,26 @@ var dashboardContent = `
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with Ethereum enabled third party web DApps. Beside all the functionality provided by the Ethereum Wallet, Mist is an extended web-browser where loaded pages have access to the Ethereum network via a web3.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
- <p>Under the hood the browser is backed by a go-ethereum full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
+ <p>The Mist browser is an <a href="https://electron.atom.io/" target="about:blank">Electron</a> based desktop application to load and interact with Wtc enabled third party web DApps. Beside all the functionality provided by the Wtc Wallet, Mist is an extended web-browser where loaded pages have access to the Wtc network via a web3.js provider, and may also interact with users' own accounts (given proper authorization and confirmation of course).</p>
+ <p>Under the hood the browser is backed by a go-wtc full node, meaning that a mid range machine is assumed. Similarly, synchronization is based on <strong>fast-sync</strong>, which will download all blockchain data from the network and make it available to the wallet. Light nodes cannot currently fully back the wallet, but it's a target actively pursued.</p>
<br/>
- <p>To connect with the Mist browser, you'll need to initialize your private network first via Geth as Mist does not currently support calling Geth directly. To initialize your local chain, download <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> and run:
- <pre>geth --datadir=$HOME/.{{.Network}} init {{.GethGenesis}}</pre>
+ <p>To connect with the Mist browser, you'll need to initialize your private network first via Gwtc as Mist does not currently support calling Gwtc directly. To initialize your local chain, download <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> and run:
+ <pre>gwtc --datadir=$HOME/.{{.Network}} init {{.GwtcGenesis}}</pre>
</p>
<p>With your local chain initialized, you can start Mist:
- <pre>mist --rpc $HOME/.{{.Network}}/geth.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
+ <pre>mist --rpc $HOME/.{{.Network}}/gwtc.ipc --node-networkid={{.NetworkID}} --node-datadir=$HOME/.{{.Network}}{{if .Ethstats}} --node-ethstats='{{.Ethstats}}'{{end}} --node-bootnodes={{.BootnodesFullFlat}}</pre>
<p>
<br/>
- <p>You can download the Mist browser from <a href="https://github.com/ethereum/mist/releases" target="about:blank">https://github.com/ethereum/mist/releases</a>.</p>
+ <p>You can download the Mist browser from <a href="https://github.com/wtc/mist/releases" target="about:blank">https://github.com/wtc/mist/releases</a>.</p>
</div>
</div>
</div>
</div>
</div>
- <div id="connect-go-ethereum-mobile" hidden style="padding: 16px;">
+ <div id="connect-go-wtc-mobile" hidden style="padding: 16px;">
<div class="page-title">
<div class="title_left">
- <h3>Connect Yourself &ndash; Go Ethereum: Android &amp; iOS</h3>
+ <h3>Connect Yourself &ndash; Go Wtc: Android &amp; iOS</h3>
</div>
</div>
<div class="clearfix"></div>
@@ -246,26 +246,26 @@ var dashboardContent = `
<div class="col-md-6">
<div class="x_panel">
<div class="x_title">
- <h2><i class="fa fa-android" aria-hidden="true"></i> Android devices <small>Accesses Ethereum via Java</small></h2>
+ <h2><i class="fa fa-android" aria-hidden="true"></i> Android devices <small>Accesses Wtc via Java</small></h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for Java based Android projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from Android too.</p>
- <p>Under the hood the Android library is backed by a go-ethereum light node, meaning that given a not-too-old Android device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
+ <p>Starting with the 1.5 release of go-wtc, we've transitioned away from shipping only full blown Wtc clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for Java based Android projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Wtc network can nonetheless be accessed from Android too.</p>
+ <p>Under the hood the Android library is backed by a go-wtc light node, meaning that given a not-too-old Android device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
<br/>
- <p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
- <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your Android project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
- <p>Inside your Java code you can now import the geth archive and connect to Ethereum:
- <pre>import org.ethereum.geth.*;</pre>
+ <p>The stable Android archives are distributed via Maven Central, and the develop snapshots via the Sonatype repositories. Before proceeding, please ensure you have a recent version configured in your Android project. You can find details in <a href="https://github.com/wtc/go-wtc/wiki/Mobile:-Introduction#android-archive" target="about:blank">Mobile: Introduction &ndash; Android archive</a>.
+ <p>Before connecting to the Wtc network, download the <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> genesis json file and either store it in your Android project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
+ <p>Inside your Java code you can now import the gwtc archive and connect to Wtc:
+ <pre>import org.wtc.gwtc.*;</pre>
<pre>
Enodes bootnodes = new Enodes();{{range .BootnodesLight}}
bootnodes.append(new Enode("{{.}}"));{{end}}
NodeConfig config = new NodeConfig();
config.setBootstrapNodes(bootnodes);
-config.setEthereumNetworkID({{.NetworkID}});
-config.setEthereumGenesis(genesis);{{if .Ethstats}}
-config.setEthereumNetStats("{{.Ethstats}}");{{end}}
+config.setWtcNetworkID({{.NetworkID}});
+config.setWtcGenesis(genesis);{{if .Ethstats}}
+config.setWtcNetStats("{{.Ethstats}}");{{end}}
Node node = new Node(getFilesDir() + "/.{{.Network}}", config);
node.start();
@@ -277,31 +277,31 @@ node.start();
<div class="col-md-6">
<div class="x_panel">
<div class="x_title">
- <h2><i class="fa fa-apple" aria-hidden="true"></i> iOS devices <small>Accesses Ethereum via ObjC/Swift</small></h2>
+ <h2><i class="fa fa-apple" aria-hidden="true"></i> iOS devices <small>Accesses Wtc via ObjC/Swift</small></h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
- <p>Starting with the 1.5 release of go-ethereum, we've transitioned away from shipping only full blown Ethereum clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for ObjC/Swift based iOS projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Ethereum network can nonetheless be accessed from iOS too.</p>
- <p>Under the hood the iOS library is backed by a go-ethereum light node, meaning that given a not-too-old Apple device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
+ <p>Starting with the 1.5 release of go-wtc, we've transitioned away from shipping only full blown Wtc clients and started focusing on releasing the code as reusable packages initially for Go projects, then later for ObjC/Swift based iOS projects too. Mobile support is still evolving, hence is bound to change often and hard, but the Wtc network can nonetheless be accessed from iOS too.</p>
+ <p>Under the hood the iOS library is backed by a go-wtc light node, meaning that given a not-too-old Apple device, you should be able to join the network without significant issues. Certain functionality is not yet available and rough edges are bound to appear here and there, please report issues if you find any.</p>
<br/>
- <p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/ethereum/go-ethereum/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
- <p>Before connecting to the Ethereum network, download the <a href="/{{.GethGenesis}}"><code>{{.GethGenesis}}</code></a> genesis json file and either store it in your iOS project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
- <p>Inside your Swift code you can now import the geth framework and connect to Ethereum (ObjC should be analogous):
- <pre>import Geth</pre>
+ <p>Both stable and develop builds of the iOS framework are available via CocoaPods. Before proceeding, please ensure you have a recent version configured in your iOS project. You can find details in <a href="https://github.com/wtc/go-wtc/wiki/Mobile:-Introduction#ios-framework" target="about:blank">Mobile: Introduction &ndash; iOS framework</a>.
+ <p>Before connecting to the Wtc network, download the <a href="/{{.GwtcGenesis}}"><code>{{.GwtcGenesis}}</code></a> genesis json file and either store it in your iOS project as a resource file you can access, or save it as a string in a variable. You're going to need to to initialize your client.</p>
+ <p>Inside your Swift code you can now import the gwtc framework and connect to Wtc (ObjC should be analogous):
+ <pre>import Gwtc</pre>
<pre>
var error: NSError?
-let bootnodes = GethNewEnodesEmpty(){{range .BootnodesLight}}
-bootnodes?.append(GethNewEnode("{{.}}", &error)){{end}}
+let bootnodes = GwtcNewEnodesEmpty(){{range .BootnodesLight}}
+bootnodes?.append(GwtcNewEnode("{{.}}", &error)){{end}}
-let config = GethNewNodeConfig()
+let config = GwtcNewNodeConfig()
config?.setBootstrapNodes(bootnodes)
-config?.setEthereumNetworkID({{.NetworkID}})
-config?.setEthereumGenesis(genesis){{if .Ethstats}}
-config?.setEthereumNetStats("{{.Ethstats}}"){{end}}
+config?.setWtcNetworkID({{.NetworkID}})
+config?.setWtcGenesis(genesis){{if .Ethstats}}
+config?.setWtcNetStats("{{.Ethstats}}"){{end}}
let datadir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
-let node = GethNewNode(datadir + "/.{{.Network}}", config, &error);
+let node = GwtcNewNode(datadir + "/.{{.Network}}", config, &error);
try! node?.start();
</pre>
<p>
@@ -315,14 +315,14 @@ try! node?.start();
<div style="margin: 0 auto;">
<div class="x_panel">
<div class="x_title">
- <h3>Puppeth &ndash; Your Ethereum private network manager</h3>
+ <h3>Puppeth &ndash; Your Wtc private network manager</h3>
<div class="clearfix"></div>
</div>
<div style="display: inline-block; vertical-align: bottom; width: 623px; margin-top: 16px;">
- <p>Puppeth is a tool to aid you in creating a new Ethereum network down to the genesis block, bootnodes, signers, ethstats server, crypto faucet, wallet browsers, block explorer, dashboard and more; without the hassle that it would normally entail to manually configure all these services one by one.</p>
+ <p>Puppeth is a tool to aid you in creating a new Wtc network down to the genesis block, bootnodes, signers, ethstats server, crypto faucet, wallet browsers, block explorer, dashboard and more; without the hassle that it would normally entail to manually configure all these services one by one.</p>
<p>Puppeth uses ssh to dial in to remote servers, and builds its network components out of docker containers using docker-compose. The user is guided through the process via a command line wizard that does the heavy lifting and topology configuration automatically behind the scenes.</p>
<br/>
- <p>Puppeth is distributed as part of the <a href="https://geth.ethereum.org/downloads/" target="about:blank">Geth &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/ethereum/go-ethereum/cmd/puppeth</pre></p>
+ <p>Puppeth is distributed as part of the <a href="https://gwtc.wtc.org/downloads/" target="about:blank">Gwtc &amp; Tools</a> bundles, but can also be installed separately via:<pre>go get github.com/wtc/go-wtc/cmd/puppeth</pre></p>
<br/>
<p><em>Copyright 2017. The go-ethereum Authors.</em></p>
</div>
@@ -345,9 +345,9 @@ try! node?.start();
<script src="https://cdnjs.cloudflare.com/ajax/libs/gentelella/1.3.0/js/custom.min.js"></script>
<script>
var load = function(url) {
- $("#connect-go-ethereum-geth").fadeOut(300)
- $("#connect-go-ethereum-mist").fadeOut(300)
- $("#connect-go-ethereum-mobile").fadeOut(300)
+ $("#connect-go-wtc-gwtc").fadeOut(300)
+ $("#connect-go-wtc-mist").fadeOut(300)
+ $("#connect-go-wtc-mobile").fadeOut(300)
$("#about").fadeOut(300)
$("#frame-wrapper").fadeOut(300);
@@ -468,7 +468,7 @@ func deployDashboard(client *sshClient, network string, port int, vhost string,
"ExplorerPage": services["explorer"],
"WalletPage": services["wallet"],
"FaucetPage": services["faucet"],
- "GethGenesis": network + ".json",
+ "GwtcGenesis": network + ".json",
"BootnodesFull": conf.bootFull,
"BootnodesLight": conf.bootLight,
"BootnodesFullFlat": strings.Join(conf.bootFull, ","),
diff --git a/cmd/puppeth/module_ethstats.go b/cmd/puppeth/module_ethstats.go
old mode 100644
new mode 100755
index 6ce662f65..dac0b6f30
--- a/cmd/puppeth/module_ethstats.go
+++ b/cmd/puppeth/module_ethstats.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -24,7 +24,7 @@ import (
"strings"
"text/template"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// ethstatsDockerfile is the Dockerfile required to build an ethstats backend
diff --git a/cmd/puppeth/module_faucet.go b/cmd/puppeth/module_faucet.go
old mode 100644
new mode 100755
index 3c1296bdd..90b19641e
--- a/cmd/puppeth/module_faucet.go
+++ b/cmd/puppeth/module_faucet.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,7 +25,7 @@ import (
"strconv"
"strings"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// faucetDockerfile is the Dockerfile required to build an faucet container to
@@ -38,9 +38,9 @@ ENV GOPATH /go
RUN \
apk add --update git go make gcc musl-dev ca-certificates linux-headers && \
- mkdir -p $GOPATH/src/github.com/ethereum && \
- (cd $GOPATH/src/github.com/ethereum && git clone --depth=1 https://github.com/ethereum/go-ethereum) && \
- go build -v github.com/ethereum/go-ethereum/cmd/faucet && \
+ mkdir -p $GOPATH/src/github.com/wtc && \
+ (cd $GOPATH/src/github.com/wtc && git clone --depth=1 https://github.com/wtc/go-wtc) && \
+ go build -v github.com/wtc/go-wtc/cmd/faucet && \
apk del git go make gcc musl-dev linux-headers && \
rm -rf $GOPATH && rm -rf /var/cache/apk/*
@@ -133,7 +133,7 @@ func deployFaucet(client *sshClient, network string, bootnodes []string, config
})
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
- files[filepath.Join(workdir, "genesis.json")] = config.node.genesis
+ files[filepath.Join(workdir, "genesis.json")] = []byte(config.node.genesis)
files[filepath.Join(workdir, "account.json")] = []byte(config.node.keyJSON)
files[filepath.Join(workdir, "account.pass")] = []byte(config.node.keyPass)
diff --git a/cmd/puppeth/module_nginx.go b/cmd/puppeth/module_nginx.go
old mode 100644
new mode 100755
index fd6d1d74e..32735765e
--- a/cmd/puppeth/module_nginx.go
+++ b/cmd/puppeth/module_nginx.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -23,7 +23,7 @@ import (
"math/rand"
"path/filepath"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// nginxDockerfile is theis the Dockerfile required to build an nginx reverse-
diff --git a/cmd/puppeth/module_node.go b/cmd/puppeth/module_node.go
old mode 100644
new mode 100755
index 375e3e646..4f36cdfc8
--- a/cmd/puppeth/module_node.go
+++ b/cmd/puppeth/module_node.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,12 +25,12 @@ import (
"strings"
"text/template"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
-// nodeDockerfile is the Dockerfile required to run an Ethereum node.
+// nodeDockerfile is the Dockerfile required to run an Wtc node.
var nodeDockerfile = `
-FROM ethereum/client-go:latest
+FROM wtc/client-go:latest
ADD genesis.json /genesis.json
{{if .Unlock}}
@@ -38,15 +38,15 @@ ADD genesis.json /genesis.json
ADD signer.pass /signer.pass
{{end}}
RUN \
- echo 'geth init /genesis.json' > geth.sh && \{{if .Unlock}}
- echo 'mkdir -p /root/.ethereum/keystore/ && cp /signer.json /root/.ethereum/keystore/' >> geth.sh && \{{end}}
- echo $'geth --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine{{end}}{{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> geth.sh
+ echo 'gwtc init /genesis.json' > gwtc.sh && \{{if .Unlock}}
+ echo 'mkdir -p /root/.wtc/keystore/ && cp /signer.json /root/.wtc/keystore/' >> gwtc.sh && \{{end}}
+ echo $'gwtc --networkid {{.NetworkID}} --cache 512 --port {{.Port}} --maxpeers {{.Peers}} {{.LightFlag}} --ethstats \'{{.Ethstats}}\' {{if .BootV4}}--bootnodesv4 {{.BootV4}}{{end}} {{if .BootV5}}--bootnodesv5 {{.BootV5}}{{end}} {{if .Etherbase}}--etherbase {{.Etherbase}} --mine{{end}}{{if .Unlock}}--unlock 0 --password /signer.pass --mine{{end}} --targetgaslimit {{.GasTarget}} --gasprice {{.GasPrice}}' >> gwtc.sh
-ENTRYPOINT ["/bin/sh", "geth.sh"]
+ENTRYPOINT ["/bin/sh", "gwtc.sh"]
`
// nodeComposefile is the docker-compose.yml file required to deploy and maintain
-// an Ethereum node (bootnode or miner for now).
+// an Wtc node (bootnode or miner for now).
var nodeComposefile = `
version: '2'
services:
@@ -58,7 +58,7 @@ services:
- "{{.FullPort}}:{{.FullPort}}/udp"{{if .Light}}
- "{{.LightPort}}:{{.LightPort}}/udp"{{end}}
volumes:
- - {{.Datadir}}:/root/.ethereum
+ - {{.Datadir}}:/root/.wtc
environment:
- FULL_PORT={{.FullPort}}/tcp
- LIGHT_PORT={{.LightPort}}/udp
@@ -76,7 +76,7 @@ services:
restart: always
`
-// deployNode deploys a new Ethereum node container to a remote machine via SSH,
+// deployNode deploys a new Wtc node container to a remote machine via SSH,
// docker and docker-compose. If an instance with the specified network name
// already exists there, it will be overwritten!
func deployNode(client *sshClient, network string, bootv4, bootv5 []string, config *nodeInfos) ([]byte, error) {
@@ -128,7 +128,7 @@ func deployNode(client *sshClient, network string, bootv4, bootv5 []string, conf
files[filepath.Join(workdir, "docker-compose.yaml")] = composefile.Bytes()
//genesisfile, _ := json.MarshalIndent(config.genesis, "", " ")
- files[filepath.Join(workdir, "genesis.json")] = config.genesis
+ files[filepath.Join(workdir, "genesis.json")] = []byte(config.genesis)
if config.keyJSON != "" {
files[filepath.Join(workdir, "signer.json")] = []byte(config.keyJSON)
@@ -197,7 +197,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
// Container available, retrieve its node ID and its genesis json
var out []byte
- if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 geth --exec admin.nodeInfo.id attach", network, kind)); err != nil {
+ if out, err = client.Run(fmt.Sprintf("docker exec %s_%s_1 gwtc --exec admin.nodeInfo.id attach", network, kind)); err != nil {
return nil, ErrServiceUnreachable
}
id := bytes.Trim(bytes.TrimSpace(out), "\"")
@@ -222,7 +222,7 @@ func checkNode(client *sshClient, network string, boot bool) (*nodeInfos, error)
// Assemble and return the useful infos
stats := &nodeInfos{
genesis: genesis,
- datadir: infos.volumes["/root/.ethereum"],
+ datadir: infos.volumes["/root/.wtc"],
portFull: infos.portmap[infos.envvars["FULL_PORT"]],
portLight: infos.portmap[infos.envvars["LIGHT_PORT"]],
peersTotal: totalPeers,
diff --git a/cmd/puppeth/puppeth.go b/cmd/puppeth/puppeth.go
old mode 100644
new mode 100755
index f783a7981..776cbb539
--- a/cmd/puppeth/puppeth.go
+++ b/cmd/puppeth/puppeth.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// puppeth is a command to assemble and maintain private networks.
package main
@@ -22,7 +22,7 @@ import (
"os"
"time"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
"gopkg.in/urfave/cli.v1"
)
@@ -30,7 +30,7 @@ import (
func main() {
app := cli.NewApp()
app.Name = "puppeth"
- app.Usage = "assemble and maintain private Ethereum networks"
+ app.Usage = "assemble and maintain private Wtc networks"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "network",
diff --git a/cmd/puppeth/ssh.go b/cmd/puppeth/ssh.go
old mode 100644
new mode 100755
index ec6a1b669..767c21caa
--- a/cmd/puppeth/ssh.go
+++ b/cmd/puppeth/ssh.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -27,8 +27,9 @@ import (
"os/user"
"path/filepath"
"strings"
+ "syscall"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/terminal"
)
@@ -77,25 +78,14 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
} else {
key, err := ssh.ParsePrivateKey(buf)
if err != nil {
- fmt.Printf("What's the decryption password for %s? (won't be echoed)\n>", path)
- blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
- fmt.Println()
- if err != nil {
- log.Warn("Couldn't read password", "err", err)
- }
- key, err := ssh.ParsePrivateKeyWithPassphrase(buf, blob)
- if err != nil {
- log.Warn("Failed to decrypt SSH key, falling back to passwords", "path", path, "err", err)
- } else {
- auths = append(auths, ssh.PublicKeys(key))
- }
+ log.Warn("Bad SSH key, falling back to passwords", "path", path, "err", err)
} else {
auths = append(auths, ssh.PublicKeys(key))
}
}
auths = append(auths, ssh.PasswordCallback(func() (string, error) {
fmt.Printf("What's the login password for %s at %s? (won't be echoed)\n> ", login, server)
- blob, err := terminal.ReadPassword(int(os.Stdin.Fd()))
+ blob, err := terminal.ReadPassword(int(syscall.Stdin))
fmt.Println()
return string(blob), err
diff --git a/cmd/puppeth/wizard.go b/cmd/puppeth/wizard.go
old mode 100644
new mode 100755
index eb6d9e5aa..93e8b1e4e
--- a/cmd/puppeth/wizard.go
+++ b/cmd/puppeth/wizard.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -28,10 +28,11 @@ import (
"sort"
"strconv"
"strings"
+ "syscall"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/log"
"golang.org/x/crypto/ssh/terminal"
)
@@ -73,7 +74,7 @@ type wizard struct {
conf config // Configurations from previous runs
servers map[string]*sshClient // SSH connections to servers to administer
- services map[string][]string // Ethereum services known to be running on servers
+ services map[string][]string // Wtc services known to be running on servers
in *bufio.Reader // Wrapper around stdin to allow reading user input
}
@@ -160,28 +161,6 @@ func (w *wizard) readDefaultInt(def int) int {
}
}
-// readDefaultBigInt reads a single line from stdin, trimming if from spaces,
-// enforcing it to parse into a big integer. If an empty line is entered, the
-// default value is returned.
-func (w *wizard) readDefaultBigInt(def *big.Int) *big.Int {
- for {
- fmt.Printf("> ")
- text, err := w.in.ReadString('\n')
- if err != nil {
- log.Crit("Failed to read user input", "err", err)
- }
- if text = strings.TrimSpace(text); text == "" {
- return def
- }
- val, ok := new(big.Int).SetString(text, 0)
- if !ok {
- log.Error("Invalid input, expected big integer")
- continue
- }
- return val
- }
-}
-
/*
// readFloat reads a single line from stdin, trimming if from spaces, enforcing it
// to parse into a float.
@@ -230,7 +209,7 @@ func (w *wizard) readDefaultFloat(def float64) float64 {
// line and returns it. The input will not be echoed.
func (w *wizard) readPassword() string {
fmt.Printf("> ")
- text, err := terminal.ReadPassword(int(os.Stdin.Fd()))
+ text, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Crit("Failed to read password", "err", err)
}
@@ -239,7 +218,7 @@ func (w *wizard) readPassword() string {
}
// readAddress reads a single line from stdin, trimming if from spaces and converts
-// it to an Ethereum address.
+// it to an Wtc address.
func (w *wizard) readAddress() *common.Address {
for {
// Read the address from the user
@@ -263,7 +242,7 @@ func (w *wizard) readAddress() *common.Address {
}
// readDefaultAddress reads a single line from stdin, trimming if from spaces and
-// converts it to an Ethereum address. If an empty line is entered, the default
+// converts it to an Wtc address. If an empty line is entered, the default
// value is returned.
func (w *wizard) readDefaultAddress(def common.Address) common.Address {
for {
@@ -301,10 +280,8 @@ func (w *wizard) readJSON() string {
}
// readIPAddress reads a single line from stdin, trimming if from spaces and
-// returning it if it's convertible to an IP address. The reason for keeping
-// the user input format instead of returning a Go net.IP is to match with
-// weird formats used by ethstats, which compares IPs textually, not by value.
-func (w *wizard) readIPAddress() string {
+// converts it to a network IP address.
+func (w *wizard) readIPAddress() net.IP {
for {
// Read the IP address from the user
fmt.Printf("> ")
@@ -313,13 +290,14 @@ func (w *wizard) readIPAddress() string {
log.Crit("Failed to read user input", "err", err)
}
if text = strings.TrimSpace(text); text == "" {
- return ""
+ return nil
}
// Make sure it looks ok and return it if so
- if ip := net.ParseIP(text); ip == nil {
+ ip := net.ParseIP(text)
+ if ip == nil {
log.Error("Invalid IP address, please retry")
continue
}
- return text
+ return ip
}
}
diff --git a/cmd/puppeth/wizard_dashboard.go b/cmd/puppeth/wizard_dashboard.go
old mode 100644
new mode 100755
index 53a28a535..6bdc22cfe
--- a/cmd/puppeth/wizard_dashboard.go
+++ b/cmd/puppeth/wizard_dashboard.go
@@ -1,25 +1,25 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"fmt"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// deployDashboard queries the user for various input on deploying a web-service
diff --git a/cmd/puppeth/wizard_ethstats.go b/cmd/puppeth/wizard_ethstats.go
old mode 100644
new mode 100755
index 8bfa1d6e5..3da9578f6
--- a/cmd/puppeth/wizard_ethstats.go
+++ b/cmd/puppeth/wizard_ethstats.go
@@ -1,26 +1,25 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"fmt"
- "sort"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// deployEthstats queries the user for various input on deploying an ethstats
@@ -65,37 +64,17 @@ func (w *wizard) deployEthstats() {
fmt.Println()
fmt.Printf("Keep existing IP %v blacklist (y/n)? (default = yes)\n", infos.banned)
if w.readDefaultString("y") != "y" {
- // The user might want to clear the entire list, although generally probably not
- fmt.Println()
- fmt.Printf("Clear out blacklist and start over (y/n)? (default = no)\n")
- if w.readDefaultString("n") != "n" {
- infos.banned = nil
- }
- // Offer the user to explicitly add/remove certain IP addresses
- fmt.Println()
- fmt.Println("Which additional IP addresses should be blacklisted?")
- for {
- if ip := w.readIPAddress(); ip != "" {
- infos.banned = append(infos.banned, ip)
- continue
- }
- break
- }
+ infos.banned = nil
+
fmt.Println()
- fmt.Println("Which IP addresses should not be blacklisted?")
+ fmt.Println("Which IP addresses should be blacklisted?")
for {
- if ip := w.readIPAddress(); ip != "" {
- for i, addr := range infos.banned {
- if ip == addr {
- infos.banned = append(infos.banned[:i], infos.banned[i+1:]...)
- break
- }
- }
+ if ip := w.readIPAddress(); ip != nil {
+ infos.banned = append(infos.banned, ip.String())
continue
}
break
}
- sort.Strings(infos.banned)
}
// Try to deploy the ethstats server on the host
trusted := make([]string, 0, len(w.servers))
diff --git a/cmd/puppeth/wizard_faucet.go b/cmd/puppeth/wizard_faucet.go
old mode 100644
new mode 100755
index 51c4e2f7f..1869adf4d
--- a/cmd/puppeth/wizard_faucet.go
+++ b/cmd/puppeth/wizard_faucet.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -21,8 +21,8 @@ import (
"fmt"
"net/http"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/log"
)
// deployFaucet queries the user for various input on deploying a faucet, after
@@ -39,7 +39,7 @@ func (w *wizard) deployFaucet() {
infos, err := checkFaucet(client, w.network)
if err != nil {
infos = &faucetInfos{
- node: &nodeInfos{portFull: 30303, peersTotal: 25},
+ node: &nodeInfos{portFull: 10101, peersTotal: 25},
port: 80,
host: client.server,
amount: 1,
diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go
old mode 100644
new mode 100755
index 222fc2a7c..f8e5565f9
--- a/cmd/puppeth/wizard_genesis.go
+++ b/cmd/puppeth/wizard_genesis.go
@@ -1,34 +1,30 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
import (
- "bytes"
- "encoding/json"
"fmt"
- "io/ioutil"
"math/big"
"math/rand"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/params"
)
// makeGenesis creates a new genesis struct based on some user input.
@@ -37,7 +33,7 @@ func (w *wizard) makeGenesis() {
genesis := &core.Genesis{
Timestamp: uint64(time.Now().Unix()),
GasLimit: 4700000,
- Difficulty: big.NewInt(1048576),
+ Difficulty: big.NewInt(65536),
Alloc: make(core.GenesisAlloc),
Config: &params.ChainConfig{
HomesteadBlock: big.NewInt(1),
@@ -49,58 +45,10 @@ func (w *wizard) makeGenesis() {
}
// Figure out which consensus engine to choose
fmt.Println()
- fmt.Println("Which consensus engine to use? (default = clique)")
- fmt.Println(" 1. Ethash - proof-of-work")
- fmt.Println(" 2. Clique - proof-of-authority")
- choice := w.read()
- switch {
- case choice == "1":
- // In case of ethash, we're pretty much done
- genesis.Config.Ethash = new(params.EthashConfig)
- genesis.ExtraData = make([]byte, 32)
+ genesis.Config.Ethash = new(params.EthashConfig)
+ genesis.ExtraData = make([]byte, 32)
- case choice == "" || choice == "2":
- // In the case of clique, configure the consensus parameters
- genesis.Difficulty = big.NewInt(1)
- genesis.Config.Clique = &params.CliqueConfig{
- Period: 15,
- Epoch: 30000,
- }
- fmt.Println()
- fmt.Println("How many seconds should blocks take? (default = 15)")
- genesis.Config.Clique.Period = uint64(w.readDefaultInt(15))
-
- // We also need the initial list of signers
- fmt.Println()
- fmt.Println("Which accounts are allowed to seal? (mandatory at least one)")
-
- var signers []common.Address
- for {
- if address := w.readAddress(); address != nil {
- signers = append(signers, *address)
- continue
- }
- if len(signers) > 0 {
- break
- }
- }
- // Sort the signers and embed into the extra-data section
- for i := 0; i < len(signers); i++ {
- for j := i + 1; j < len(signers); j++ {
- if bytes.Compare(signers[i][:], signers[j][:]) > 0 {
- signers[i], signers[j] = signers[j], signers[i]
- }
- }
- }
- genesis.ExtraData = make([]byte, 32+len(signers)*common.AddressLength+65)
- for i, signer := range signers {
- copy(genesis.ExtraData[32+i*common.AddressLength:], signer[:])
- }
-
- default:
- log.Crit("Invalid consensus engine choice", "choice", choice)
- }
// Consensus all set, just ask for initial funds and go
fmt.Println()
fmt.Println("Which accounts should be pre-funded? (advisable at least one)")
@@ -137,53 +85,3 @@ func (w *wizard) makeGenesis() {
// All done, store the genesis and flush to disk
w.conf.genesis = genesis
}
-
-// manageGenesis permits the modification of chain configuration parameters in
-// a genesis config and the export of the entire genesis spec.
-func (w *wizard) manageGenesis() {
- // Figure out whether to modify or export the genesis
- fmt.Println()
- fmt.Println(" 1. Modify existing fork rules")
- fmt.Println(" 2. Export genesis configuration")
-
- choice := w.read()
- switch {
- case choice == "1":
- // Fork rule updating requested, iterate over each fork
- fmt.Println()
- fmt.Printf("Which block should Homestead come into effect? (default = %v)\n", w.conf.genesis.Config.HomesteadBlock)
- w.conf.genesis.Config.HomesteadBlock = w.readDefaultBigInt(w.conf.genesis.Config.HomesteadBlock)
-
- fmt.Println()
- fmt.Printf("Which block should EIP150 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP150Block)
- w.conf.genesis.Config.EIP150Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP150Block)
-
- fmt.Println()
- fmt.Printf("Which block should EIP155 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP155Block)
- w.conf.genesis.Config.EIP155Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP155Block)
-
- fmt.Println()
- fmt.Printf("Which block should EIP158 come into effect? (default = %v)\n", w.conf.genesis.Config.EIP158Block)
- w.conf.genesis.Config.EIP158Block = w.readDefaultBigInt(w.conf.genesis.Config.EIP158Block)
-
- fmt.Println()
- fmt.Printf("Which block should Byzantium come into effect? (default = %v)\n", w.conf.genesis.Config.ByzantiumBlock)
- w.conf.genesis.Config.ByzantiumBlock = w.readDefaultBigInt(w.conf.genesis.Config.ByzantiumBlock)
-
- out, _ := json.MarshalIndent(w.conf.genesis.Config, "", " ")
- fmt.Printf("Chain configuration updated:\n\n%s\n", out)
-
- case choice == "2":
- // Save whatever genesis configuration we currently have
- fmt.Println()
- fmt.Printf("Which file to save the genesis into? (default = %s.json)\n", w.network)
- out, _ := json.MarshalIndent(w.conf.genesis, "", " ")
- if err := ioutil.WriteFile(w.readDefaultString(fmt.Sprintf("%s.json", w.network)), out, 0644); err != nil {
- log.Error("Failed to save genesis file", "err", err)
- }
- log.Info("Exported existing genesis block")
-
- default:
- log.Error("That's not something I can do")
- }
-}
diff --git a/cmd/puppeth/wizard_intro.go b/cmd/puppeth/wizard_intro.go
old mode 100644
new mode 100755
index 2d9a097ee..d073315af
--- a/cmd/puppeth/wizard_intro.go
+++ b/cmd/puppeth/wizard_intro.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -25,7 +25,7 @@ import (
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// makeWizard creates and returns a new puppeth wizard.
@@ -42,12 +42,12 @@ func makeWizard(network string) *wizard {
}
// run displays some useful infos to the user, starting on the journey of
-// setting up a new or managing an existing Ethereum private network.
+// setting up a new or managing an existing Wtc private network.
func (w *wizard) run() {
fmt.Println("+-----------------------------------------------------------+")
- fmt.Println("| Welcome to puppeth, your Ethereum private network manager |")
+ fmt.Println("| Welcome to puppeth, your Wtc private network manager |")
fmt.Println("| |")
- fmt.Println("| This tool lets you create a new Ethereum network down to |")
+ fmt.Println("| This tool lets you create a new Wtc network down to |")
fmt.Println("| the genesis block, bootnodes, miners and ethstats servers |")
fmt.Println("| without the hassle that it would normally entail. |")
fmt.Println("| |")
@@ -69,7 +69,7 @@ func (w *wizard) run() {
log.Error("I also like to live dangerously, still no spaces")
}
}
- log.Info("Administering Ethereum network", "name", w.network)
+ log.Info("Administering Wtc network", "name", w.network)
// Load initial configurations and connect to all live servers
w.conf.path = filepath.Join(os.Getenv("HOME"), ".puppeth", w.network)
@@ -98,7 +98,7 @@ func (w *wizard) run() {
if w.conf.genesis == nil {
fmt.Println(" 2. Configure new genesis")
} else {
- fmt.Println(" 2. Manage existing genesis")
+ fmt.Println(" 2. Save existing genesis")
}
if len(w.servers) == 0 {
fmt.Println(" 3. Track new remote server")
@@ -118,10 +118,18 @@ func (w *wizard) run() {
w.networkStats(false)
case choice == "2":
+ // If we don't have a genesis, make one
if w.conf.genesis == nil {
w.makeGenesis()
} else {
- w.manageGenesis()
+ // Otherwise just save whatever we currently have
+ fmt.Println()
+ fmt.Printf("Which file to save the genesis into? (default = %s.json)\n", w.network)
+ out, _ := json.MarshalIndent(w.conf.genesis, "", " ")
+ if err := ioutil.WriteFile(w.readDefaultString(fmt.Sprintf("%s.json", w.network)), out, 0644); err != nil {
+ log.Error("Failed to save genesis file", "err", err)
+ }
+ log.Info("Exported existing genesis block")
}
case choice == "3":
if len(w.servers) == 0 {
diff --git a/cmd/puppeth/wizard_netstats.go b/cmd/puppeth/wizard_netstats.go
old mode 100644
new mode 100755
index c06972198..4cae920b0
--- a/cmd/puppeth/wizard_netstats.go
+++ b/cmd/puppeth/wizard_netstats.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -22,8 +22,8 @@ import (
"os"
"strings"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/log"
"github.com/olekukonko/tablewriter"
)
@@ -129,7 +129,7 @@ func (w *wizard) networkStats(tips bool) {
}
}
// If a genesis block was found, load it into our configs
- if protips.genesis != "" && w.conf.genesis == nil {
+ if protips.genesis != "" {
genesis := new(core.Genesis)
if err := json.Unmarshal([]byte(protips.genesis), genesis); err != nil {
log.Error("Failed to parse remote genesis", "err", err)
@@ -168,8 +168,8 @@ func (p *protips) print(network string) {
// If a known genesis block is available, display it and prepend an init command
fullinit, lightinit := "", ""
if p.genesis != "" {
- fullinit = fmt.Sprintf("geth --datadir=$HOME/.%s init %s.json && ", network, network)
- lightinit = fmt.Sprintf("geth --datadir=$HOME/.%s --light init %s.json && ", network, network)
+ fullinit = fmt.Sprintf("gwtc --datadir=$HOME/.%s init %s.json && ", network, network)
+ lightinit = fmt.Sprintf("gwtc --datadir=$HOME/.%s --light init %s.json && ", network, network)
}
// If an ethstats server is available, add the ethstats flag
statsflag := ""
@@ -193,16 +193,16 @@ func (p *protips) print(network string) {
var tasks, tips []string
tasks = append(tasks, "Run an archive node with historical data")
- tips = append(tips, fmt.Sprintf("%sgeth --networkid=%d --datadir=$HOME/.%s --cache=1024%s%s", fullinit, p.network, network, statsflag, bootflagFull))
+ tips = append(tips, fmt.Sprintf("%sgwtc --networkid=%d --datadir=$HOME/.%s --cache=1024%s%s", fullinit, p.network, network, statsflag, bootflagFull))
tasks = append(tasks, "Run a full node with recent data only")
- tips = append(tips, fmt.Sprintf("%sgeth --networkid=%d --datadir=$HOME/.%s --cache=512 --fast%s%s", fullinit, p.network, network, statsflag, bootflagFull))
+ tips = append(tips, fmt.Sprintf("%sgwtc --networkid=%d --datadir=$HOME/.%s --cache=512 --fast%s%s", fullinit, p.network, network, statsflag, bootflagFull))
tasks = append(tasks, "Run a light node with on demand retrievals")
- tips = append(tips, fmt.Sprintf("%sgeth --networkid=%d --datadir=$HOME/.%s --light%s%s", lightinit, p.network, network, statsflag, bootflagLight))
+ tips = append(tips, fmt.Sprintf("%sgwtc --networkid=%d --datadir=$HOME/.%s --light%s%s", lightinit, p.network, network, statsflag, bootflagLight))
tasks = append(tasks, "Run an embedded node with constrained memory")
- tips = append(tips, fmt.Sprintf("%sgeth --networkid=%d --datadir=$HOME/.%s --cache=32 --light%s%s", lightinit, p.network, network, statsflag, bootflagLight))
+ tips = append(tips, fmt.Sprintf("%sgwtc --networkid=%d --datadir=$HOME/.%s --cache=32 --light%s%s", lightinit, p.network, network, statsflag, bootflagLight))
// If the tips are short, display in a table
short := true
diff --git a/cmd/puppeth/wizard_network.go b/cmd/puppeth/wizard_network.go
old mode 100644
new mode 100755
index c20e31fab..7c5e1d6a0
--- a/cmd/puppeth/wizard_network.go
+++ b/cmd/puppeth/wizard_network.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -20,7 +20,7 @@ import (
"fmt"
"strings"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// manageServers displays a list of servers the user can disconnect from, and an
@@ -71,7 +71,7 @@ func (w *wizard) makeServer() string {
fmt.Println()
fmt.Println("Please enter remote server's address:")
- // Read and dial the server to ensure docker is present
+ // Read and fial the server to ensure docker is present
input := w.readString()
client, err := dial(input, nil)
diff --git a/cmd/puppeth/wizard_nginx.go b/cmd/puppeth/wizard_nginx.go
old mode 100644
new mode 100755
index 86fba29f5..482fe49c9
--- a/cmd/puppeth/wizard_nginx.go
+++ b/cmd/puppeth/wizard_nginx.go
@@ -1,25 +1,25 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
import (
"fmt"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/log"
)
// ensureVirtualHost checks whether a reverse-proxy is running on the specified
diff --git a/cmd/puppeth/wizard_node.go b/cmd/puppeth/wizard_node.go
old mode 100644
new mode 100755
index 05232486b..d5220ce20
--- a/cmd/puppeth/wizard_node.go
+++ b/cmd/puppeth/wizard_node.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -21,9 +21,8 @@ import (
"fmt"
"time"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/log"
)
// deployNode creates a new node configuration based on some user input.
@@ -48,9 +47,9 @@ func (w *wizard) deployNode(boot bool) {
infos, err := checkNode(client, w.network, boot)
if err != nil {
if boot {
- infos = &nodeInfos{portFull: 30303, peersTotal: 512, peersLight: 256}
+ infos = &nodeInfos{portFull: 10101, peersTotal: 512, peersLight: 256}
} else {
- infos = &nodeInfos{portFull: 30303, peersTotal: 50, peersLight: 0, gasTarget: 4.7, gasPrice: 18}
+ infos = &nodeInfos{portFull: 10101, peersTotal: 50, peersLight: 0, gasTarget: 4.7, gasPrice: 18}
}
}
infos.genesis, _ = json.MarshalIndent(w.conf.genesis, "", " ")
@@ -106,35 +105,7 @@ func (w *wizard) deployNode(boot bool) {
fmt.Printf("What address should the miner user? (default = %s)\n", infos.etherbase)
infos.etherbase = w.readDefaultAddress(common.HexToAddress(infos.etherbase)).Hex()
}
- } else if w.conf.genesis.Config.Clique != nil {
- // If a previous signer was already set, offer to reuse it
- if infos.keyJSON != "" {
- if key, err := keystore.DecryptKey([]byte(infos.keyJSON), infos.keyPass); err != nil {
- infos.keyJSON, infos.keyPass = "", ""
- } else {
- fmt.Println()
- fmt.Printf("Reuse previous (%s) signing account (y/n)? (default = yes)\n", key.Address.Hex())
- if w.readDefaultString("y") != "y" {
- infos.keyJSON, infos.keyPass = "", ""
- }
- }
- }
- // Clique based signers need a keyfile and unlock password, ask if unavailable
- if infos.keyJSON == "" {
- fmt.Println()
- fmt.Println("Please paste the signer's key JSON:")
- infos.keyJSON = w.readJSON()
-
- fmt.Println()
- fmt.Println("What's the unlock password for the account? (won't be echoed)")
- infos.keyPass = w.readPassword()
-
- if _, err := keystore.DecryptKey([]byte(infos.keyJSON), infos.keyPass); err != nil {
- log.Error("Failed to decrypt key with given passphrase")
- return
- }
- }
- }
+ }
// Establish the gas dynamics to be enforced by the signer
fmt.Println()
fmt.Printf("What gas limit should empty blocks target (MGas)? (default = %0.3f)\n", infos.gasTarget)
@@ -146,7 +117,7 @@ func (w *wizard) deployNode(boot bool) {
}
// Try to deploy the full node on the host
if out, err := deployNode(client, w.network, w.conf.bootFull, w.conf.bootLight, infos); err != nil {
- log.Error("Failed to deploy Ethereum node container", "err", err)
+ log.Error("Failed to deploy Wtc node container", "err", err)
if len(out) > 0 {
fmt.Printf("%s\n", out)
}
diff --git a/cmd/rlpdump/main.go b/cmd/rlpdump/main.go
old mode 100644
new mode 100755
index d0f993c5b..155939bc3
--- a/cmd/rlpdump/main.go
+++ b/cmd/rlpdump/main.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// rlpdump is a pretty-printer for RLP data.
package main
@@ -26,7 +26,7 @@ import (
"os"
"strings"
- "github.com/ethereum/go-ethereum/rlp"
+ "github.com/wtc/go-wtc/rlp"
)
var (
@@ -51,7 +51,7 @@ func main() {
var r io.Reader
switch {
case *hexMode != "":
- data, err := hex.DecodeString(strings.TrimPrefix(*hexMode, "0x"))
+ data, err := hex.DecodeString(*hexMode)
if err != nil {
die(err)
}
diff --git a/cmd/swarm/db.go b/cmd/swarm/db.go
old mode 100644
new mode 100755
index dfd2d069b..cac08b59a
--- a/cmd/swarm/db.go
+++ b/cmd/swarm/db.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -22,9 +22,9 @@ import (
"os"
"path/filepath"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/swarm/storage"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/swarm/storage"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/swarm/hash.go b/cmd/swarm/hash.go
old mode 100644
new mode 100755
index 792e8d0d7..212315312
--- a/cmd/swarm/hash.go
+++ b/cmd/swarm/hash.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// Command bzzhash computes a swarm tree hash.
package main
@@ -21,8 +21,8 @@ import (
"fmt"
"os"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/swarm/storage"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/swarm/storage"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/swarm/list.go b/cmd/swarm/list.go
old mode 100644
new mode 100755
index 57b5517c6..47c3358de
--- a/cmd/swarm/list.go
+++ b/cmd/swarm/list.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -22,8 +22,8 @@ import (
"strings"
"text/tabwriter"
- "github.com/ethereum/go-ethereum/cmd/utils"
- swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+ "github.com/wtc/go-wtc/cmd/utils"
+ swarm "github.com/wtc/go-wtc/swarm/api/client"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
old mode 100644
new mode 100755
index 603fd9b94..78700dab8
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -31,23 +31,23 @@ import (
"syscall"
"time"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/contracts/ens"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethclient"
- "github.com/ethereum/go-ethereum/internal/debug"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rpc"
- "github.com/ethereum/go-ethereum/swarm"
- bzzapi "github.com/ethereum/go-ethereum/swarm/api"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/contracts/ens"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/wtcclient"
+ "github.com/wtc/go-wtc/internal/debug"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/params"
+ "github.com/wtc/go-wtc/rpc"
+ "github.com/wtc/go-wtc/swarm"
+ bzzapi "github.com/wtc/go-wtc/swarm/api"
"gopkg.in/urfave/cli.v1"
)
@@ -95,7 +95,7 @@ var (
}
SwarmSwapAPIFlag = cli.StringFlag{
Name: "swap-api",
- Usage: "URL of the Ethereum API provider to use to settle SWAP payments",
+ Usage: "URL of the Wtc API provider to use to settle SWAP payments",
}
SwarmSyncEnabledFlag = cli.BoolTFlag{
Name: "sync",
@@ -103,8 +103,8 @@ var (
}
EnsAPIFlag = cli.StringFlag{
Name: "ens-api",
- Usage: "URL of the Ethereum API provider to use for ENS record lookups",
- Value: node.DefaultIPCEndpoint("geth"),
+ Usage: "URL of the Wtc API provider to use for ENS record lookups",
+ Value: node.DefaultIPCEndpoint("gwtc"),
}
EnsAddrFlag = cli.StringFlag{
Name: "ens-addr",
@@ -149,7 +149,7 @@ var (
var defaultNodeConfig = node.DefaultConfig
-// This init function sets defaults so cmd/swarm can run alongside geth.
+// This init function sets defaults so cmd/swarm can run alongside gwtc.
func init() {
defaultNodeConfig.Name = clientIdentifier
defaultNodeConfig.Version = params.VersionWithCommit(gitCommit)
@@ -159,7 +159,7 @@ func init() {
utils.ListenPortFlag.Value = 30399
}
-var app = utils.NewApp(gitCommit, "Ethereum Swarm")
+var app = utils.NewApp(gitCommit, "Wtc Swarm")
// This init function creates the cli.App.
func init() {
@@ -256,12 +256,12 @@ Manage the local chunk database.
Description: `
Export a local chunk database as a tar archive (use - to send to stdout).
- swarm db export ~/.ethereum/swarm/bzz-KEY/chunks chunks.tar
+ swarm db export ~/.wtc/swarm/bzz-KEY/chunks chunks.tar
The export may be quite large, consider piping the output through the Unix
pv(1) tool to get a progress bar:
- swarm db export ~/.ethereum/swarm/bzz-KEY/chunks - | pv > chunks.tar
+ swarm db export ~/.wtc/swarm/bzz-KEY/chunks - | pv > chunks.tar
`,
},
{
@@ -272,12 +272,12 @@ pv(1) tool to get a progress bar:
Description: `
Import chunks from a tar archive into a local chunk database (use - to read from stdin).
- swarm db import ~/.ethereum/swarm/bzz-KEY/chunks chunks.tar
+ swarm db import ~/.wtc/swarm/bzz-KEY/chunks chunks.tar
The import may be quite large, consider piping the input through the Unix
pv(1) tool to get a progress bar:
- pv chunks.tar | swarm db import ~/.ethereum/swarm/bzz-KEY/chunks -
+ pv chunks.tar | swarm db import ~/.wtc/swarm/bzz-KEY/chunks -
`,
},
{
@@ -428,7 +428,7 @@ func detectEnsAddr(client *rpc.Client) (common.Address, error) {
return common.Address{}, err
}
- block, err := ethclient.NewClient(client).BlockByNumber(ctx, big.NewInt(0))
+ block, err := wtcclient.NewClient(client).BlockByNumber(ctx, big.NewInt(0))
if err != nil {
return common.Address{}, err
}
@@ -482,23 +482,23 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
cors := ctx.GlobalString(CorsStringFlag.Name)
boot := func(ctx *node.ServiceContext) (node.Service, error) {
- var swapClient *ethclient.Client
+ var swapClient *wtcclient.Client
if swapapi != "" {
log.Info("connecting to SWAP API", "url", swapapi)
- swapClient, err = ethclient.Dial(swapapi)
+ swapClient, err = wtcclient.Dial(swapapi)
if err != nil {
return nil, fmt.Errorf("error connecting to SWAP API %s: %s", swapapi, err)
}
}
- var ensClient *ethclient.Client
+ var ensClient *wtcclient.Client
if ensapi != "" {
log.Info("connecting to ENS API", "url", ensapi)
client, err := rpc.Dial(ensapi)
if err != nil {
return nil, fmt.Errorf("error connecting to ENS API %s: %s", ensapi, err)
}
- ensClient = ethclient.NewClient(client)
+ ensClient = wtcclient.NewClient(client)
if ensAddr != "" {
bzzconfig.EnsRoot = common.HexToAddress(ensAddr)
diff --git a/cmd/swarm/manifest.go b/cmd/swarm/manifest.go
old mode 100644
new mode 100755
index 7c4d6052c..7113b5548
--- a/cmd/swarm/manifest.go
+++ b/cmd/swarm/manifest.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// Command MANIFEST update
package main
@@ -24,9 +24,9 @@ import (
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/swarm/api"
- swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/swarm/api"
+ swarm "github.com/wtc/go-wtc/swarm/api/client"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/swarm/run_test.go b/cmd/swarm/run_test.go
old mode 100644
new mode 100755
index aaaf9e1e5..fca7b06a9
--- a/cmd/swarm/run_test.go
+++ b/cmd/swarm/run_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
@@ -27,12 +27,12 @@ import (
"time"
"github.com/docker/docker/pkg/reexec"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/internal/cmdtest"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/rpc"
- "github.com/ethereum/go-ethereum/swarm"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/internal/cmdtest"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/rpc"
+ "github.com/wtc/go-wtc/swarm"
)
func init() {
diff --git a/cmd/swarm/upload.go b/cmd/swarm/upload.go
old mode 100644
new mode 100755
index 9f4c525bb..ea6e53065
--- a/cmd/swarm/upload.go
+++ b/cmd/swarm/upload.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// Command bzzup uploads files to the swarm HTTP API.
package main
@@ -30,8 +30,8 @@ import (
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/cmd/utils"
- swarm "github.com/ethereum/go-ethereum/swarm/api/client"
+ "github.com/wtc/go-wtc/cmd/utils"
+ swarm "github.com/wtc/go-wtc/swarm/api/client"
"gopkg.in/urfave/cli.v1"
)
diff --git a/cmd/swarm/upload_test.go b/cmd/swarm/upload_test.go
old mode 100644
new mode 100755
index 5656186e1..18f6cd969
--- a/cmd/swarm/upload_test.go
+++ b/cmd/swarm/upload_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package main
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
old mode 100644
new mode 100755
index 23b10c2d7..8c8f41b64
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -1,20 +1,20 @@
// Copyright 2014 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
-// Package utils contains internal helper functions for go-ethereum commands.
+// Package utils contains internal helper functions for go-wtc commands.
package utils
import (
@@ -26,12 +26,12 @@ import (
"runtime"
"strings"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/internal/debug"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/rlp"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/internal/debug"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/rlp"
)
const (
diff --git a/cmd/utils/customflags.go b/cmd/utils/customflags.go
old mode 100644
new mode 100755
index e5bf8724c..7a39bc6b7
--- a/cmd/utils/customflags.go
+++ b/cmd/utils/customflags.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package utils
@@ -27,7 +27,7 @@ import (
"path"
"strings"
- "github.com/ethereum/go-ethereum/common/math"
+ "github.com/wtc/go-wtc/common/math"
"gopkg.in/urfave/cli.v1"
)
@@ -48,7 +48,7 @@ func (self *DirectoryString) Set(value string) error {
}
// Custom cli.Flag type which expand the received string to an absolute path.
-// e.g. ~/.ethereum -> /home/username/.ethereum
+// e.g. ~/.wtc -> /home/username/.wtc
type DirectoryFlag struct {
Name string
Value DirectoryString
diff --git a/cmd/utils/customflags_test.go b/cmd/utils/customflags_test.go
old mode 100644
new mode 100755
index de39ca36a..60927bafa
--- a/cmd/utils/customflags_test.go
+++ b/cmd/utils/customflags_test.go
@@ -1,18 +1,18 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package utils
diff --git a/cmd/utils/fdlimit_freebsd.go b/cmd/utils/fdlimit_freebsd.go
old mode 100644
new mode 100755
index 4cb5013c8..085ef9fb7
--- a/cmd/utils/fdlimit_freebsd.go
+++ b/cmd/utils/fdlimit_freebsd.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// +build freebsd
diff --git a/cmd/utils/fdlimit_test.go b/cmd/utils/fdlimit_test.go
old mode 100644
new mode 100755
index 0a950a6c9..fd0ff9a79
--- a/cmd/utils/fdlimit_test.go
+++ b/cmd/utils/fdlimit_test.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package utils
diff --git a/cmd/utils/fdlimit_unix.go b/cmd/utils/fdlimit_unix.go
old mode 100644
new mode 100755
index 08e153bbd..92a923920
--- a/cmd/utils/fdlimit_unix.go
+++ b/cmd/utils/fdlimit_unix.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// +build linux darwin netbsd openbsd solaris
diff --git a/cmd/utils/fdlimit_windows.go b/cmd/utils/fdlimit_windows.go
old mode 100644
new mode 100755
index 53aad3d7a..aff8a1710
--- a/cmd/utils/fdlimit_windows.go
+++ b/cmd/utils/fdlimit_windows.go
@@ -1,18 +1,18 @@
// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
package utils
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
old mode 100644
new mode 100755
index 5c2929268..1ba6c31dd
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -1,26 +1,25 @@
// Copyright 2015 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
-// Package utils contains internal helper functions for go-ethereum commands.
+// Package utils contains internal helper functions for go-wtc commands.
package utils
import (
"crypto/ecdsa"
"fmt"
- "io/ioutil"
"math/big"
"os"
"path/filepath"
@@ -28,33 +27,30 @@ import (
"strconv"
"strings"
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/accounts/keystore"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/consensus/clique"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/dashboard"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/eth/downloader"
- "github.com/ethereum/go-ethereum/eth/gasprice"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/ethstats"
- "github.com/ethereum/go-ethereum/les"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/metrics"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/p2p/discv5"
- "github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/p2p/netutil"
- "github.com/ethereum/go-ethereum/params"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ "github.com/wtc/go-wtc/accounts"
+ "github.com/wtc/go-wtc/accounts/keystore"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/wtc/downloader"
+ "github.com/wtc/go-wtc/wtc/gasprice"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/wtcstats"
+ "github.com/wtc/go-wtc/les"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/metrics"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/p2p/discv5"
+ "github.com/wtc/go-wtc/p2p/nat"
+ "github.com/wtc/go-wtc/p2p/netutil"
+ "github.com/wtc/go-wtc/params"
+ whisper "github.com/wtc/go-wtc/whisper/whisperv5"
"gopkg.in/urfave/cli.v1"
)
@@ -138,13 +134,9 @@ var (
Name: "rinkeby",
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
}
- DeveloperFlag = cli.BoolFlag{
+ DevModeFlag = cli.BoolFlag{
Name: "dev",
- Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
- }
- DeveloperPeriodFlag = cli.IntFlag{
- Name: "dev.period",
- Usage: "Block period to use in developer mode (0 = mine only if transaction pending)",
+ Usage: "Developer mode: pre-configured private network with several debugging flags",
}
IdentityFlag = cli.StringFlag{
Name: "identity",
@@ -184,31 +176,6 @@ var (
Name: "lightkdf",
Usage: "Reduce key-derivation RAM & CPU usage at some expense of KDF strength",
}
- // Dashboard settings
- DashboardEnabledFlag = cli.BoolFlag{
- Name: "dashboard",
- Usage: "Enable the dashboard",
- }
- DashboardAddrFlag = cli.StringFlag{
- Name: "dashboard.addr",
- Usage: "Dashboard listening interface",
- Value: dashboard.DefaultConfig.Host,
- }
- DashboardPortFlag = cli.IntFlag{
- Name: "dashboard.host",
- Usage: "Dashboard listening port",
- Value: dashboard.DefaultConfig.Port,
- }
- DashboardRefreshFlag = cli.DurationFlag{
- Name: "dashboard.refresh",
- Usage: "Dashboard metrics collection refresh rate",
- Value: dashboard.DefaultConfig.Refresh,
- }
- DashboardAssetsFlag = cli.StringFlag{
- Name: "dashboard.assets",
- Usage: "Developer flag to serve the dashboard from the local file system",
- Value: dashboard.DefaultConfig.Assets,
- }
// Ethash settings
EthashCacheDirFlag = DirectoryFlag{
Name: "ethash.cachedir",
@@ -358,6 +325,18 @@ var (
Name: "fakepow",
Usage: "Disables proof-of-work verification",
}
+ GPUPowFlag = cli.BoolFlag{
+ Name: "gpupow",
+ Usage: "GPU speedup",
+ }
+ GPUPortFlag = cli.Int64Flag{
+ Name: "gpuport",
+ Usage: "Port for GPU send to miner",
+ }
+ GPUGetFlag = cli.Int64Flag{
+ Name: "gpugetport",
+ Usage: "Port for miner send to GPU",
+ }
NoCompactionFlag = cli.BoolFlag{
Name: "nocompaction",
Usage: "Disables db compaction after import",
@@ -442,7 +421,7 @@ var (
ListenPortFlag = cli.IntFlag{
Name: "port",
Usage: "Network listening port",
- Value: 30303,
+ Value: 10101,
}
BootnodesFlag = cli.StringFlag{
Name: "bootnodes",
@@ -717,7 +696,7 @@ func setIPC(ctx *cli.Context, cfg *node.Config) {
}
// makeDatabaseHandles raises out the number of allowed file handles per process
-// for Geth and returns half of the allowance to assign to the database.
+// for Gwtc and returns half of the allowance to assign to the database.
func makeDatabaseHandles() int {
if err := raiseFdLimit(2048); err != nil {
Fatalf("Failed to raise file descriptor allowance: %v", err)
@@ -767,7 +746,7 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
if len(accounts) > 0 {
cfg.Etherbase = accounts[0].Address
} else {
- log.Warn("No etherbase set and no accounts found as default")
+ // log.Warn("No etherbase set and no accounts found as default")
}
}
}
@@ -775,18 +754,20 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
// MakePasswordList reads password lines from the file specified by the global --password flag.
func MakePasswordList(ctx *cli.Context) []string {
path := ctx.GlobalString(PasswordFileFlag.Name)
- if path == "" {
- return nil
- }
- text, err := ioutil.ReadFile(path)
- if err != nil {
- Fatalf("Failed to read password file: %v", err)
- }
- lines := strings.Split(string(text), "\n")
- // Sanitise DOS line endings.
- for i := range lines {
- lines[i] = strings.TrimRight(lines[i], "\r")
- }
+ // if path == "" {
+ // return nil
+ // }
+ // text, err := ioutil.ReadFile(path)
+ // if err != nil {
+ // Fatalf("Failed to read password file: %v", err)
+ // }
+ // lines := strings.Split(string(text), "\n")
+ // // Sanitise DOS line endings.
+ // for i := range lines {
+ // lines[i] = strings.TrimRight(lines[i], "\r")
+ // }
+ lines := make([]string, 0)
+ lines = append(lines, path)
return lines
}
@@ -826,7 +807,7 @@ func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
cfg.NetRestrict = list
}
- if ctx.GlobalBool(DeveloperFlag.Name) {
+ if ctx.GlobalBool(DevModeFlag.Name) {
// --dev mode can't use p2p networking.
cfg.MaxPeers = 0
cfg.ListenAddr = ":0"
@@ -847,8 +828,8 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
switch {
case ctx.GlobalIsSet(DataDirFlag.Name):
cfg.DataDir = ctx.GlobalString(DataDirFlag.Name)
- case ctx.GlobalBool(DeveloperFlag.Name):
- cfg.DataDir = "" // unless explicitly requested, use memory databases
+ case ctx.GlobalBool(DevModeFlag.Name):
+ cfg.DataDir = filepath.Join(os.TempDir(), "wtc_dev_mode")
case ctx.GlobalBool(TestnetFlag.Name):
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
case ctx.GlobalBool(RinkebyFlag.Name):
@@ -927,6 +908,15 @@ func setEthash(ctx *cli.Context, cfg *eth.Config) {
if ctx.GlobalIsSet(EthashDatasetsOnDiskFlag.Name) {
cfg.EthashDatasetsOnDisk = ctx.GlobalInt(EthashDatasetsOnDiskFlag.Name)
}
+ if ctx.GlobalIsSet(GPUPowFlag.Name) {
+ cfg.PowGPU = ctx.GlobalBool(GPUPowFlag.Name)
+ }
+ if ctx.GlobalIsSet(GPUPortFlag.Name) {
+ cfg.GPUPort = ctx.GlobalInt64(GPUPortFlag.Name)
+ }
+ if ctx.GlobalIsSet(GPUGetFlag.Name) {
+ cfg.GPUGetPort = ctx.GlobalInt64(GPUGetFlag.Name)
+ }
}
func checkExclusive(ctx *cli.Context, flags ...cli.Flag) {
@@ -954,7 +944,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
// SetEthConfig applies eth-related command line flags to the config.
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
// Avoid conflicting network flags
- checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag)
+ checkExclusive(ctx, DevModeFlag, TestnetFlag, RinkebyFlag)
checkExclusive(ctx, FastSyncFlag, LightModeFlag, SyncModeFlag)
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -1015,45 +1005,21 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
cfg.NetworkId = 4
}
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
- case ctx.GlobalBool(DeveloperFlag.Name):
- // Create new developer account or reuse existing one
- var (
- developer accounts.Account
- err error
- )
- if accs := ks.Accounts(); len(accs) > 0 {
- developer = ks.Accounts()[0]
- } else {
- developer, err = ks.NewAccount("")
- if err != nil {
- Fatalf("Failed to create developer account: %v", err)
- }
- }
- if err := ks.Unlock(developer, ""); err != nil {
- Fatalf("Failed to unlock developer account: %v", err)
- }
- log.Info("Using developer account", "address", developer.Address)
-
- cfg.Genesis = core.DeveloperGenesisBlock(uint64(ctx.GlobalInt(DeveloperPeriodFlag.Name)), developer.Address)
+ case ctx.GlobalBool(DevModeFlag.Name):
+ cfg.Genesis = core.DevGenesisBlock()
if !ctx.GlobalIsSet(GasPriceFlag.Name) {
- cfg.GasPrice = big.NewInt(1)
+ cfg.GasPrice = new(big.Int)
}
+ cfg.PowTest = true
}
+
// TODO(fjl): move trie cache generations into config
if gen := ctx.GlobalInt(TrieCacheGenFlag.Name); gen > 0 {
state.MaxTrieCacheGen = uint16(gen)
}
}
-// SetDashboardConfig applies dashboard related command line flags to the config.
-func SetDashboardConfig(ctx *cli.Context, cfg *dashboard.Config) {
- cfg.Host = ctx.GlobalString(DashboardAddrFlag.Name)
- cfg.Port = ctx.GlobalInt(DashboardPortFlag.Name)
- cfg.Refresh = ctx.GlobalDuration(DashboardRefreshFlag.Name)
- cfg.Assets = ctx.GlobalString(DashboardAssetsFlag.Name)
-}
-
-// RegisterEthService adds an Ethereum client to the stack.
+// RegisterEthService adds an Wtc client to the stack.
func RegisterEthService(stack *node.Node, cfg *eth.Config) {
var err error
if cfg.SyncMode == downloader.LightSync {
@@ -1071,17 +1037,10 @@ func RegisterEthService(stack *node.Node, cfg *eth.Config) {
})
}
if err != nil {
- Fatalf("Failed to register the Ethereum service: %v", err)
+ Fatalf("Failed to register the Wtc service: %v", err)
}
}
-// RegisterDashboardService adds a dashboard to the stack.
-func RegisterDashboardService(stack *node.Node, cfg *dashboard.Config) {
- stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
- return dashboard.New(cfg)
- })
-}
-
// RegisterShhService configures Whisper and adds it to the given node.
func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
if err := stack.Register(func(n *node.ServiceContext) (node.Service, error) {
@@ -1091,20 +1050,20 @@ func RegisterShhService(stack *node.Node, cfg *whisper.Config) {
}
}
-// RegisterEthStatsService configures the Ethereum Stats daemon and adds it to
+// RegisterEthStatsService configures the Wtc Stats daemon and adds it to
// th egiven node.
func RegisterEthStatsService(stack *node.Node, url string) {
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
// Retrieve both eth and les services
- var ethServ *eth.Ethereum
+ var ethServ *eth.Wtc
ctx.Service(&ethServ)
- var lesServ *les.LightEthereum
+ var lesServ *les.LightWtc
ctx.Service(&lesServ)
return ethstats.New(url, ethServ, lesServ)
}); err != nil {
- Fatalf("Failed to register the Ethereum Stats service: %v", err)
+ Fatalf("Failed to register the Wtc Stats service: %v", err)
}
}
@@ -1115,7 +1074,7 @@ func SetupNetwork(ctx *cli.Context) {
}
// MakeChainDatabase open an LevelDB using the flags passed to the client and will hard crash if it fails.
-func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
+func MakeChainDatabase(ctx *cli.Context, stack *node.Node) wtcdb.Database {
var (
cache = ctx.GlobalInt(CacheFlag.Name)
handles = makeDatabaseHandles()
@@ -1138,33 +1097,29 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
genesis = core.DefaultTestnetGenesisBlock()
case ctx.GlobalBool(RinkebyFlag.Name):
genesis = core.DefaultRinkebyGenesisBlock()
- case ctx.GlobalBool(DeveloperFlag.Name):
- Fatalf("Developer chains are ephemeral")
+ case ctx.GlobalBool(DevModeFlag.Name):
+ genesis = core.DevGenesisBlock()
}
return genesis
}
// MakeChain creates a chain manager from set command line flags.
-func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb ethdb.Database) {
+func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chainDb wtcdb.Database) {
var err error
chainDb = MakeChainDatabase(ctx, stack)
+ engine := ethash.NewFaker()
+ if !ctx.GlobalBool(FakePoWFlag.Name) {
+ engine = ethash.New(
+ stack.ResolvePath(eth.DefaultConfig.EthashCacheDir), eth.DefaultConfig.EthashCachesInMem, eth.DefaultConfig.EthashCachesOnDisk,
+ stack.ResolvePath(eth.DefaultConfig.EthashDatasetDir), eth.DefaultConfig.EthashDatasetsInMem, eth.DefaultConfig.EthashDatasetsOnDisk,
+ eth.DefaultConfig.PowGPU,eth.DefaultConfig.GPUPort,eth.DefaultConfig.GPUGetPort,
+ )
+ }
config, _, err := core.SetupGenesisBlock(chainDb, MakeGenesis(ctx))
if err != nil {
Fatalf("%v", err)
}
- var engine consensus.Engine
- if config.Clique != nil {
- engine = clique.New(config.Clique, chainDb)
- } else {
- engine = ethash.NewFaker()
- if !ctx.GlobalBool(FakePoWFlag.Name) {
- engine = ethash.New(
- stack.ResolvePath(eth.DefaultConfig.EthashCacheDir), eth.DefaultConfig.EthashCachesInMem, eth.DefaultConfig.EthashCachesOnDisk,
- stack.ResolvePath(eth.DefaultConfig.EthashDatasetDir), eth.DefaultConfig.EthashDatasetsInMem, eth.DefaultConfig.EthashDatasetsOnDisk,
- )
- }
- }
vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)}
chain, err = core.NewBlockChain(chainDb, config, engine, vmcfg)
if err != nil {
@@ -1194,11 +1149,11 @@ func MakeConsolePreloads(ctx *cli.Context) []string {
// This is a temporary function used for migrating old command/flags to the
// new format.
//
-// e.g. geth account new --keystore /tmp/mykeystore --lightkdf
+// e.g. gwtc account new --keystore /tmp/mykeystore --lightkdf
//
// is equivalent after calling this method with:
//
-// geth --keystore /tmp/mykeystore --lightkdf account new
+// gwtc --keystore /tmp/mykeystore --lightkdf account new
//
// This allows the use of the existing configuration functionality.
// When all flags are migrated this function can be removed and the existing
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go
old mode 100644
new mode 100755
index 05e6b2908..485fdc6a5
--- a/cmd/wnode/main.go
+++ b/cmd/wnode/main.go
@@ -1,18 +1,18 @@
// Copyright 2017 The go-ethereum Authors
-// This file is part of go-ethereum.
+// This file is part of go-wtc.
//
-// go-ethereum is free software: you can redistribute it and/or modify
+// go-wtc is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// go-ethereum is distributed in the hope that it will be useful,
+// go-wtc is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
+// along with go-wtc. If not, see <http://www.gnu.org/licenses/>.
// This is a simple Whisper node. It could be used as a stand-alone bootstrap node.
// Also, could be used for different test and diagnostics purposes.
@@ -34,16 +34,16 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/cmd/utils"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/console"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/p2p/discover"
- "github.com/ethereum/go-ethereum/p2p/nat"
- "github.com/ethereum/go-ethereum/whisper/mailserver"
- whisper "github.com/ethereum/go-ethereum/whisper/whisperv5"
+ "github.com/wtc/go-wtc/cmd/utils"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/console"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/p2p/discover"
+ "github.com/wtc/go-wtc/p2p/nat"
+ "github.com/wtc/go-wtc/whisper/mailserver"
+ whisper "github.com/wtc/go-wtc/whisper/whisperv5"
"golang.org/x/crypto/pbkdf2"
)
@@ -91,7 +91,7 @@ var (
argPoW = flag.Float64("pow", whisper.DefaultMinimumPoW, "PoW for normal messages in float format (e.g. 2.7)")
argServerPoW = flag.Float64("mspow", whisper.DefaultMinimumPoW, "PoW requirement for Mail Server request")
- argIP = flag.String("ip", "", "IP address and port of this node (e.g. 127.0.0.1:30303)")
+ argIP = flag.String("ip", "", "IP address and port of this node (e.g. 127.0.0.1:10101)")
argPub = flag.String("pub", "", "public key for asymmetric encryption")
argDBPath = flag.String("dbpath", "", "path to the server's DB directory")
argIDFile = flag.String("idfile", "", "file name with node id (private key)")
diff --git a/common/big.go b/common/big.go
old mode 100644
new mode 100755
index b552608bc..31799ddd9
--- a/common/big.go
+++ b/common/big.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -27,4 +27,6 @@ var (
Big32 = big.NewInt(32)
Big256 = big.NewInt(0xff)
Big257 = big.NewInt(257)
+ Big60 = big.NewInt(60)
+ Big24 = big.NewInt(24)
)
diff --git a/common/bitutil/bitutil.go b/common/bitutil/bitutil.go
old mode 100644
new mode 100755
diff --git a/common/bitutil/bitutil_test.go b/common/bitutil/bitutil_test.go
old mode 100644
new mode 100755
diff --git a/common/bitutil/compress.go b/common/bitutil/compress.go
old mode 100644
new mode 100755
index c057cee4a..f91b5feac
--- a/common/bitutil/compress.go
+++ b/common/bitutil/compress.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/bitutil/compress_fuzz.go b/common/bitutil/compress_fuzz.go
old mode 100644
new mode 100755
index 1b87f50ed..ae2eb7bde
--- a/common/bitutil/compress_fuzz.go
+++ b/common/bitutil/compress_fuzz.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/bitutil/compress_test.go b/common/bitutil/compress_test.go
old mode 100644
new mode 100755
index 9bd1de103..929eea4c8
--- a/common/bitutil/compress_test.go
+++ b/common/bitutil/compress_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,7 @@ import (
"math/rand"
"testing"
- "github.com/ethereum/go-ethereum/common/hexutil"
+ "github.com/wtc/go-wtc/common/hexutil"
)
// Tests that data bitset encoding and decoding works and is bijective.
diff --git a/common/bytes.go b/common/bytes.go
old mode 100644
new mode 100755
index 66577bbfd..c1edd8131
--- a/common/bytes.go
+++ b/common/bytes.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/bytes_test.go b/common/bytes_test.go
old mode 100644
new mode 100755
index fc164b13d..552a109e3
--- a/common/bytes_test.go
+++ b/common/bytes_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/compiler/solidity.go b/common/compiler/solidity.go
old mode 100644
new mode 100755
index abb803989..df7ba98dc
--- a/common/compiler/solidity.go
+++ b/common/compiler/solidity.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/compiler/solidity_test.go b/common/compiler/solidity_test.go
old mode 100644
new mode 100755
index 0da3bb337..1a4fdd441
--- a/common/compiler/solidity_test.go
+++ b/common/compiler/solidity_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/debug.go b/common/debug.go
old mode 100644
new mode 100755
index 61acd8ce7..7a87a0131
--- a/common/debug.go
+++ b/common/debug.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -26,7 +26,7 @@ import (
// Report gives off a warning requesting the user to submit an issue to the github tracker.
func Report(extra ...interface{}) {
- fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/ethereum/go-ethereum/issues")
+ fmt.Fprintln(os.Stderr, "You've encountered a sought after, hard to reproduce bug. Please report this to the developers <3 https://github.com/wtc/go-wtc/issues")
fmt.Fprintln(os.Stderr, extra...)
_, file, line, _ := runtime.Caller(1)
diff --git a/common/format.go b/common/format.go
old mode 100644
new mode 100755
index fccc29962..0df3654cf
--- a/common/format.go
+++ b/common/format.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go
old mode 100644
new mode 100755
index 02c488a3f..eec3517d1
--- a/common/hexutil/hexutil.go
+++ b/common/hexutil/hexutil.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -16,7 +16,7 @@
/*
Package hexutil implements hex encoding with 0x prefix.
-This encoding is used by the Ethereum RPC API to transport binary data in JSON payloads.
+This encoding is used by the Wtc RPC API to transport binary data in JSON payloads.
Encoding Rules
@@ -53,7 +53,9 @@ var (
type decError struct{ msg string }
-func (err decError) Error() string { return err.msg }
+func (err decError) Error() string {
+ return string(err.msg)
+}
// Decode decodes a hex string with 0x prefix.
func Decode(input string) ([]byte, error) {
diff --git a/common/hexutil/hexutil_test.go b/common/hexutil/hexutil_test.go
old mode 100644
new mode 100755
index ed6fccc3c..5302b7891
--- a/common/hexutil/hexutil_test.go
+++ b/common/hexutil/hexutil_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/hexutil/json.go b/common/hexutil/json.go
old mode 100644
new mode 100755
index fbc21241c..fe9b3f6c6
--- a/common/hexutil/json.go
+++ b/common/hexutil/json.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -223,7 +223,7 @@ func (b *Uint64) UnmarshalText(input []byte) error {
return ErrSyntax
}
dec *= 16
- dec += nib
+ dec += uint64(nib)
}
*b = Uint64(dec)
return nil
diff --git a/common/hexutil/json_example_test.go b/common/hexutil/json_example_test.go
old mode 100644
new mode 100755
index 80180d918..6b06dccf3
--- a/common/hexutil/json_example_test.go
+++ b/common/hexutil/json_example_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,7 +20,7 @@ import (
"encoding/json"
"fmt"
- "github.com/ethereum/go-ethereum/common/hexutil"
+ "github.com/wtc/go-wtc/common/hexutil"
)
type MyType [5]byte
diff --git a/common/hexutil/json_test.go b/common/hexutil/json_test.go
old mode 100644
new mode 100755
index 8a6b8643a..8a92dd610
--- a/common/hexutil/json_test.go
+++ b/common/hexutil/json_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/main_test.go b/common/main_test.go
old mode 100644
new mode 100755
index 149d09928..1fcce34d7
--- a/common/main_test.go
+++ b/common/main_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/math/big.go b/common/math/big.go
old mode 100644
new mode 100755
index 787278650..7e0a1b3fd
--- a/common/math/big.go
+++ b/common/math/big.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/math/big_test.go b/common/math/big_test.go
old mode 100644
new mode 100755
index be9810dc8..90d975b27
--- a/common/math/big_test.go
+++ b/common/math/big_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,7 +22,7 @@ import (
"math/big"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
func TestHexOrDecimal256(t *testing.T) {
diff --git a/common/math/integer.go b/common/math/integer.go
old mode 100644
new mode 100755
index 7eff4d3b0..0e8e5a8cc
--- a/common/math/integer.go
+++ b/common/math/integer.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/math/integer_test.go b/common/math/integer_test.go
old mode 100644
new mode 100755
index b31c7c26c..1417ebfb1
--- a/common/math/integer_test.go
+++ b/common/math/integer_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/mclock/mclock.go b/common/mclock/mclock.go
old mode 100644
new mode 100755
index 92005252e..f2c913005
--- a/common/mclock/mclock.go
+++ b/common/mclock/mclock.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/now.go b/common/now.go
new file mode 100755
index 000000000..6c45bea38
--- /dev/null
+++ b/common/now.go
@@ -0,0 +1,39 @@
+// Copyright 2014 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-wtc library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-wtc library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package common
+
+import (
+ "time"
+ "math/big"
+)
+
+
+func getNow() *big.Int {
+ return big.NewInt(time.Now().Unix())
+}
+
+func SecChangeToMine(i *big.Int) (*big.Int,*big.Int) {
+ return new(big.Int).Div(i,Big60),new(big.Int).Mod(i,Big60)
+}
+
+func mineChangeToHour(i *big.Int) (*big.Int,*big.Int) {
+ return new(big.Int).Div(i,Big60),new(big.Int).Mod(i,Big60)
+}
+
+func HourChangeToDay(i *big.Int) (*big.Int,*big.Int) {
+ return new(big.Int).Div(i,Big24),new(big.Int).Mod(i,Big24)
+}
\ No newline at end of file
diff --git a/common/number/int.go b/common/number/int.go
old mode 100644
new mode 100755
index 6dab2436d..e169242c2
--- a/common/number/int.go
+++ b/common/number/int.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -19,7 +19,7 @@ package number
import (
"math/big"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
var tt256 = new(big.Int).Lsh(big.NewInt(1), 256)
diff --git a/common/number/uint_test.go b/common/number/uint_test.go
old mode 100644
new mode 100755
index 3ab9e4c34..246b162f7
--- a/common/number/uint_test.go
+++ b/common/number/uint_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,7 +20,7 @@ import (
"math/big"
"testing"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
func TestSet(t *testing.T) {
diff --git a/common/path.go b/common/path.go
old mode 100644
new mode 100755
index bd8da86e7..2f34582ce
--- a/common/path.go
+++ b/common/path.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,7 +23,7 @@ import (
"runtime"
)
-// MakeName creates a node name that follows the ethereum convention
+// MakeName creates a node name that follows the wtc convention
// for such names. It adds the operation system name and Go runtime version
// the name.
func MakeName(name, version string) string {
diff --git a/common/size.go b/common/size.go
old mode 100644
new mode 100755
index c5a0cb0f2..c8b2307ee
--- a/common/size.go
+++ b/common/size.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/size_test.go b/common/size_test.go
old mode 100644
new mode 100755
index f5b6c725e..b39b730d5
--- a/common/size_test.go
+++ b/common/size_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/test_utils.go b/common/test_utils.go
old mode 100644
new mode 100755
index a848642f7..2a9ffdf1f
--- a/common/test_utils.go
+++ b/common/test_utils.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/types.go b/common/types.go
old mode 100644
new mode 100755
index d31bbf741..82d112c88
--- a/common/types.go
+++ b/common/types.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,8 +23,8 @@ import (
"math/rand"
"reflect"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/crypto/sha3"
+ "github.com/wtc/go-wtc/common/hexutil"
+ "github.com/wtc/go-wtc/crypto/sha3"
)
const (
@@ -135,7 +135,7 @@ func (h UnprefixedHash) MarshalText() ([]byte, error) {
/////////// Address
-// Address represents the 20 byte address of an Ethereum account.
+// Address represents the 20 byte address of an Wtc account.
type Address [AddressLength]byte
func BytesToAddress(b []byte) Address {
@@ -148,7 +148,7 @@ func BigToAddress(b *big.Int) Address { return BytesToAddress(b.Bytes()) }
func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) }
// IsHexAddress verifies whether a string can represent a valid hex-encoded
-// Ethereum address or not.
+// Wtc address or not.
func IsHexAddress(s string) bool {
if len(s) == 2+2*AddressLength && IsHex(s) {
return true
diff --git a/common/types_template.go b/common/types_template.go
old mode 100644
new mode 100755
index 9a8f29977..cf21edbaf
--- a/common/types_template.go
+++ b/common/types_template.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/common/types_test.go b/common/types_test.go
old mode 100644
new mode 100755
index 6f3b31576..7b95388a3
--- a/common/types_test.go
+++ b/common/types_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -100,7 +100,7 @@ func TestAddressHexChecksum(t *testing.T) {
Input string
Output string
}{
- // Test cases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md#specification
+ // Test cases from https://github.com/wtc/EIPs/blob/master/EIPS/eip-55.md#specification
{"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed", "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"},
{"0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359", "0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"},
{"0xdbf03b407c01e7cd3cbea99509d93f8dddc8c6fb", "0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB"},
diff --git a/compression/rle/read_write.go b/compression/rle/read_write.go
old mode 100644
new mode 100755
index 0e7ad90ae..04f2eab04
--- a/compression/rle/read_write.go
+++ b/compression/rle/read_write.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,14 +14,14 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package rle implements the run-length encoding used for Ethereum data.
+// Package rle implements the run-length encoding used for Wtc data.
package rle
import (
"bytes"
"errors"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/crypto"
)
const (
diff --git a/compression/rle/read_write_test.go b/compression/rle/read_write_test.go
old mode 100644
new mode 100755
index b36f7907b..56f913b58
--- a/compression/rle/read_write_test.go
+++ b/compression/rle/read_write_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/consensus/clique/api.go b/consensus/clique/api.go
deleted file mode 100644
index b875eef01..000000000
--- a/consensus/clique/api.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2017 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package clique
-
-import (
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/rpc"
-)
-
-// API is a user facing RPC API to allow controlling the signer and voting
-// mechanisms of the proof-of-authority scheme.
-type API struct {
- chain consensus.ChainReader
- clique *Clique
-}
-
-// GetSnapshot retrieves the state snapshot at a given block.
-func (api *API) GetSnapshot(number *rpc.BlockNumber) (*Snapshot, error) {
- // Retrieve the requested block number (or current if none requested)
- var header *types.Header
- if number == nil || *number == rpc.LatestBlockNumber {
- header = api.chain.CurrentHeader()
- } else {
- header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
- }
- // Ensure we have an actually valid block and return its snapshot
- if header == nil {
- return nil, errUnknownBlock
- }
- return api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
-}
-
-// GetSnapshotAtHash retrieves the state snapshot at a given block.
-func (api *API) GetSnapshotAtHash(hash common.Hash) (*Snapshot, error) {
- header := api.chain.GetHeaderByHash(hash)
- if header == nil {
- return nil, errUnknownBlock
- }
- return api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
-}
-
-// GetSigners retrieves the list of authorized signers at the specified block.
-func (api *API) GetSigners(number *rpc.BlockNumber) ([]common.Address, error) {
- // Retrieve the requested block number (or current if none requested)
- var header *types.Header
- if number == nil || *number == rpc.LatestBlockNumber {
- header = api.chain.CurrentHeader()
- } else {
- header = api.chain.GetHeaderByNumber(uint64(number.Int64()))
- }
- // Ensure we have an actually valid block and return the signers from its snapshot
- if header == nil {
- return nil, errUnknownBlock
- }
- snap, err := api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
- if err != nil {
- return nil, err
- }
- return snap.signers(), nil
-}
-
-// GetSignersAtHash retrieves the state snapshot at a given block.
-func (api *API) GetSignersAtHash(hash common.Hash) ([]common.Address, error) {
- header := api.chain.GetHeaderByHash(hash)
- if header == nil {
- return nil, errUnknownBlock
- }
- snap, err := api.clique.snapshot(api.chain, header.Number.Uint64(), header.Hash(), nil)
- if err != nil {
- return nil, err
- }
- return snap.signers(), nil
-}
-
-// Proposals returns the current proposals the node tries to uphold and vote on.
-func (api *API) Proposals() map[common.Address]bool {
- api.clique.lock.RLock()
- defer api.clique.lock.RUnlock()
-
- proposals := make(map[common.Address]bool)
- for address, auth := range api.clique.proposals {
- proposals[address] = auth
- }
- return proposals
-}
-
-// Propose injects a new authorization proposal that the signer will attempt to
-// push through.
-func (api *API) Propose(address common.Address, auth bool) {
- api.clique.lock.Lock()
- defer api.clique.lock.Unlock()
-
- api.clique.proposals[address] = auth
-}
-
-// Discard drops a currently running proposal, stopping the signer from casting
-// further votes (either for or against).
-func (api *API) Discard(address common.Address) {
- api.clique.lock.Lock()
- defer api.clique.lock.Unlock()
-
- delete(api.clique.proposals, address)
-}
diff --git a/consensus/clique/clique.go b/consensus/clique/clique.go
deleted file mode 100644
index 6892d8390..000000000
--- a/consensus/clique/clique.go
+++ /dev/null
@@ -1,667 +0,0 @@
-// Copyright 2017 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-// Package clique implements the proof-of-authority consensus engine.
-package clique
-
-import (
- "bytes"
- "errors"
- "math/big"
- "math/rand"
- "sync"
- "time"
-
- "github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/consensus/misc"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/crypto/sha3"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rlp"
- "github.com/ethereum/go-ethereum/rpc"
- lru "github.com/hashicorp/golang-lru"
-)
-
-const (
- checkpointInterval = 1024 // Number of blocks after which to save the vote snapshot to the database
- inmemorySnapshots = 128 // Number of recent vote snapshots to keep in memory
- inmemorySignatures = 4096 // Number of recent block signatures to keep in memory
-
- wiggleTime = 500 * time.Millisecond // Random delay (per signer) to allow concurrent signers
-)
-
-// Clique proof-of-authority protocol constants.
-var (
- epochLength = uint64(30000) // Default number of blocks after which to checkpoint and reset the pending votes
- blockPeriod = uint64(15) // Default minimum difference between two consecutive block's timestamps
-
- extraVanity = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity
- extraSeal = 65 // Fixed number of extra-data suffix bytes reserved for signer seal
-
- nonceAuthVote = hexutil.MustDecode("0xffffffffffffffff") // Magic nonce number to vote on adding a new signer
- nonceDropVote = hexutil.MustDecode("0x0000000000000000") // Magic nonce number to vote on removing a signer.
-
- uncleHash = types.CalcUncleHash(nil) // Always Keccak256(RLP([])) as uncles are meaningless outside of PoW.
-
- diffInTurn = big.NewInt(2) // Block difficulty for in-turn signatures
- diffNoTurn = big.NewInt(1) // Block difficulty for out-of-turn signatures
-)
-
-// Various error messages to mark blocks invalid. These should be private to
-// prevent engine specific errors from being referenced in the remainder of the
-// codebase, inherently breaking if the engine is swapped out. Please put common
-// error types into the consensus package.
-var (
- // errUnknownBlock is returned when the list of signers is requested for a block
- // that is not part of the local blockchain.
- errUnknownBlock = errors.New("unknown block")
-
- // errInvalidCheckpointBeneficiary is returned if a checkpoint/epoch transition
- // block has a beneficiary set to non-zeroes.
- errInvalidCheckpointBeneficiary = errors.New("beneficiary in checkpoint block non-zero")
-
- // errInvalidVote is returned if a nonce value is something else that the two
- // allowed constants of 0x00..0 or 0xff..f.
- errInvalidVote = errors.New("vote nonce not 0x00..0 or 0xff..f")
-
- // errInvalidCheckpointVote is returned if a checkpoint/epoch transition block
- // has a vote nonce set to non-zeroes.
- errInvalidCheckpointVote = errors.New("vote nonce in checkpoint block non-zero")
-
- // errMissingVanity is returned if a block's extra-data section is shorter than
- // 32 bytes, which is required to store the signer vanity.
- errMissingVanity = errors.New("extra-data 32 byte vanity prefix missing")
-
- // errMissingSignature is returned if a block's extra-data section doesn't seem
- // to contain a 65 byte secp256k1 signature.
- errMissingSignature = errors.New("extra-data 65 byte suffix signature missing")
-
- // errExtraSigners is returned if non-checkpoint block contain signer data in
- // their extra-data fields.
- errExtraSigners = errors.New("non-checkpoint block contains extra signer list")
-
- // errInvalidCheckpointSigners is returned if a checkpoint block contains an
- // invalid list of signers (i.e. non divisible by 20 bytes, or not the correct
- // ones).
- errInvalidCheckpointSigners = errors.New("invalid signer list on checkpoint block")
-
- // errInvalidMixDigest is returned if a block's mix digest is non-zero.
- errInvalidMixDigest = errors.New("non-zero mix digest")
-
- // errInvalidUncleHash is returned if a block contains an non-empty uncle list.
- errInvalidUncleHash = errors.New("non empty uncle hash")
-
- // errInvalidDifficulty is returned if the difficulty of a block is not either
- // of 1 or 2, or if the value does not match the turn of the signer.
- errInvalidDifficulty = errors.New("invalid difficulty")
-
- // ErrInvalidTimestamp is returned if the timestamp of a block is lower than
- // the previous block's timestamp + the minimum block period.
- ErrInvalidTimestamp = errors.New("invalid timestamp")
-
- // errInvalidVotingChain is returned if an authorization list is attempted to
- // be modified via out-of-range or non-contiguous headers.
- errInvalidVotingChain = errors.New("invalid voting chain")
-
- // errUnauthorized is returned if a header is signed by a non-authorized entity.
- errUnauthorized = errors.New("unauthorized")
-
- // errWaitTransactions is returned if an empty block is attempted to be sealed
- // on an instant chain (0 second period). It's important to refuse these as the
- // block reward is zero, so an empty block just bloats the chain... fast.
- errWaitTransactions = errors.New("waiting for transactions")
-)
-
-// SignerFn is a signer callback function to request a hash to be signed by a
-// backing account.
-type SignerFn func(accounts.Account, []byte) ([]byte, error)
-
-// sigHash returns the hash which is used as input for the proof-of-authority
-// signing. It is the hash of the entire header apart from the 65 byte signature
-// contained at the end of the extra data.
-//
-// Note, the method requires the extra data to be at least 65 bytes, otherwise it
-// panics. This is done to avoid accidentally using both forms (signature present
-// or not), which could be abused to produce different hashes for the same header.
-func sigHash(header *types.Header) (hash common.Hash) {
- hasher := sha3.NewKeccak256()
-
- rlp.Encode(hasher, []interface{}{
- header.ParentHash,
- header.UncleHash,
- header.Coinbase,
- header.Root,
- header.TxHash,
- header.ReceiptHash,
- header.Bloom,
- header.Difficulty,
- header.Number,
- header.GasLimit,
- header.GasUsed,
- header.Time,
- header.Extra[:len(header.Extra)-65], // Yes, this will panic if extra is too short
- header.MixDigest,
- header.Nonce,
- })
- hasher.Sum(hash[:0])
- return hash
-}
-
-// ecrecover extracts the Ethereum account address from a signed header.
-func ecrecover(header *types.Header, sigcache *lru.ARCCache) (common.Address, error) {
- // If the signature's already cached, return that
- hash := header.Hash()
- if address, known := sigcache.Get(hash); known {
- return address.(common.Address), nil
- }
- // Retrieve the signature from the header extra-data
- if len(header.Extra) < extraSeal {
- return common.Address{}, errMissingSignature
- }
- signature := header.Extra[len(header.Extra)-extraSeal:]
-
- // Recover the public key and the Ethereum address
- pubkey, err := crypto.Ecrecover(sigHash(header).Bytes(), signature)
- if err != nil {
- return common.Address{}, err
- }
- var signer common.Address
- copy(signer[:], crypto.Keccak256(pubkey[1:])[12:])
-
- sigcache.Add(hash, signer)
- return signer, nil
-}
-
-// Clique is the proof-of-authority consensus engine proposed to support the
-// Ethereum testnet following the Ropsten attacks.
-type Clique struct {
- config *params.CliqueConfig // Consensus engine configuration parameters
- db ethdb.Database // Database to store and retrieve snapshot checkpoints
-
- recents *lru.ARCCache // Snapshots for recent block to speed up reorgs
- signatures *lru.ARCCache // Signatures of recent blocks to speed up mining
-
- proposals map[common.Address]bool // Current list of proposals we are pushing
-
- signer common.Address // Ethereum address of the signing key
- signFn SignerFn // Signer function to authorize hashes with
- lock sync.RWMutex // Protects the signer fields
-}
-
-// New creates a Clique proof-of-authority consensus engine with the initial
-// signers set to the ones provided by the user.
-func New(config *params.CliqueConfig, db ethdb.Database) *Clique {
- // Set any missing consensus parameters to their defaults
- conf := *config
- if conf.Epoch == 0 {
- conf.Epoch = epochLength
- }
- // Allocate the snapshot caches and create the engine
- recents, _ := lru.NewARC(inmemorySnapshots)
- signatures, _ := lru.NewARC(inmemorySignatures)
-
- return &Clique{
- config: &conf,
- db: db,
- recents: recents,
- signatures: signatures,
- proposals: make(map[common.Address]bool),
- }
-}
-
-// Author implements consensus.Engine, returning the Ethereum address recovered
-// from the signature in the header's extra-data section.
-func (c *Clique) Author(header *types.Header) (common.Address, error) {
- return ecrecover(header, c.signatures)
-}
-
-// VerifyHeader checks whether a header conforms to the consensus rules.
-func (c *Clique) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error {
- return c.verifyHeader(chain, header, nil)
-}
-
-// VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers. The
-// method returns a quit channel to abort the operations and a results channel to
-// retrieve the async verifications (the order is that of the input slice).
-func (c *Clique) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error) {
- abort := make(chan struct{})
- results := make(chan error, len(headers))
-
- go func() {
- for i, header := range headers {
- err := c.verifyHeader(chain, header, headers[:i])
-
- select {
- case <-abort:
- return
- case results <- err:
- }
- }
- }()
- return abort, results
-}
-
-// verifyHeader checks whether a header conforms to the consensus rules.The
-// caller may optionally pass in a batch of parents (ascending order) to avoid
-// looking those up from the database. This is useful for concurrently verifying
-// a batch of new headers.
-func (c *Clique) verifyHeader(chain consensus.ChainReader, header *types.Header, parents []*types.Header) error {
- if header.Number == nil {
- return errUnknownBlock
- }
- number := header.Number.Uint64()
-
- // Don't waste time checking blocks from the future
- if header.Time.Cmp(big.NewInt(time.Now().Unix())) > 0 {
- return consensus.ErrFutureBlock
- }
- // Checkpoint blocks need to enforce zero beneficiary
- checkpoint := (number % c.config.Epoch) == 0
- if checkpoint && header.Coinbase != (common.Address{}) {
- return errInvalidCheckpointBeneficiary
- }
- // Nonces must be 0x00..0 or 0xff..f, zeroes enforced on checkpoints
- if !bytes.Equal(header.Nonce[:], nonceAuthVote) && !bytes.Equal(header.Nonce[:], nonceDropVote) {
- return errInvalidVote
- }
- if checkpoint && !bytes.Equal(header.Nonce[:], nonceDropVote) {
- return errInvalidCheckpointVote
- }
- // Check that the extra-data contains both the vanity and signature
- if len(header.Extra) < extraVanity {
- return errMissingVanity
- }
- if len(header.Extra) < extraVanity+extraSeal {
- return errMissingSignature
- }
- // Ensure that the extra-data contains a signer list on checkpoint, but none otherwise
- signersBytes := len(header.Extra) - extraVanity - extraSeal
- if !checkpoint && signersBytes != 0 {
- return errExtraSigners
- }
- if checkpoint && signersBytes%common.AddressLength != 0 {
- return errInvalidCheckpointSigners
- }
- // Ensure that the mix digest is zero as we don't have fork protection currently
- if header.MixDigest != (common.Hash{}) {
- return errInvalidMixDigest
- }
- // Ensure that the block doesn't contain any uncles which are meaningless in PoA
- if header.UncleHash != uncleHash {
- return errInvalidUncleHash
- }
- // Ensure that the block's difficulty is meaningful (may not be correct at this point)
- if number > 0 {
- if header.Difficulty == nil || (header.Difficulty.Cmp(diffInTurn) != 0 && header.Difficulty.Cmp(diffNoTurn) != 0) {
- return errInvalidDifficulty
- }
- }
- // If all checks passed, validate any special fields for hard forks
- if err := misc.VerifyForkHashes(chain.Config(), header, false); err != nil {
- return err
- }
- // All basic checks passed, verify cascading fields
- return c.verifyCascadingFields(chain, header, parents)
-}
-
-// verifyCascadingFields verifies all the header fields that are not standalone,
-// rather depend on a batch of previous headers. The caller may optionally pass
-// in a batch of parents (ascending order) to avoid looking those up from the
-// database. This is useful for concurrently verifying a batch of new headers.
-func (c *Clique) verifyCascadingFields(chain consensus.ChainReader, header *types.Header, parents []*types.Header) error {
- // The genesis block is the always valid dead-end
- number := header.Number.Uint64()
- if number == 0 {
- return nil
- }
- // Ensure that the block's timestamp isn't too close to it's parent
- var parent *types.Header
- if len(parents) > 0 {
- parent = parents[len(parents)-1]
- } else {
- parent = chain.GetHeader(header.ParentHash, number-1)
- }
- if parent == nil || parent.Number.Uint64() != number-1 || parent.Hash() != header.ParentHash {
- return consensus.ErrUnknownAncestor
- }
- if parent.Time.Uint64()+c.config.Period > header.Time.Uint64() {
- return ErrInvalidTimestamp
- }
- // Retrieve the snapshot needed to verify this header and cache it
- snap, err := c.snapshot(chain, number-1, header.ParentHash, parents)
- if err != nil {
- return err
- }
- // If the block is a checkpoint block, verify the signer list
- if number%c.config.Epoch == 0 {
- signers := make([]byte, len(snap.Signers)*common.AddressLength)
- for i, signer := range snap.signers() {
- copy(signers[i*common.AddressLength:], signer[:])
- }
- extraSuffix := len(header.Extra) - extraSeal
- if !bytes.Equal(header.Extra[extraVanity:extraSuffix], signers) {
- return errInvalidCheckpointSigners
- }
- }
- // All basic checks passed, verify the seal and return
- return c.verifySeal(chain, header, parents)
-}
-
-// snapshot retrieves the authorization snapshot at a given point in time.
-func (c *Clique) snapshot(chain consensus.ChainReader, number uint64, hash common.Hash, parents []*types.Header) (*Snapshot, error) {
- // Search for a snapshot in memory or on disk for checkpoints
- var (
- headers []*types.Header
- snap *Snapshot
- )
- for snap == nil {
- // If an in-memory snapshot was found, use that
- if s, ok := c.recents.Get(hash); ok {
- snap = s.(*Snapshot)
- break
- }
- // If an on-disk checkpoint snapshot can be found, use that
- if number%checkpointInterval == 0 {
- if s, err := loadSnapshot(c.config, c.signatures, c.db, hash); err == nil {
- log.Trace("Loaded voting snapshot form disk", "number", number, "hash", hash)
- snap = s
- break
- }
- }
- // If we're at block zero, make a snapshot
- if number == 0 {
- genesis := chain.GetHeaderByNumber(0)
- if err := c.VerifyHeader(chain, genesis, false); err != nil {
- return nil, err
- }
- signers := make([]common.Address, (len(genesis.Extra)-extraVanity-extraSeal)/common.AddressLength)
- for i := 0; i < len(signers); i++ {
- copy(signers[i][:], genesis.Extra[extraVanity+i*common.AddressLength:])
- }
- snap = newSnapshot(c.config, c.signatures, 0, genesis.Hash(), signers)
- if err := snap.store(c.db); err != nil {
- return nil, err
- }
- log.Trace("Stored genesis voting snapshot to disk")
- break
- }
- // No snapshot for this header, gather the header and move backward
- var header *types.Header
- if len(parents) > 0 {
- // If we have explicit parents, pick from there (enforced)
- header = parents[len(parents)-1]
- if header.Hash() != hash || header.Number.Uint64() != number {
- return nil, consensus.ErrUnknownAncestor
- }
- parents = parents[:len(parents)-1]
- } else {
- // No explicit parents (or no more left), reach out to the database
- header = chain.GetHeader(hash, number)
- if header == nil {
- return nil, consensus.ErrUnknownAncestor
- }
- }
- headers = append(headers, header)
- number, hash = number-1, header.ParentHash
- }
- // Previous snapshot found, apply any pending headers on top of it
- for i := 0; i < len(headers)/2; i++ {
- headers[i], headers[len(headers)-1-i] = headers[len(headers)-1-i], headers[i]
- }
- snap, err := snap.apply(headers)
- if err != nil {
- return nil, err
- }
- c.recents.Add(snap.Hash, snap)
-
- // If we've generated a new checkpoint snapshot, save to disk
- if snap.Number%checkpointInterval == 0 && len(headers) > 0 {
- if err = snap.store(c.db); err != nil {
- return nil, err
- }
- log.Trace("Stored voting snapshot to disk", "number", snap.Number, "hash", snap.Hash)
- }
- return snap, err
-}
-
-// VerifyUncles implements consensus.Engine, always returning an error for any
-// uncles as this consensus mechanism doesn't permit uncles.
-func (c *Clique) VerifyUncles(chain consensus.ChainReader, block *types.Block) error {
- if len(block.Uncles()) > 0 {
- return errors.New("uncles not allowed")
- }
- return nil
-}
-
-// VerifySeal implements consensus.Engine, checking whether the signature contained
-// in the header satisfies the consensus protocol requirements.
-func (c *Clique) VerifySeal(chain consensus.ChainReader, header *types.Header) error {
- return c.verifySeal(chain, header, nil)
-}
-
-// verifySeal checks whether the signature contained in the header satisfies the
-// consensus protocol requirements. The method accepts an optional list of parent
-// headers that aren't yet part of the local blockchain to generate the snapshots
-// from.
-func (c *Clique) verifySeal(chain consensus.ChainReader, header *types.Header, parents []*types.Header) error {
- // Verifying the genesis block is not supported
- number := header.Number.Uint64()
- if number == 0 {
- return errUnknownBlock
- }
- // Retrieve the snapshot needed to verify this header and cache it
- snap, err := c.snapshot(chain, number-1, header.ParentHash, parents)
- if err != nil {
- return err
- }
-
- // Resolve the authorization key and check against signers
- signer, err := ecrecover(header, c.signatures)
- if err != nil {
- return err
- }
- if _, ok := snap.Signers[signer]; !ok {
- return errUnauthorized
- }
- for seen, recent := range snap.Recents {
- if recent == signer {
- // Signer is among recents, only fail if the current block doesn't shift it out
- if limit := uint64(len(snap.Signers)/2 + 1); seen > number-limit {
- return errUnauthorized
- }
- }
- }
- // Ensure that the difficulty corresponds to the turn-ness of the signer
- inturn := snap.inturn(header.Number.Uint64(), signer)
- if inturn && header.Difficulty.Cmp(diffInTurn) != 0 {
- return errInvalidDifficulty
- }
- if !inturn && header.Difficulty.Cmp(diffNoTurn) != 0 {
- return errInvalidDifficulty
- }
- return nil
-}
-
-// Prepare implements consensus.Engine, preparing all the consensus fields of the
-// header for running the transactions on top.
-func (c *Clique) Prepare(chain consensus.ChainReader, header *types.Header) error {
- // If the block isn't a checkpoint, cast a random vote (good enough for now)
- header.Coinbase = common.Address{}
- header.Nonce = types.BlockNonce{}
-
- number := header.Number.Uint64()
-
- // Assemble the voting snapshot to check which votes make sense
- snap, err := c.snapshot(chain, number-1, header.ParentHash, nil)
- if err != nil {
- return err
- }
- if number%c.config.Epoch != 0 {
- c.lock.RLock()
-
- // Gather all the proposals that make sense voting on
- addresses := make([]common.Address, 0, len(c.proposals))
- for address, authorize := range c.proposals {
- if snap.validVote(address, authorize) {
- addresses = append(addresses, address)
- }
- }
- // If there's pending proposals, cast a vote on them
- if len(addresses) > 0 {
- header.Coinbase = addresses[rand.Intn(len(addresses))]
- if c.proposals[header.Coinbase] {
- copy(header.Nonce[:], nonceAuthVote)
- } else {
- copy(header.Nonce[:], nonceDropVote)
- }
- }
- c.lock.RUnlock()
- }
- // Set the correct difficulty
- header.Difficulty = diffNoTurn
- if snap.inturn(header.Number.Uint64(), c.signer) {
- header.Difficulty = diffInTurn
- }
- // Ensure the extra data has all it's components
- if len(header.Extra) < extraVanity {
- header.Extra = append(header.Extra, bytes.Repeat([]byte{0x00}, extraVanity-len(header.Extra))...)
- }
- header.Extra = header.Extra[:extraVanity]
-
- if number%c.config.Epoch == 0 {
- for _, signer := range snap.signers() {
- header.Extra = append(header.Extra, signer[:]...)
- }
- }
- header.Extra = append(header.Extra, make([]byte, extraSeal)...)
-
- // Mix digest is reserved for now, set to empty
- header.MixDigest = common.Hash{}
-
- // Ensure the timestamp has the correct delay
- parent := chain.GetHeader(header.ParentHash, number-1)
- if parent == nil {
- return consensus.ErrUnknownAncestor
- }
- header.Time = new(big.Int).Add(parent.Time, new(big.Int).SetUint64(c.config.Period))
- if header.Time.Int64() < time.Now().Unix() {
- header.Time = big.NewInt(time.Now().Unix())
- }
- return nil
-}
-
-// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
-// rewards given, and returns the final block.
-func (c *Clique) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
- // No block rewards in PoA, so the state remains as is and uncles are dropped
- header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
- header.UncleHash = types.CalcUncleHash(nil)
-
- // Assemble and return the final block for sealing
- return types.NewBlock(header, txs, nil, receipts), nil
-}
-
-// Authorize injects a private key into the consensus engine to mint new blocks
-// with.
-func (c *Clique) Authorize(signer common.Address, signFn SignerFn) {
- c.lock.Lock()
- defer c.lock.Unlock()
-
- c.signer = signer
- c.signFn = signFn
-}
-
-// Seal implements consensus.Engine, attempting to create a sealed block using
-// the local signing credentials.
-func (c *Clique) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error) {
- header := block.Header()
-
- // Sealing the genesis block is not supported
- number := header.Number.Uint64()
- if number == 0 {
- return nil, errUnknownBlock
- }
- // For 0-period chains, refuse to seal empty blocks (no reward but would spin sealing)
- if c.config.Period == 0 && len(block.Transactions()) == 0 {
- return nil, errWaitTransactions
- }
- // Don't hold the signer fields for the entire sealing procedure
- c.lock.RLock()
- signer, signFn := c.signer, c.signFn
- c.lock.RUnlock()
-
- // Bail out if we're unauthorized to sign a block
- snap, err := c.snapshot(chain, number-1, header.ParentHash, nil)
- if err != nil {
- return nil, err
- }
- if _, authorized := snap.Signers[signer]; !authorized {
- return nil, errUnauthorized
- }
- // If we're amongst the recent signers, wait for the next block
- for seen, recent := range snap.Recents {
- if recent == signer {
- // Signer is among recents, only wait if the current block doesn't shift it out
- if limit := uint64(len(snap.Signers)/2 + 1); number < limit || seen > number-limit {
- log.Info("Signed recently, must wait for others")
- <-stop
- return nil, nil
- }
- }
- }
- // Sweet, the protocol permits us to sign the block, wait for our time
- delay := time.Unix(header.Time.Int64(), 0).Sub(time.Now())
- if header.Difficulty.Cmp(diffNoTurn) == 0 {
- // It's not our turn explicitly to sign, delay it a bit
- wiggle := time.Duration(len(snap.Signers)/2+1) * wiggleTime
- delay += time.Duration(rand.Int63n(int64(wiggle)))
-
- log.Trace("Out-of-turn signing requested", "wiggle", common.PrettyDuration(wiggle))
- }
- log.Trace("Waiting for slot to sign and propagate", "delay", common.PrettyDuration(delay))
-
- select {
- case <-stop:
- return nil, nil
- case <-time.After(delay):
- }
- // Sign all the things!
- sighash, err := signFn(accounts.Account{Address: signer}, sigHash(header).Bytes())
- if err != nil {
- return nil, err
- }
- copy(header.Extra[len(header.Extra)-extraSeal:], sighash)
-
- return block.WithSeal(header), nil
-}
-
-// APIs implements consensus.Engine, returning the user facing RPC API to allow
-// controlling the signer voting.
-func (c *Clique) APIs(chain consensus.ChainReader) []rpc.API {
- return []rpc.API{{
- Namespace: "clique",
- Version: "1.0",
- Service: &API{chain: chain, clique: c},
- Public: false,
- }}
-}
diff --git a/consensus/clique/snapshot.go b/consensus/clique/snapshot.go
deleted file mode 100644
index 9ebdb8df1..000000000
--- a/consensus/clique/snapshot.go
+++ /dev/null
@@ -1,310 +0,0 @@
-// Copyright 2017 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package clique
-
-import (
- "bytes"
- "encoding/json"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
- lru "github.com/hashicorp/golang-lru"
-)
-
-// Vote represents a single vote that an authorized signer made to modify the
-// list of authorizations.
-type Vote struct {
- Signer common.Address `json:"signer"` // Authorized signer that cast this vote
- Block uint64 `json:"block"` // Block number the vote was cast in (expire old votes)
- Address common.Address `json:"address"` // Account being voted on to change its authorization
- Authorize bool `json:"authorize"` // Whether to authorize or deauthorize the voted account
-}
-
-// Tally is a simple vote tally to keep the current score of votes. Votes that
-// go against the proposal aren't counted since it's equivalent to not voting.
-type Tally struct {
- Authorize bool `json:"authorize"` // Whether the vote is about authorizing or kicking someone
- Votes int `json:"votes"` // Number of votes until now wanting to pass the proposal
-}
-
-// Snapshot is the state of the authorization voting at a given point in time.
-type Snapshot struct {
- config *params.CliqueConfig // Consensus engine parameters to fine tune behavior
- sigcache *lru.ARCCache // Cache of recent block signatures to speed up ecrecover
-
- Number uint64 `json:"number"` // Block number where the snapshot was created
- Hash common.Hash `json:"hash"` // Block hash where the snapshot was created
- Signers map[common.Address]struct{} `json:"signers"` // Set of authorized signers at this moment
- Recents map[uint64]common.Address `json:"recents"` // Set of recent signers for spam protections
- Votes []*Vote `json:"votes"` // List of votes cast in chronological order
- Tally map[common.Address]Tally `json:"tally"` // Current vote tally to avoid recalculating
-}
-
-// newSnapshot creates a new snapshot with the specified startup parameters. This
-// method does not initialize the set of recent signers, so only ever use if for
-// the genesis block.
-func newSnapshot(config *params.CliqueConfig, sigcache *lru.ARCCache, number uint64, hash common.Hash, signers []common.Address) *Snapshot {
- snap := &Snapshot{
- config: config,
- sigcache: sigcache,
- Number: number,
- Hash: hash,
- Signers: make(map[common.Address]struct{}),
- Recents: make(map[uint64]common.Address),
- Tally: make(map[common.Address]Tally),
- }
- for _, signer := range signers {
- snap.Signers[signer] = struct{}{}
- }
- return snap
-}
-
-// loadSnapshot loads an existing snapshot from the database.
-func loadSnapshot(config *params.CliqueConfig, sigcache *lru.ARCCache, db ethdb.Database, hash common.Hash) (*Snapshot, error) {
- blob, err := db.Get(append([]byte("clique-"), hash[:]...))
- if err != nil {
- return nil, err
- }
- snap := new(Snapshot)
- if err := json.Unmarshal(blob, snap); err != nil {
- return nil, err
- }
- snap.config = config
- snap.sigcache = sigcache
-
- return snap, nil
-}
-
-// store inserts the snapshot into the database.
-func (s *Snapshot) store(db ethdb.Database) error {
- blob, err := json.Marshal(s)
- if err != nil {
- return err
- }
- return db.Put(append([]byte("clique-"), s.Hash[:]...), blob)
-}
-
-// copy creates a deep copy of the snapshot, though not the individual votes.
-func (s *Snapshot) copy() *Snapshot {
- cpy := &Snapshot{
- config: s.config,
- sigcache: s.sigcache,
- Number: s.Number,
- Hash: s.Hash,
- Signers: make(map[common.Address]struct{}),
- Recents: make(map[uint64]common.Address),
- Votes: make([]*Vote, len(s.Votes)),
- Tally: make(map[common.Address]Tally),
- }
- for signer := range s.Signers {
- cpy.Signers[signer] = struct{}{}
- }
- for block, signer := range s.Recents {
- cpy.Recents[block] = signer
- }
- for address, tally := range s.Tally {
- cpy.Tally[address] = tally
- }
- copy(cpy.Votes, s.Votes)
-
- return cpy
-}
-
-// validVote returns whether it makes sense to cast the specified vote in the
-// given snapshot context (e.g. don't try to add an already authorized signer).
-func (s *Snapshot) validVote(address common.Address, authorize bool) bool {
- _, signer := s.Signers[address]
- return (signer && !authorize) || (!signer && authorize)
-}
-
-// cast adds a new vote into the tally.
-func (s *Snapshot) cast(address common.Address, authorize bool) bool {
- // Ensure the vote is meaningful
- if !s.validVote(address, authorize) {
- return false
- }
- // Cast the vote into an existing or new tally
- if old, ok := s.Tally[address]; ok {
- old.Votes++
- s.Tally[address] = old
- } else {
- s.Tally[address] = Tally{Authorize: authorize, Votes: 1}
- }
- return true
-}
-
-// uncast removes a previously cast vote from the tally.
-func (s *Snapshot) uncast(address common.Address, authorize bool) bool {
- // If there's no tally, it's a dangling vote, just drop
- tally, ok := s.Tally[address]
- if !ok {
- return false
- }
- // Ensure we only revert counted votes
- if tally.Authorize != authorize {
- return false
- }
- // Otherwise revert the vote
- if tally.Votes > 1 {
- tally.Votes--
- s.Tally[address] = tally
- } else {
- delete(s.Tally, address)
- }
- return true
-}
-
-// apply creates a new authorization snapshot by applying the given headers to
-// the original one.
-func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
- // Allow passing in no headers for cleaner code
- if len(headers) == 0 {
- return s, nil
- }
- // Sanity check that the headers can be applied
- for i := 0; i < len(headers)-1; i++ {
- if headers[i+1].Number.Uint64() != headers[i].Number.Uint64()+1 {
- return nil, errInvalidVotingChain
- }
- }
- if headers[0].Number.Uint64() != s.Number+1 {
- return nil, errInvalidVotingChain
- }
- // Iterate through the headers and create a new snapshot
- snap := s.copy()
-
- for _, header := range headers {
- // Remove any votes on checkpoint blocks
- number := header.Number.Uint64()
- if number%s.config.Epoch == 0 {
- snap.Votes = nil
- snap.Tally = make(map[common.Address]Tally)
- }
- // Delete the oldest signer from the recent list to allow it signing again
- if limit := uint64(len(snap.Signers)/2 + 1); number >= limit {
- delete(snap.Recents, number-limit)
- }
- // Resolve the authorization key and check against signers
- signer, err := ecrecover(header, s.sigcache)
- if err != nil {
- return nil, err
- }
- if _, ok := snap.Signers[signer]; !ok {
- return nil, errUnauthorized
- }
- for _, recent := range snap.Recents {
- if recent == signer {
- return nil, errUnauthorized
- }
- }
- snap.Recents[number] = signer
-
- // Header authorized, discard any previous votes from the signer
- for i, vote := range snap.Votes {
- if vote.Signer == signer && vote.Address == header.Coinbase {
- // Uncast the vote from the cached tally
- snap.uncast(vote.Address, vote.Authorize)
-
- // Uncast the vote from the chronological list
- snap.Votes = append(snap.Votes[:i], snap.Votes[i+1:]...)
- break // only one vote allowed
- }
- }
- // Tally up the new vote from the signer
- var authorize bool
- switch {
- case bytes.Equal(header.Nonce[:], nonceAuthVote):
- authorize = true
- case bytes.Equal(header.Nonce[:], nonceDropVote):
- authorize = false
- default:
- return nil, errInvalidVote
- }
- if snap.cast(header.Coinbase, authorize) {
- snap.Votes = append(snap.Votes, &Vote{
- Signer: signer,
- Block: number,
- Address: header.Coinbase,
- Authorize: authorize,
- })
- }
- // If the vote passed, update the list of signers
- if tally := snap.Tally[header.Coinbase]; tally.Votes > len(snap.Signers)/2 {
- if tally.Authorize {
- snap.Signers[header.Coinbase] = struct{}{}
- } else {
- delete(snap.Signers, header.Coinbase)
-
- // Signer list shrunk, delete any leftover recent caches
- if limit := uint64(len(snap.Signers)/2 + 1); number >= limit {
- delete(snap.Recents, number-limit)
- }
- // Discard any previous votes the deauthorized signer cast
- for i := 0; i < len(snap.Votes); i++ {
- if snap.Votes[i].Signer == header.Coinbase {
- // Uncast the vote from the cached tally
- snap.uncast(snap.Votes[i].Address, snap.Votes[i].Authorize)
-
- // Uncast the vote from the chronological list
- snap.Votes = append(snap.Votes[:i], snap.Votes[i+1:]...)
-
- i--
- }
- }
- }
- // Discard any previous votes around the just changed account
- for i := 0; i < len(snap.Votes); i++ {
- if snap.Votes[i].Address == header.Coinbase {
- snap.Votes = append(snap.Votes[:i], snap.Votes[i+1:]...)
- i--
- }
- }
- delete(snap.Tally, header.Coinbase)
- }
- }
- snap.Number += uint64(len(headers))
- snap.Hash = headers[len(headers)-1].Hash()
-
- return snap, nil
-}
-
-// signers retrieves the list of authorized signers in ascending order.
-func (s *Snapshot) signers() []common.Address {
- signers := make([]common.Address, 0, len(s.Signers))
- for signer := range s.Signers {
- signers = append(signers, signer)
- }
- for i := 0; i < len(signers); i++ {
- for j := i + 1; j < len(signers); j++ {
- if bytes.Compare(signers[i][:], signers[j][:]) > 0 {
- signers[i], signers[j] = signers[j], signers[i]
- }
- }
- }
- return signers
-}
-
-// inturn returns if a signer at a given block height is in-turn or not.
-func (s *Snapshot) inturn(number uint64, signer common.Address) bool {
- signers, offset := s.signers(), 0
- for offset < len(signers) && signers[offset] != signer {
- offset++
- }
- return (number % uint64(len(signers))) == uint64(offset)
-}
diff --git a/consensus/clique/snapshot_test.go b/consensus/clique/snapshot_test.go
deleted file mode 100644
index 8b51e6e09..000000000
--- a/consensus/clique/snapshot_test.go
+++ /dev/null
@@ -1,405 +0,0 @@
-// Copyright 2017 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package clique
-
-import (
- "bytes"
- "crypto/ecdsa"
- "math/big"
- "testing"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
-)
-
-type testerVote struct {
- signer string
- voted string
- auth bool
-}
-
-// testerAccountPool is a pool to maintain currently active tester accounts,
-// mapped from textual names used in the tests below to actual Ethereum private
-// keys capable of signing transactions.
-type testerAccountPool struct {
- accounts map[string]*ecdsa.PrivateKey
-}
-
-func newTesterAccountPool() *testerAccountPool {
- return &testerAccountPool{
- accounts: make(map[string]*ecdsa.PrivateKey),
- }
-}
-
-func (ap *testerAccountPool) sign(header *types.Header, signer string) {
- // Ensure we have a persistent key for the signer
- if ap.accounts[signer] == nil {
- ap.accounts[signer], _ = crypto.GenerateKey()
- }
- // Sign the header and embed the signature in extra data
- sig, _ := crypto.Sign(sigHash(header).Bytes(), ap.accounts[signer])
- copy(header.Extra[len(header.Extra)-65:], sig)
-}
-
-func (ap *testerAccountPool) address(account string) common.Address {
- // Ensure we have a persistent key for the account
- if ap.accounts[account] == nil {
- ap.accounts[account], _ = crypto.GenerateKey()
- }
- // Resolve and return the Ethereum address
- return crypto.PubkeyToAddress(ap.accounts[account].PublicKey)
-}
-
-// testerChainReader implements consensus.ChainReader to access the genesis
-// block. All other methods and requests will panic.
-type testerChainReader struct {
- db ethdb.Database
-}
-
-func (r *testerChainReader) Config() *params.ChainConfig { return params.AllCliqueProtocolChanges }
-func (r *testerChainReader) CurrentHeader() *types.Header { panic("not supported") }
-func (r *testerChainReader) GetHeader(common.Hash, uint64) *types.Header { panic("not supported") }
-func (r *testerChainReader) GetBlock(common.Hash, uint64) *types.Block { panic("not supported") }
-func (r *testerChainReader) GetHeaderByHash(common.Hash) *types.Header { panic("not supported") }
-func (r *testerChainReader) GetHeaderByNumber(number uint64) *types.Header {
- if number == 0 {
- return core.GetHeader(r.db, core.GetCanonicalHash(r.db, 0), 0)
- }
- panic("not supported")
-}
-
-// Tests that voting is evaluated correctly for various simple and complex scenarios.
-func TestVoting(t *testing.T) {
- // Define the various voting scenarios to test
- tests := []struct {
- epoch uint64
- signers []string
- votes []testerVote
- results []string
- }{
- {
- // Single signer, no votes cast
- signers: []string{"A"},
- votes: []testerVote{{signer: "A"}},
- results: []string{"A"},
- }, {
- // Single signer, voting to add two others (only accept first, second needs 2 votes)
- signers: []string{"A"},
- votes: []testerVote{
- {signer: "A", voted: "B", auth: true},
- {signer: "B"},
- {signer: "A", voted: "C", auth: true},
- },
- results: []string{"A", "B"},
- }, {
- // Two signers, voting to add three others (only accept first two, third needs 3 votes already)
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: true},
- {signer: "B", voted: "C", auth: true},
- {signer: "A", voted: "D", auth: true},
- {signer: "B", voted: "D", auth: true},
- {signer: "C"},
- {signer: "A", voted: "E", auth: true},
- {signer: "B", voted: "E", auth: true},
- },
- results: []string{"A", "B", "C", "D"},
- }, {
- // Single signer, dropping itself (weird, but one less cornercase by explicitly allowing this)
- signers: []string{"A"},
- votes: []testerVote{
- {signer: "A", voted: "A", auth: false},
- },
- results: []string{},
- }, {
- // Two signers, actually needing mutual consent to drop either of them (not fulfilled)
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "B", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Two signers, actually needing mutual consent to drop either of them (fulfilled)
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "B", auth: false},
- {signer: "B", voted: "B", auth: false},
- },
- results: []string{"A"},
- }, {
- // Three signers, two of them deciding to drop the third
- signers: []string{"A", "B", "C"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B", voted: "C", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Four signers, consensus of two not being enough to drop anyone
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B", voted: "C", auth: false},
- },
- results: []string{"A", "B", "C", "D"},
- }, {
- // Four signers, consensus of three already being enough to drop someone
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "D", auth: false},
- {signer: "B", voted: "D", auth: false},
- {signer: "C", voted: "D", auth: false},
- },
- results: []string{"A", "B", "C"},
- }, {
- // Authorizations are counted once per signer per target
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: true},
- {signer: "B"},
- {signer: "A", voted: "C", auth: true},
- {signer: "B"},
- {signer: "A", voted: "C", auth: true},
- },
- results: []string{"A", "B"},
- }, {
- // Authorizing multiple accounts concurrently is permitted
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: true},
- {signer: "B"},
- {signer: "A", voted: "D", auth: true},
- {signer: "B"},
- {signer: "A"},
- {signer: "B", voted: "D", auth: true},
- {signer: "A"},
- {signer: "B", voted: "C", auth: true},
- },
- results: []string{"A", "B", "C", "D"},
- }, {
- // Deauthorizations are counted once per signer per target
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "B", auth: false},
- {signer: "B"},
- {signer: "A", voted: "B", auth: false},
- {signer: "B"},
- {signer: "A", voted: "B", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Deauthorizing multiple accounts concurrently is permitted
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B"},
- {signer: "C"},
- {signer: "A", voted: "D", auth: false},
- {signer: "B"},
- {signer: "C"},
- {signer: "A"},
- {signer: "B", voted: "D", auth: false},
- {signer: "C", voted: "D", auth: false},
- {signer: "A"},
- {signer: "B", voted: "C", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Votes from deauthorized signers are discarded immediately (deauth votes)
- signers: []string{"A", "B", "C"},
- votes: []testerVote{
- {signer: "C", voted: "B", auth: false},
- {signer: "A", voted: "C", auth: false},
- {signer: "B", voted: "C", auth: false},
- {signer: "A", voted: "B", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Votes from deauthorized signers are discarded immediately (auth votes)
- signers: []string{"A", "B", "C"},
- votes: []testerVote{
- {signer: "C", voted: "B", auth: false},
- {signer: "A", voted: "C", auth: false},
- {signer: "B", voted: "C", auth: false},
- {signer: "A", voted: "B", auth: false},
- },
- results: []string{"A", "B"},
- }, {
- // Cascading changes are not allowed, only the account being voted on may change
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B"},
- {signer: "C"},
- {signer: "A", voted: "D", auth: false},
- {signer: "B", voted: "C", auth: false},
- {signer: "C"},
- {signer: "A"},
- {signer: "B", voted: "D", auth: false},
- {signer: "C", voted: "D", auth: false},
- },
- results: []string{"A", "B", "C"},
- }, {
- // Changes reaching consensus out of bounds (via a deauth) execute on touch
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B"},
- {signer: "C"},
- {signer: "A", voted: "D", auth: false},
- {signer: "B", voted: "C", auth: false},
- {signer: "C"},
- {signer: "A"},
- {signer: "B", voted: "D", auth: false},
- {signer: "C", voted: "D", auth: false},
- {signer: "A"},
- {signer: "C", voted: "C", auth: true},
- },
- results: []string{"A", "B"},
- }, {
- // Changes reaching consensus out of bounds (via a deauth) may go out of consensus on first touch
- signers: []string{"A", "B", "C", "D"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: false},
- {signer: "B"},
- {signer: "C"},
- {signer: "A", voted: "D", auth: false},
- {signer: "B", voted: "C", auth: false},
- {signer: "C"},
- {signer: "A"},
- {signer: "B", voted: "D", auth: false},
- {signer: "C", voted: "D", auth: false},
- {signer: "A"},
- {signer: "B", voted: "C", auth: true},
- },
- results: []string{"A", "B", "C"},
- }, {
- // Ensure that pending votes don't survive authorization status changes. This
- // corner case can only appear if a signer is quickly added, removed and then
- // readded (or the inverse), while one of the original voters dropped. If a
- // past vote is left cached in the system somewhere, this will interfere with
- // the final signer outcome.
- signers: []string{"A", "B", "C", "D", "E"},
- votes: []testerVote{
- {signer: "A", voted: "F", auth: true}, // Authorize F, 3 votes needed
- {signer: "B", voted: "F", auth: true},
- {signer: "C", voted: "F", auth: true},
- {signer: "D", voted: "F", auth: false}, // Deauthorize F, 4 votes needed (leave A's previous vote "unchanged")
- {signer: "E", voted: "F", auth: false},
- {signer: "B", voted: "F", auth: false},
- {signer: "C", voted: "F", auth: false},
- {signer: "D", voted: "F", auth: true}, // Almost authorize F, 2/3 votes needed
- {signer: "E", voted: "F", auth: true},
- {signer: "B", voted: "A", auth: false}, // Deauthorize A, 3 votes needed
- {signer: "C", voted: "A", auth: false},
- {signer: "D", voted: "A", auth: false},
- {signer: "B", voted: "F", auth: true}, // Finish authorizing F, 3/3 votes needed
- },
- results: []string{"B", "C", "D", "E", "F"},
- }, {
- // Epoch transitions reset all votes to allow chain checkpointing
- epoch: 3,
- signers: []string{"A", "B"},
- votes: []testerVote{
- {signer: "A", voted: "C", auth: true},
- {signer: "B"},
- {signer: "A"}, // Checkpoint block, (don't vote here, it's validated outside of snapshots)
- {signer: "B", voted: "C", auth: true},
- },
- results: []string{"A", "B"},
- },
- }
- // Run through the scenarios and test them
- for i, tt := range tests {
- // Create the account pool and generate the initial set of signers
- accounts := newTesterAccountPool()
-
- signers := make([]common.Address, len(tt.signers))
- for j, signer := range tt.signers {
- signers[j] = accounts.address(signer)
- }
- for j := 0; j < len(signers); j++ {
- for k := j + 1; k < len(signers); k++ {
- if bytes.Compare(signers[j][:], signers[k][:]) > 0 {
- signers[j], signers[k] = signers[k], signers[j]
- }
- }
- }
- // Create the genesis block with the initial set of signers
- genesis := &core.Genesis{
- ExtraData: make([]byte, extraVanity+common.AddressLength*len(signers)+extraSeal),
- }
- for j, signer := range signers {
- copy(genesis.ExtraData[extraVanity+j*common.AddressLength:], signer[:])
- }
- // Create a pristine blockchain with the genesis injected
- db, _ := ethdb.NewMemDatabase()
- genesis.Commit(db)
-
- // Assemble a chain of headers from the cast votes
- headers := make([]*types.Header, len(tt.votes))
- for j, vote := range tt.votes {
- headers[j] = &types.Header{
- Number: big.NewInt(int64(j) + 1),
- Time: big.NewInt(int64(j) * int64(blockPeriod)),
- Coinbase: accounts.address(vote.voted),
- Extra: make([]byte, extraVanity+extraSeal),
- }
- if j > 0 {
- headers[j].ParentHash = headers[j-1].Hash()
- }
- if vote.auth {
- copy(headers[j].Nonce[:], nonceAuthVote)
- }
- accounts.sign(headers[j], vote.signer)
- }
- // Pass all the headers through clique and ensure tallying succeeds
- head := headers[len(headers)-1]
-
- snap, err := New(&params.CliqueConfig{Epoch: tt.epoch}, db).snapshot(&testerChainReader{db: db}, head.Number.Uint64(), head.Hash(), headers)
- if err != nil {
- t.Errorf("test %d: failed to create voting snapshot: %v", i, err)
- continue
- }
- // Verify the final list of signers against the expected ones
- signers = make([]common.Address, len(tt.results))
- for j, signer := range tt.results {
- signers[j] = accounts.address(signer)
- }
- for j := 0; j < len(signers); j++ {
- for k := j + 1; k < len(signers); k++ {
- if bytes.Compare(signers[j][:], signers[k][:]) > 0 {
- signers[j], signers[k] = signers[k], signers[j]
- }
- }
- }
- result := snap.signers()
- if len(result) != len(signers) {
- t.Errorf("test %d: signers mismatch: have %x, want %x", i, result, signers)
- continue
- }
- for j := 0; j < len(result); j++ {
- if !bytes.Equal(result[j][:], signers[j][:]) {
- t.Errorf("test %d, signer %d: signer mismatch: have %x, want %x", i, j, result[j], signers[j])
- }
- }
- }
-}
diff --git a/consensus/consensus.go b/consensus/consensus.go
old mode 100644
new mode 100755
index 865238cee..39c3a60fe
--- a/consensus/consensus.go
+++ b/consensus/consensus.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,15 +14,16 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package consensus implements different Ethereum consensus engines.
+// Package consensus implements different Wtc consensus engines.
package consensus
import (
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rpc"
+ "math/big"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/params"
+ "github.com/wtc/go-wtc/rpc"
)
// ChainReader defines a small collection of methods needed to access the local
@@ -45,11 +46,15 @@ type ChainReader interface {
// GetBlock retrieves a block from the database by hash and number.
GetBlock(hash common.Hash, number uint64) *types.Block
+
+ GetBalanceAndCoinAgeByHeaderHash(addr common.Address) (*big.Int, *big.Int, *big.Int, *big.Int)
+
+ //GetCoinAgeByHeaderHash(addr common.Address) (*big.Int,*big.Int)
}
// Engine is an algorithm agnostic consensus engine.
type Engine interface {
- // Author retrieves the Ethereum address of the account that minted the given
+ // Author retrieves the Wtc address of the account that minted the given
// block, which may be different from the header's coinbase if a consensus
// engine is based on signatures.
Author(header *types.Header) (common.Address, error)
@@ -86,10 +91,12 @@ type Engine interface {
// Seal generates a new block for the given input block with the local miner's
// seal place on top.
- Seal(chain ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)
+ Seal(chain ChainReader, block *types.Block, stop <-chan struct{}, serverFound chan uint64) (*types.Block, error)
// APIs returns the RPC APIs this consensus engine provides.
APIs(chain ChainReader) []rpc.API
+
+ IsGPU() (bool, int64, int64)
}
// PoW is a consensus engine based on proof-of-work.
diff --git a/consensus/errors.go b/consensus/errors.go
old mode 100644
new mode 100755
index 3b136dbdd..5ab88aa38
--- a/consensus/errors.go
+++ b/consensus/errors.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/consensus/ethash/algorithm.go b/consensus/ethash/algorithm.go
old mode 100644
new mode 100755
index 76f19252f..6fd436932
--- a/consensus/ethash/algorithm.go
+++ b/consensus/ethash/algorithm.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -18,19 +18,23 @@ package ethash
import (
"encoding/binary"
+ // "fmt"
"hash"
+ "math/big"
"reflect"
"runtime"
"sync"
"sync/atomic"
"time"
"unsafe"
+ "crypto/sha256"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/bitutil"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/crypto/sha3"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/bitutil"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/crypto/sha3"
+ "github.com/wtc/go-wtc/crypto/x11"
+ "github.com/wtc/go-wtc/log"
)
const (
@@ -47,6 +51,11 @@ const (
loopAccesses = 64 // Number of accesses in hashimoto loop
)
+var N11 *big.Int = big.NewInt(11)
+var meta []byte = []byte("ABCDEFGHIJK")
+var metaDiscard []byte = []byte("CFIJK")
+var metaReplace []byte = []byte("AHDGEB")
+
// hasher is a repetitive hasher allowing the same hash data structures to be
// reused between hash runs instead of requiring new ones to be created.
type hasher func(dest []byte, data []byte)
@@ -102,7 +111,7 @@ func generateCache(dest []uint32, epoch uint64, seed []byte) {
header.Cap *= 4
cache := *(*[]byte)(unsafe.Pointer(&header))
- // Calculate the number of theoretical rows (we'll store in one buffer nonetheless)
+ // Calculate the number of thoretical rows (we'll store in one buffer nonetheless)
size := uint64(len(cache))
rows := int(size) / hashBytes
@@ -187,7 +196,7 @@ func fnvHash(mix []uint32, data []uint32) {
// generateDatasetItem combines data from 256 pseudorandomly selected cache nodes,
// and hashes that to compute a single dataset node.
func generateDatasetItem(cache []uint32, index uint32, keccak512 hasher) []byte {
- // Calculate the number of theoretical rows (we use one buffer nonetheless)
+ // Calculate the number of thoretical rows (we use one buffer nonetheless)
rows := uint32(len(cache) / hashWords)
// Initialize the mix
@@ -284,10 +293,74 @@ func generateDataset(dest []uint32, epoch uint64, cache []uint32) {
pend.Wait()
}
+
+func mysha256(set []byte,nonce uint64) ([]byte,[]byte) {
+ digest := make([]byte, common.HashLength)
+ hash := sha256.New()
+
+ var res = make([]byte, 8)
+ binary.BigEndian.PutUint64(res, nonce)
+
+
+ for _,v := range res {
+ set=append(set,v)
+ }
+
+ hash.Write(set)
+ md := hash.Sum(nil)
+ //mdStr := hex.EncodeToString(md)
+ return digest,md
+}
+
+func myx11(set []byte, nonce uint64, order []byte) ([]byte, []byte) {
+ digest := make([]byte, common.HashLength)
+ hash,out := x11.New(),[32]byte{}
+
+ var res = make([]byte, 8)
+ binary.BigEndian.PutUint64(res, nonce)
+
+
+ for _,v := range res {
+ set=append(set,v)
+ }
+ for i := 0; i < 24; i++ {
+ set = append(set, 0)
+ }
+ hash.Hash(set, out[:], order)
+ return digest,out[:]
+}
+
+func getX11Order(hash []byte, length int) []byte {
+ x11Array := make([]byte, length)
+ for i := 0; i < length ; i++ {
+ // index := int(hash[i]) % (length - i)
+ index := int(hash[i]) % (length)
+ x11Array[i] = meta[index]
+ }
+ // fmt.Printf("x11Array0: %s \n", x11Array[:])
+
+ for i := 0; i < len(metaDiscard) ; i++ {
+ var k = 0
+ for j := 0; j < length ; j++ {
+ if x11Array[j] == metaDiscard[i] {
+ if k == 0 {
+ k = 1
+ }else {
+ metaReplaceIndex := int(hash[11]) % len(metaReplace)
+ x11Array[j] = metaReplace[metaReplaceIndex]
+ }
+ }
+ }
+ }
+
+ // fmt.Printf("x11Array1: %s", x11Array[:])
+ return x11Array
+}
+
// hashimoto aggregates data from the full dataset in order to produce our final
// value for a particular header hash and nonce.
func hashimoto(hash []byte, nonce uint64, size uint64, lookup func(index uint32) []uint32) ([]byte, []byte) {
- // Calculate the number of theoretical rows (we use one buffer nonetheless)
+ // Calculate the number of thoretical rows (we use one buffer nonetheless)
rows := uint32(size / mixBytes)
// Combine header+nonce into a 64 byte seed
diff --git a/consensus/ethash/algorithm_go1.7.go b/consensus/ethash/algorithm_go1.7.go
old mode 100644
new mode 100755
index c34d041c3..9c6328a87
--- a/consensus/ethash/algorithm_go1.7.go
+++ b/consensus/ethash/algorithm_go1.7.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/consensus/ethash/algorithm_go1.8.go b/consensus/ethash/algorithm_go1.8.go
old mode 100644
new mode 100755
index d691b758f..e3172dcd8
--- a/consensus/ethash/algorithm_go1.8.go
+++ b/consensus/ethash/algorithm_go1.8.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -31,7 +31,7 @@ func cacheSize(block uint64) uint64 {
return cacheSizes[epoch]
}
// No known cache size, calculate manually (sanity branch only)
- size := cacheInitBytes + cacheGrowthBytes*uint64(epoch) - hashBytes
+ size := uint64(cacheInitBytes + cacheGrowthBytes*uint64(epoch) - hashBytes)
for !new(big.Int).SetUint64(size / hashBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
size -= 2 * hashBytes
}
@@ -49,7 +49,7 @@ func datasetSize(block uint64) uint64 {
return datasetSizes[epoch]
}
// No known dataset size, calculate manually (sanity branch only)
- size := datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes
+ size := uint64(datasetInitBytes + datasetGrowthBytes*uint64(epoch) - mixBytes)
for !new(big.Int).SetUint64(size / mixBytes).ProbablyPrime(1) { // Always accurate for n < 2^64
size -= 2 * mixBytes
}
diff --git a/consensus/ethash/algorithm_go1.8_test.go b/consensus/ethash/algorithm_go1.8_test.go
old mode 100644
new mode 100755
index a822944a6..5b81a9558
--- a/consensus/ethash/algorithm_go1.8_test.go
+++ b/consensus/ethash/algorithm_go1.8_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/consensus/ethash/algorithm_test.go b/consensus/ethash/algorithm_test.go
old mode 100644
new mode 100755
index 7e4307a74..bf73d3e73
--- a/consensus/ethash/algorithm_test.go
+++ b/consensus/ethash/algorithm_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,9 +25,9 @@ import (
"sync"
"testing"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/hexutil"
+ "github.com/wtc/go-wtc/core/types"
)
// Tests that verification caches can be correctly generated.
diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go
old mode 100644
new mode 100755
index 6a19d449f..3608ce882
--- a/consensus/ethash/consensus.go
+++ b/consensus/ethash/consensus.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,13 +24,13 @@ import (
"runtime"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/consensus/misc"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/consensus/misc"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/params"
set "gopkg.in/fatih/set.v0"
)
@@ -65,7 +65,7 @@ func (ethash *Ethash) Author(header *types.Header) (common.Address, error) {
}
// VerifyHeader checks whether a header conforms to the consensus rules of the
-// stock Ethereum ethash engine.
+// stock Wtc ethash engine.
func (ethash *Ethash) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool) error {
// If we're running a full engine faking, accept any input as valid
if ethash.fakeFull {
@@ -166,7 +166,7 @@ func (ethash *Ethash) verifyHeaderWorker(chain consensus.ChainReader, headers []
}
// VerifyUncles verifies that the given block's uncles conform to the consensus
-// rules of the stock Ethereum ethash engine.
+// rules of the stock Wtc ethash engine.
func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Block) error {
// If we're running a full engine faking, accept any input as valid
if ethash.fakeFull {
@@ -218,7 +218,7 @@ func (ethash *Ethash) VerifyUncles(chain consensus.ChainReader, block *types.Blo
}
// verifyHeader checks whether a header conforms to the consensus rules of the
-// stock Ethereum ethash engine.
+// stock Wtc ethash engine.
// See YP section 4.3.4. "Block Header Validity"
func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *types.Header, uncle bool, seal bool) error {
// Ensure that the header's extra-data section is of a reasonable size
@@ -273,10 +273,6 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
return err
}
}
- // If all checks passed, validate any special fields for hard forks
- if err := misc.VerifyDAOHeaderExtraData(chain.Config(), header); err != nil {
- return err
- }
if err := misc.VerifyForkHashes(chain.Config(), header, uncle); err != nil {
return err
}
@@ -287,7 +283,7 @@ func (ethash *Ethash) verifyHeader(chain consensus.ChainReader, header, parent *
// the difficulty that a new block should have when created at time
// given the parent block's time and difficulty.
// TODO (karalabe): Move the chain maker into this package and make this private!
-func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
+/*func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
next := new(big.Int).Add(parent.Number, big1)
switch {
case config.IsByzantium(next):
@@ -297,6 +293,11 @@ func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Heade
default:
return calcDifficultyFrontier(time, parent)
}
+}*/
+func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Header) *big.Int {
+ next := new(big.Int).Add(parent.Number, big1)
+ _ = config.IsByzantium(next)
+ return calcDifficultyWtc(time,parent)
}
// Some weird constants to avoid constant memory allocs for them.
@@ -304,8 +305,12 @@ var (
expDiffPeriod = big.NewInt(100000)
big1 = big.NewInt(1)
big2 = big.NewInt(2)
+ big3 = big.NewInt(3)
+ big5 = big.NewInt(5)
+ big6 = big.NewInt(6)
big9 = big.NewInt(9)
big10 = big.NewInt(10)
+ big60 = big.NewInt(60)
bigMinus99 = big.NewInt(-99)
big2999999 = big.NewInt(2999999)
)
@@ -314,7 +319,7 @@ var (
// the difficulty that a new block should have when created at time given the
// parent block's time and difficulty. The calculation uses the Byzantium rules.
func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int {
- // https://github.com/ethereum/EIPs/issues/100.
+ // https://github.com/wtc/EIPs/issues/100.
// algorithm:
// diff = (parent_diff +
// (parent_diff / 2048 * max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99))
@@ -349,7 +354,7 @@ func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int {
x.Set(params.MinimumDifficulty)
}
// calculate a fake block numer for the ice-age delay:
- // https://github.com/ethereum/EIPs/pull/669
+ // https://github.com/wtc/EIPs/pull/669
// fake_block_number = min(0, block.number - 3_000_000
fakeBlockNumber := new(big.Int)
if parent.Number.Cmp(big2999999) >= 0 {
@@ -369,11 +374,47 @@ func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int {
return x
}
+func calcDifficultyWtc(time uint64, parent *types.Header) *big.Int {
+ // algorithm:
+ // diff = parent_diff +
+ // (parent_diff / 2048 * max(6 - (block_timestamp - parent_timestamp) // 10, -99))
+ //
+ //logger := log.New("epoch", epoch)
+ bigTime := new(big.Int).SetUint64(time)
+ bigParentTime := new(big.Int).Set(parent.Time)
+
+ // holds intermediate values to make the algo easier to read & audit
+ x := new(big.Int)
+ y := new(big.Int)
+
+
+
+ // 6 - (block_timestamp - parent_timestamp) // 10
+ x.Sub(bigTime, bigParentTime)
+ x.Div(x, big10)
+ x.Sub(big3, x)
+ // max(6 - (block_timestamp - parent_timestamp) // 10, -99)
+ if x.Cmp(bigMinus99) < 0 {
+ x.Set(bigMinus99)
+ }
+ // (parent_diff + parent_diff // 2048 * max(6 - (block_timestamp - parent_timestamp) // 10, -99))
+ y.Div(parent.Difficulty, params.DifficultyBoundDivisor)
+ x.Mul(y, x)
+ x.Add(parent.Difficulty, x)
+
+ // minimum difficulty can ever be (before exponential factor)
+ if x.Cmp(params.MinimumDifficulty) < 0 {
+ x.Set(params.MinimumDifficulty)
+ }
+
+ return x
+}
+
// calcDifficultyHomestead is the difficulty adjustment algorithm. It returns
// the difficulty that a new block should have when created at time given the
// parent block's time and difficulty. The calculation uses the Homestead rules.
func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int {
- // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.mediawiki
+ // https://github.com/wtc/EIPs/blob/master/EIPS/eip-2.mediawiki
// algorithm:
// diff = (parent_diff +
// (parent_diff / 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99))
@@ -454,6 +495,8 @@ func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int {
// VerifySeal implements consensus.Engine, checking whether the given block satisfies
// the PoW difficulty requirements.
func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Header) error {
+ hash := header.HashNoNonce().Bytes()
+
// If we're running a fake PoW, accept any seal as valid
if ethash.fakeMode {
time.Sleep(ethash.fakeDelay)
@@ -477,18 +520,34 @@ func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Head
return errInvalidDifficulty
}
// Recompute the digest and PoW value and verify against the header
- cache := ethash.cache(number)
+ /*cache := ethash.cache(number)
size := datasetSize(number)
if ethash.tester {
size = 32 * 1024
- }
- digest, result := hashimotoLight(size, cache, header.HashNoNonce().Bytes(), header.Nonce.Uint64())
+ }*/
+ //digest, result := hashimotoLight(size, cache, header.HashNoNonce().Bytes(), header.Nonce.Uint64())
+ //-----------------------------------------------
+ coinage := header.CoinAge
+ order := getX11Order(hash, 11)
+ digest, result := myx11(header.HashNoNonce().Bytes(), header.Nonce.Uint64(), order)
if !bytes.Equal(header.MixDigest[:], digest) {
return errInvalidMixDigest
}
target := new(big.Int).Div(maxUint256, header.Difficulty)
- if new(big.Int).SetBytes(result).Cmp(target) > 0 {
+ //if new(big.Int).SetBytes(result).Cmp(target) > 0 {
+ bn_coinage := new(big.Int).Mul(coinage, big.NewInt(1))
+ bn_coinage = Sqrt(bn_coinage, 6)
+ bn_txnumber := new(big.Int).Mul(new(big.Int).SetUint64(header.TxNumber), big.NewInt(5e+18))
+ bn_txnumber = Sqrt(bn_txnumber, 6)
+ if bn_coinage.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_coinage, target)
+ }
+ if bn_txnumber.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_txnumber, target)
+ }
+
+ if Compare(result, FullTo32(target.Bytes()), 32) > 0 {
return errInvalidPoW
}
return nil
@@ -510,7 +569,7 @@ func (ethash *Ethash) Prepare(chain consensus.ChainReader, header *types.Header)
// setting the final state and assembling the block.
func (ethash *Ethash) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
// Accumulate any block and uncle rewards and commit the final state root
- AccumulateRewards(chain.Config(), state, header, uncles)
+ AccumulateRewards(state, header, uncles)
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
// Header seems complete, assemble into a block and return
@@ -527,24 +586,46 @@ var (
// reward. The total reward consists of the static block reward and rewards for
// included uncles. The coinbase of each uncle block is also rewarded.
// TODO (karalabe): Move the chain maker into this package and make this private!
-func AccumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) {
- // Select the correct block reward based on chain progression
- blockReward := frontierBlockReward
- if config.IsByzantium(header.Number) {
- blockReward = byzantiumBlockReward
- }
- // Accumulate the rewards for the miner and any included uncles
- reward := new(big.Int).Set(blockReward)
- r := new(big.Int)
- for _, uncle := range uncles {
- r.Add(uncle.Number, big8)
- r.Sub(r, header.Number)
- r.Mul(r, blockReward)
- r.Div(r, big8)
- state.AddBalance(uncle.Coinbase, r)
-
- r.Div(blockReward, big32)
- reward.Add(reward, r)
- }
- state.AddBalance(header.Coinbase, reward)
+func AccumulateRewards(state *state.StateDB, header *types.Header, uncles []*types.Header) {
+ balance := state.GetBalance(header.Coinbase)
+ reward := getReward(header.Number, balance)
+
+ state.AddBalance(header.Coinbase, reward, header.Number, header.Time)
+ state.SetCoinAge(header.Coinbase, big.NewInt(0))
+}
+
+func getReward(block, balance *big.Int) *big.Int {
+ oneyear := big.NewInt(2 * 60 * 24 * 365)
+ var reward *big.Int
+ big5000 := new(big.Int).Mul(params.AddedRewardForMN, big.NewInt(1e+18))
+ years := new(big.Int).Div(block, oneyear).Int64()
+
+ if block.Int64() <= 40000 {
+ reward = big.NewInt(1e+17)
+ }else if block.Int64() > 40000 && block.Int64() <= 100000{
+ reward = big.NewInt(1e+18)
+ }else if block.Int64() > 100000 && block.Int64() <= 200000{
+ reward = big.NewInt(2e+18)
+ }else if years < 2 {
+ reward = big.NewInt(25e+17)
+ if balance.Cmp(big5000) >= 0 {
+ reward = reward.Add(reward, big.NewInt(5e+17))
+ }
+ } else {
+ var discount float64 = 100000
+ y := years / 2
+ for i := 0; int64(i) < y; i++ {
+ discount = discount * 0.75
+ }
+
+ reward = big.NewInt(25e+17)
+ if balance.Cmp(big5000) >= 0 {
+ reward = reward.Add(reward, big.NewInt(5e+17))
+ }
+
+ reward = new(big.Int).Div(reward, big.NewInt(100000))
+ reward = new(big.Int).Mul(reward, big.NewInt(int64(discount)))
+ }
+
+ return reward
}
diff --git a/consensus/ethash/consensus_test.go b/consensus/ethash/consensus_test.go
old mode 100644
new mode 100755
index a58d220ef..d669a0202
--- a/consensus/ethash/consensus_test.go
+++ b/consensus/ethash/consensus_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,9 +23,9 @@ import (
"path/filepath"
"testing"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/params"
)
type diffTest struct {
diff --git a/consensus/ethash/ethash.go b/consensus/ethash/ethash.go
old mode 100644
new mode 100755
index dd6147072..f16548745
--- a/consensus/ethash/ethash.go
+++ b/consensus/ethash/ethash.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -32,9 +32,9 @@ import (
"unsafe"
mmap "github.com/edsrzf/mmap-go"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/rpc"
metrics "github.com/rcrowley/go-metrics"
)
@@ -45,7 +45,7 @@ var (
maxUint256 = new(big.Int).Exp(big.NewInt(2), big.NewInt(256), big.NewInt(0))
// sharedEthash is a full instance that can be shared between multiple users.
- sharedEthash = New("", 3, 0, "", 1, 0)
+ sharedEthash = New("", 3, 0, "", 1, 0, false, 12125, 10240)
// algorithmRevision is the data structure version used for file naming.
algorithmRevision = 23
@@ -329,6 +329,8 @@ type Ethash struct {
dagdir string // Data directory to store full mining datasets
dagsinmem int // Number of mining datasets to keep in memory
dagsondisk int // Number of mining datasets to keep on disk
+ GPUPort int64
+ GPUGetPort int64
caches map[uint64]*cache // In memory caches to avoid regenerating too often
fcache *cache // Pre-generated cache for the estimated future epoch
@@ -344,6 +346,7 @@ type Ethash struct {
// The fields below are hooks for testing
tester bool // Flag whether to use a smaller test dataset
shared *Ethash // Shared PoW verifier to avoid cache regeneration
+ GPUMode bool
fakeMode bool // Flag whether to disable PoW checking
fakeFull bool // Flag whether to disable all consensus rules
fakeFail uint64 // Block number which fails PoW check even in fake mode
@@ -353,16 +356,16 @@ type Ethash struct {
}
// New creates a full sized ethash PoW scheme.
-func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinmem, dagsondisk int) *Ethash {
+func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinmem, dagsondisk int, gpuMode bool, gpuPort int64, gpuGetPort int64) *Ethash {
if cachesinmem <= 0 {
log.Warn("One ethash cache must always be in memory", "requested", cachesinmem)
cachesinmem = 1
}
if cachedir != "" && cachesondisk > 0 {
- log.Info("Disk storage enabled for ethash caches", "dir", cachedir, "count", cachesondisk)
+ // log.Info("Disk storage enabled for ethash caches", "dir", cachedir, "count", cachesondisk)
}
if dagdir != "" && dagsondisk > 0 {
- log.Info("Disk storage enabled for ethash DAGs", "dir", dagdir, "count", dagsondisk)
+ // log.Info("Disk storage enabled for ethash DAGs", "dir", dagdir, "count", dagsondisk)
}
return &Ethash{
cachedir: cachedir,
@@ -375,6 +378,9 @@ func New(cachedir string, cachesinmem, cachesondisk int, dagdir string, dagsinme
datasets: make(map[uint64]*dataset),
update: make(chan struct{}),
hashrate: metrics.NewMeter(),
+ GPUMode: gpuMode,
+ GPUPort: gpuPort,
+ GPUGetPort: gpuGetPort,
}
}
@@ -392,7 +398,7 @@ func NewTester() *Ethash {
}
// NewFaker creates a ethash consensus engine with a fake PoW scheme that accepts
-// all blocks' seal as valid, though they still have to conform to the Ethereum
+// all blocks' seal as valid, though they still have to conform to the Wtc
// consensus rules.
func NewFaker() *Ethash {
return &Ethash{fakeMode: true}
@@ -400,14 +406,14 @@ func NewFaker() *Ethash {
// NewFakeFailer creates a ethash consensus engine with a fake PoW scheme that
// accepts all blocks as valid apart from the single one specified, though they
-// still have to conform to the Ethereum consensus rules.
+// still have to conform to the Wtc consensus rules.
func NewFakeFailer(fail uint64) *Ethash {
return &Ethash{fakeMode: true, fakeFail: fail}
}
// NewFakeDelayer creates a ethash consensus engine with a fake PoW scheme that
// accepts all blocks as valid, but delays verifications by some time, though
-// they still have to conform to the Ethereum consensus rules.
+// they still have to conform to the Wtc consensus rules.
func NewFakeDelayer(delay time.Duration) *Ethash {
return &Ethash{fakeMode: true, fakeDelay: delay}
}
@@ -586,6 +592,10 @@ func (ethash *Ethash) Hashrate() float64 {
return ethash.hashrate.Rate1()
}
+func (ethash *Ethash) IsGPU() (bool, int64, int64) {
+ return ethash.GPUMode, ethash.GPUPort, ethash.GPUGetPort
+}
+
// APIs implements consensus.Engine, returning the user facing RPC APIs. Currently
// that is empty.
func (ethash *Ethash) APIs(chain consensus.ChainReader) []rpc.API {
diff --git a/consensus/ethash/ethash_test.go b/consensus/ethash/ethash_test.go
old mode 100644
new mode 100755
index b3a2f32f7..7c2a37a4b
--- a/consensus/ethash/ethash_test.go
+++ b/consensus/ethash/ethash_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,7 +20,7 @@ import (
"math/big"
"testing"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc/core/types"
)
// Tests that ethash works correctly in test mode.
@@ -28,7 +28,7 @@ func TestTestMode(t *testing.T) {
head := &types.Header{Number: big.NewInt(1), Difficulty: big.NewInt(100)}
ethash := NewTester()
- block, err := ethash.Seal(nil, types.NewBlockWithHeader(head), nil)
+ block, err := ethash.SealbyCPU(nil, types.NewBlockWithHeader(head), nil, nil)
if err != nil {
t.Fatalf("failed to seal block: %v", err)
}
diff --git a/consensus/ethash/sealerByGPU.go b/consensus/ethash/sealerByGPU.go
new file mode 100755
index 000000000..f7f54ba18
--- /dev/null
+++ b/consensus/ethash/sealerByGPU.go
@@ -0,0 +1,257 @@
+// Copyright 2017 The go-ethereum Authors
+// This file is part of the go-ethereum library.
+//
+// The go-wtc library is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// The go-wtc library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
+
+package ethash
+
+import (
+ crand "crypto/rand"
+ "encoding/binary"
+ "fmt"
+ "math"
+ "math/big"
+ "math/rand"
+ "net"
+ "os"
+ "strconv"
+ "sync"
+ "time"
+
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
+)
+
+// Seal implements consensus.Engine, attempting to find a nonce that satisfies
+// the block's difficulty requirements.
+func (ethash *Ethash) SealbyGPU(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}, serverFound chan uint64, t int) (*types.Block, error) {
+ oldbalance, coinage, preNumber, preTime := chain.GetBalanceAndCoinAgeByHeaderHash(block.Header().Coinbase)
+ balance := new(big.Int).Add(oldbalance, big.NewInt(1e+18))
+ //--------------------------------- --------------
+ Time := block.Header().Time
+ Number := block.Header().Number
+ if preTime.Cmp(Time) < 0 && preNumber.Cmp(Number) < 0 {
+ t := new(big.Int).Sub(Time, preTime)
+ coinage = new(big.Int).Add(new(big.Int).Mul(balance, t), coinage)
+ }
+
+ // fmt.Println("set coinage to: ",coinage)
+
+ fmt.Print()
+ //-----------------------------------------------
+ // If we're running a fake PoW, simply return a 0 nonce immediately
+ if ethash.fakeMode {
+ header := block.Header()
+ header.Nonce, header.MixDigest = types.BlockNonce{}, common.Hash{}
+ return block.WithSeal(header), nil
+ }
+ // If we're running a shared PoW, delegate sealing to it
+ if ethash.shared != nil {
+ return ethash.shared.SealbyGPU(chain, block, stop, serverFound, 1)
+ }
+ // Create a runner and the multiple search threads it directs
+ abort := make(chan struct{})
+ found := make(chan *types.Block)
+
+ ethash.lock.Lock()
+ threads := ethash.threads
+ if ethash.rand == nil {
+ seed, err := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
+ if err != nil {
+ ethash.lock.Unlock()
+ return nil, err
+ }
+ ethash.rand = rand.New(rand.NewSource(seed.Int64()))
+ }
+ ethash.lock.Unlock()
+ // if threads == 0 {
+ // threads = runtime.NumCPU()
+ // }
+ // if threads < 0 {
+ // threads = 0 // Allows disabling local mining without extra logic around local/remote
+ // }
+ threads = 1
+ var pend sync.WaitGroup
+ for i := 0; i < threads; i++ {
+ pend.Add(1)
+ go func(id int, nonce uint64, serverFound chan uint64) {
+ defer pend.Done()
+ ethash.minebyGPU(block, id, nonce, abort, found, balance, coinage, serverFound, t)
+ }(0, uint64(ethash.rand.Int63()), serverFound)
+ }
+ // Wait until sealing is terminated or a nonce is found
+ var result *types.Block
+ select {
+ case <-stop:
+ sendStop(block, ethash.GPUPort)
+ // Outside abort, stop all miner threads
+ close(abort)
+ case result = <-found:
+ // One of the threads found a block, abort all others
+ close(abort)
+ case <-ethash.update:
+ // Thread count was changed on user request, restart
+ close(abort)
+ pend.Wait()
+ return ethash.SealbyGPU(chain, block, stop, serverFound, 1)
+ }
+ // Wait for all miners to terminate and return the block
+ pend.Wait()
+ return result, nil
+}
+
+// mine is the actual proof-of-work miner that searches for a nonce starting from
+// seed that results in correct final block difficulty.
+func (ethash *Ethash) minebyGPU(block *types.Block, id int, seed uint64, abort chan struct{}, found chan *types.Block, balance *big.Int, coinage *big.Int, serverFound chan uint64, t int) {
+ // Extract some data from the header
+ var (
+ header = block.Header()
+ hash = header.HashNoNonce().Bytes()
+ target = new(big.Int).Div(maxUint256, header.Difficulty)
+
+ //number = header.Number.Uint64()
+ //dataset = ethash.dataset(number)
+ )
+
+ // Start generating random nonces until we abort or find a good one
+ var (
+ // attempts = int64(0)
+ nonce = seed
+ )
+ logger := log.New("miner", id)
+ logger.Trace("Started ethash search for new nonces", "seed", seed)
+ bn_coinage := new(big.Int).Mul(coinage, big.NewInt(1))
+ bn_coinage = Sqrt(bn_coinage, 6)
+ bn_txnumber := new(big.Int).Mul(new(big.Int).SetUint64(header.TxNumber), big.NewInt(5e+18))
+ bn_txnumber = Sqrt(bn_txnumber, 6)
+ if bn_coinage.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_coinage, target)
+ }
+ if bn_txnumber.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_txnumber, target)
+ }
+ order := getX11Order(hash, 11)
+ var servernonce uint64
+
+ if t == 0 {
+ time.Sleep(time.Second * 2)
+ send(0, nonce, header.Number, hash, target, order, ethash.GPUPort)
+ fmt.Println("send start")
+ }
+ for {
+ select {
+ case <-abort:
+ //sendStop(block)
+ logger.Trace("Ethash nonce search aborted", "attempts", servernonce-seed)
+ return
+ case servernonce = <-serverFound:
+ digest, result := myx11(hash, servernonce, order)
+ if Compare(result, FullTo32(target.Bytes()), 32) < 1 {
+ // send(0, nonce, header.Number, hash, target, order)
+
+ header = types.CopyHeader(header)
+ header.Nonce = types.EncodeNonce(servernonce)
+ header.MixDigest = common.BytesToHash(digest)
+ header.CoinAge = coinage
+ select {
+ case found <- block.WithSeal(header):
+ logger.Trace("Ethash nonce found and reported", "attempts", servernonce-seed, "nonce", servernonce)
+ case <-abort:
+ logger.Trace("Ethash nonce found but discarded", "attempts", servernonce-seed, "nonce", servernonce)
+ }
+ return
+ } else {
+ send(0, nonce, header.Number, hash, target, order, ethash.GPUPort)
+ }
+ default:
+ time.Sleep(time.Second * 1)
+ }
+ }
+}
+
+func sendStop(block *types.Block, port int64) {
+ fmt.Println("send stop")
+ var (
+ header = block.Header()
+ hash = header.HashNoNonce().Bytes()
+ target = big.NewInt(0)
+ )
+ number := big.NewInt(0)
+ order := getX11Order(hash, 11)
+ send(1, 0, number, hash, target, order, port)
+}
+
+func send(control int, nonce uint64, number *big.Int, input []byte, target *big.Int, order []byte, port int64) {
+ server := "127.0.0.1:" + strconv.FormatInt(port, 10)
+ fmt.Println("send to ", server)
+ tcpAddr, err := net.ResolveTCPAddr("tcp4", server)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
+ os.Exit(1)
+ }
+
+ conn, err := net.DialTCP("tcp", nil, tcpAddr)
+ if err != nil {
+ fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
+ os.Exit(1)
+ }
+ defer conn.Close()
+ sender(conn, control, nonce, number, input, target, order)
+
+}
+
+func sender(conn net.Conn, control int, nonce uint64, number *big.Int, input []byte, target *big.Int, order []byte) {
+ words := encodeByte(control, number, input, nonce, target, 9e+18, order)
+ conn.Write(words)
+}
+
+func encodeByte(control int, blockNumber *big.Int, input []byte, nonce uint64, target *big.Int, count uint64, alg []byte) []byte {
+ str := make([]byte, 1)
+ str[0] = byte(control)
+ str = append(str, Int64ToBytes(blockNumber.Uint64())[4:]...)
+ str = append(str, input...)
+ str = append(str, Int64ToBytes(nonce)...)
+ str = append(str, FullTo32(target.Bytes())...)
+ str = append(str, Int64ToBytes(count)...)
+ str = append(str, alg...)
+ return str
+}
+func Int64ToBytes(i uint64) []byte {
+ var buf = make([]byte, 8)
+ binary.BigEndian.PutUint64(buf, i)
+ return buf
+}
+
+func FullTo32(word []byte) []byte {
+ str := make([]byte, 32-len(word))
+ str = append(str, word...)
+ return str
+}
+
+func Compare(stra []byte, strb []byte, length int) int {
+ for i := 0; i < length; i++ {
+ if stra[i] > strb[i] {
+ return 1
+ } else {
+ if stra[i] < strb[i] {
+ return -1
+ } else {
+ continue
+ }
+ }
+ }
+ return 0
+}
diff --git a/consensus/ethash/sealer.go b/consensus/ethash/sealerbyCPU.go
old mode 100644
new mode 100755
similarity index 58%
rename from consensus/ethash/sealer.go
rename to consensus/ethash/sealerbyCPU.go
index 784e8f649..79c306441
--- a/consensus/ethash/sealer.go
+++ b/consensus/ethash/sealerbyCPU.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -18,21 +18,43 @@ package ethash
import (
crand "crypto/rand"
+ // "fmt"
"math"
"math/big"
"math/rand"
"runtime"
"sync"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/log"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/log"
)
+func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}, serverFound chan uint64) (*types.Block, error) {
+ if ethash.GPUMode {
+ return ethash.SealbyGPU(chain, block, stop, serverFound, 0)
+ }
+ return ethash.SealbyCPU(chain, block, stop, serverFound)
+}
+
// Seal implements consensus.Engine, attempting to find a nonce that satisfies
// the block's difficulty requirements.
-func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error) {
+func (ethash *Ethash) SealbyCPU(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}, serverFound chan uint64) (*types.Block, error) {
+
+ oldbalance, coinage, preNumber, preTime := chain.GetBalanceAndCoinAgeByHeaderHash(block.Header().Coinbase)
+ balance := new(big.Int).Add(oldbalance, big.NewInt(1e+18))
+ //--------------------------------- --------------
+ Time := block.Header().Time
+ Number := block.Header().Number
+ if preTime.Cmp(Time) < 0 && preNumber.Cmp(Number) < 0 {
+ t := new(big.Int).Sub(Time, preTime)
+ coinage = new(big.Int).Add(new(big.Int).Mul(balance, t), coinage)
+ }
+
+ // fmt.Println("disy.yin ====>coinage:",coinage, "log2", log2(coinage))
+
+ //-----------------------------------------------
// If we're running a fake PoW, simply return a 0 nonce immediately
if ethash.fakeMode {
header := block.Header()
@@ -41,7 +63,7 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
}
// If we're running a shared PoW, delegate sealing to it
if ethash.shared != nil {
- return ethash.shared.Seal(chain, block, stop)
+ return ethash.shared.SealbyCPU(chain, block, stop, serverFound)
}
// Create a runner and the multiple search threads it directs
abort := make(chan struct{})
@@ -69,7 +91,7 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
pend.Add(1)
go func(id int, nonce uint64) {
defer pend.Done()
- ethash.mine(block, id, nonce, abort, found)
+ ethash.minebyCPU(block, id, nonce, abort, found, coinage)
}(i, uint64(ethash.rand.Int63()))
}
// Wait until sealing is terminated or a nonce is found
@@ -85,7 +107,7 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
// Thread count was changed on user request, restart
close(abort)
pend.Wait()
- return ethash.Seal(chain, block, stop)
+ return ethash.SealbyCPU(chain, block, stop, serverFound)
}
// Wait for all miners to terminate and return the block
pend.Wait()
@@ -94,23 +116,41 @@ func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, stop
// mine is the actual proof-of-work miner that searches for a nonce starting from
// seed that results in correct final block difficulty.
-func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan struct{}, found chan *types.Block) {
+func (ethash *Ethash) minebyCPU(block *types.Block, id int, seed uint64, abort chan struct{}, found chan *types.Block, coinage *big.Int) {
+
// Extract some data from the header
var (
header = block.Header()
hash = header.HashNoNonce().Bytes()
target = new(big.Int).Div(maxUint256, header.Difficulty)
- number = header.Number.Uint64()
- dataset = ethash.dataset(number)
+ //number = header.Number.Uint64()
+ //dataset = ethash.dataset(number)
)
+
// Start generating random nonces until we abort or find a good one
var (
attempts = int64(0)
nonce = seed
)
+ // fmt.Println("disy.yin ====>Difficulty:",header.Difficulty, "log2:", log2(header.Difficulty))
+ // fmt.Println("disy.yin ====>target:",target, "log2:", log2(target))
+
logger := log.New("miner", id)
logger.Trace("Started ethash search for new nonces", "seed", seed)
+ bn_coinage := new(big.Int).Mul(coinage, big.NewInt(1))
+ bn_coinage = Sqrt(bn_coinage, 6)
+ bn_txnumber := new(big.Int).Mul(new(big.Int).SetUint64(header.TxNumber), big.NewInt(5e+18))
+ bn_txnumber = Sqrt(bn_txnumber, 6)
+ if bn_coinage.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_coinage, target)
+ }
+ if bn_txnumber.Cmp(big.NewInt(0)) > 0 {
+ target.Mul(bn_txnumber, target)
+ }
+ order := getX11Order(hash, 11)
+
+ // send(nonce, header.Number, hash, target, order)
for {
select {
case <-abort:
@@ -127,13 +167,14 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s
attempts = 0
}
// Compute the PoW value of this nonce
- digest, result := hashimotoFull(dataset, hash, nonce)
- if new(big.Int).SetBytes(result).Cmp(target) <= 0 {
+ digest, result := myx11(hash, nonce, order)
+ if Compare(result, FullTo32(target.Bytes()), 32) < 1 {
+
// Correct nonce found, create a new header with it
header = types.CopyHeader(header)
header.Nonce = types.EncodeNonce(nonce)
header.MixDigest = common.BytesToHash(digest)
-
+ header.CoinAge = coinage
// Seal and return a block (if still needed)
select {
case found <- block.WithSeal(header):
@@ -147,3 +188,21 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s
}
}
}
+
+func log2(number *big.Int) uint {
+ var x = big.NewInt(0)
+ var i uint
+ for i = 0; ; i++ {
+ if x.Rsh(number, i).Cmp(big.NewInt(0)) < 1 {
+ return i
+ }
+
+ }
+ return 0
+}
+func Sqrt(oldnumber *big.Int, exp uint) *big.Int {
+ number := new(big.Int).Div(oldnumber, big.NewInt(1e+14))
+ var x = number.BitLen()
+ var y = new(big.Int).Rsh(number, uint(x)*(exp-1)/exp)
+ return y.Div(y, big.NewInt(32))
+}
diff --git a/consensus/misc/dao.go b/consensus/misc/dao.go
deleted file mode 100644
index 9b22bd7a5..000000000
--- a/consensus/misc/dao.go
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of the go-ethereum library.
-//
-// The go-ethereum library is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// The go-ethereum library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-
-package misc
-
-import (
- "bytes"
- "errors"
- "math/big"
-
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
-)
-
-var (
- // ErrBadProDAOExtra is returned if a header doens't support the DAO fork on a
- // pro-fork client.
- ErrBadProDAOExtra = errors.New("bad DAO pro-fork extra-data")
-
- // ErrBadNoDAOExtra is returned if a header does support the DAO fork on a no-
- // fork client.
- ErrBadNoDAOExtra = errors.New("bad DAO no-fork extra-data")
-)
-
-// VerifyDAOHeaderExtraData validates the extra-data field of a block header to
-// ensure it conforms to DAO hard-fork rules.
-//
-// DAO hard-fork extension to the header validity:
-// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range
-// with the fork specific extra-data set
-// b) if the node is pro-fork, require blocks in the specific range to have the
-// unique extra-data set.
-func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error {
- // Short circuit validation if the node doesn't care about the DAO fork
- if config.DAOForkBlock == nil {
- return nil
- }
- // Make sure the block is within the fork's modified extra-data range
- limit := new(big.Int).Add(config.DAOForkBlock, params.DAOForkExtraRange)
- if header.Number.Cmp(config.DAOForkBlock) < 0 || header.Number.Cmp(limit) >= 0 {
- return nil
- }
- // Depending on whether we support or oppose the fork, validate the extra-data contents
- if config.DAOForkSupport {
- if !bytes.Equal(header.Extra, params.DAOForkBlockExtra) {
- return ErrBadProDAOExtra
- }
- } else {
- if bytes.Equal(header.Extra, params.DAOForkBlockExtra) {
- return ErrBadNoDAOExtra
- }
- }
- // All ok, header has the same extra-data we expect
- return nil
-}
-
-// ApplyDAOHardFork modifies the state database according to the DAO hard-fork
-// rules, transferring all balances of a set of DAO accounts to a single refund
-// contract.
-func ApplyDAOHardFork(statedb *state.StateDB) {
- // Retrieve the contract to refund balances into
- if !statedb.Exist(params.DAORefundContract) {
- statedb.CreateAccount(params.DAORefundContract)
- }
-
- // Move every DAO account and extra-balance account funds into the refund contract
- for _, addr := range params.DAODrainList() {
- statedb.AddBalance(params.DAORefundContract, statedb.GetBalance(addr))
- statedb.SetBalance(addr, new(big.Int))
- }
-}
diff --git a/consensus/misc/forks.go b/consensus/misc/forks.go
old mode 100644
new mode 100755
index 4a5e7c37e..562b9c379
--- a/consensus/misc/forks.go
+++ b/consensus/misc/forks.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -19,9 +19,9 @@ package misc
import (
"fmt"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/params"
)
// VerifyForkHashes verifies that blocks conforming to network hard-forks do have
diff --git a/console/bridge.go b/console/bridge.go
old mode 100644
new mode 100755
index b28cc438e..97354572b
--- a/console/bridge.go
+++ b/console/bridge.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,16 +23,16 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/accounts/usbwallet"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/accounts/usbwallet"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/rpc"
"github.com/robertkrimen/otto"
)
// bridge is a collection of JavaScript utility methods to bride the .js runtime
// environment and the Go RPC connection backing the remote method calls.
type bridge struct {
- client *rpc.Client // RPC client to execute Ethereum requests through
+ client *rpc.Client // RPC client to execute Wtc requests through
prompter UserPrompter // Input prompter to allow interactive user feedback
printer io.Writer // Output writer to serialize any display strings to
}
diff --git a/console/console.go b/console/console.go
old mode 100644
new mode 100755
index 3cd2ad34b..435320322
--- a/console/console.go
+++ b/console/console.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -27,9 +27,9 @@ import (
"sort"
"strings"
- "github.com/ethereum/go-ethereum/internal/jsre"
- "github.com/ethereum/go-ethereum/internal/web3ext"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/internal/jsre"
+ "github.com/wtc/go-wtc/internal/web3ext"
+ "github.com/wtc/go-wtc/rpc"
"github.com/mattn/go-colorable"
"github.com/peterh/liner"
"github.com/robertkrimen/otto"
@@ -52,7 +52,7 @@ const DefaultPrompt = "> "
type Config struct {
DataDir string // Data directory to store the console history at
DocRoot string // Filesystem path from where to load JavaScript files from
- Client *rpc.Client // RPC client to execute Ethereum requests through
+ Client *rpc.Client // RPC client to execute Wtc requests through
Prompt string // Input prompt prefix string (defaults to DefaultPrompt)
Prompter UserPrompter // Input prompter to allow interactive user feedback (defaults to TerminalPrompter)
Printer io.Writer // Output writer to serialize any display strings to (defaults to os.Stdout)
@@ -63,7 +63,7 @@ type Config struct {
// JavaScript console attached to a running node via an external or in-process RPC
// client.
type Console struct {
- client *rpc.Client // RPC client to execute Ethereum requests through
+ client *rpc.Client // RPC client to execute Wtc requests through
jsre *jsre.JSRE // JavaScript runtime environment running the interpreter
prompt string // Input prompt prefix string
prompter UserPrompter // Input prompter to allow interactive user feedback
@@ -131,7 +131,7 @@ func (c *Console) init(preload []string) error {
if err != nil {
return fmt.Errorf("api modules: %v", err)
}
- flatten := "var eth = web3.eth; var personal = web3.personal; "
+ flatten := "var wtc = web3.eth; var personal = web3.personal; "
for api := range apis {
if api == "web3" {
continue // manually mapped or ignore
@@ -254,16 +254,16 @@ func (c *Console) AutoCompleteInput(line string, pos int) (string, []string, str
return line[:start], c.jsre.CompleteKeywords(line[start:pos]), line[pos:]
}
-// Welcome show summary of current Geth instance and some metadata about the
+// Welcome show summary of current Gwtc instance and some metadata about the
// console's available modules.
func (c *Console) Welcome() {
- // Print some generic Geth metadata
- fmt.Fprintf(c.printer, "Welcome to the Geth JavaScript console!\n\n")
+ // Print some generic GWTC metadata
+ fmt.Fprintf(c.printer, "============== GWTC ==============\n")
c.jsre.Run(`
- console.log("instance: " + web3.version.node);
- console.log("coinbase: " + eth.coinbase);
- console.log("at block: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")");
- console.log(" datadir: " + admin.datadir);
+ console.log("Instance: " + web3.version.node);
+ console.log("Coinbase: " + eth.coinbase);
+ console.log("Location: " + eth.blockNumber + " (" + new Date(1000 * eth.getBlock(eth.blockNumber).timestamp) + ")");
+ console.log("Datadir: " + admin.datadir);
`)
// List all the supported modules for the user to call
if apis, err := c.client.SupportedModules(); err == nil {
@@ -272,7 +272,7 @@ func (c *Console) Welcome() {
modules = append(modules, fmt.Sprintf("%s:%s", api, version))
}
sort.Strings(modules)
- fmt.Fprintln(c.printer, " modules:", strings.Join(modules, " "))
+ // fmt.Fprintln(c.printer, " modules:", strings.Join(modules, " "))
}
fmt.Fprintln(c.printer)
}
diff --git a/console/console_test.go b/console/console_test.go
old mode 100644
new mode 100755
index a159b62bb..53ac720aa
--- a/console/console_test.go
+++ b/console/console_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -26,11 +26,11 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/internal/jsre"
- "github.com/ethereum/go-ethereum/node"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/internal/jsre"
+ "github.com/wtc/go-wtc/node"
)
const (
@@ -73,7 +73,7 @@ func (p *hookedPrompter) SetWordCompleter(completer WordCompleter) {}
type tester struct {
workspace string
stack *node.Node
- ethereum *eth.Ethereum
+ wtc *eth.Wtc
console *Console
input *hookedPrompter
output *bytes.Buffer
@@ -88,13 +88,13 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
t.Fatalf("failed to create temporary keystore: %v", err)
}
- // Create a networkless protocol stack and start an Ethereum service within
+ // Create a networkless protocol stack and start an Wtc service within
stack, err := node.New(&node.Config{DataDir: workspace, UseLightweightKDF: true, Name: testInstance})
if err != nil {
t.Fatalf("failed to create node: %v", err)
}
ethConf := &eth.Config{
- Genesis: core.DeveloperGenesisBlock(15, common.Address{}),
+ Genesis: core.DevGenesisBlock(),
Etherbase: common.HexToAddress(testAddress),
PowTest: true,
}
@@ -102,7 +102,7 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
confOverride(ethConf)
}
if err = stack.Register(func(ctx *node.ServiceContext) (node.Service, error) { return eth.New(ctx, ethConf) }); err != nil {
- t.Fatalf("failed to register Ethereum protocol: %v", err)
+ t.Fatalf("failed to register Wtc protocol: %v", err)
}
// Start the node and assemble the JavaScript console around it
if err = stack.Start(); err != nil {
@@ -127,13 +127,13 @@ func newTester(t *testing.T, confOverride func(*eth.Config)) *tester {
t.Fatalf("failed to create JavaScript console: %v", err)
}
// Create the final tester and return
- var ethereum *eth.Ethereum
- stack.Service(&ethereum)
+ var wtc *eth.Wtc
+ stack.Service(&wtc)
return &tester{
workspace: workspace,
stack: stack,
- ethereum: ethereum,
+ wtc: wtc,
console: console,
input: prompter,
output: printer,
diff --git a/console/prompter.go b/console/prompter.go
old mode 100644
new mode 100755
index 6acbfb0e2..cc0766a04
--- a/console/prompter.go
+++ b/console/prompter.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/console/testdata/exec.js b/console/testdata/exec.js
old mode 100644
new mode 100755
diff --git a/console/testdata/preload.js b/console/testdata/preload.js
old mode 100644
new mode 100755
diff --git a/containers/docker/develop-alpine/Dockerfile b/containers/docker/develop-alpine/Dockerfile
old mode 100644
new mode 100755
index d239129d5..1431c94c6
--- a/containers/docker/develop-alpine/Dockerfile
+++ b/containers/docker/develop-alpine/Dockerfile
@@ -2,13 +2,13 @@ FROM alpine:3.5
RUN \
apk add --update go git make gcc musl-dev linux-headers ca-certificates && \
- git clone --depth 1 https://github.com/ethereum/go-ethereum && \
- (cd go-ethereum && make geth) && \
- cp go-ethereum/build/bin/geth /geth && \
+ git clone --depth 1 https://github.com/wtc/go-wtc && \
+ (cd go-wtc && make gwtc) && \
+ cp go-wtc/build/bin/gwtc /gwtc && \
apk del go git make gcc musl-dev linux-headers && \
- rm -rf /go-ethereum && rm -rf /var/cache/apk/*
+ rm -rf /go-wtc && rm -rf /var/cache/apk/*
EXPOSE 8545
-EXPOSE 30303
+EXPOSE 10101
-ENTRYPOINT ["/geth"]
+ENTRYPOINT ["/gwtc"]
diff --git a/containers/docker/develop-ubuntu/Dockerfile b/containers/docker/develop-ubuntu/Dockerfile
old mode 100644
new mode 100755
index c79becb55..e6b614ed1
--- a/containers/docker/develop-ubuntu/Dockerfile
+++ b/containers/docker/develop-ubuntu/Dockerfile
@@ -3,13 +3,13 @@ FROM ubuntu:xenial
RUN \
apt-get update && apt-get upgrade -q -y && \
apt-get install -y --no-install-recommends golang git make gcc libc-dev ca-certificates && \
- git clone --depth 1 https://github.com/ethereum/go-ethereum && \
- (cd go-ethereum && make geth) && \
- cp go-ethereum/build/bin/geth /geth && \
+ git clone --depth 1 https://github.com/wtc/go-wtc && \
+ (cd go-wtc && make gwtc) && \
+ cp go-wtc/build/bin/gwtc /gwtc && \
apt-get remove -y golang git make gcc libc-dev && apt autoremove -y && apt-get clean && \
- rm -rf /go-ethereum
+ rm -rf /go-wtc
EXPOSE 8545
-EXPOSE 30303
+EXPOSE 10101
-ENTRYPOINT ["/geth"]
+ENTRYPOINT ["/gwtc"]
diff --git a/containers/docker/master-alpine/Dockerfile b/containers/docker/master-alpine/Dockerfile
old mode 100644
new mode 100755
index 44402361d..f4da2ce4f
--- a/containers/docker/master-alpine/Dockerfile
+++ b/containers/docker/master-alpine/Dockerfile
@@ -2,13 +2,13 @@ FROM alpine:3.5
RUN \
apk add --update go git make gcc musl-dev linux-headers ca-certificates && \
- git clone --depth 1 --branch release/1.7 https://github.com/ethereum/go-ethereum && \
- (cd go-ethereum && make geth) && \
- cp go-ethereum/build/bin/geth /geth && \
+ git clone --depth 1 --branch release/1.7 https://github.com/wtc/go-wtc && \
+ (cd go-wtc && make gwtc) && \
+ cp go-wtc/build/bin/gwtc /gwtc && \
apk del go git make gcc musl-dev linux-headers && \
- rm -rf /go-ethereum && rm -rf /var/cache/apk/*
+ rm -rf /go-wtc && rm -rf /var/cache/apk/*
EXPOSE 8545
-EXPOSE 30303
+EXPOSE 10101
-ENTRYPOINT ["/geth"]
+ENTRYPOINT ["/gwtc"]
diff --git a/containers/docker/master-ubuntu/Dockerfile b/containers/docker/master-ubuntu/Dockerfile
old mode 100644
new mode 100755
index cc4fad10c..5cef0d147
--- a/containers/docker/master-ubuntu/Dockerfile
+++ b/containers/docker/master-ubuntu/Dockerfile
@@ -3,13 +3,13 @@ FROM ubuntu:xenial
RUN \
apt-get update && apt-get upgrade -q -y && \
apt-get install -y --no-install-recommends golang git make gcc libc-dev ca-certificates && \
- git clone --depth 1 --branch release/1.7 https://github.com/ethereum/go-ethereum && \
- (cd go-ethereum && make geth) && \
- cp go-ethereum/build/bin/geth /geth && \
+ git clone --depth 1 --branch release/1.7 https://github.com/wtc/go-wtc && \
+ (cd go-wtc && make gwtc) && \
+ cp go-wtc/build/bin/gwtc /gwtc && \
apt-get remove -y golang git make gcc libc-dev && apt autoremove -y && apt-get clean && \
- rm -rf /go-ethereum
+ rm -rf /go-wtc
EXPOSE 8545
-EXPOSE 30303
+EXPOSE 10101
-ENTRYPOINT ["/geth"]
+ENTRYPOINT ["/gwtc"]
diff --git a/containers/vagrant/.gitignore b/containers/vagrant/.gitignore
old mode 100644
new mode 100755
diff --git a/containers/vagrant/Vagrantfile b/containers/vagrant/Vagrantfile
old mode 100644
new mode 100755
index 72ec366e2..ca474240f
--- a/containers/vagrant/Vagrantfile
+++ b/containers/vagrant/Vagrantfile
@@ -34,5 +34,5 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
end
config.vm.synced_folder ".", "/vagrant", :disabled => true
- config.vm.synced_folder "../../", "/home/vagrant/go/src/github.com/ethereum/go-ethereum"
+ config.vm.synced_folder "../../", "/home/vagrant/go/src/github.com/wtc/go-wtc"
end
diff --git a/containers/vagrant/provisioners/shell/centos.sh b/containers/vagrant/provisioners/shell/centos.sh
index 744da4bfd..a0b50b9d4 100755
--- a/containers/vagrant/provisioners/shell/centos.sh
+++ b/containers/vagrant/provisioners/shell/centos.sh
@@ -6,6 +6,6 @@ sudo yum update -y
wget --continue https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz
-GETH_PATH="~vagrant/go/src/github.com/ethereum/go-ethereum/build/bin/"
+GETH_PATH="~vagrant/go/src/github.com/wtc/go-wtc/build/bin/"
echo "export PATH=$PATH:/usr/local/go/bin:$GETH_PATH" >> ~vagrant/.bashrc
diff --git a/containers/vagrant/provisioners/shell/debian.sh b/containers/vagrant/provisioners/shell/debian.sh
index 1c1793336..04c105991 100755
--- a/containers/vagrant/provisioners/shell/debian.sh
+++ b/containers/vagrant/provisioners/shell/debian.sh
@@ -6,6 +6,6 @@ sudo apt-get update
wget --continue https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz
-GETH_PATH="~vagrant/go/src/github.com/ethereum/go-ethereum/build/bin/"
+GETH_PATH="~vagrant/go/src/github.com/wtc/go-wtc/build/bin/"
echo "export PATH=$PATH:/usr/local/go/bin:$GETH_PATH" >> ~vagrant/.bashrc
diff --git a/containers/vagrant/provisioners/shell/ubuntu.sh b/containers/vagrant/provisioners/shell/ubuntu.sh
index 1c1793336..04c105991 100755
--- a/containers/vagrant/provisioners/shell/ubuntu.sh
+++ b/containers/vagrant/provisioners/shell/ubuntu.sh
@@ -6,6 +6,6 @@ sudo apt-get update
wget --continue https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz
-GETH_PATH="~vagrant/go/src/github.com/ethereum/go-ethereum/build/bin/"
+GETH_PATH="~vagrant/go/src/github.com/wtc/go-wtc/build/bin/"
echo "export PATH=$PATH:/usr/local/go/bin:$GETH_PATH" >> ~vagrant/.bashrc
diff --git a/contracts/chequebook/api.go b/contracts/chequebook/api.go
old mode 100644
new mode 100755
index b2b2365f3..fc751c73c
--- a/contracts/chequebook/api.go
+++ b/contracts/chequebook/api.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,7 +20,7 @@ import (
"errors"
"math/big"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/wtc/go-wtc/common"
)
const Version = "1.0"
diff --git a/contracts/chequebook/cheque.go b/contracts/chequebook/cheque.go
old mode 100644
new mode 100755
index 09daa9248..be198c7ba
--- a/contracts/chequebook/cheque.go
+++ b/contracts/chequebook/cheque.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package chequebook package wraps the 'chequebook' Ethereum smart contract.
+// Package chequebook package wraps the 'chequebook' Wtc smart contract.
//
// The functions in this package allow using chequebook for
// issuing, receiving, verifying cheques in ether; (auto)cashing cheques in ether
@@ -36,14 +36,14 @@ import (
"sync"
"time"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/contracts/chequebook/contract"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/swarm/services/swap/swap"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/hexutil"
+ "github.com/wtc/go-wtc/contracts/chequebook/contract"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/swarm/services/swap/swap"
)
// TODO(zelig): watch peer solvency and notify of bouncing cheques
@@ -620,7 +620,7 @@ func sig2vrs(sig []byte) (v byte, r, s [32]byte) {
return
}
-// Cash cashes the cheque by sending an Ethereum transaction.
+// Cash cashes the cheque by sending an Wtc transaction.
func (self *Cheque) Cash(session *contract.ChequebookSession) (string, error) {
v, r, s := sig2vrs(self.Sig)
tx, err := session.Cash(self.Beneficiary, self.Amount, v, r, s)
diff --git a/contracts/chequebook/cheque_test.go b/contracts/chequebook/cheque_test.go
old mode 100644
new mode 100755
index b7555d081..21dcd9a1c
--- a/contracts/chequebook/cheque_test.go
+++ b/contracts/chequebook/cheque_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,12 +24,12 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/contracts/chequebook/contract"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/accounts/abi/bind/backends"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/contracts/chequebook/contract"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/crypto"
)
var (
diff --git a/contracts/chequebook/contract/chequebook.go b/contracts/chequebook/contract/chequebook.go
old mode 100644
new mode 100755
index 47090152c..c18b43d53
--- a/contracts/chequebook/contract/chequebook.go
+++ b/contracts/chequebook/contract/chequebook.go
@@ -7,10 +7,10 @@ import (
"math/big"
"strings"
- "github.com/ethereum/go-ethereum/accounts/abi"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc/accounts/abi"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
)
// ChequebookABI is the input ABI used to generate the binding from.
@@ -19,7 +19,7 @@ const ChequebookABI = `[{"constant":false,"inputs":[],"name":"kill","outputs":[]
// ChequebookBin is the compiled bytecode used for deploying new contracts.
const ChequebookBin = `0x606060405260008054600160a060020a031916331790556101ff806100246000396000f3606060405260e060020a600035046341c0e1b581146100315780637bf786f814610059578063fbf788d614610071575b005b61002f60005433600160a060020a03908116911614156100bd57600054600160a060020a0316ff5b6100ab60043560016020526000908152604090205481565b61002f600435602435604435606435608435600160a060020a03851660009081526001602052604081205485116100bf575b505050505050565b60408051918252519081900360200190f35b565b50604080516c0100000000000000000000000030600160a060020a0390811682028352881602601482015260288101869052815190819003604801812080825260ff861660208381019190915282840186905260608301859052925190926001926080818101939182900301816000866161da5a03f11561000257505060405151600054600160a060020a0390811691161461015a576100a3565b600160a060020a038681166000908152600160205260409020543090911631908603106101b357604060008181208790559051600160a060020a0388169190819081818181818881f1935050505015156100a357610002565b60005460408051600160a060020a03929092168252517f2250e2993c15843b32621c89447cc589ee7a9f049c026986e545d3c2c0c6f9789181900360200190a185600160a060020a0316ff`
-// DeployChequebook deploys a new Ethereum contract, binding an instance of Chequebook to it.
+// DeployChequebook deploys a new Wtc contract, binding an instance of Chequebook to it.
func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Chequebook, error) {
parsed, err := abi.JSON(strings.NewReader(ChequebookABI))
if err != nil {
@@ -32,23 +32,23 @@ func DeployChequebook(auth *bind.TransactOpts, backend bind.ContractBackend) (co
return address, tx, &Chequebook{ChequebookCaller: ChequebookCaller{contract: contract}, ChequebookTransactor: ChequebookTransactor{contract: contract}}, nil
}
-// Chequebook is an auto generated Go binding around an Ethereum contract.
+// Chequebook is an auto generated Go binding around an Wtc contract.
type Chequebook struct {
ChequebookCaller // Read-only binding to the contract
ChequebookTransactor // Write-only binding to the contract
}
-// ChequebookCaller is an auto generated read-only Go binding around an Ethereum contract.
+// ChequebookCaller is an auto generated read-only Go binding around an Wtc contract.
type ChequebookCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ChequebookTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// ChequebookTransactor is an auto generated write-only Go binding around an Wtc contract.
type ChequebookTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ChequebookSession is an auto generated Go binding around an Ethereum contract,
+// ChequebookSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type ChequebookSession struct {
Contract *Chequebook // Generic contract binding to set the session for
@@ -56,31 +56,31 @@ type ChequebookSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ChequebookCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// ChequebookCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type ChequebookCallerSession struct {
Contract *ChequebookCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// ChequebookTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// ChequebookTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type ChequebookTransactorSession struct {
Contract *ChequebookTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ChequebookRaw is an auto generated low-level Go binding around an Ethereum contract.
+// ChequebookRaw is an auto generated low-level Go binding around an Wtc contract.
type ChequebookRaw struct {
Contract *Chequebook // Generic contract binding to access the raw methods on
}
-// ChequebookCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// ChequebookCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type ChequebookCallerRaw struct {
Contract *ChequebookCaller // Generic read-only contract binding to access the raw methods on
}
-// ChequebookTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// ChequebookTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type ChequebookTransactorRaw struct {
Contract *ChequebookTransactor // Generic write-only contract binding to access the raw methods on
}
@@ -233,7 +233,7 @@ const MortalABI = `[{"constant":false,"inputs":[],"name":"kill","outputs":[],"ty
// MortalBin is the compiled bytecode used for deploying new contracts.
const MortalBin = `0x606060405260008054600160a060020a03191633179055605c8060226000396000f3606060405260e060020a600035046341c0e1b58114601a575b005b60186000543373ffffffffffffffffffffffffffffffffffffffff90811691161415605a5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b56`
-// DeployMortal deploys a new Ethereum contract, binding an instance of Mortal to it.
+// DeployMortal deploys a new Wtc contract, binding an instance of Mortal to it.
func DeployMortal(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Mortal, error) {
parsed, err := abi.JSON(strings.NewReader(MortalABI))
if err != nil {
@@ -246,23 +246,23 @@ func DeployMortal(auth *bind.TransactOpts, backend bind.ContractBackend) (common
return address, tx, &Mortal{MortalCaller: MortalCaller{contract: contract}, MortalTransactor: MortalTransactor{contract: contract}}, nil
}
-// Mortal is an auto generated Go binding around an Ethereum contract.
+// Mortal is an auto generated Go binding around an Wtc contract.
type Mortal struct {
MortalCaller // Read-only binding to the contract
MortalTransactor // Write-only binding to the contract
}
-// MortalCaller is an auto generated read-only Go binding around an Ethereum contract.
+// MortalCaller is an auto generated read-only Go binding around an Wtc contract.
type MortalCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// MortalTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// MortalTransactor is an auto generated write-only Go binding around an Wtc contract.
type MortalTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// MortalSession is an auto generated Go binding around an Ethereum contract,
+// MortalSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type MortalSession struct {
Contract *Mortal // Generic contract binding to set the session for
@@ -270,31 +270,31 @@ type MortalSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// MortalCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// MortalCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type MortalCallerSession struct {
Contract *MortalCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// MortalTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// MortalTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type MortalTransactorSession struct {
Contract *MortalTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// MortalRaw is an auto generated low-level Go binding around an Ethereum contract.
+// MortalRaw is an auto generated low-level Go binding around an Wtc contract.
type MortalRaw struct {
Contract *Mortal // Generic contract binding to access the raw methods on
}
-// MortalCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// MortalCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type MortalCallerRaw struct {
Contract *MortalCaller // Generic read-only contract binding to access the raw methods on
}
-// MortalTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// MortalTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type MortalTransactorRaw struct {
Contract *MortalTransactor // Generic write-only contract binding to access the raw methods on
}
@@ -400,7 +400,7 @@ const OwnedABI = `[{"inputs":[],"type":"constructor"}]`
// OwnedBin is the compiled bytecode used for deploying new contracts.
const OwnedBin = `0x606060405260008054600160a060020a0319163317905560068060226000396000f3606060405200`
-// DeployOwned deploys a new Ethereum contract, binding an instance of Owned to it.
+// DeployOwned deploys a new Wtc contract, binding an instance of Owned to it.
func DeployOwned(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Owned, error) {
parsed, err := abi.JSON(strings.NewReader(OwnedABI))
if err != nil {
@@ -413,23 +413,23 @@ func DeployOwned(auth *bind.TransactOpts, backend bind.ContractBackend) (common.
return address, tx, &Owned{OwnedCaller: OwnedCaller{contract: contract}, OwnedTransactor: OwnedTransactor{contract: contract}}, nil
}
-// Owned is an auto generated Go binding around an Ethereum contract.
+// Owned is an auto generated Go binding around an Wtc contract.
type Owned struct {
OwnedCaller // Read-only binding to the contract
OwnedTransactor // Write-only binding to the contract
}
-// OwnedCaller is an auto generated read-only Go binding around an Ethereum contract.
+// OwnedCaller is an auto generated read-only Go binding around an Wtc contract.
type OwnedCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// OwnedTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// OwnedTransactor is an auto generated write-only Go binding around an Wtc contract.
type OwnedTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// OwnedSession is an auto generated Go binding around an Ethereum contract,
+// OwnedSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type OwnedSession struct {
Contract *Owned // Generic contract binding to set the session for
@@ -437,31 +437,31 @@ type OwnedSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// OwnedCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// OwnedCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type OwnedCallerSession struct {
Contract *OwnedCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// OwnedTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// OwnedTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type OwnedTransactorSession struct {
Contract *OwnedTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// OwnedRaw is an auto generated low-level Go binding around an Ethereum contract.
+// OwnedRaw is an auto generated low-level Go binding around an Wtc contract.
type OwnedRaw struct {
Contract *Owned // Generic contract binding to access the raw methods on
}
-// OwnedCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// OwnedCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type OwnedCallerRaw struct {
Contract *OwnedCaller // Generic read-only contract binding to access the raw methods on
}
-// OwnedTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// OwnedTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type OwnedTransactorRaw struct {
Contract *OwnedTransactor // Generic write-only contract binding to access the raw methods on
}
diff --git a/contracts/chequebook/contract/chequebook.sol b/contracts/chequebook/contract/chequebook.sol
old mode 100644
new mode 100755
index 8d6e85d11..9198c1af9
--- a/contracts/chequebook/contract/chequebook.sol
+++ b/contracts/chequebook/contract/chequebook.sol
@@ -1,9 +1,7 @@
-pragma solidity ^0.4.18;
+import "mortal";
-import "https://github.com/ethereum/solidity/std/mortal.sol";
-
-/// @title Chequebook for Ethereum micropayments
-/// @author Daniel A. Nagy <daniel@ethereum.org>
+/// @title Chequebook for Wtc micropayments
+/// @author Daniel A. Nagy <daniel@ethdev.com>
contract chequebook is mortal {
// Cumulative paid amount in wei to each beneficiary
mapping (address => uint256) public sent;
@@ -23,23 +21,26 @@ contract chequebook is mortal {
uint8 sig_v, bytes32 sig_r, bytes32 sig_s) {
// Check if the cheque is old.
// Only cheques that are more recent than the last cashed one are considered.
- require(amount > sent[beneficiary]);
+ if(amount <= sent[beneficiary]) return;
// Check the digital signature of the cheque.
- bytes32 hash = keccak256(address(this), beneficiary, amount);
- require(owner == ecrecover(hash, sig_v, sig_r, sig_s));
+ bytes32 hash = sha3(address(this), beneficiary, amount);
+ if(owner != ecrecover(hash, sig_v, sig_r, sig_s)) return;
// Attempt sending the difference between the cumulative amount on the cheque
// and the cumulative amount on the last cashed cheque to beneficiary.
uint256 diff = amount - sent[beneficiary];
if (diff <= this.balance) {
// update the cumulative amount before sending
sent[beneficiary] = amount;
- beneficiary.transfer(diff);
+ if (!beneficiary.send(diff)) {
+ // Upon failure to execute send, revert everything
+ throw;
+ }
} else {
// Upon failure, punish owner for writing a bounced cheque.
// owner.sendToDebtorsPrison();
Overdraft(owner);
// Compensate beneficiary.
- selfdestruct(beneficiary);
+ suicide(beneficiary);
}
}
}
diff --git a/contracts/chequebook/contract/code.go b/contracts/chequebook/contract/code.go
old mode 100644
new mode 100755
diff --git a/contracts/chequebook/gencode.go b/contracts/chequebook/gencode.go
old mode 100644
new mode 100755
index faa927279..cae445c12
--- a/contracts/chequebook/gencode.go
+++ b/contracts/chequebook/gencode.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,11 +25,11 @@ import (
"io/ioutil"
"math/big"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
- "github.com/ethereum/go-ethereum/contracts/chequebook/contract"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/accounts/abi/bind/backends"
+ "github.com/wtc/go-wtc/contracts/chequebook/contract"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/crypto"
)
var (
diff --git a/contracts/ens/README.md b/contracts/ens/README.md
old mode 100644
new mode 100755
index c09b47e39..14ce6dbcd
--- a/contracts/ens/README.md
+++ b/contracts/ens/README.md
@@ -2,7 +2,7 @@
## Usage
-Full documentation for the Ethereum Name Service [can be found as EIP 137](https://github.com/ethereum/EIPs/issues/137).
+Full documentation for the Wtc Name Service [can be found as EIP 137](https://github.com/wtc/EIPs/issues/137).
This package offers a simple binding that streamlines the registration of arbitrary UTF8 domain names to swarm content hashes.
## Development
diff --git a/contracts/ens/contract/ens.go b/contracts/ens/contract/ens.go
old mode 100644
new mode 100755
index aca16de50..7150be2f1
--- a/contracts/ens/contract/ens.go
+++ b/contracts/ens/contract/ens.go
@@ -6,10 +6,10 @@ package contract
import (
"strings"
- "github.com/ethereum/go-ethereum/accounts/abi"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc/accounts/abi"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
)
// ENSABI is the input ABI used to generate the binding from.
@@ -18,7 +18,7 @@ const ENSABI = `[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"n
// ENSBin is the compiled bytecode used for deploying new contracts.
const ENSBin = `0x606060405260405160208061032683395060806040525160008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a03191682179055506102c88061005e6000396000f3606060405260e060020a60003504630178b8bf811461004757806302571be31461006e57806306ab5923146100915780631896f70a146100c85780635b0fc9c3146100fc575b005b610130600435600081815260208190526040902060010154600160a060020a03165b919050565b610130600435600081815260208190526040902054600160a060020a0316610069565b6100456004356024356044356000838152602081905260408120548490600160a060020a0390811633919091161461014d57610002565b6100456004356024356000828152602081905260409020548290600160a060020a039081163391909116146101e757610002565b6100456004356024356000828152602081905260409020548290600160a060020a0390811633919091161461025957610002565b60408051600160a060020a03929092168252519081900360200190f35b60408051868152602081810187905282519182900383018220600160a060020a03871683529251929450869288927fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8292908290030190a382600060005060008460001916815260200190815260200160002060005060000160006101000a815481600160a060020a03021916908302179055505050505050565b60408051600160a060020a0384168152905184917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a2506000828152602081905260409020600101805473ffffffffffffffffffffffffffffffffffffffff1916821790555050565b60408051600160a060020a0384168152905184917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a2506000828152602081905260409020805473ffffffffffffffffffffffffffffffffffffffff191682179055505056`
-// DeployENS deploys a new Ethereum contract, binding an instance of ENS to it.
+// DeployENS deploys a new Wtc contract, binding an instance of ENS to it.
func DeployENS(auth *bind.TransactOpts, backend bind.ContractBackend, owner common.Address) (common.Address, *types.Transaction, *ENS, error) {
parsed, err := abi.JSON(strings.NewReader(ENSABI))
if err != nil {
@@ -31,23 +31,23 @@ func DeployENS(auth *bind.TransactOpts, backend bind.ContractBackend, owner comm
return address, tx, &ENS{ENSCaller: ENSCaller{contract: contract}, ENSTransactor: ENSTransactor{contract: contract}}, nil
}
-// ENS is an auto generated Go binding around an Ethereum contract.
+// ENS is an auto generated Go binding around an Wtc contract.
type ENS struct {
ENSCaller // Read-only binding to the contract
ENSTransactor // Write-only binding to the contract
}
-// ENSCaller is an auto generated read-only Go binding around an Ethereum contract.
+// ENSCaller is an auto generated read-only Go binding around an Wtc contract.
type ENSCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ENSTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// ENSTransactor is an auto generated write-only Go binding around an Wtc contract.
type ENSTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ENSSession is an auto generated Go binding around an Ethereum contract,
+// ENSSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type ENSSession struct {
Contract *ENS // Generic contract binding to set the session for
@@ -55,31 +55,31 @@ type ENSSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ENSCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// ENSCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type ENSCallerSession struct {
Contract *ENSCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// ENSTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// ENSTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type ENSTransactorSession struct {
Contract *ENSTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ENSRaw is an auto generated low-level Go binding around an Ethereum contract.
+// ENSRaw is an auto generated low-level Go binding around an Wtc contract.
type ENSRaw struct {
Contract *ENS // Generic contract binding to access the raw methods on
}
-// ENSCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// ENSCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type ENSCallerRaw struct {
Contract *ENSCaller // Generic read-only contract binding to access the raw methods on
}
-// ENSTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// ENSTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type ENSTransactorRaw struct {
Contract *ENSTransactor // Generic write-only contract binding to access the raw methods on
}
@@ -279,7 +279,7 @@ const FIFSRegistrarABI = `[{"constant":false,"inputs":[{"name":"subnode","type":
// FIFSRegistrarBin is the compiled bytecode used for deploying new contracts.
const FIFSRegistrarBin = `0x6060604081815280610620833960a090525160805160008054600160a060020a031916831790558160a0610367806100878339018082600160a060020a03168152602001915050604051809103906000f0600160006101000a815481600160a060020a0302191690830217905550806002600050819055505050610232806103ee6000396000f3606060405260405160208061036783395060806040525160008054600160a060020a0319168217905550610330806100376000396000f36060604052361561004b5760e060020a60003504632dff694181146100535780633b3b57de1461007557806341b9dc2b146100a0578063c3d014d614610139578063d5fa2b00146101b2575b61022b610002565b61022d6004356000818152600260205260408120549081141561027057610002565b61023f600435600081815260016020526040812054600160a060020a03169081141561027057610002565b61025c60043560243560007f6164647200000000000000000000000000000000000000000000000000000000821480156100f05750600083815260016020526040812054600160a060020a031614155b8061013257507f636f6e74656e740000000000000000000000000000000000000000000000000082148015610132575060008381526002602052604081205414155b9392505050565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a031691909114905061027557610002565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a03169190911490506102c157610002565b005b60408051918252519081900360200190f35b60408051600160a060020a03929092168252519081900360200190f35b604080519115158252519081900360200190f35b919050565b6000838152600260209081526040918290208490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600083815260016020908152604091829020805473ffffffffffffffffffffffffffffffffffffffff1916851790558151600160a060020a0385168152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a250505056606060405260e060020a6000350463d22057a9811461001b575b005b61001960043560243560025460408051918252602082810185905260008054835194859003840185207f02571be300000000000000000000000000000000000000000000000000000000865260048601819052935193949193600160a060020a03909116926302571be39260248181019391829003018187876161da5a03f11561000257505060405151915050600160a060020a0381166000148015906100d4575033600160a060020a031681600160a060020a031614155b156100de57610002565b60408051600080546002547f06ab592300000000000000000000000000000000000000000000000000000000845260048401526024830188905230600160a060020a03908116604485015293519316926306ab5923926064818101939291829003018183876161da5a03f11561000257505060008054600154604080517f1896f70a00000000000000000000000000000000000000000000000000000000815260048101889052600160a060020a0392831660248201529051929091169350631896f70a926044828101939192829003018183876161da5a03f11561000257505060008054604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260048101879052600160a060020a0388811660248301529151929091169350635b0fc9c3926044828101939192829003018183876161da5a03f115610002575050505050505056`
-// DeployFIFSRegistrar deploys a new Ethereum contract, binding an instance of FIFSRegistrar to it.
+// DeployFIFSRegistrar deploys a new Wtc contract, binding an instance of FIFSRegistrar to it.
func DeployFIFSRegistrar(auth *bind.TransactOpts, backend bind.ContractBackend, ensAddr common.Address, node [32]byte) (common.Address, *types.Transaction, *FIFSRegistrar, error) {
parsed, err := abi.JSON(strings.NewReader(FIFSRegistrarABI))
if err != nil {
@@ -292,23 +292,23 @@ func DeployFIFSRegistrar(auth *bind.TransactOpts, backend bind.ContractBackend,
return address, tx, &FIFSRegistrar{FIFSRegistrarCaller: FIFSRegistrarCaller{contract: contract}, FIFSRegistrarTransactor: FIFSRegistrarTransactor{contract: contract}}, nil
}
-// FIFSRegistrar is an auto generated Go binding around an Ethereum contract.
+// FIFSRegistrar is an auto generated Go binding around an Wtc contract.
type FIFSRegistrar struct {
FIFSRegistrarCaller // Read-only binding to the contract
FIFSRegistrarTransactor // Write-only binding to the contract
}
-// FIFSRegistrarCaller is an auto generated read-only Go binding around an Ethereum contract.
+// FIFSRegistrarCaller is an auto generated read-only Go binding around an Wtc contract.
type FIFSRegistrarCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// FIFSRegistrarTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// FIFSRegistrarTransactor is an auto generated write-only Go binding around an Wtc contract.
type FIFSRegistrarTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// FIFSRegistrarSession is an auto generated Go binding around an Ethereum contract,
+// FIFSRegistrarSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type FIFSRegistrarSession struct {
Contract *FIFSRegistrar // Generic contract binding to set the session for
@@ -316,31 +316,31 @@ type FIFSRegistrarSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// FIFSRegistrarCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// FIFSRegistrarCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type FIFSRegistrarCallerSession struct {
Contract *FIFSRegistrarCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// FIFSRegistrarTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// FIFSRegistrarTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type FIFSRegistrarTransactorSession struct {
Contract *FIFSRegistrarTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// FIFSRegistrarRaw is an auto generated low-level Go binding around an Ethereum contract.
+// FIFSRegistrarRaw is an auto generated low-level Go binding around an Wtc contract.
type FIFSRegistrarRaw struct {
Contract *FIFSRegistrar // Generic contract binding to access the raw methods on
}
-// FIFSRegistrarCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// FIFSRegistrarCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type FIFSRegistrarCallerRaw struct {
Contract *FIFSRegistrarCaller // Generic read-only contract binding to access the raw methods on
}
-// FIFSRegistrarTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// FIFSRegistrarTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type FIFSRegistrarTransactorRaw struct {
Contract *FIFSRegistrarTransactor // Generic write-only contract binding to access the raw methods on
}
@@ -446,7 +446,7 @@ const PublicResolverABI = `[{"constant":true,"inputs":[{"name":"node","type":"by
// PublicResolverBin is the compiled bytecode used for deploying new contracts.
const PublicResolverBin = `0x606060405260405160208061036783395060806040525160008054600160a060020a0319168217905550610330806100376000396000f36060604052361561004b5760e060020a60003504632dff694181146100535780633b3b57de1461007557806341b9dc2b146100a0578063c3d014d614610139578063d5fa2b00146101b2575b61022b610002565b61022d6004356000818152600260205260408120549081141561027057610002565b61023f600435600081815260016020526040812054600160a060020a03169081141561027057610002565b61025c60043560243560007f6164647200000000000000000000000000000000000000000000000000000000821480156100f05750600083815260016020526040812054600160a060020a031614155b8061013257507f636f6e74656e740000000000000000000000000000000000000000000000000082148015610132575060008381526002602052604081205414155b9392505050565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a031691909114905061027557610002565b61022b600435602435600080546040805160e060020a6302571be30281526004810186905290518593600160a060020a033381169416926302571be392602482810193602093839003909101908290876161da5a03f11561000257505060405151600160a060020a03169190911490506102c157610002565b005b60408051918252519081900360200190f35b60408051600160a060020a03929092168252519081900360200190f35b604080519115158252519081900360200190f35b919050565b6000838152600260209081526040918290208490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600083815260016020908152604091829020805473ffffffffffffffffffffffffffffffffffffffff1916851790558151600160a060020a0385168152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a250505056`
-// DeployPublicResolver deploys a new Ethereum contract, binding an instance of PublicResolver to it.
+// DeployPublicResolver deploys a new Wtc contract, binding an instance of PublicResolver to it.
func DeployPublicResolver(auth *bind.TransactOpts, backend bind.ContractBackend, ensAddr common.Address) (common.Address, *types.Transaction, *PublicResolver, error) {
parsed, err := abi.JSON(strings.NewReader(PublicResolverABI))
if err != nil {
@@ -459,23 +459,23 @@ func DeployPublicResolver(auth *bind.TransactOpts, backend bind.ContractBackend,
return address, tx, &PublicResolver{PublicResolverCaller: PublicResolverCaller{contract: contract}, PublicResolverTransactor: PublicResolverTransactor{contract: contract}}, nil
}
-// PublicResolver is an auto generated Go binding around an Ethereum contract.
+// PublicResolver is an auto generated Go binding around an Wtc contract.
type PublicResolver struct {
PublicResolverCaller // Read-only binding to the contract
PublicResolverTransactor // Write-only binding to the contract
}
-// PublicResolverCaller is an auto generated read-only Go binding around an Ethereum contract.
+// PublicResolverCaller is an auto generated read-only Go binding around an Wtc contract.
type PublicResolverCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// PublicResolverTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// PublicResolverTransactor is an auto generated write-only Go binding around an Wtc contract.
type PublicResolverTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// PublicResolverSession is an auto generated Go binding around an Ethereum contract,
+// PublicResolverSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type PublicResolverSession struct {
Contract *PublicResolver // Generic contract binding to set the session for
@@ -483,31 +483,31 @@ type PublicResolverSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// PublicResolverCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// PublicResolverCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type PublicResolverCallerSession struct {
Contract *PublicResolverCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// PublicResolverTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// PublicResolverTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type PublicResolverTransactorSession struct {
Contract *PublicResolverTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// PublicResolverRaw is an auto generated low-level Go binding around an Ethereum contract.
+// PublicResolverRaw is an auto generated low-level Go binding around an Wtc contract.
type PublicResolverRaw struct {
Contract *PublicResolver // Generic contract binding to access the raw methods on
}
-// PublicResolverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// PublicResolverCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type PublicResolverCallerRaw struct {
Contract *PublicResolverCaller // Generic read-only contract binding to access the raw methods on
}
-// PublicResolverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// PublicResolverTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type PublicResolverTransactorRaw struct {
Contract *PublicResolverTransactor // Generic write-only contract binding to access the raw methods on
}
@@ -707,7 +707,7 @@ const ResolverABI = `[{"constant":true,"inputs":[{"name":"node","type":"bytes32"
// ResolverBin is the compiled bytecode used for deploying new contracts.
const ResolverBin = `0x`
-// DeployResolver deploys a new Ethereum contract, binding an instance of Resolver to it.
+// DeployResolver deploys a new Wtc contract, binding an instance of Resolver to it.
func DeployResolver(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *Resolver, error) {
parsed, err := abi.JSON(strings.NewReader(ResolverABI))
if err != nil {
@@ -720,23 +720,23 @@ func DeployResolver(auth *bind.TransactOpts, backend bind.ContractBackend) (comm
return address, tx, &Resolver{ResolverCaller: ResolverCaller{contract: contract}, ResolverTransactor: ResolverTransactor{contract: contract}}, nil
}
-// Resolver is an auto generated Go binding around an Ethereum contract.
+// Resolver is an auto generated Go binding around an Wtc contract.
type Resolver struct {
ResolverCaller // Read-only binding to the contract
ResolverTransactor // Write-only binding to the contract
}
-// ResolverCaller is an auto generated read-only Go binding around an Ethereum contract.
+// ResolverCaller is an auto generated read-only Go binding around an Wtc contract.
type ResolverCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ResolverTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// ResolverTransactor is an auto generated write-only Go binding around an Wtc contract.
type ResolverTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ResolverSession is an auto generated Go binding around an Ethereum contract,
+// ResolverSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type ResolverSession struct {
Contract *Resolver // Generic contract binding to set the session for
@@ -744,31 +744,31 @@ type ResolverSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ResolverCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// ResolverCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type ResolverCallerSession struct {
Contract *ResolverCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// ResolverTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// ResolverTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type ResolverTransactorSession struct {
Contract *ResolverTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ResolverRaw is an auto generated low-level Go binding around an Ethereum contract.
+// ResolverRaw is an auto generated low-level Go binding around an Wtc contract.
type ResolverRaw struct {
Contract *Resolver // Generic contract binding to access the raw methods on
}
-// ResolverCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// ResolverCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type ResolverCallerRaw struct {
Contract *ResolverCaller // Generic read-only contract binding to access the raw methods on
}
-// ResolverTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// ResolverTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type ResolverTransactorRaw struct {
Contract *ResolverTransactor // Generic write-only contract binding to access the raw methods on
}
diff --git a/contracts/ens/contract/ens.sol b/contracts/ens/contract/ens.sol
old mode 100644
new mode 100755
index 114cd7319..ca5b74d28
--- a/contracts/ens/contract/ens.sol
+++ b/contracts/ens/contract/ens.sol
@@ -1,4 +1,4 @@
-// Ethereum Name Service contracts by Nick Johnson <nick@ethereum.org>
+// Wtc Name Service contracts by Nick Johnson <nick@wtc.org>
//
// To the extent possible under law, the person who associated CC0 with
// ENS contracts has waived all copyright and related or neighboring rights
diff --git a/contracts/ens/ens.go b/contracts/ens/ens.go
old mode 100644
new mode 100755
index c292a1714..714a9bffb
--- a/contracts/ens/ens.go
+++ b/contracts/ens/ens.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -22,11 +22,11 @@ import (
"math/big"
"strings"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/contracts/ens/contract"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/contracts/ens/contract"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/crypto"
)
var (
@@ -41,7 +41,7 @@ type ENS struct {
}
// NewENS creates a struct exposing convenient high-level operations for interacting with
-// the Ethereum Name Service.
+// the Wtc Name Service.
func NewENS(transactOpts *bind.TransactOpts, contractAddr common.Address, contractBackend bind.ContractBackend) (*ENS, error) {
ens, err := contract.NewENS(contractAddr, contractBackend)
if err != nil {
diff --git a/contracts/ens/ens_test.go b/contracts/ens/ens_test.go
old mode 100644
new mode 100755
index 5faa9b1ad..274d6682e
--- a/contracts/ens/ens_test.go
+++ b/contracts/ens/ens_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,10 +20,10 @@ import (
"math/big"
"testing"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/accounts/abi/bind/backends"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/crypto"
)
var (
diff --git a/contracts/release/contract.go b/contracts/release/contract.go
old mode 100644
new mode 100755
index 6a0b09931..29fac0579
--- a/contracts/release/contract.go
+++ b/contracts/release/contract.go
@@ -7,10 +7,10 @@ import (
"math/big"
"strings"
- "github.com/ethereum/go-ethereum/accounts/abi"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core/types"
+ "github.com/wtc/go-wtc/accounts/abi"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core/types"
)
// ReleaseOracleABI is the input ABI used to generate the binding from.
@@ -19,7 +19,7 @@ const ReleaseOracleABI = `[{"constant":true,"inputs":[],"name":"proposedVersion"
// ReleaseOracleBin is the compiled bytecode used for deploying new contracts.
const ReleaseOracleBin = `0x606060405260405161135338038061135383398101604052805101600081516000141561008457600160a060020a0333168152602081905260408120805460ff19166001908117909155805480820180835582818380158290116100ff576000838152602090206100ff9181019083015b8082111561012f5760008155600101610070565b5060005b815181101561011f5760016000600050600084848151811015610002576020908102909101810151600160a060020a03168252810191909152604001600020805460ff1916909117905560018054808201808355828183801582901161013357600083815260209020610133918101908301610070565b5050506000928352506020909120018054600160a060020a031916331790555b50506111df806101746000396000f35b5090565b50505091909060005260206000209001600084848151811015610002575050506020838102850101518154600160a060020a0319161790555060010161008856606060405236156100775760e060020a600035046326db7648811461007957806346f0975a1461019e5780635c3d005d1461020a57806364ed31fe146102935780639d888e861461038d578063bc8fbbf8146103b2578063bf8ecf9c146103fc578063d0e0813a14610468578063d67cbec914610479575b005b610496604080516020818101835260008083528351808301855281815260045460068054875181870281018701909852808852939687968796879691959463ffffffff818116956401000000008304821695604060020a840490921694606060020a938490049093029390926007929184919083018282801561012657602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610107575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561018357602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610164575b50505050509050955095509550955095509550909192939495565b6040805160208181018352600082526001805484518184028101840190955280855261055894928301828280156101ff57602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116101e0575b505050505090505b90565b61007760043561066d8160005b600160a060020a033316600090815260208190526040812054819060ff161561070057600160a060020a038416815260026020526040812091505b8154811015610706578154600160a060020a033316908390839081101561000257600091825260209091200154600160a060020a0316141561075157610700565b6105a26004356040805160208181018352600080835283518083018552818152600160a060020a038616825260028352908490208054855181850281018501909652808652939491939092600184019291849183018282801561032057602002820191906000526020600020905b8154600160a060020a0316815260019190910190602001808311610301575b505050505091508080548060200260200160405190810160405280929190818152602001828054801561037d57602002820191906000526020600020905b8154600160a060020a031681526001919091019060200180831161035e575b5050505050905091509150915091565b61062760006000600060006000600060086000508054905060001415610670576106f1565b6100776106f96000808080805b600160a060020a033316600090815260208190526040812054819060ff16156111b657821580156103f257506006546000145b15610c2e576111b6565b6040805160208181018352600082526003805484518184028101840190955280855261055894928301828280156101ff57602002820191906000526020600020908154600160a060020a03168152600191909101906020018083116101e0575b50505050509050610207565b61007760043561066d816001610217565b6100776004356024356044356064356107008484848460016103bf565b604051808763ffffffff1681526020018663ffffffff1681526020018563ffffffff168152602001846bffffffffffffffffffffffff1916815260200180602001806020018381038352858181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050018381038252848181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019850505050505050505060405180910390f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b6040518080602001806020018381038352858181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050018381038252848181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f15090500194505050505060405180910390f35b6040805163ffffffff9687168152948616602086015292909416838301526bffffffffffffffffffffffff19166060830152608082019290925290519081900360a00190f35b50565b600880546000198101908110156100025760009182526004027ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30190508054600182015463ffffffff8281169950640100000000830481169850604060020a8304169650606060020a91829004909102945067ffffffffffffffff16925090505b509091929394565b565b505050505b50505050565b5060005b60018201548110156107595733600160a060020a03168260010160005082815481101561000257600091825260209091200154600160a060020a031614156107a357610700565b600101610252565b8154600014801561076e575060018201546000145b156107cb57600380546001810180835582818380158290116107ab578183600052602060002091820191016107ab9190610851565b60010161070a565b5050506000928352506020909120018054600160a060020a031916851790555b821561086957815460018101808455839190828183801582901161089e5760008381526020902061089e918101908301610851565b5050506000928352506020909120018054600160a060020a031916851790555b600160a060020a038416600090815260026020908152604082208054838255818452918320909291610b2f91908101905b808211156108655760008155600101610851565b5090565b816001016000508054806001018281815481835581811511610950578183600052602060002091820191016109509190610851565b5050506000928352506020909120018054600160a060020a031916331790556001548254600290910490116108d257610700565b8280156108f85750600160a060020a03841660009081526020819052604090205460ff16155b1561098757600160a060020a0384166000908152602081905260409020805460ff1916600190811790915580548082018083558281838015829011610800578183600052602060002091820191016108009190610851565b5050506000928352506020909120018054600160a060020a031916331790556001805490830154600290910490116108d257610700565b821580156109ad5750600160a060020a03841660009081526020819052604090205460ff165b156108205750600160a060020a0383166000908152602081905260408120805460ff191690555b6001548110156108205783600160a060020a0316600160005082815481101561000257600091825260209091200154600160a060020a03161415610aa357600180546000198101908110156100025760206000908120929052600180549290910154600160a060020a031691839081101561000257906000526020600020900160006101000a815481600160a060020a030219169083021790555060016000508054809190600190039090815481835581811511610aab57600083815260209020610aab918101908301610851565b6001016109d4565b5050600060048181556005805467ffffffffffffffff19169055600680548382558184529194509192508290610b05907ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b5060018201805460008083559182526020909120610b2591810190610851565b5050505050610820565b5060018201805460008083559182526020909120610b4f91810190610851565b506000925050505b6003548110156107005783600160a060020a0316600360005082815481101561000257600091825260209091200154600160a060020a03161415610c2657600380546000198101908110156100025760206000908120929052600380549290910154600160a060020a031691839081101561000257906000526020600020900160006101000a815481600160a060020a0302191690830217905550600360005080548091906001900390908154818355818115116106fb576000838152602090206106fb918101908301610851565b600101610b57565b60065460001415610c8c576004805463ffffffff1916881767ffffffff0000000019166401000000008802176bffffffff00000000000000001916604060020a8702176bffffffffffffffffffffffff16606060020a808704021790555b828015610d08575060045463ffffffff8881169116141580610cc1575060045463ffffffff8781166401000000009092041614155b80610cde575060045463ffffffff868116604060020a9092041614155b80610d085750600454606060020a90819004026bffffffffffffffffffffffff1990811690851614155b15610d12576111b6565b506006905060005b8154811015610d5b578154600160a060020a033316908390839081101561000257600091825260209091200154600160a060020a03161415610da6576111b6565b5060005b6001820154811015610dae5733600160a060020a03168260010160005082815481101561000257600091825260209091200154600160a060020a03161415610de3576111b6565b600101610d1a565b8215610deb578154600181018084558391908281838015829011610e2057600083815260209020610e20918101908301610851565b600101610d5f565b816001016000508054806001018281815481835581811511610ea357818360005260206000209182019101610ea39190610851565b5050506000928352506020909120018054600160a060020a03191633179055600154825460029091049011610e54576111b6565b8215610eda576005805467ffffffffffffffff19164217905560088054600181018083558281838015829011610f2f57600402816004028360005260206000209182019101610f2f9190611048565b5050506000928352506020909120018054600160a060020a03191633179055600180549083015460029091049011610e54576111b6565b600060048181556005805467ffffffffffffffff191690556006805483825581845291929182906111bf907ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b5050509190906000526020600020906004020160005060048054825463ffffffff191663ffffffff9182161780845582546401000000009081900483160267ffffffff000000001991909116178084558254604060020a908190049092169091026bffffffff00000000000000001991909116178083558154606060020a908190048102819004026bffffffffffffffffffffffff9190911617825560055460018301805467ffffffffffffffff191667ffffffffffffffff9092169190911790556006805460028401805482825560008281526020902094959491928392918201918582156110a75760005260206000209182015b828111156110a7578254825591600101919060010190611025565b505050506004015b8082111561086557600080825560018201805467ffffffffffffffff191690556002820180548282558183526020832083916110879190810190610851565b506001820180546000808355918252602090912061104091810190610851565b506110cd9291505b80821115610865578054600160a060020a03191681556001016110af565b505060018181018054918401805480835560008381526020902092938301929091821561111b5760005260206000209182015b8281111561111b578254825591600101919060010190611100565b506111279291506110af565b5050600060048181556005805467ffffffffffffffff191690556006805483825581845291975091955090935084925061118691507ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f90810190610851565b50600182018054600080835591825260209091206111a691810190610851565b50505050506111b6565b50505050505b50505050505050565b50600182018054600080835591825260209091206111b09181019061085156`
-// DeployReleaseOracle deploys a new Ethereum contract, binding an instance of ReleaseOracle to it.
+// DeployReleaseOracle deploys a new Wtc contract, binding an instance of ReleaseOracle to it.
func DeployReleaseOracle(auth *bind.TransactOpts, backend bind.ContractBackend, signers []common.Address) (common.Address, *types.Transaction, *ReleaseOracle, error) {
parsed, err := abi.JSON(strings.NewReader(ReleaseOracleABI))
if err != nil {
@@ -32,23 +32,23 @@ func DeployReleaseOracle(auth *bind.TransactOpts, backend bind.ContractBackend,
return address, tx, &ReleaseOracle{ReleaseOracleCaller: ReleaseOracleCaller{contract: contract}, ReleaseOracleTransactor: ReleaseOracleTransactor{contract: contract}}, nil
}
-// ReleaseOracle is an auto generated Go binding around an Ethereum contract.
+// ReleaseOracle is an auto generated Go binding around an Wtc contract.
type ReleaseOracle struct {
ReleaseOracleCaller // Read-only binding to the contract
ReleaseOracleTransactor // Write-only binding to the contract
}
-// ReleaseOracleCaller is an auto generated read-only Go binding around an Ethereum contract.
+// ReleaseOracleCaller is an auto generated read-only Go binding around an Wtc contract.
type ReleaseOracleCaller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ReleaseOracleTransactor is an auto generated write-only Go binding around an Ethereum contract.
+// ReleaseOracleTransactor is an auto generated write-only Go binding around an Wtc contract.
type ReleaseOracleTransactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
-// ReleaseOracleSession is an auto generated Go binding around an Ethereum contract,
+// ReleaseOracleSession is an auto generated Go binding around an Wtc contract,
// with pre-set call and transact options.
type ReleaseOracleSession struct {
Contract *ReleaseOracle // Generic contract binding to set the session for
@@ -56,31 +56,31 @@ type ReleaseOracleSession struct {
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ReleaseOracleCallerSession is an auto generated read-only Go binding around an Ethereum contract,
+// ReleaseOracleCallerSession is an auto generated read-only Go binding around an Wtc contract,
// with pre-set call options.
type ReleaseOracleCallerSession struct {
Contract *ReleaseOracleCaller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
-// ReleaseOracleTransactorSession is an auto generated write-only Go binding around an Ethereum contract,
+// ReleaseOracleTransactorSession is an auto generated write-only Go binding around an Wtc contract,
// with pre-set transact options.
type ReleaseOracleTransactorSession struct {
Contract *ReleaseOracleTransactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
-// ReleaseOracleRaw is an auto generated low-level Go binding around an Ethereum contract.
+// ReleaseOracleRaw is an auto generated low-level Go binding around an Wtc contract.
type ReleaseOracleRaw struct {
Contract *ReleaseOracle // Generic contract binding to access the raw methods on
}
-// ReleaseOracleCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
+// ReleaseOracleCallerRaw is an auto generated low-level read-only Go binding around an Wtc contract.
type ReleaseOracleCallerRaw struct {
Contract *ReleaseOracleCaller // Generic read-only contract binding to access the raw methods on
}
-// ReleaseOracleTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
+// ReleaseOracleTransactorRaw is an auto generated low-level write-only Go binding around an Wtc contract.
type ReleaseOracleTransactorRaw struct {
Contract *ReleaseOracleTransactor // Generic write-only contract binding to access the raw methods on
}
diff --git a/contracts/release/contract.sol b/contracts/release/contract.sol
old mode 100644
new mode 100755
index 554cf7290..66ea6cd52
--- a/contracts/release/contract.sol
+++ b/contracts/release/contract.sol
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,13 +14,13 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// ReleaseOracle is an Ethereum contract to store the current and previous
-// versions of the go-ethereum implementation. Its goal is to allow Geth to
+// ReleaseOracle is an Wtc contract to store the current and previous
+// versions of the go-wtc implementation. Its goal is to allow Gwtc to
// check for new releases automatically without the need to consult a central
// repository.
//
// The contract takes a vote based approach on both assigning authorised signers
-// as well as signing off on new Geth releases.
+// as well as signing off on new Gwtc releases.
//
// Note, when a signer is demoted, the currently pending release is auto-nuked.
// The reason is to prevent suprises where a demotion actually tilts the votes
@@ -33,7 +33,7 @@ contract ReleaseOracle {
address[] fail; // List of signers voting to fail a proposal
}
- // Version is the version details of a particular Geth release
+ // Version is the version details of a particular Gwtc release
struct Version {
uint32 major; // Major version component of the release
uint32 minor; // Minor version component of the release
@@ -135,7 +135,7 @@ contract ReleaseOracle {
updateRelease(0, 0, 0, 0, false);
}
- // updateSigner marks a vote for changing the status of an Ethereum user, either
+ // updateSigner marks a vote for changing the status of an Wtc user, either
// for or against the user being an authorised signer.
function updateSigner(address user, bool authorize) internal isSigner {
// Gather the current votes and ensure we don't double vote
diff --git a/contracts/release/contract_test.go b/contracts/release/contract_test.go
old mode 100644
new mode 100755
index 0b2b2f048..f8fb28380
--- a/contracts/release/contract_test.go
+++ b/contracts/release/contract_test.go
@@ -1,12 +1,12 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,11 +21,11 @@ import (
"math/big"
"testing"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/core"
- "github.com/ethereum/go-ethereum/crypto"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/accounts/abi/bind/backends"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/core"
+ "github.com/wtc/go-wtc/crypto"
)
// setupReleaseTest creates a blockchain simulator and deploys a version oracle
diff --git a/contracts/release/release.go b/contracts/release/release.go
old mode 100644
new mode 100755
index 28a35381d..e6e8beb30
--- a/contracts/release/release.go
+++ b/contracts/release/release.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -25,15 +25,15 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/accounts/abi/bind"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/eth"
- "github.com/ethereum/go-ethereum/internal/ethapi"
- "github.com/ethereum/go-ethereum/les"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/p2p"
- "github.com/ethereum/go-ethereum/rpc"
+ "github.com/wtc/go-wtc/accounts/abi/bind"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/wtc"
+ "github.com/wtc/go-wtc/internal/ethapi"
+ "github.com/wtc/go-wtc/les"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/node"
+ "github.com/wtc/go-wtc/p2p"
+ "github.com/wtc/go-wtc/rpc"
)
// Interval to check for new releases
@@ -41,7 +41,7 @@ const releaseRecheckInterval = time.Hour
// Config contains the configurations of the release service.
type Config struct {
- Oracle common.Address // Ethereum address of the release oracle
+ Oracle common.Address // Wtc address of the release oracle
Major uint32 // Major version component of the release
Minor uint32 // Minor version component of the release
Patch uint32 // Patch version component of the release
@@ -60,15 +60,15 @@ type ReleaseService struct {
// NewReleaseService creates a new service to periodically check for new client
// releases and notify the user of such.
func NewReleaseService(ctx *node.ServiceContext, config Config) (node.Service, error) {
- // Retrieve the Ethereum service dependency to access the blockchain
+ // Retrieve the Wtc service dependency to access the blockchain
var apiBackend ethapi.Backend
- var ethereum *eth.Ethereum
- if err := ctx.Service(&ethereum); err == nil {
- apiBackend = ethereum.ApiBackend
+ var wtc *eth.Wtc
+ if err := ctx.Service(&wtc); err == nil {
+ apiBackend = wtc.ApiBackend
} else {
- var ethereum *les.LightEthereum
- if err := ctx.Service(&ethereum); err == nil {
- apiBackend = ethereum.ApiBackend
+ var wtc *les.LightWtc
+ if err := ctx.Service(&wtc); err == nil {
+ apiBackend = wtc.ApiBackend
} else {
return nil, err
}
@@ -149,7 +149,7 @@ func (r *ReleaseService) checkVersion() {
warning := fmt.Sprintf("Client v%d.%d.%d-%x seems older than the latest upstream release v%d.%d.%d-%x",
r.config.Major, r.config.Minor, r.config.Patch, r.config.Commit[:4], version.Major, version.Minor, version.Patch, version.Commit[:4])
- howtofix := fmt.Sprintf("Please check https://github.com/ethereum/go-ethereum/releases for new releases")
+ howtofix := fmt.Sprintf("Please check https://github.com/wtc/go-wtc/releases for new releases")
separator := strings.Repeat("-", len(warning))
log.Warn(separator)
diff --git a/core/.gitignore b/core/.gitignore
old mode 100644
new mode 100755
diff --git a/core/asm/asm.go b/core/asm/asm.go
old mode 100644
new mode 100755
index 5fe827e7c..ea14472b3
--- a/core/asm/asm.go
+++ b/core/asm/asm.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,7 +21,7 @@ import (
"encoding/hex"
"fmt"
- "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/wtc/go-wtc/core/vm"
)
// Iterator for disassembled EVM instructions
diff --git a/core/asm/asm_test.go b/core/asm/asm_test.go
old mode 100644
new mode 100755
index 92b26b67a..f050b27cf
--- a/core/asm/asm_test.go
+++ b/core/asm/asm_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/core/asm/compiler.go b/core/asm/compiler.go
old mode 100644
new mode 100755
index b2c85375c..34e6ac202
--- a/core/asm/compiler.go
+++ b/core/asm/compiler.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,8 +23,8 @@ import (
"os"
"strings"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/core/vm"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/core/vm"
)
// Compiler contains information about the parsed source
diff --git a/core/asm/lex_test.go b/core/asm/lex_test.go
old mode 100644
new mode 100755
index e6901d4e3..2fb42746a
--- a/core/asm/lex_test.go
+++ b/core/asm/lex_test.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/core/asm/lexer.go b/core/asm/lexer.go
old mode 100644
new mode 100755
index a34b2cbd8..b688f5db7
--- a/core/asm/lexer.go
+++ b/core/asm/lexer.go
@@ -1,12 +1,12 @@
// Copyright 2017 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
diff --git a/core/bench_test.go b/core/bench_test.go
old mode 100644
new mode 100755
index ab25c27d3..8ba38611d
--- a/core/bench_test.go
+++ b/core/bench_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -23,14 +23,14 @@ import (
"os"
"testing"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/params"
)
func BenchmarkInsertChain_empty_memdb(b *testing.B) {
@@ -147,16 +147,16 @@ func genUncles(i int, gen *BlockGen) {
func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
// Create the database in memory or in a temporary directory.
- var db ethdb.Database
+ var db wtcdb.Database
if !disk {
- db, _ = ethdb.NewMemDatabase()
+ db, _ = wtcdb.NewMemDatabase()
} else {
dir, err := ioutil.TempDir("", "eth-core-bench")
if err != nil {
b.Fatalf("cannot create temporary directory: %v", err)
}
defer os.RemoveAll(dir)
- db, err = ethdb.NewLDBDatabase(dir, 128, 128)
+ db, err = wtcdb.NewLDBDatabase(dir, 128, 128)
if err != nil {
b.Fatalf("cannot create temporary database: %v", err)
}
@@ -222,7 +222,7 @@ func BenchmarkChainWrite_full_500k(b *testing.B) {
// makeChainForBench writes a given number of headers or empty blocks/receipts
// into a database.
-func makeChainForBench(db ethdb.Database, full bool, count uint64) {
+func makeChainForBench(db wtcdb.Database, full bool, count uint64) {
var hash common.Hash
for n := uint64(0); n < count; n++ {
header := &types.Header{
@@ -252,7 +252,7 @@ func benchWriteChain(b *testing.B, full bool, count uint64) {
if err != nil {
b.Fatalf("cannot create temporary directory: %v", err)
}
- db, err := ethdb.NewLDBDatabase(dir, 128, 1024)
+ db, err := wtcdb.NewLDBDatabase(dir, 128, 1024)
if err != nil {
b.Fatalf("error opening database at %v: %v", dir, err)
}
@@ -269,7 +269,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
}
defer os.RemoveAll(dir)
- db, err := ethdb.NewLDBDatabase(dir, 128, 1024)
+ db, err := wtcdb.NewLDBDatabase(dir, 128, 1024)
if err != nil {
b.Fatalf("error opening database at %v: %v", dir, err)
}
@@ -280,7 +280,7 @@ func benchReadChain(b *testing.B, full bool, count uint64) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
- db, err := ethdb.NewLDBDatabase(dir, 128, 1024)
+ db, err := wtcdb.NewLDBDatabase(dir, 128, 1024)
if err != nil {
b.Fatalf("error opening database at %v: %v", dir, err)
}
diff --git a/core/block_validator.go b/core/block_validator.go
old mode 100644
new mode 100755
index e9cfd0482..4462719bf
--- a/core/block_validator.go
+++ b/core/block_validator.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -20,11 +20,11 @@ import (
"fmt"
"math/big"
- "github.com/ethereum/go-ethereum/common/math"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common/math"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/params"
)
// BlockValidator is responsible for validating block headers, uncles and
@@ -69,6 +69,7 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
if hash := types.DeriveSha(block.Transactions()); hash != header.TxHash {
return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash)
}
+
return nil
}
@@ -97,6 +98,24 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
if root := statedb.IntermediateRoot(v.config.IsEIP158(header.Number)); header.Root != root {
return fmt.Errorf("invalid merkle root (remote: %x local: %x)", header.Root, root)
}
+
+ // Validate the balance need to be great than MinGasFloorCreateContract to create contract.
+ // add by disy.yin disy.yin@gmail.com 2018-12-10
+ transactions := block.Transactions()
+ for i,transaction := range transactions {
+ from, err := transaction.From()
+ if err == nil {
+ balanceNow := statedb.GetBalance(from)
+ balanceBefore := new(big.Int).Add(balanceNow, transaction.Value())
+ totalGas := new(big.Int).Mul(transaction.Gas(), transaction.GasPrice())
+ balanceBefore = new(big.Int).Add(balanceBefore, totalGas)
+ gasFloor := new(big.Int).Mul(params.MinGasFloorCreateContract, big.NewInt(1e+18))
+ if balanceBefore.Cmp(gasFloor) < 0 && transaction.To() == nil {
+ return fmt.Errorf("Not enough balance(%s) < %s with sender to create contract, transaction[%s] intend to create contract.", balanceBefore, gasFloor, big.NewInt(int64(i)))
+ }
+ }
+ }
+
return nil
}
diff --git a/core/block_validator_test.go b/core/block_validator_test.go
old mode 100644
new mode 100755
index 6d54c2b93..239ced013
--- a/core/block_validator_test.go
+++ b/core/block_validator_test.go
@@ -1,12 +1,12 @@
// Copyright 2015 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -21,18 +21,18 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/params"
)
// Tests that simple header verification works, for both good and bad blocks.
func TestHeaderVerification(t *testing.T) {
// Create a simple chain to verify
var (
- testdb, _ = ethdb.NewMemDatabase()
+ testdb, _ = wtcdb.NewMemDatabase()
gspec = &Genesis{Config: params.TestChainConfig}
genesis = gspec.MustCommit(testdb)
blocks, _ = GenerateChain(params.TestChainConfig, genesis, testdb, 8, nil)
@@ -84,7 +84,7 @@ func TestHeaderConcurrentVerification32(t *testing.T) { testHeaderConcurrentVeri
func testHeaderConcurrentVerification(t *testing.T, threads int) {
// Create a simple chain to verify
var (
- testdb, _ = ethdb.NewMemDatabase()
+ testdb, _ = wtcdb.NewMemDatabase()
gspec = &Genesis{Config: params.TestChainConfig}
genesis = gspec.MustCommit(testdb)
blocks, _ = GenerateChain(params.TestChainConfig, genesis, testdb, 8, nil)
@@ -156,7 +156,7 @@ func TestHeaderConcurrentAbortion32(t *testing.T) { testHeaderConcurrentAbortion
func testHeaderConcurrentAbortion(t *testing.T, threads int) {
// Create a simple chain to verify
var (
- testdb, _ = ethdb.NewMemDatabase()
+ testdb, _ = wtcdb.NewMemDatabase()
gspec = &Genesis{Config: params.TestChainConfig}
genesis = gspec.MustCommit(testdb)
blocks, _ = GenerateChain(params.TestChainConfig, genesis, testdb, 1024, nil)
diff --git a/core/blockchain.go b/core/blockchain.go
old mode 100644
new mode 100755
index 325753c7a..8004e54c4
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
-// Package core implements the Ethereum consensus protocol.
+// Package core implements the Wtc consensus protocol.
package core
import (
@@ -27,20 +27,20 @@ import (
"sync/atomic"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/mclock"
- "github.com/ethereum/go-ethereum/consensus"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/event"
- "github.com/ethereum/go-ethereum/log"
- "github.com/ethereum/go-ethereum/metrics"
- "github.com/ethereum/go-ethereum/params"
- "github.com/ethereum/go-ethereum/rlp"
- "github.com/ethereum/go-ethereum/trie"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/common/mclock"
+ "github.com/wtc/go-wtc/consensus"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/event"
+ "github.com/wtc/go-wtc/log"
+ "github.com/wtc/go-wtc/metrics"
+ "github.com/wtc/go-wtc/params"
+ "github.com/wtc/go-wtc/rlp"
+ "github.com/wtc/go-wtc/trie"
"github.com/hashicorp/golang-lru"
)
@@ -79,7 +79,7 @@ type BlockChain struct {
config *params.ChainConfig // chain & network configuration
hc *HeaderChain
- chainDb ethdb.Database
+ chainDb wtcdb.Database
rmLogsFeed event.Feed
chainFeed event.Feed
chainSideFeed event.Feed
@@ -117,9 +117,9 @@ type BlockChain struct {
}
// NewBlockChain returns a fully initialised block chain using information
-// available in the database. It initialises the default Ethereum Validator and
+// available in the database. It initialises the default Wtc Validator and
// Processor.
-func NewBlockChain(chainDb ethdb.Database, config *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) {
+func NewBlockChain(chainDb wtcdb.Database, config *params.ChainConfig, engine consensus.Engine, vmConfig vm.Config) (*BlockChain, error) {
bodyCache, _ := lru.New(bodyCacheLimit)
bodyRLPCache, _ := lru.New(bodyCacheLimit)
blockCache, _ := lru.New(blockCacheLimit)
@@ -222,11 +222,11 @@ func (bc *BlockChain) loadLastState() error {
// Issue a status log for the user
headerTd := bc.GetTd(currentHeader.Hash(), currentHeader.Number.Uint64())
blockTd := bc.GetTd(bc.currentBlock.Hash(), bc.currentBlock.NumberU64())
- fastTd := bc.GetTd(bc.currentFastBlock.Hash(), bc.currentFastBlock.NumberU64())
+ // fastTd := bc.GetTd(bc.currentFastBlock.Hash(), bc.currentFastBlock.NumberU64())
- log.Info("Loaded most recent local header", "number", currentHeader.Number, "hash", currentHeader.Hash(), "td", headerTd)
- log.Info("Loaded most recent local full block", "number", bc.currentBlock.Number(), "hash", bc.currentBlock.Hash(), "td", blockTd)
- log.Info("Loaded most recent local fast block", "number", bc.currentFastBlock.Number(), "hash", bc.currentFastBlock.Hash(), "td", fastTd)
+ log.Info("Local recent header", "number", currentHeader.Number, "hash", currentHeader.Hash(), "td", headerTd)
+ log.Info("Local most recent full block", "number", bc.currentBlock.Number(), "hash", bc.currentBlock.Hash(), "td", blockTd)
+ // log.Info("Loaded most recent local fast block", "number", bc.currentFastBlock.Number(), "hash", bc.currentFastBlock.Hash(), "td", fastTd)
return nil
}
@@ -376,8 +376,9 @@ func (bc *BlockChain) Processor() Processor {
}
// State returns a new mutable state based on the current HEAD block.
-func (bc *BlockChain) State() (*state.StateDB, error) {
- return bc.StateAt(bc.CurrentBlock().Root())
+func (bc *BlockChain) State() (*state.StateDB, error, *big.Int, *big.Int) {
+ s,e := bc.StateAt(bc.CurrentBlock().Root())
+ return s,e, bc.CurrentBlock().Header().Number, bc.CurrentBlock().Header().Time
}
// StateAt returns a new mutable state based on a particular point in time.
@@ -744,7 +745,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
}
stats.processed++
- if batch.ValueSize() >= ethdb.IdealBatchSize {
+ if batch.ValueSize() >= wtcdb.IdealBatchSize {
if err := batch.Write(); err != nil {
return 0, err
}
@@ -818,12 +819,7 @@ func (bc *BlockChain) WriteBlockAndState(block *types.Block, receipts []*types.R
// If the total difficulty is higher than our known, add it to the canonical chain
// Second clause in the if statement reduces the vulnerability to selfish mining.
// Please refer to http://www.cs.cornell.edu/~ie53/publications/btcProcFC.pdf
- reorg := externTd.Cmp(localTd) > 0
- if !reorg && externTd.Cmp(localTd) == 0 {
- // Split same-difficulty blocks by number, then at random
- reorg = block.NumberU64() < bc.currentBlock.NumberU64() || (block.NumberU64() == bc.currentBlock.NumberU64() && mrand.Float64() < 0.5)
- }
- if reorg {
+ if externTd.Cmp(localTd) > 0 || (externTd.Cmp(localTd) == 0 && mrand.Float64() < 0.5) {
// Reorganise the chain if the parent is not the head block
if block.ParentHash() != bc.currentBlock.Hash() {
if err := bc.reorg(bc.currentBlock, block); err != nil {
@@ -1039,9 +1035,8 @@ func (st *insertStats) report(chain []*types.Block, index int) {
txs = countTransactions(chain[st.lastIndex : index+1])
)
context := []interface{}{
- "blocks", st.processed, "txs", txs, "mgas", float64(st.usedGas) / 1000000,
- "elapsed", common.PrettyDuration(elapsed), "mgasps", float64(st.usedGas) * 1000 / float64(elapsed),
- "number", end.Number(), "hash", end.Hash(),
+ "blocks", st.processed, "txs", txs,
+ "blockheight", end.Number(), "hash", end.Hash(),
}
if st.queued > 0 {
context = append(context, []interface{}{"queued", st.queued}...)
@@ -1049,7 +1044,7 @@ func (st *insertStats) report(chain []*types.Block, index int) {
if st.ignored > 0 {
context = append(context, []interface{}{"ignored", st.ignored}...)
}
- log.Info("Imported new chain segment", context...)
+ log.Info("Update data from other nodes", context...)
*st = insertStats{startTime: now, lastIndex: index + 1}
}
@@ -1259,28 +1254,13 @@ Error: %v
// should be done or not. The reason behind the optional check is because some
// of the header retrieval mechanisms already need to verify nonces, as well as
// because nonces can be verified sparsely, not needing to check each.
-func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
- start := time.Now()
- if i, err := bc.hc.ValidateHeaderChain(chain, checkFreq); err != nil {
- return i, err
+func (bc *BlockChain) InsertHeaderChain(chain types.Blocks) (int, error) {
+// func (bc *BlockChain) InsertHeaderChain(chain []*types.Header, checkFreq int) (int, error) {
+ lightblocks := make([]*types.Block, len(chain))
+ for i,h := range chain {
+ lightblocks[i] = bc.GetBlockByHash(h.Hash())
}
-
- // Make sure only one thread manipulates the chain at once
- bc.chainmu.Lock()
- defer bc.chainmu.Unlock()
-
- bc.wg.Add(1)
- defer bc.wg.Done()
-
- whFunc := func(header *types.Header) error {
- bc.mu.Lock()
- defer bc.mu.Unlock()
-
- _, err := bc.hc.WriteHeader(header)
- return err
- }
-
- return bc.hc.InsertHeaderChain(chain, whFunc, start)
+ return bc.InsertChain(lightblocks)
}
// writeHeader writes a header into the local chain, given that its parent is
@@ -1360,6 +1340,12 @@ func (bc *BlockChain) Config() *params.ChainConfig { return bc.config }
// Engine retrieves the blockchain's consensus engine.
func (bc *BlockChain) Engine() consensus.Engine { return bc.engine }
+
+func (bc *BlockChain) GetBalanceAndCoinAgeByHeaderHash(addr common.Address) (*big.Int, *big.Int, *big.Int, *big.Int) {
+ s,_,Number,Time :=bc.State()
+ return s.GetBalance(addr),s.GetCoinAge(addr,Number,Time),Number,Time
+}
+
// SubscribeRemovedLogsEvent registers a subscription of RemovedLogsEvent.
func (bc *BlockChain) SubscribeRemovedLogsEvent(ch chan<- RemovedLogsEvent) event.Subscription {
return bc.scope.Track(bc.rmLogsFeed.Subscribe(ch))
diff --git a/core/blockchain_test.go b/core/blockchain_test.go
old mode 100644
new mode 100755
index cb1df8d4b..0e39e91e4
--- a/core/blockchain_test.go
+++ b/core/blockchain_test.go
@@ -1,12 +1,12 @@
// Copyright 2014 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
-// The go-ethereum library is free software: you can redistribute it and/or modify
+// The go-wtc library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// The go-ethereum library is distributed in the hope that it will be useful,
+// The go-wtc library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
@@ -24,19 +24,19 @@ import (
"testing"
"time"
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/consensus/ethash"
- "github.com/ethereum/go-ethereum/core/state"
- "github.com/ethereum/go-ethereum/core/types"
- "github.com/ethereum/go-ethereum/core/vm"
- "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/params"
+ "github.com/wtc/go-wtc/common"
+ "github.com/wtc/go-wtc/consensus/ethash"
+ "github.com/wtc/go-wtc/core/state"
+ "github.com/wtc/go-wtc/core/types"
+ "github.com/wtc/go-wtc/core/vm"
+ "github.com/wtc/go-wtc/crypto"
+ "github.com/wtc/go-wtc/wtcdb"
+ "github.com/wtc/go-wtc/params"
)
// newTestBlockChain creates a blockchain without validation.
func newTestBlockChain(fake bool) *BlockChain {
- db, _ := ethdb.NewMemDatabase()
+ db, _ := wtcdb.NewMemDatabase()
gspec := &Genesis{
Config: params.TestChainConfig,
Difficulty: big.NewInt(1),
@@ -577,7 +577,7 @@ func testInsertNonceError(t *testing.T, full bool) {
func TestFastVsFullChains(t *testing.T) {
// Configure and generate a sample block chain
var (
- gendb, _ = ethdb.NewMemDatabase()
+ gendb, _ = wtcdb.NewMemDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(1000000000)
@@ -607,7 +607,7 @@ func TestFastVsFullChains(t *testing.T) {
}
})
// Import the chain as an archive node for the comparison baseline
- archiveDb, _ := ethdb.NewMemDatabase()
+ archiveDb, _ := wtcdb.NewMemDatabase()
gspec.MustCommit(archiveDb)
archive, _ := NewBlockChain(archiveDb, gspec.Config, ethash.NewFaker(), vm.Config{})
defer archive.Stop()
@@ -616,7 +616,7 @@ func TestFastVsFullChains(t *testing.T) {
t.Fatalf("failed to process block %d: %v", n, err)
}
// Fast import the chain as a non-archive node to test
- fastDb, _ := ethdb.NewMemDatabase()
+ fastDb, _ := wtcdb.NewMemDatabase()
gspec.MustCommit(fastDb)
fast, _ := NewBlockChain(fastDb, gspec.Config, ethash.NewFaker(), vm.Config{})
defer fast.Stop()
@@ -665,7 +665,7 @@ func TestFastVsFullChains(t *testing.T) {
func TestLightVsFastVsFullChainHeads(t *testing.T) {
// Configure and generate a sample block chain
var (
- gendb, _ = ethdb.NewMemDatabase()
+ gendb, _ = wtcdb.NewMemDatabase()
key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
address = crypto.PubkeyToAddress(key.PublicKey)
funds = big.NewInt(1000000000)
@@ -693,7 +693,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
}
}
// Import the chain as an archive node and ensure all pointers are updated
- archiveDb, _ := ethdb.NewMemDatabase()
+ archiveDb, _ := wtcdb.NewMemDatabase()
gspec.MustCommit(archiveDb)
archive, _ := NewBlockChain(archiveDb, gspec.Config, ethash.NewFaker(), vm.Config{})
@@ -707,7 +707,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
assert(t, "archive", archive, height/2, height/2, height/2)
// Import the chain as a non-archive node and ensure all pointers are updated
- fastDb, _ := ethdb.NewMemDatabase()
+ fastDb, _ := wtcdb.NewMemDatabase()
gspec.MustCommit(fastDb)
fast, _ := NewBlockChain(fastDb, gspec.Config, ethash.NewFaker(), vm.Config{})
defer fast.Stop()
@@ -727,7 +727,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
assert(t, "fast", fast, height/2, height/2, 0)
// Import the chain as a light node and ensure all pointers are updated
- lightDb, _ := ethdb.NewMemDatabase()
+ lightDb, _ := wtcdb.NewMemDatabase()
gspec.MustCommit(lightDb)
light, _ := NewBlockChain(lightDb, gspec.Config, ethash.NewFaker(), vm.Config{})
@@ -750,7 +750,7 @@ func TestChainTxReorgs(t *testing.T) {
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
addr2 = crypto.PubkeyToAddress(key2.PublicKey)
addr3 = crypto.PubkeyToAddress(key3.PublicKey)
- db, _ = ethdb.NewMemDatabase()
+ db, _ = wtcdb.NewMemDatabase()
gspec = &Genesis{
Config: params.TestChainConfig,
GasLimit: 3141592,
@@ -862,7 +862,7 @@ func TestLogReorgs(t *testing.T) {
var (
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
- db, _ = ethdb.NewMemDatabase()
+ db, _ = wtcdb.NewMemDatabase()
// this code generates a log
code = common.Hex2Bytes("60606040525b7f24ec1d3ff24c2f6ff210738839dbc339cd45a5294d85c79361016243157aae7b60405180905060405180910390a15b600a8060416000396000f360606040526008565b00")
gspec = &Genesis{Config: params.TestChainConfig, Alloc: GenesisAlloc{addr1: {Balance: big.NewInt(10000000000000)}}}
@@ -906,7 +906,7 @@ func TestLogReorgs(t *testing.T) {
func TestReorgSideEvent(t *testing.T) {
var (
- db, _ = ethdb.NewMemDatabase()
+ db, _ = wtcdb.NewMemDatabase()
key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
addr1 = crypto.PubkeyToAddress(key1.PublicKey)
gspec = &Genesis{
@@ -1031,7 +1031,7 @@ func TestCanonicalBlockRetrieval(t *testing.T) {
func TestEIP155Tran
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment