├── LICENSE ├── README.md ├── compile.sh ├── createjar ├── keygen.sh ├── keysign.sh ├── makerelease.sh └── packager.sh ├── generate_package.sh ├── resources ├── db │ ├── ppk-1.db │ ├── ppk.h2.db │ ├── ppktest-1.db │ └── ppktest.h2.db ├── jars │ ├── IPFS.jar │ ├── bitcoinj-core-0.14.7-bundled.jar │ ├── freemarker.jar │ ├── gson-2.7.jar │ ├── jackson-annotations-2.0.0.jar │ ├── jackson-core-2.0.0.jar │ ├── jackson-databind-2.0.0.jar │ ├── java-json.jar │ ├── javax.servlet-5.1.12.jar │ ├── javax.servlet-api-3.1.0.jar │ ├── jetty9 │ │ ├── README.TXT │ │ ├── VERSION.txt │ │ ├── demo-base │ │ │ ├── etc │ │ │ │ ├── demo-rewrite-rules.xml │ │ │ │ ├── keystore │ │ │ │ ├── login.conf │ │ │ │ ├── login.properties │ │ │ │ ├── realm.properties │ │ │ │ └── test-realm.xml │ │ │ ├── lib │ │ │ │ └── ext │ │ │ │ │ ├── javax.mail.glassfish-1.4.1.v201005082020.jar │ │ │ │ │ └── test-mock-resources-9.1.4.v20140401.jar │ │ │ ├── start.d │ │ │ │ ├── http.ini │ │ │ │ ├── https.ini │ │ │ │ ├── jsp.ini │ │ │ │ └── ssl.ini │ │ │ ├── start.ini │ │ │ └── webapps │ │ │ │ ├── README.TXT │ │ │ │ ├── ROOT │ │ │ │ ├── images │ │ │ │ │ ├── jetty-header.jpg │ │ │ │ │ └── webtide_logo.jpg │ │ │ │ ├── index.html │ │ │ │ └── jetty.css │ │ │ │ ├── async-rest.war │ │ │ │ ├── example-moved.xml │ │ │ │ ├── test-jaas.war │ │ │ │ ├── test-jaas.xml │ │ │ │ ├── test-jndi.war │ │ │ │ ├── test-jndi.xml │ │ │ │ ├── test-spec.war │ │ │ │ ├── test-spec.xml │ │ │ │ ├── test.d │ │ │ │ └── override-web.xml │ │ │ │ ├── test.war │ │ │ │ ├── test.xml │ │ │ │ └── xref-proxy.war │ │ ├── etc │ │ │ ├── README.spnego │ │ │ ├── jdbcRealm.properties │ │ │ ├── jetty-annotations.xml │ │ │ ├── jetty-debug.xml │ │ │ ├── jetty-deploy.xml │ │ │ ├── jetty-http.xml │ │ │ ├── jetty-https.xml │ │ │ ├── jetty-ipaccess.xml │ │ │ ├── jetty-jaas.xml │ │ │ ├── jetty-jmx-remote.xml │ │ │ ├── jetty-jmx.xml │ │ │ ├── jetty-logging.xml │ │ │ ├── jetty-lowresources.xml │ │ │ ├── jetty-monitor.xml │ │ │ ├── jetty-plus.xml │ │ │ ├── jetty-proxy.xml │ │ │ ├── jetty-requestlog.xml │ │ │ ├── jetty-rewrite.xml │ │ │ ├── jetty-setuid.xml │ │ │ ├── jetty-spdy-proxy.xml │ │ │ ├── jetty-spdy.xml │ │ │ ├── jetty-ssl.xml │ │ │ ├── jetty-started.xml │ │ │ ├── jetty-stats.xml │ │ │ ├── jetty-xinetd.xml │ │ │ ├── jetty.conf │ │ │ ├── jetty.xml │ │ │ ├── keystore │ │ │ ├── krb5.ini │ │ │ ├── spnego.conf │ │ │ ├── spnego.properties │ │ │ └── webdefault.xml │ │ ├── lib │ │ │ ├── annotations │ │ │ │ ├── asm-4.1.jar │ │ │ │ ├── asm-commons-4.1.jar │ │ │ │ └── javax.annotation-api-1.2.jar │ │ │ ├── ext │ │ │ │ └── .donotdelete │ │ │ ├── fcgi │ │ │ │ ├── fcgi-client-9.1.4.v20140401.jar │ │ │ │ └── fcgi-server-9.1.4.v20140401.jar │ │ │ ├── jaspi │ │ │ │ └── javax.security.auth.message-1.0.0.v201108011116.jar │ │ │ ├── jetty-annotations-9.1.4.v20140401.jar │ │ │ ├── jetty-client-9.1.4.v20140401.jar │ │ │ ├── jetty-continuation-9.1.4.v20140401.jar │ │ │ ├── jetty-deploy-9.1.4.v20140401.jar │ │ │ ├── jetty-http-9.1.4.v20140401.jar │ │ │ ├── jetty-io-9.1.4.v20140401.jar │ │ │ ├── jetty-jaas-9.1.4.v20140401.jar │ │ │ ├── jetty-jaspi-9.1.4.v20140401.jar │ │ │ ├── jetty-jmx-9.1.4.v20140401.jar │ │ │ ├── jetty-jndi-9.1.4.v20140401.jar │ │ │ ├── jetty-plus-9.1.4.v20140401.jar │ │ │ ├── jetty-proxy-9.1.4.v20140401.jar │ │ │ ├── jetty-rewrite-9.1.4.v20140401.jar │ │ │ ├── jetty-schemas-3.1.jar │ │ │ ├── jetty-security-9.1.4.v20140401.jar │ │ │ ├── jetty-server-9.1.4.v20140401.jar │ │ │ ├── jetty-servlet-9.1.4.v20140401.jar │ │ │ ├── jetty-servlets-9.1.4.v20140401.jar │ │ │ ├── jetty-util-9.1.4.v20140401.jar │ │ │ ├── jetty-webapp-9.1.4.v20140401.jar │ │ │ ├── jetty-xml-9.1.4.v20140401.jar │ │ │ ├── jndi │ │ │ │ ├── javax.mail.glassfish-1.4.1.v201005082020.jar │ │ │ │ └── javax.transaction-api-1.2.jar │ │ │ ├── jsp │ │ │ │ ├── javax.el-3.0.0.jar │ │ │ │ ├── javax.servlet.jsp-2.3.2.jar │ │ │ │ ├── javax.servlet.jsp-api-2.3.1.jar │ │ │ │ ├── javax.servlet.jsp.jstl-1.2.2.jar │ │ │ │ ├── jetty-jsp-jdt-2.3.3.jar │ │ │ │ ├── org.eclipse.jdt.core-3.8.2.v20130121.jar │ │ │ │ └── org.eclipse.jetty.orbit.javax.servlet.jsp.jstl-1.2.0.v201105211821.jar │ │ │ ├── monitor │ │ │ │ └── jetty-monitor-9.1.4.v20140401.jar │ │ │ ├── servlet-api-3.1.jar │ │ │ ├── setuid │ │ │ │ ├── jetty-setuid-java-1.0.1.jar │ │ │ │ ├── libsetuid-linux.so │ │ │ │ └── libsetuid-osx.so │ │ │ ├── spdy │ │ │ │ ├── spdy-client-9.1.4.v20140401.jar │ │ │ │ ├── spdy-core-9.1.4.v20140401.jar │ │ │ │ ├── spdy-http-common-9.1.4.v20140401.jar │ │ │ │ ├── spdy-http-server-9.1.4.v20140401.jar │ │ │ │ └── spdy-server-9.1.4.v20140401.jar │ │ │ └── websocket │ │ │ │ ├── javax-websocket-client-impl-9.1.4.v20140401.jar │ │ │ │ ├── javax-websocket-server-impl-9.1.4.v20140401.jar │ │ │ │ ├── javax.websocket-api-1.0.jar │ │ │ │ ├── websocket-api-9.1.4.v20140401.jar │ │ │ │ ├── websocket-client-9.1.4.v20140401.jar │ │ │ │ ├── websocket-common-9.1.4.v20140401.jar │ │ │ │ ├── websocket-server-9.1.4.v20140401.jar │ │ │ │ └── websocket-servlet-9.1.4.v20140401.jar │ │ ├── license-eplv10-aslv20.html │ │ ├── logs │ │ │ └── .donotdelete │ │ ├── modules │ │ │ ├── .donotdelete │ │ │ ├── annotations.mod │ │ │ ├── client.mod │ │ │ ├── continuation.mod │ │ │ ├── debug.mod │ │ │ ├── deploy.mod │ │ │ ├── ext.mod │ │ │ ├── fcgi.mod │ │ │ ├── http.mod │ │ │ ├── https.mod │ │ │ ├── ipaccess.mod │ │ │ ├── jaas.mod │ │ │ ├── jaspi.mod │ │ │ ├── jmx-remote.mod │ │ │ ├── jmx.mod │ │ │ ├── jndi.mod │ │ │ ├── jsp.mod │ │ │ ├── jvm.mod │ │ │ ├── logging.mod │ │ │ ├── lowresources.mod │ │ │ ├── monitor.mod │ │ │ ├── npn.mod │ │ │ ├── npn │ │ │ │ ├── npn-1.7.0_04.mod │ │ │ │ ├── npn-1.7.0_05.mod │ │ │ │ ├── npn-1.7.0_06.mod │ │ │ │ ├── npn-1.7.0_07.mod │ │ │ │ ├── npn-1.7.0_09.mod │ │ │ │ ├── npn-1.7.0_10.mod │ │ │ │ ├── npn-1.7.0_11.mod │ │ │ │ ├── npn-1.7.0_13.mod │ │ │ │ ├── npn-1.7.0_15.mod │ │ │ │ ├── npn-1.7.0_17.mod │ │ │ │ ├── npn-1.7.0_21.mod │ │ │ │ ├── npn-1.7.0_25.mod │ │ │ │ ├── npn-1.7.0_40.mod │ │ │ │ ├── npn-1.7.0_45.mod │ │ │ │ └── npn-1.7.0_51.mod │ │ │ ├── plus.mod │ │ │ ├── proxy.mod │ │ │ ├── requestlog.mod │ │ │ ├── resources.mod │ │ │ ├── rewrite.mod │ │ │ ├── security.mod │ │ │ ├── server.mod │ │ │ ├── servlet.mod │ │ │ ├── servlets.mod │ │ │ ├── setuid.mod │ │ │ ├── spdy.mod │ │ │ ├── ssl.mod │ │ │ ├── stats.mod │ │ │ ├── webapp.mod │ │ │ ├── websocket.mod │ │ │ └── xinetd.mod │ │ ├── notice.html │ │ ├── resources │ │ │ └── log4j.properties │ │ ├── start.d │ │ │ ├── README.TXT │ │ │ ├── http.ini │ │ │ └── jsp.ini │ │ ├── start.ini │ │ ├── start.jar │ │ └── webapps │ │ │ └── README.TXT │ ├── jkademlia-1.7.jar │ ├── jsonrpc4j-1.0.jar │ ├── portlet-api-2.0-r12.jar │ ├── servlet-api-2.5.jar │ ├── slf4j-api-1.6.4-sources.jar │ ├── slf4j-api-1.6.4.jar │ ├── slf4j-ext-1.6.4-sources.jar │ ├── slf4j-ext-1.6.4.jar │ ├── slf4j-jcl-1.6.4-sources.jar │ ├── slf4j-jcl-1.6.4.jar │ ├── slf4j-jdk14-1.6.4-sources.jar │ ├── slf4j-jdk14-1.6.4.jar │ ├── slf4j-log4j12-1.6.4-sources.jar │ ├── slf4j-log4j12-1.6.4.jar │ ├── slf4j-migrator-1.6.4.jar │ ├── slf4j-nop-1.6.4-sources.jar │ ├── slf4j-nop-1.6.4.jar │ ├── slf4j-simple-1.6.4-sources.jar │ ├── slf4j-simple-1.6.4.jar │ ├── spark-core-1.1.1.jar │ ├── spark-template-freemarker-1.0.jar │ ├── spark-template-velocity-1.0.jar │ ├── spongycastle-prov-1.58.0.0.jar │ └── sqlite-jdbc-3.7.15-M1.jar ├── ppk.conf ├── shell │ ├── README.md.txt │ ├── ppk.bat │ ├── ppk.sh │ ├── ppk_browser.bat │ ├── ppk_browser.sh │ ├── ppk_daemon.bat │ ├── ppk_daemon.sh │ ├── ppk_guiserver.bat │ ├── ppk_guiserver.sh │ ├── update.bat │ └── update.sh ├── static │ ├── css │ │ └── style.css │ ├── images │ │ ├── add-user.png │ │ ├── add.png │ │ ├── aperture_alt_32x32.png │ │ ├── back.png │ │ ├── bookmark.png │ │ ├── calendar_alt_stroke_32x32.png │ │ ├── cog_32x32.png │ │ ├── color_wheel.png │ │ ├── comment.png │ │ ├── cubes_background.jpg │ │ ├── faq.png │ │ ├── favicon.ico │ │ ├── forward.png │ │ ├── fullscreen_exit_32x32.png │ │ ├── go.png │ │ ├── home.png │ │ ├── info.png │ │ ├── logo.png │ │ ├── ok.png │ │ ├── refresh.png │ │ ├── search.png │ │ ├── setting.png │ │ ├── star.png │ │ ├── stop.png │ │ ├── t-topic.jpg │ │ ├── user.png │ │ └── wallet.png │ └── lang │ │ └── CN.txt └── templates │ ├── broadcast-tx.html │ ├── check-sign.html │ ├── community.html │ ├── confirm-tx.html │ ├── error.html │ ├── index.html │ ├── index_nowallet.html │ ├── odin-add.html │ ├── odin-ap-edit.html │ ├── odin-ap-sign.html │ ├── odin-browser.html │ ├── odin-check-ap-vd.html │ ├── odin-confirm.html │ ├── odin-create-first-ap-old.html │ ├── odin-create-first-ap.html │ ├── odin-detail.html │ ├── odin-match.html │ ├── odin-more-list.html │ ├── odin-trans.html │ ├── odin-update-ap.html │ ├── odin-update-list.html │ ├── odin-update-vd.html │ ├── odin-update.html │ ├── odin.html │ ├── pttp-browser.html │ ├── pttp-daemon.html │ ├── pttp-data.html │ ├── template.html │ ├── unspents.html │ ├── upload-result.html │ └── wallet.html └── src ├── APoverETH.java ├── APoverHTTP.java ├── APoverPTTP.java ├── BitcoinVarint.java ├── Blocks.java ├── BrowserAddBookMark.java ├── BrowserHelpWindow.java ├── BrowserMainUI.java ├── BrowserPageList.java ├── BrowserPageNode.java ├── Coder.java ├── CommonHttpUtil.java ├── Config.java ├── Database.java ├── GUI.java ├── GenOdinDataByRequest.java ├── GuiServer.java ├── HtmlRegexpUtil.java ├── JsonRpcService.java ├── JsonRpcServiceImpl.java ├── JsonRpcServlet.java ├── JsonRpcServletEngine.java ├── JsonRpcTest.java ├── Language.java ├── NetCache.java ├── NoGUI.java ├── Odin.java ├── OdinTransctionData.java ├── OdinUpdate.java ├── PPkPeerEventListener.java ├── PPkTool.java ├── PPkURI.java ├── PTTP.java ├── Paseto.java ├── PasetoCryptoFunctions.java ├── PasetoLocal.java ├── PasetoPublic.java ├── PasetoUtil.java ├── PttpBrowser.java ├── PttpDaemon.java ├── PttpServer.java ├── RSACoder.java ├── Send.java ├── UnspentList.java ├── UnspentOutput.java ├── Update.java └── Util.java /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 newbiecoin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PPk open management tool 2 | 3 | ============================================ 4 | 5 | A simple&open tool for registing and managing ODIN ,which is a decentralized name 6 | based on Bitocin blockchain. 7 | 8 | For compile this software, please do as below in linux like Ubuntu: 9 | 10 | (1) install JAVA SDK 1.8 above 11 | 12 | (2) run ./createjar/keygen.sh 13 | 14 | (3) run ./compile.sh 15 | 16 | (4) run ./generate_package.sh 17 | 18 | (5) cd ./build 19 | 20 | (6) unzip PPk-newest.zip 21 | 22 | (7) run ./ppk.sh 23 | 24 | More see http://ppkpub.org/ 25 | ================================================================== 26 | 用JAVA语言编写的PPk ODIN标识注册管理开源工具示例的源码。 27 | 28 | 29 | 更多介绍请访问 http://ppkpub.org/ 30 | 31 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | mkdir bin 2 | del bin/* 3 | mkdir resources/db 4 | javac -cp "/home/ppk/jdk1.8.0/jre/lib/jfxrt.jar:resources/jars/slf4j-api-1.6.4.jar:resources/jars/slf4j-simple-1.6.4.jar:resources/jars/bitcoinj-core-0.14.7-bundled.jar:resources/jars/jackson-annotations-2.0.0.jar:resources/jars/jackson-core-2.0.0.jar:resources/jars/jackson-databind-2.0.0.jar:resources/jars/sqlite-jdbc-3.7.15-M1.jar:resources/jars/jetty9/lib/jetty-server-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-util-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-http-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-servlet-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-io-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-continuation-9.1.4.v20140401.jar:resources/jars/jetty9/lib/jetty-security-9.1.4.v20140401.jar:resources/jars/javax.servlet-api-3.1.0.jar:resources/jars/javax.servlet-5.1.12.jar:resources/jars/spark-core-1.1.1.jar:resources/jars/spark-template-freemarker-1.0.jar:resources/jars/spark-template-velocity-1.0.jar:resources/jars/freemarker.jar:resources/jars/jsonrpc4j-1.0.jar:resources/jars/portlet-api-2.0-r12.jar:resources/jars/java-json.jar:resources/jars/IPFS.jar:resources/jars/spongycastle-prov-1.58.0.0.jar:resources/jars/jkademlia-1.7.jar:resources/jars/gson-2.7.jar" -sourcepath "src" -d "bin" src/*.java 5 | -------------------------------------------------------------------------------- /createjar/keygen.sh: -------------------------------------------------------------------------------- 1 | keytool -genkey -keystore ../ppkkeystore -alias ppkkey 2 | -------------------------------------------------------------------------------- /createjar/keysign.sh: -------------------------------------------------------------------------------- 1 | jarsigner -keystore ../ppkkeystore -storepass ppk2015 -keypass ppk2015 release/PPkTool.jar ppkkey 2 | jarsigner -keystore ../ppkkeystore -storepass ppk2015 -keypass ppk2015 release/PPkToolServer.jar ppkkey 3 | jarsigner -keystore ../ppkkeystore -storepass ppk2015 -keypass ppk2015 release/PPkBrowser.jar ppkkey 4 | jarsigner -keystore ../ppkkeystore -storepass ppk2015 -keypass ppk2015 release/PPkDaemon.jar ppkkey 5 | jarsigner -keystore ../ppkkeystore -storepass ppk2015 -keypass ppk2015 release/update/update.jar ppkkey 6 | -------------------------------------------------------------------------------- /createjar/makerelease.sh: -------------------------------------------------------------------------------- 1 | rm release.zip 2 | rm update.zip 3 | cd release 4 | zip -r release.zip * -x "*.DS_Store" 5 | cp release.zip ../ 6 | zip update.zip PPkTool.jar PPkToolServer.jar PPkBrowser.jar PPkDaemon.jar 7 | cp update.zip ../ 8 | cd ../ 9 | -------------------------------------------------------------------------------- /generate_package.sh: -------------------------------------------------------------------------------- 1 | mkdir build 2 | cd createjar 3 | sh packager.sh 4 | sh makerelease.sh 5 | cd ../ 6 | cp createjar/release.zip build/PPk-newest.zip 7 | cp createjar/update.zip build/update.zip 8 | unzip -u -o -d build/ build/update.zip 9 | -------------------------------------------------------------------------------- /resources/db/ppk-1.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/db/ppk-1.db -------------------------------------------------------------------------------- /resources/db/ppk.h2.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/db/ppk.h2.db -------------------------------------------------------------------------------- /resources/db/ppktest-1.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/db/ppktest-1.db -------------------------------------------------------------------------------- /resources/db/ppktest.h2.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/db/ppktest.h2.db -------------------------------------------------------------------------------- /resources/jars/IPFS.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/IPFS.jar -------------------------------------------------------------------------------- /resources/jars/bitcoinj-core-0.14.7-bundled.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/bitcoinj-core-0.14.7-bundled.jar -------------------------------------------------------------------------------- /resources/jars/freemarker.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/freemarker.jar -------------------------------------------------------------------------------- /resources/jars/gson-2.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/gson-2.7.jar -------------------------------------------------------------------------------- /resources/jars/jackson-annotations-2.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jackson-annotations-2.0.0.jar -------------------------------------------------------------------------------- /resources/jars/jackson-core-2.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jackson-core-2.0.0.jar -------------------------------------------------------------------------------- /resources/jars/jackson-databind-2.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jackson-databind-2.0.0.jar -------------------------------------------------------------------------------- /resources/jars/java-json.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/java-json.jar -------------------------------------------------------------------------------- /resources/jars/javax.servlet-5.1.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/javax.servlet-5.1.12.jar -------------------------------------------------------------------------------- /resources/jars/javax.servlet-api-3.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/javax.servlet-api-3.1.0.jar -------------------------------------------------------------------------------- /resources/jars/jetty9/README.TXT: -------------------------------------------------------------------------------- 1 | 2 | JETTY 3 | ===== 4 | The Jetty project is a 100% Java HTTP Server, HTTP Client 5 | and Servlet Container from the eclipse foundation 6 | 7 | http://www.eclipse.org/jetty/ 8 | 9 | Jetty is open source and is dual licensed using the Apache 2.0 and 10 | Eclipse Public License 1.0. You may choose either license when 11 | distributing Jetty. 12 | 13 | 14 | RUNNING JETTY 15 | ============= 16 | The run directory is either the top-level of a binary release 17 | or jetty-distribution/target/assembly-prep directory when built from 18 | source. 19 | 20 | To run with the default options: 21 | 22 | java -jar start.jar 23 | 24 | To see the available options and the default arguments 25 | provided by the start.ini file: 26 | 27 | java -jar start.jar --help 28 | 29 | 30 | Many Jetty features can be enabled by using the --module command 31 | For example: 32 | 33 | java -jar start.jar --module=https,deploy 34 | 35 | Will enable HTTPS and its dependencies in the files start.ini 36 | To list the know modules: 37 | 38 | java -jar start.jar --list-modules 39 | 40 | 41 | 42 | JETTY BASE 43 | ========== 44 | 45 | If the property jetty.base is defined on the command line, then the jetty start.jar 46 | mechanism will look for start.ini, start.d, webapps and etc files relative to the 47 | jetty.base and jetty.home directories 48 | 49 | java -jar start.jar jetty.base=/opt/myjettybase/ 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/etc/keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jetty9/demo-base/etc/keystore -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/etc/login.conf: -------------------------------------------------------------------------------- 1 | xyz { 2 | org.eclipse.jetty.jaas.spi.PropertyFileLoginModule required 3 | debug="true" 4 | file="${jetty.base}/etc/login.properties"; 5 | }; 6 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/etc/login.properties: -------------------------------------------------------------------------------- 1 | me=me,me,roleA 2 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/etc/realm.properties: -------------------------------------------------------------------------------- 1 | # 2 | # This file defines users passwords and roles for a HashUserRealm 3 | # 4 | # The format is 5 | # : [, ...] 6 | # 7 | # Passwords may be clear text, obfuscated or checksummed. The class 8 | # org.eclipse.util.Password should be used to generate obfuscated 9 | # passwords or password checksums 10 | # 11 | # If DIGEST Authentication is used, the password must be in a recoverable 12 | # format, either plain text or OBF:. 13 | # 14 | jetty: MD5:164c88b302622e17050af52c89945d44,user 15 | admin: CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user 16 | other: OBF:1xmk1w261u9r1w1c1xmq,user 17 | plain: plain,user 18 | user: password,user 19 | 20 | # This entry is for digest auth. The credential is a MD5 hash of username:realmname:password 21 | digest: MD5:6e120743ad67abfbc385bc2bb754e297,user 22 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/etc/test-realm.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Test Realm 15 | 16 | 0 17 | 18 | 19 | 20 | 21 | 22 | demo test-realm is deployed. DO NOT USE IN PRODUCTION! 23 | 24 | 25 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/lib/ext/javax.mail.glassfish-1.4.1.v201005082020.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jetty9/demo-base/lib/ext/javax.mail.glassfish-1.4.1.v201005082020.jar -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/lib/ext/test-mock-resources-9.1.4.v20140401.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jetty9/demo-base/lib/ext/test-mock-resources-9.1.4.v20140401.jar -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/start.d/http.ini: -------------------------------------------------------------------------------- 1 | # 2 | # HTTP connector 3 | # 4 | --module=http 5 | jetty.port=8080 6 | 7 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/start.d/https.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Initialize module https 3 | # 4 | --module=https 5 | ## HTTPS Configuration 6 | # HTTP port to listen on 7 | https.port=8443 8 | # HTTPS idle timeout in milliseconds 9 | https.timeout=30000 10 | # HTTPS Socket.soLingerTime in seconds. (-1 to disable) 11 | # https.soLingerTime=-1 12 | 13 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/start.d/jsp.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Initialize module jsp 3 | # 4 | --module=jsp 5 | # JSP Configuration 6 | # To use an non-jdk compiler for JSP compilation uncomment next line 7 | # -Dorg.apache.jasper.compiler.disablejsr199=true 8 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/start.d/ssl.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Initialize module ssl 3 | # 4 | --module=ssl 5 | ## SSL Keystore Configuration 6 | # define the port to use for secure redirection 7 | jetty.secure.port=8443 8 | 9 | # Setup a demonstration keystore and truststore 10 | jetty.keystore=etc/keystore 11 | jetty.truststore=etc/keystore 12 | 13 | # Set the demonstration passwords. 14 | # Note that OBF passwords are not secure, just protected from casual observation 15 | # See http://www.eclipse.org/jetty/documentation/current/configuring-security-secure-passwords.html 16 | jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 17 | jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g 18 | jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4 19 | 20 | # Set the client auth behavior 21 | # Set to true if client certificate authentication is required 22 | # jetty.ssl.needClientAuth=true 23 | # Set to true if client certificate authentication is desired 24 | # jetty.ssl.wantClientAuth=true 25 | 26 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/start.ini: -------------------------------------------------------------------------------- 1 | # 2 | # Example of providing a demo configuration, using a ${jetty.base} 3 | # 4 | # Additional ini files are in demo-base/start.d 5 | # 6 | 7 | # Enable security via jaas, and configure it 8 | --module=jaas 9 | jaas.login.conf=etc/login.conf 10 | 11 | # Enable rewrite examples 12 | --module=rewrite 13 | etc/demo-rewrite-rules.xml 14 | 15 | # Websocket chat examples needs websocket enabled 16 | # Don't start for all contexts (set to true in test.xml context) 17 | org.eclipse.jetty.websocket.jsr356=false 18 | --module=websocket 19 | 20 | # Create and configure the test realm 21 | etc/test-realm.xml 22 | demo.realm=etc/realm.properties 23 | 24 | 25 | # 26 | # Initialize module server 27 | # 28 | --module=server 29 | ## 30 | ## Server Threading Configuration 31 | ## 32 | # minimum number of threads 33 | threads.min=10 34 | # maximum number of threads 35 | threads.max=200 36 | # thread idle timeout in milliseconds 37 | threads.timeout=60000 38 | # buffer size for output 39 | jetty.output.buffer.size=32768 40 | # request header buffer size 41 | jetty.request.header.size=8192 42 | # response header buffer size 43 | jetty.response.header.size=8192 44 | # should jetty send the server version header? 45 | jetty.send.server.version=true 46 | # should jetty send the date header? 47 | jetty.send.date.header=false 48 | # What host to listen on (leave commented to listen on all interfaces) 49 | #jetty.host=myhost.com 50 | # Dump the state of the Jetty server, components, and webapps after startup 51 | jetty.dump.start=false 52 | # Dump the state of the Jetty server, before stop 53 | jetty.dump.stop=false 54 | 55 | 56 | 57 | # 58 | # Initialize module continuation 59 | # 60 | --module=continuation 61 | 62 | # 63 | # Initialize module deploy 64 | # 65 | --module=deploy 66 | ## DeployManager configuration 67 | # Monitored Directory name (relative to jetty.base) 68 | # jetty.deploy.monitoredDirName=webapps 69 | 70 | 71 | # 72 | # Initialize module ext 73 | # 74 | --module=ext 75 | 76 | # 77 | # Initialize module resources 78 | # 79 | --module=resources 80 | 81 | # 82 | # Initialize module client 83 | # 84 | --module=client 85 | 86 | # 87 | # Initialize module annotations 88 | # 89 | --module=annotations 90 | 91 | # 92 | # Initialize module servlets 93 | # 94 | --module=servlets 95 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/webapps/README.TXT: -------------------------------------------------------------------------------- 1 | 2 | This directory is scanned by the demo WebAppDeployer provider 3 | created in the etc/jetty-demo.xml file and enabled by the 4 | start.d/900-demo.ini file. 5 | 6 | To disable the demo, either remove the start.d/900-demo.ini or issue the following command: 7 | 8 | java -jar start.jar --disable=demo 9 | 10 | 11 | For normal webapp deployment, use the webapps directory. 12 | 13 | -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/webapps/ROOT/images/jetty-header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jetty9/demo-base/webapps/ROOT/images/jetty-header.jpg -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/webapps/ROOT/images/webtide_logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ppkpub/javatool/f2917ce7eb5c631af1ef133be4a1ee555bb315e7/resources/jars/jetty9/demo-base/webapps/ROOT/images/webtide_logo.jpg -------------------------------------------------------------------------------- /resources/jars/jetty9/demo-base/webapps/ROOT/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to Jetty-9 7 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Welcome to Jetty 9

17 | 18 |

19 | The Jetty project is a 100% Java Servlet 21 | Container which supports asynchronous server and client 22 | implementations of the HTTP, 23 | Websocket and SPDY protocols. The 25 | project is 100% Open Source and hosted by the Eclipse Foundation at http://www.eclipse.org/jetty. 26 |

27 |
28 | 29 | 66 | 67 |
68 |

Jetty Blog

69 | 5 |
6 | 7 | -------------------------------------------------------------------------------- /resources/templates/confirm-tx.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if odin_tx_json_hex??> 4 |
5 |

${GENERATING_ODIN_TX}

6 |
7 | 8 |
9 | 10 |
11 | 12 |
13 |
14 | 15 |
16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /resources/templates/error.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | 4 |
5 |

An error has occurred.

6 |
7 | 8 | 9 | -------------------------------------------------------------------------------- /resources/templates/index_nowallet.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 |
4 |
5 | 6 | 10 |
11 |
12 | 13 |
14 | 15 | <#if recent_odins??> 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | <#list recent_odins as odin> 29 | 30 | 31 | 32 | 33 | 37 | 43 | 44 | 45 | 46 |
${LANG_FULL_ODIN}${LANG_SHORT_ODIN}${LANG_TIME}${LANG_ADMIN_REGISTER}${LANG_STATUS}
${odin["full_odin"]}${odin["short_odin"]}${odin["block_time"]} 34 | ${LANG_ADMIN_BY} ${odin["admin"]}
35 | ${LANG_REGISTED_BY} ${odin["register"]} 36 |
38 | ${odin["validity"]}
39 | <#if odin["me_updatable"]??> 40 | ${LANG_UPDATE}...
41 | 42 |
47 | 48 |
49 | 50 | 51 | -------------------------------------------------------------------------------- /resources/templates/odin-browser.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !success?? && !error??> 4 |
5 |
6 | 7 | 8 | 9 | 12 | 13 |

${LANG_BROWSE_PPK_NETWORK}

10 |
11 |
14 |
15 | ${LANG_RESPONSE_URI}:<#if ap_resp_ppk_uri??>${ap_resp_ppk_uri}
16 | ${LANG_RESPONSE_URL}:<#if ap_resp_url??>${ap_resp_url}
17 | ${LANG_VALIDATE_RESULT}:<#if ap_resp_validate_result??>${ap_resp_validate_result}
18 |
19 | <#if ap_resp_content??>${ap_resp_content} 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /resources/templates/odin-check-ap-vd.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !success?? && !error??> 4 |
5 |
6 | 7 | 12 |
13 |
14 | 15 |
16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 |
35 | 43 |
44 | 45 |
46 | 47 |
48 |
49 | 50 |
51 | 52 |
53 | 54 |
55 |
56 | 57 | 58 |
59 | 60 |
61 | 62 |
63 |
64 | 65 |
66 | 67 |
68 | ${ap_resp_validate_result} 69 |
70 |
71 | 72 |
73 | 74 |
75 | 76 |
77 |
78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /resources/templates/odin-confirm.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | 4 | 5 | -------------------------------------------------------------------------------- /resources/templates/odin-match.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !success?? && !error??> 4 |
5 |

${LANG_MATCH_WORD} : ${input_word}

6 |

${matched_result}

7 |
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /resources/templates/odin-more-list.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !error??> 4 |
5 |
6 | 7 |
8 | 9 |
10 |
11 |
12 | <#if my_odins??> 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | <#list my_odins as odin> 30 | 31 | 32 | 33 | 34 | 35 | 39 | 46 | 47 | 48 | 49 | 50 | 51 |
${LANG_FULL_ODIN}${LANG_SHORT_ODIN}${LANG_TIME}${LANG_ODIN_TITLE}${LANG_ADMIN_REGISTER}${LANG_STATUS}${LANG_AP_LIST}
${odin["full_odin"]}${odin["short_odin"]}${odin["block_time"]}${odin["title"]} 36 | ${LANG_ADMIN_BY} ${odin["admin_label"]}
37 | ${LANG_REGISTED_BY} ${odin["register_label"]} 38 |
40 | ${odin["validity_label"]} 41 |
42 | <#if odin["me_updatable"]??> 43 | ${LANG_UPDATE}...
44 | 45 |
${odin["ap_set_debug"]}
52 |
53 | 54 |
${list_navi_html}
55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /resources/templates/odin-trans.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !success?? && !error??> 4 |
5 |

${LANG_TRANSFER_THE_REGISTER_OF} ${LANG_ODIN}[${odin["short_odin"]}]:${odin["full_odin"]}

6 |
7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 | 18 |
19 | 20 |
21 | 22 |
23 |
24 | 25 |
26 |
27 | 28 |
29 |
30 |
31 |
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /resources/templates/odin-update-ap.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | <#if !success?? && !error??> 4 |
5 |
6 | 7 | 11 |
12 |
13 | 14 |
15 | 16 | 17 | 18 | 19 | <#assign apids=0..4/> 20 | <#list apids as apid> 21 |
22 | 23 | 26 |
27 | 28 | 29 |
30 |
31 | 32 |
33 |
34 | 35 |

${LANG_SUBMIT_TO_CREATE_FIRST_AP}

36 | 37 |
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /resources/templates/odin-update-list.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 | 4 | <#if !error??> 5 |
6 |
7 | 8 |
9 | 10 |
11 |
12 |
13 | 14 | <#if my_updates??> 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | <#list my_updates as odin> 29 | 30 | 31 | 32 | 33 | 38 | 44 | 45 | 46 | 47 | 48 |
${LANG_FULL_ODIN}${LANG_SHORT_ODIN}${LANG_TIME}${LANG_UPDATE_DESC}${LANG_STATUS}
${odin["full_odin"]}${odin["short_odin"]}${odin["block_time"]} 34 | ${odin["update_desc"]} 35 |
36 |

${LANG_UPDATER}: ${odin["updater"]}

37 |
39 | ${odin["validity_label"]}
40 | <#if odin["awaiting_my_receipting"]?? || odin["awaiting_my_confirm"]??> 41 | <#if odin["awaiting_my_receipting"]??>${LANG_AWAIT_YOUR_RECEIPT}<#else>${LANG_AWAIT_YOUR_CONFIRM}... 42 | 43 |
49 |
50 | 51 |
${list_navi_html}
52 | 53 | 54 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /resources/templates/pttp-browser.html: -------------------------------------------------------------------------------- 1 | <#if info?? || error?? || success?? || warning?? > 2 | <#if info??> 3 |
${info}
4 | 5 | <#if error??> 6 |
${LANG_ERROR}:${error}
7 | 8 | <#if success??> 9 |
${success}
10 | 11 | <#if warning??> 12 |
${warning}
13 | 14 | 15 | <#if ap_resp_content??>${ap_resp_content} -------------------------------------------------------------------------------- /resources/templates/pttp-daemon.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ${LANG_PPK_BROWSER}<#if title??> - ${title}</#if> 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | <#if info?? || error?? || success?? || warning?? > 18 |
19 | <#if info??> 20 |
${info}
21 | 22 | <#if error??> 23 |
${LANG_ERROR}:${error}
24 | 25 | <#if success??> 26 |
${success}
27 | 28 | <#if warning??> 29 |
${warning}
30 | 31 |
32 | 33 | 34 |
35 |
36 | 37 | 38 | 39 | 42 | 43 |

${LANG_BROWSE_PPK_NETWORK}

40 |
41 |
44 |
45 | ${LANG_RESPONSE_URI}:<#if ap_resp_ppk_uri??>${ap_resp_ppk_uri}
46 | ${LANG_RESPONSE_URL}:<#if ap_resp_url??>${ap_resp_url}
47 | ${LANG_VALIDATE_RESULT}:<#if ap_resp_validate_result??>${ap_resp_validate_result}
48 |
49 | <#if ap_resp_content??>${ap_resp_content} 50 |
51 | 54 | 55 | -------------------------------------------------------------------------------- /resources/templates/pttp-data.html: -------------------------------------------------------------------------------- 1 | <#if pttp_data??>${pttp_data} -------------------------------------------------------------------------------- /resources/templates/unspents.html: -------------------------------------------------------------------------------- 1 | <#import "template.html" as template> 2 | <@template.content> 3 |
4 |

My unspent outputs

5 |

Available balance: ${ unspent_total?string(",##0.00000000") } BTC

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | <#if unspents??> 19 | <#list unspents as unspent> 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Transaction hashVoutAmountTypeConfirmations
${ unspent["tx_hash"] }${ unspent["vout"] }${ unspent["amount"]?string(",##0.00000000") }${ unspent["type"] }${ unspent["confirmations"] }
31 |

Source: ${ unspent_address }

32 |
33 | 34 | -------------------------------------------------------------------------------- /resources/templates/upload-result.html: -------------------------------------------------------------------------------- 1 | <#if error??> 2 |
error:${error}
3 | 4 | <#if upload_result??>${upload_result} -------------------------------------------------------------------------------- /src/APoverHTTP.java: -------------------------------------------------------------------------------- 1 | import java.net.URL; 2 | import java.net.HttpURLConnection; 3 | import java.io.InputStream; 4 | import java.io.OutputStream; 5 | import java.util.Map; 6 | import java.util.Iterator; 7 | import java.util.List; 8 | import java.util.ArrayList; 9 | 10 | import org.slf4j.Logger; 11 | import org.slf4j.LoggerFactory; 12 | import org.json.JSONArray; 13 | import org.json.JSONObject; 14 | import org.json.JSONException; 15 | 16 | import com.googlecode.jsonrpc4j.JsonRpcHttpClient; 17 | 18 | public class APoverHTTP { 19 | static Logger logger = LoggerFactory.getLogger(APoverHTTP.class); 20 | 21 | public static String fetchInterest(String ap_url, String interest) { 22 | String str_ap_resp_json=null; 23 | String ap_fetch_url=ap_url+"?"+Config.PTTP_INTEREST+"="+java.net.URLEncoder.encode(interest); 24 | logger.info("fetchInterest("+ap_fetch_url+") ..."); 25 | 26 | try{ 27 | str_ap_resp_json=new String(CommonHttpUtil.getInstance().getContentFromUrl(ap_fetch_url)); 28 | }catch(Exception e){ 29 | logger.error("fetchInterest("+ap_fetch_url+") error: "+e.toString()); 30 | } 31 | 32 | //System.out.println("APoverHTTP.fetchInterest() str_ap_resp_json:"+str_ap_resp_json); 33 | return str_ap_resp_json; 34 | } 35 | } -------------------------------------------------------------------------------- /src/APoverPTTP.java: -------------------------------------------------------------------------------- 1 | import org.slf4j.Logger; 2 | import org.slf4j.LoggerFactory; 3 | 4 | public class APoverPTTP { 5 | static Logger logger = LoggerFactory.getLogger(APoverPTTP.class); 6 | 7 | public static String fetchInterest(String ap_url, String interest) { 8 | if(ap_url==null) 9 | return null; 10 | 11 | String str_ap_resp_json=null; 12 | String ap_fetch_url=ap_url; 13 | 14 | try{ 15 | if( ap_fetch_url.endsWith("/")){ 16 | ap_fetch_url += "pttp("+Util.bytesToHexString(interest.getBytes(Config.PPK_TEXT_CHARSET))+")"+Config.PPK_URI_RESOURCE_MARK; 17 | } 18 | logger.info("fetchInterest("+ap_fetch_url+") ..."); 19 | 20 | //存在循环锁的可能,需进一步完善处理 21 | str_ap_resp_json = Util.fetchUriContent(ap_fetch_url); 22 | }catch(Exception e){ 23 | logger.error("fetchInterest("+ap_fetch_url+") error: "+e.toString()); 24 | } 25 | 26 | //System.out.println("APoverPTTP.fetchInterest() str_ap_resp_json:"+str_ap_resp_json); 27 | return str_ap_resp_json; 28 | } 29 | } -------------------------------------------------------------------------------- /src/BitcoinVarint.java: -------------------------------------------------------------------------------- 1 | import java.nio.ByteBuffer; 2 | 3 | //比特币协议定义的可变长度整型VARINT格式处理 4 | public class BitcoinVarint { 5 | private int mIntVal; 6 | private int mIntSize; 7 | 8 | public BitcoinVarint(int val,int size){ 9 | mIntVal=val; 10 | mIntSize=size; 11 | } 12 | 13 | public int intValue(){ 14 | return mIntVal; 15 | } 16 | 17 | public int size(){ 18 | return mIntSize; 19 | } 20 | 21 | //32位无符号整数转换成VARINT格式的字节数组(低位在前,高位在后) 22 | public static byte[] toBytes(int val){ 23 | byte[] result_array=null; 24 | 25 | if(val<0xFD){ 26 | result_array=new byte[1]; 27 | result_array[0] = (byte)val; 28 | }else if(val<0xFFFF ){ 29 | result_array=new byte[3]; 30 | result_array[0] = (byte)0xFD; 31 | result_array[1] = (byte)(val%256); 32 | result_array[2] = (byte)(val/256); 33 | }else if(val<0xFFFFFFF ){ 34 | result_array=new byte[5]; 35 | result_array[0] = (byte)0xFE; 36 | result_array[1] = (byte)((val%65536)%256); 37 | result_array[2] = (byte)((val%65536)/256); 38 | result_array[3] = (byte)((val/65536)%256); 39 | result_array[4] = (byte)((val/65536)/256); 40 | } 41 | 42 | return result_array; 43 | } 44 | 45 | //从指定直接缓存的指定位置读取Varint格式数据 46 | public static BitcoinVarint getFromBuffer(ByteBuffer byteBuffer,int from){ 47 | BitcoinVarint result_val=null; 48 | int tmp_byte=getUnsignedByteVal(byteBuffer.get(from)); 49 | if(tmp_byte<0xFD){ 50 | result_val=new BitcoinVarint(tmp_byte,1); 51 | }else if(tmp_byte==0xFD){ 52 | result_val=new BitcoinVarint( 53 | getUnsignedByteVal(byteBuffer.get(from+1)) 54 | +getUnsignedByteVal(byteBuffer.get(from+2))*256, 55 | 3); 56 | }else if(tmp_byte==0xFE){ 57 | result_val=new BitcoinVarint( 58 | getUnsignedByteVal(byteBuffer.get(from+1)) 59 | +getUnsignedByteVal(byteBuffer.get(from+2))*256 60 | +getUnsignedByteVal(byteBuffer.get(from+3))*65536 61 | +getUnsignedByteVal(byteBuffer.get(from+4))*65536*256, 62 | 5); 63 | } 64 | 65 | return result_val; 66 | } 67 | 68 | public static int getUnsignedByteVal(byte a){ 69 | int i = a; 70 | i = a&0xff; 71 | return i; 72 | } 73 | } -------------------------------------------------------------------------------- /src/BrowserAddBookMark.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Name:BrowserAddBookMark.java 3 | * Writer:bitsjx 4 | * Date:2018-11-26 5 | * Time:00:20 6 | * Function:Use class MainUI to implement a BrowserAddBookMark GUI 7 | * */ 8 | import java.awt.AWTEvent; 9 | import java.awt.BorderLayout; 10 | import java.awt.Dimension; 11 | import java.awt.FlowLayout; 12 | import java.awt.event.ActionEvent; 13 | import java.awt.event.ActionListener; 14 | import javax.swing.JButton; 15 | import javax.swing.JFrame; 16 | import javax.swing.JLabel; 17 | import javax.swing.JOptionPane; 18 | import javax.swing.JPanel; 19 | import javax.swing.JTextField; 20 | public class BrowserAddBookMark extends JFrame implements ActionListener { 21 | //定义组件 22 | JPanel contentpane; 23 | //添加文本区域的面板 24 | JPanel textpanel=new JPanel(); 25 | //添加按钮的面板 26 | JPanel buttonpanel=new JPanel(); 27 | //名称、地址 28 | JLabel namelabel=new JLabel("名称"); 29 | JLabel addresslabel=new JLabel("地址"); 30 | //显示名称和地址的文本框 31 | JTextField nametext=new JTextField(20); 32 | JTextField addresstext=new JTextField(20); 33 | //确定、取消按钮 34 | JButton OKbuuton=new JButton("确定"); 35 | JButton Cancelbuuton=new JButton("取消"); 36 | //isExist用于判断是否已经存在书签项 37 | boolean isExist=false; 38 | public BrowserAddBookMark(String title,String urladdress,boolean isExist) 39 | { 40 | //设置窗口属性 41 | setLocationRelativeTo(null); 42 | setResizable(false); 43 | setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); 44 | this.enableEvents(AWTEvent.WINDOW_EVENT_MASK); 45 | this.setSize(new Dimension(300,150)); 46 | this.setTitle(" 收藏夹"); 47 | this.isExist=isExist; 48 | //设置窗体属性 49 | contentpane=(JPanel)this.getContentPane(); 50 | contentpane.setLayout(new BorderLayout()); 51 | textpanel.setLayout(new FlowLayout()); 52 | textpanel.add(namelabel); 53 | textpanel.add(nametext); 54 | nametext.setEnabled(true); 55 | nametext.setText(title); 56 | nametext.setFocusable(true); 57 | textpanel.add(addresslabel); 58 | textpanel.add(addresstext); 59 | addresstext.setEditable(true); 60 | addresstext.setText(urladdress); 61 | buttonpanel.setLayout(new FlowLayout()); 62 | buttonpanel.add(OKbuuton); 63 | OKbuuton.setFocusable(false); 64 | buttonpanel.add(Cancelbuuton); 65 | Cancelbuuton.setFocusable(false); 66 | contentpane.add(textpanel,BorderLayout.CENTER); 67 | contentpane.add(buttonpanel,BorderLayout.SOUTH); 68 | OKbuuton.addActionListener(this); 69 | Cancelbuuton.addActionListener(this); 70 | } 71 | //响应按钮事件 72 | @Override 73 | public void actionPerformed(ActionEvent e) { 74 | if(e.getSource()==Cancelbuuton) 75 | { 76 | dispose(); 77 | } 78 | if(e.getSource()==OKbuuton) 79 | { 80 | //如果存在了书签项 81 | if(this.isExist==true) 82 | { 83 | if (JOptionPane.showConfirmDialog(BrowserAddBookMark.this, "项目已存在,是否覆盖?", 84 | "提示:", JOptionPane.OK_CANCEL_OPTION)==0) { 85 | } 86 | } 87 | dispose(); 88 | } 89 | } 90 | } -------------------------------------------------------------------------------- /src/BrowserPageList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Name:BrowserPageList.java 3 | * Writer:bitsjx 4 | * Date:2018-11-26 5 | * Time:00:26 6 | * Function:Construct a LinkList to save History and BookMarks Nodes 7 | * */ 8 | public class BrowserPageList { 9 | //头节点 10 | private BrowserPageNode head; 11 | //自由节点 12 | private BrowserPageNode link; 13 | //记录当前的节点所在位置 14 | private BrowserPageNode linkpointer; 15 | public BrowserPageList() 16 | { 17 | head=new BrowserPageNode(); 18 | link=head; 19 | linkpointer=head; 20 | } 21 | //添加新的页面到链表 22 | public void addURL(String pagename,String urladdress) 23 | { 24 | BrowserPageNode node=new BrowserPageNode(pagename,urladdress); 25 | link=head; 26 | while(link.getNext()!=null) 27 | { 28 | link=link.getNext(); 29 | } 30 | link.setNext(node); 31 | node.setPre(link); 32 | node.setNext(null); 33 | linkpointer=node; 34 | } 35 | //获得最新的链表头 36 | public BrowserPageNode getLastPageNode() 37 | { 38 | return this.head; 39 | } 40 | 41 | //获得当前页面 42 | public BrowserPageNode getCurrentPageNode() 43 | { 44 | return this.linkpointer; 45 | } 46 | 47 | //查找某个pagename对应的URL 48 | public String getURL(String pagename) 49 | { 50 | link=head; 51 | String url=""; 52 | while(!((link.getNext()).getPagename()).equalsIgnoreCase(pagename)) 53 | { 54 | link=link.getNext(); 55 | } 56 | url=(link.getNext()).getUrl(); 57 | linkpointer=link; 58 | return url; 59 | } 60 | 61 | //获取某个URL对应的pagename 62 | public String getPageName(String urladdress) 63 | { 64 | link=head; 65 | String pagename=""; 66 | while(!(link.getNext().getUrl()).equalsIgnoreCase(urladdress)) 67 | { 68 | link=link.getNext(); 69 | } 70 | pagename=link.getNext().getPagename(); 71 | linkpointer=link; 72 | return pagename; 73 | } 74 | //获取当前page的前一个pageurl 75 | public String getPrePageURL( ) 76 | { 77 | link=linkpointer.getPre(); 78 | linkpointer=link; 79 | return link.getUrl(); 80 | } 81 | //获取当前page的下一个pageurl 82 | public String getNextPageURL() 83 | { 84 | link=linkpointer.getNext(); 85 | linkpointer=link; 86 | return link.getUrl(); 87 | } 88 | //查找某个pageurl地址是否存在 89 | public boolean isPageUrlExist(String pageurl) 90 | { 91 | link=this.head.getNext(); 92 | //标记是否找到 93 | boolean isfind=false; 94 | String tmpUrl=""; 95 | while(link!=null) 96 | { 97 | tmpUrl=link.getUrl(); 98 | if(tmpUrl.equalsIgnoreCase(pageurl)) 99 | { 100 | isfind=true; 101 | break; 102 | } 103 | link=link.getNext(); 104 | } 105 | System.out.println("查找本页结果:"+isfind); 106 | return isfind; 107 | } 108 | //判断前一个page是否存在 109 | public boolean isPrePageExist( ) 110 | { 111 | boolean isfind=false; 112 | link=head; 113 | link=linkpointer.getPre(); 114 | if(link!=null&&link!=head) 115 | { 116 | isfind=true; 117 | } 118 | System.out.println("查找前页结果:"+isfind); 119 | return isfind; 120 | } 121 | //判断后一个page是否存在 122 | public boolean isNextPageExist( ) 123 | { 124 | boolean isfind=false; 125 | link=head; 126 | link=linkpointer.getNext(); 127 | if(link!=null) 128 | { 129 | isfind=true; 130 | } 131 | System.out.println("查找后页结果:"+isfind); 132 | return isfind; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/BrowserPageNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Name:BrowserPageNode.java 3 | * Writer:bitsjx 4 | * Date:2018-11-26 5 | * Time:00:20 6 | * Function:implement a Node of LinkList 7 | * */ 8 | public class BrowserPageNode { 9 | //页面的名称 10 | private String pagename=""; 11 | //url为网址实例 12 | private String url=""; 13 | //next为后一个节点 14 | private BrowserPageNode next=null; 15 | //pre为前一个节点 16 | private BrowserPageNode pre=null; 17 | 18 | //get、set方法 19 | public String getPagename() { 20 | return pagename; 21 | } 22 | public void setPagename(String pagename) { 23 | this.pagename = pagename; 24 | } 25 | public String getUrl() { 26 | return url; 27 | } 28 | public void setUrl(String url) { 29 | this.url = url; 30 | } 31 | public BrowserPageNode getNext() { 32 | return next; 33 | } 34 | public void setNext(BrowserPageNode next) { 35 | this.next = next; 36 | } 37 | public BrowserPageNode getPre() { 38 | return pre; 39 | } 40 | public void setPre(BrowserPageNode pre) { 41 | this.pre = pre; 42 | } 43 | 44 | //重写默认构造函数 45 | public BrowserPageNode() 46 | { 47 | //System.out.println("BrowserPageNode blank"); 48 | this.pagename=""; 49 | this.url=""; 50 | this.next=null; 51 | this.pre=null; 52 | } 53 | //自定义构造函数 54 | public BrowserPageNode(String pagename,String urladdress) 55 | { 56 | //System.out.println("BrowserPageNode:"+pagename+","+urladdress); 57 | this.pagename=pagename; 58 | this.url=urladdress; 59 | this.next=null; 60 | this.pre=null; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Coder.java: -------------------------------------------------------------------------------- 1 | import java.security.MessageDigest; 2 | 3 | import javax.crypto.KeyGenerator; 4 | import javax.crypto.Mac; 5 | import javax.crypto.SecretKey; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | import sun.misc.BASE64Decoder; 9 | import sun.misc.BASE64Encoder; 10 | 11 | /** 12 | * 基础加密哈希组件 13 | * 14 | * @author 梁栋 15 | * @version 1.0 16 | * @since 1.0 17 | */ 18 | public abstract class Coder { 19 | public static final String KEY_SHA = "SHA"; 20 | public static final String KEY_MD5 = "MD5"; 21 | 22 | /** 23 | * MAC算法可选以下多种算法 24 | * 25 | *
 
 26 |      * HmacMD5  
 27 |      * HmacSHA1  
 28 |      * HmacSHA256  
 29 |      * HmacSHA384  
 30 |      * HmacSHA512 
 31 |      * 
32 | */ 33 | public static final String KEY_MAC = "HmacMD5"; 34 | 35 | /** 36 | * BASE64解密 37 | * 38 | * @param key 39 | * @return 40 | * @throws Exception 41 | */ 42 | public static byte[] decryptBASE64(String key) throws Exception { 43 | return (new BASE64Decoder()).decodeBuffer(key); 44 | } 45 | 46 | /** 47 | * BASE64加密 48 | * 49 | * @param key 50 | * @return 51 | * @throws Exception 52 | */ 53 | public static String encryptBASE64(byte[] key) throws Exception { 54 | return (new BASE64Encoder()).encodeBuffer(key); 55 | } 56 | 57 | /** 58 | * MD5加密 59 | * 60 | * @param data 61 | * @return 62 | * @throws Exception 63 | */ 64 | public static byte[] encryptMD5(byte[] data) throws Exception { 65 | 66 | MessageDigest md5 = MessageDigest.getInstance(KEY_MD5); 67 | md5.update(data); 68 | 69 | return md5.digest(); 70 | 71 | } 72 | 73 | /** 74 | * SHA加密 75 | * 76 | * @param data 77 | * @return 78 | * @throws Exception 79 | */ 80 | public static byte[] encryptSHA(byte[] data) throws Exception { 81 | 82 | MessageDigest sha = MessageDigest.getInstance(KEY_SHA); 83 | sha.update(data); 84 | 85 | return sha.digest(); 86 | 87 | } 88 | 89 | /** 90 | * 初始化HMAC密钥 91 | * 92 | * @return 93 | * @throws Exception 94 | */ 95 | public static String initMacKey() throws Exception { 96 | KeyGenerator keyGenerator = KeyGenerator.getInstance(KEY_MAC); 97 | 98 | SecretKey secretKey = keyGenerator.generateKey(); 99 | return encryptBASE64(secretKey.getEncoded()); 100 | } 101 | 102 | /** 103 | * HMAC加密 104 | * 105 | * @param data 106 | * @param key 107 | * @return 108 | * @throws Exception 109 | */ 110 | public static byte[] encryptHMAC(byte[] data, String key) throws Exception { 111 | 112 | SecretKey secretKey = new SecretKeySpec(decryptBASE64(key), KEY_MAC); 113 | Mac mac = Mac.getInstance(secretKey.getAlgorithm()); 114 | mac.init(secretKey); 115 | 116 | return mac.doFinal(data); 117 | 118 | } 119 | } -------------------------------------------------------------------------------- /src/CommonHttpUtil.java: -------------------------------------------------------------------------------- 1 | import java.util.Map; 2 | import java.io.IOException; 3 | import java.util.concurrent.TimeUnit; 4 | 5 | import com.squareup.okhttp.*; //okhttp2 6 | 7 | //import org.apache.http.util.CharsetUtils; 8 | 9 | public final class CommonHttpUtil { 10 | private OkHttpClient client = null; 11 | 12 | //协议类型 13 | private final static String HTTP = "http:"; 14 | private final static String HTTPS = "https:"; 15 | 16 | // 设置连接超时时间,单位秒。 17 | private static final int CONNECT_TIMEOUT = 10; 18 | 19 | // 请求获取数据的超时时间(即响应时间),单位秒。 20 | private static final int SOCKET_TIMEOUT = 50; 21 | 22 | //共用的静态对象,在强调安全性时最好自行new一个对象使用 23 | private static CommonHttpUtil instance = null; 24 | 25 | public static CommonHttpUtil getInstance() { 26 | if(instance == null) { 27 | instance = new CommonHttpUtil(); 28 | } 29 | return instance; 30 | } 31 | 32 | public CommonHttpUtil(){ 33 | client = new OkHttpClient(); 34 | client.setConnectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS); 35 | //client.setWriteTimeout(SOCKET_TIMEOUT, TimeUnit.SECONDS); 36 | client.setReadTimeout(SOCKET_TIMEOUT, TimeUnit.SECONDS); 37 | //client.retryOnConnectionFailure(false); 38 | } 39 | 40 | public String getContentFromUrl(String url) { 41 | try{ 42 | Request request = new Request.Builder().url(url).build(); 43 | return client.newCall(request).execute().body().string(); 44 | }catch(IOException e){ 45 | e.printStackTrace(); 46 | return null; 47 | } 48 | } 49 | 50 | private String sendPostForm(String url,final Map params) throws Exception { 51 | FormEncodingBuilder builder = new FormEncodingBuilder(); 52 | if (params != null) { 53 | for (Map.Entry entry: params.entrySet()) { 54 | builder.add(entry.getKey(), entry.getValue()); 55 | } 56 | } 57 | RequestBody requestBody = builder.build(); 58 | Request request = new Request.Builder().url(url).post(requestBody).build(); 59 | return client.newCall(request).execute().body().string(); 60 | 61 | } 62 | 63 | public String sendPostJSON(String url,final String post_json)throws Exception { 64 | return sendPostContent(url, post_json, "application/json"); 65 | } 66 | public String sendPostContent(String url,final String post_content,String content_type ) throws Exception { 67 | String result=null; 68 | MediaType media_type = MediaType.parse(content_type); 69 | 70 | RequestBody requestBody = RequestBody.create(media_type,post_content); 71 | Request request = new Request 72 | .Builder() 73 | .post(requestBody)//Post请求的参数传递 74 | .url(url) 75 | .build(); 76 | try{ 77 | Response response = client.newCall(request).execute(); 78 | result = response.body().string(); 79 | response.body().close(); 80 | }catch(IOException e){ 81 | e.printStackTrace(); 82 | } 83 | return result; 84 | } 85 | } -------------------------------------------------------------------------------- /src/JsonRpcService.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | 3 | import org.json.JSONObject; 4 | 5 | import org.bitcoinj.core.Transaction; 6 | 7 | 8 | public interface JsonRpcService { 9 | public String getBalance(String address); 10 | public String send(String source, String destination, Double amount); 11 | public String importPrivateKey(String privateKey); 12 | public String importPrivKey(String privateKey); 13 | public void reparse(); 14 | } 15 | -------------------------------------------------------------------------------- /src/JsonRpcServiceImpl.java: -------------------------------------------------------------------------------- 1 | import java.io.UnsupportedEncodingException; 2 | import java.math.BigDecimal; 3 | import java.math.BigInteger; 4 | import java.nio.ByteBuffer; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | 11 | import org.json.JSONArray; 12 | import org.json.JSONObject; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | import org.bitcoinj.core.Transaction; 17 | 18 | public class JsonRpcServiceImpl implements JsonRpcService { 19 | static Logger logger = LoggerFactory.getLogger(JsonRpcServiceImpl.class); 20 | 21 | public String getBalance(String address) { 22 | BigInteger balance = Util.getBalance(address, "BTC"); 23 | return Double.toString(balance.doubleValue() / Config.btc_unit); 24 | } 25 | 26 | public String send(String source, String destination, Double amount) { 27 | Blocks blocks = Blocks.getInstance(); 28 | BigInteger quantity = new BigDecimal(amount*Config.btc_unit).toBigInteger(); 29 | try { 30 | Transaction tx = blocks.transaction(source, destination, quantity, BigInteger.valueOf(Config.ppkStandardDataFee),null, null); 31 | 32 | blocks.sendTransaction(source, tx); 33 | logger.info("Success! You sent "+amount+" BTC to "+destination+"."); 34 | return tx.getHashAsString(); 35 | } catch (Exception e) { 36 | logger.info("Error! There was a problem with your transaction: "+e.getMessage()); 37 | return "Error: "+e.getMessage(); 38 | } 39 | } 40 | 41 | public String importPrivKey(String privateKey) { 42 | return importPrivateKey(privateKey); 43 | } 44 | public String importPrivateKey(String privateKey) { 45 | Blocks blocks = Blocks.getInstance(); 46 | String address; 47 | try { 48 | address = blocks.importPrivateKey(privateKey); 49 | BigInteger balanceBTC = Util.getBalance(address, "BTC"); 50 | return "\""+address+"\""+":"+String.format("%.8f",balanceBTC.doubleValue() / Config.btc_unit.doubleValue()); 51 | } catch (Exception e) { 52 | return "Error: "+e.getMessage(); 53 | } 54 | } 55 | 56 | public void reparse() { 57 | Blocks blocks = Blocks.getInstance(); 58 | blocks.reparse(); 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /src/JsonRpcServlet.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | 3 | import javax.servlet.ServletException; 4 | import javax.servlet.http.HttpServlet; 5 | import javax.servlet.http.HttpServletRequest; 6 | import javax.servlet.http.HttpServletResponse; 7 | 8 | import com.googlecode.jsonrpc4j.JsonRpcServer; 9 | 10 | 11 | public class JsonRpcServlet extends HttpServlet { 12 | 13 | private JsonRpcServer jsonRpcServer; 14 | 15 | public void init() { 16 | jsonRpcServer = new JsonRpcServer(new JsonRpcServiceImpl()); 17 | } 18 | 19 | @Override 20 | protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 21 | jsonRpcServer.handle(req, resp); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/JsonRpcServletEngine.java: -------------------------------------------------------------------------------- 1 | import org.eclipse.jetty.security.ConstraintMapping; 2 | import org.eclipse.jetty.security.ConstraintSecurityHandler; 3 | import org.eclipse.jetty.security.HashLoginService; 4 | import org.eclipse.jetty.security.SecurityHandler; 5 | import org.eclipse.jetty.security.authentication.BasicAuthenticator; 6 | import org.eclipse.jetty.servlet.ServletContextHandler; 7 | import org.eclipse.jetty.server.Server; 8 | import org.eclipse.jetty.util.security.Constraint; 9 | import org.eclipse.jetty.util.security.Credential; 10 | 11 | public class JsonRpcServletEngine { 12 | public static final int PORT = Config.RPCPort; 13 | Server server; 14 | 15 | public void startup() throws Exception { 16 | server = new Server(PORT); 17 | ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); 18 | context.setContextPath("/"); 19 | if (!Config.RPCUsername.equals("") && !Config.RPCPassword.equals("")) { 20 | context.setSecurityHandler(basicAuth(Config.RPCUsername, Config.RPCPassword, Config.appName)); 21 | } 22 | server.setHandler(context); 23 | context.addServlet(JsonRpcServlet.class, "/"+Config.appName.toLowerCase()); 24 | server.start(); 25 | } 26 | 27 | public void stop() throws Exception { 28 | server.stop(); 29 | } 30 | 31 | public static void main(String args[]) { 32 | JsonRpcServletEngine engine = new JsonRpcServletEngine(); 33 | try { 34 | engine.startup(); 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | private static final SecurityHandler basicAuth(String username, String password, String realm) { 41 | HashLoginService l = new HashLoginService(); 42 | l.putUser(username, Credential.getCredential(password), new String[] {"user"}); 43 | l.setName(realm); 44 | 45 | Constraint constraint = new Constraint(); 46 | constraint.setName(Constraint.__BASIC_AUTH); 47 | constraint.setRoles(new String[]{"user"}); 48 | constraint.setAuthenticate(true); 49 | 50 | ConstraintMapping cm = new ConstraintMapping(); 51 | cm.setConstraint(constraint); 52 | cm.setPathSpec("/*"); 53 | 54 | ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); 55 | csh.setAuthenticator(new BasicAuthenticator()); 56 | csh.setRealmName("myrealm"); 57 | csh.addConstraintMapping(cm); 58 | csh.setLoginService(l); 59 | 60 | return csh; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/JsonRpcTest.java: -------------------------------------------------------------------------------- 1 | import java.net.MalformedURLException; 2 | import java.net.URL; 3 | 4 | import com.googlecode.jsonrpc4j.JsonRpcHttpClient; 5 | import com.googlecode.jsonrpc4j.ProxyUtil; 6 | 7 | public class JsonRpcTest { 8 | 9 | private JsonRpcServletEngine JsonRpcServletEngine; 10 | 11 | public void setup() throws Exception { 12 | JsonRpcServletEngine = new JsonRpcServletEngine(); 13 | JsonRpcServletEngine.startup(); 14 | } 15 | 16 | public void runJsonRpcHttpClient() throws MalformedURLException { 17 | JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL( 18 | "http://127.0.0.1:" + JsonRpcServletEngine.PORT + "/"+ Config.appName.toLowerCase())); 19 | JsonRpcService service = ProxyUtil.createClientProxy( 20 | JsonRpcService.class.getClassLoader(), JsonRpcService.class, 21 | jsonRpcHttpClient); 22 | 23 | System.out.println(service.getBalance("1BckY64TE6VrjVcGMizYBE7gt22axnq6CM")); 24 | } 25 | 26 | public void teardown() throws Exception { 27 | JsonRpcServletEngine.stop(); 28 | } 29 | 30 | public static void main(String args[]) { 31 | JsonRpcTest test = new JsonRpcTest(); 32 | try { 33 | test.setup(); 34 | test.runJsonRpcHttpClient(); 35 | test.teardown(); 36 | } catch (Exception e) { 37 | // TODO Auto-generated catch block 38 | e.printStackTrace(); 39 | } 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /src/Language.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | 3 | import org.json.JSONObject; 4 | 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public class Language { 9 | //uses https://bitbucket.org/xerial/sqlite-jdbc 10 | static Logger logger = LoggerFactory.getLogger(Language.class); 11 | private static JSONObject objLang = null; 12 | private static String currentLang = ""; 13 | 14 | 15 | public static void setLang(String lang) { 16 | if(lang.equals("EN")) 17 | return; 18 | 19 | String langFilename="./resources/static/lang/"+lang+".txt"; 20 | 21 | if (!(new File(langFilename)).exists() ){ 22 | logger.error("Not found language file : "+langFilename); 23 | return; 24 | } 25 | 26 | try{ 27 | String tmpKeyStr=Util.readTextFile(langFilename,Config.PPK_TEXT_CHARSET); 28 | if(tmpKeyStr==null){ 29 | logger.error("Failed to read language data from "+langFilename); 30 | System.exit(0); 31 | } 32 | 33 | objLang=new JSONObject(tmpKeyStr); 34 | 35 | currentLang=lang; 36 | }catch(Exception ex){ 37 | logger.error("Failed to set language :"+ex.toString()); 38 | System.exit(0); 39 | } 40 | } 41 | 42 | public static String getCurrentLang(){ 43 | return currentLang; 44 | } 45 | 46 | public static String getLangLabel(String enStr) { 47 | try{ 48 | if(objLang !=null && objLang.has(enStr)) 49 | return objLang.getString(enStr); 50 | }catch(Exception ex){ 51 | logger.error("Failed to get language string :"+ex.toString()); 52 | } 53 | 54 | return enStr; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/NetCache.java: -------------------------------------------------------------------------------- 1 | //网络内容本地缓存管理 2 | public class NetCache { 3 | //写入缓存,待完善 4 | //改用org.apache.commons.io.FileUtils 5 | public static boolean saveNetCache( String uri, String data ) 6 | { 7 | String cache_filename = getNetCacheFilename(uri); 8 | 9 | if( cache_filename == null ){ 10 | return false; 11 | } 12 | 13 | System.out.println("NetCache.saveNetCache() :"+cache_filename); 14 | Util.exportTextToFile(data,cache_filename); 15 | 16 | return true; 17 | } 18 | 19 | //读取缓存 20 | public static String readNetCache( String uri ) 21 | { 22 | String cache_filename = getNetCacheFilename(uri); 23 | //System.out.println("Util.readNetCache() cache_filename = "+cache_filename); 24 | String str_cached_data = Util.readTextFile(cache_filename); 25 | 26 | /* 27 | if(str_cached_data==null){ 28 | System.out.println("Util.readNetCache() failed to read cache for "+uri); 29 | }else{ 30 | System.out.println("Util.readNetCache() matched cache for "+uri); 31 | } 32 | */ 33 | 34 | return str_cached_data; 35 | } 36 | 37 | //删除缓存 38 | public static void deleteNetCache( String uri ) 39 | { 40 | String cache_filename = getNetCacheFilename(uri); 41 | System.out.println("Util.deleteNetCache() cache_filename = "+cache_filename); 42 | 43 | Util.deleteDir(cache_filename,true); 44 | } 45 | 46 | public static String getNetCacheFilename( String uri ) 47 | { 48 | if(uri==null) 49 | return null; 50 | 51 | String format_safe_filename = java.net.URLEncoder.encode(uri.replaceFirst(":","/")) 52 | .replace("%2F","/").replace("*","#").replace("..","__"); 53 | return Config.cacheDirPrefix + format_safe_filename; 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /src/NoGUI.java: -------------------------------------------------------------------------------- 1 | import java.util.Locale; 2 | 3 | 4 | import kademlia.JKademliaNode; 5 | import kademlia.dht.*; 6 | import kademlia.node.*; 7 | import kademlia.simulations.*; 8 | 9 | public class NoGUI { 10 | /* Kademlia instance */ 11 | public static JKademliaNode kad1; 12 | private final static String BOOTSTRAP_OWNER_ID = "DOSNA"; // Owner id of the bootstrap kademlia instance 13 | private final static int BOOTSTRAP_NODE_PORT = 15049; 14 | 15 | public static void main(String[] args) throws Exception { 16 | boolean bNoSyncBlocks=false; 17 | 18 | if(args!=null){ 19 | System.out.println("args.length:"+args.length); 20 | 21 | for(int aa=0;aa 0) { 65 | if( blocks.ppkBlock < blocks.bitcoinBlock ) 66 | System.out.println(Language.getLangLabel("Getting block")+" " + blocks.ppkBlock + "/" + blocks.bitcoinBlock); 67 | else 68 | System.out.println(Language.getLangLabel("Parsing")+" " + blocks.ppkBlock + "/" + blocks.bitcoinBlock); 69 | } else { 70 | System.out.println(blocks.statusMessage); 71 | } 72 | try { 73 | Thread.sleep(2000); 74 | } catch (InterruptedException e) { 75 | // TODO Auto-generated catch block 76 | e.printStackTrace(); 77 | } 78 | lastParsedBlock=Util.getLastParsedBlock(); 79 | } 80 | 81 | } 82 | }; 83 | 84 | progressUpdateThread.start(); 85 | blocks.init(); 86 | blocks.versionCheck(); 87 | blocks.follow(); 88 | 89 | Thread.sleep(60000); 90 | } 91 | } 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/PPkPeerEventListener.java: -------------------------------------------------------------------------------- 1 | import java.util.List; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import org.bitcoinj.core.Block; 7 | import org.bitcoinj.core.GetDataMessage; 8 | import org.bitcoinj.core.Message; 9 | import org.bitcoinj.core.Peer; 10 | import org.bitcoinj.core.listeners.AbstractPeerEventListener; 11 | import org.bitcoinj.core.Transaction; 12 | import org.bitcoinj.store.BlockStoreException; 13 | import org.bitcoinj.core.FilteredBlock; 14 | import org.bitcoinj.core.PeerAddress; 15 | import java.util.Set; 16 | 17 | public class PPkPeerEventListener extends AbstractPeerEventListener { 18 | Logger logger = LoggerFactory.getLogger(PPkPeerEventListener.class); 19 | 20 | @Override 21 | public List getData(Peer peer, GetDataMessage message) { 22 | return null; 23 | } 24 | 25 | @Override 26 | public void onBlocksDownloaded(Peer peer, Block block, FilteredBlock filteredBlock, int blocksLeft){ 27 | logger.info("BlockHeader left: "+blocksLeft); 28 | /* 29 | //this doesn't work 30 | Blocks blocks = Blocks.getInstance(); 31 | try { 32 | blocks.importBlock(block, blocks.blockStore.get(block.getHash()).getHeight()); 33 | } catch (BlockStoreException e) { 34 | } 35 | */ 36 | } 37 | 38 | @Override 39 | public void onChainDownloadStarted(Peer peer, int blocksLeft) { 40 | logger.info("Chain download started: "+blocksLeft); 41 | } 42 | 43 | @Override 44 | public void onPeerConnected(Peer peer, int peerCount) { 45 | logger.info("Peer connected: "+peerCount); 46 | } 47 | 48 | @Override 49 | public void onPeerDisconnected(Peer peer, int peerCount) { 50 | logger.info("Peer disconnected: "+peerCount); 51 | } 52 | 53 | @Override 54 | public Message onPreMessageReceived(Peer peer, Message message) { 55 | return null; 56 | } 57 | 58 | @Override 59 | public void onTransaction(Peer peer, Transaction tx) { 60 | //logger.info("Got transaction"); 61 | } 62 | 63 | @Override 64 | public void onPeersDiscovered(Set peerAddresses){ 65 | logger.info("Peers discovered"); 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/PPkTool.java: -------------------------------------------------------------------------------- 1 | import java.io.File; 2 | import java.io.FileInputStream; 3 | import java.io.FileNotFoundException; 4 | import java.io.IOException; 5 | import java.util.Properties; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | public class PPkTool { 11 | public static Logger logger = LoggerFactory.getLogger(Blocks.class); 12 | 13 | public static void main(String[] args) { 14 | Config.loadUserDefined(); 15 | 16 | System.out.println(Language.getLangLabel("PPkPub")); 17 | System.out.println(Language.getLangLabel("Loading")+" "+Config.appName+" Tool V"+Config.version); 18 | 19 | Blocks blocks = Blocks.getInstanceSkipVersionCheck(); 20 | 21 | blocks.init(); 22 | blocks.versionCheck(false); 23 | 24 | JsonRpcServletEngine engine = new JsonRpcServletEngine(); 25 | try { 26 | engine.startup(); 27 | } catch (Exception e) { 28 | e.printStackTrace(); 29 | } 30 | 31 | blocks.follow(); 32 | Thread blocksThread = new Thread(blocks); 33 | blocksThread.setDaemon(true); 34 | blocksThread.start(); 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /src/Paseto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Nanne Baars 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import java.security.SignatureException; 26 | 27 | public class Paseto { 28 | 29 | private Paseto() {} 30 | 31 | /** 32 | * https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Version1.md#encrypt 33 | */ 34 | public static String encrypt(byte[] key, String payload, String footer) { 35 | return PasetoLocal.encrypt(key, payload, footer); 36 | } 37 | 38 | /** 39 | * https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Version1.md#decrypt 40 | */ 41 | public static String decrypt(byte[] key, String signedMessage, String footer) { 42 | return PasetoLocal.decrypt(key, signedMessage, footer); 43 | } 44 | 45 | /** 46 | * Sign the token, https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Version1.md#sign 47 | */ 48 | public static String sign(byte[] privateKey, String payload, String footer) { 49 | return PasetoPublic.sign(privateKey, payload, footer); 50 | } 51 | 52 | /** 53 | * Parse the token, https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Version1.md#verify 54 | */ 55 | public static String parse(byte[] publicKey, String signedMessage, String footer) throws SignatureException { 56 | return PasetoPublic.parse(publicKey, signedMessage, footer); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/PasetoUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Nanne Baars 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | import com.google.common.io.BaseEncoding; 26 | import okio.Buffer; 27 | import java.util.Base64; 28 | 29 | public class PasetoUtil { 30 | 31 | private PasetoUtil() {} 32 | 33 | /** 34 | * Authentication Padding 35 | *

36 | * https://github.com/paragonie/paseto/blob/master/docs/01-Protocol-Versions/Common.md#pae-definition 37 | * 38 | * @param pieces string[] of the pieces 39 | */ 40 | public static byte[] pae(byte[]... pieces) { 41 | try (Buffer accumulator = new Buffer()) { 42 | accumulator.writeLongLe(pieces.length); 43 | 44 | for (byte[] piece : pieces) { 45 | accumulator.writeLongLe(piece.length); 46 | accumulator.write(piece); 47 | } 48 | return accumulator.snapshot().toByteArray(); 49 | } 50 | } 51 | 52 | public static byte[] hexToBytes(String hex) { 53 | return BaseEncoding.base16().lowerCase().decode(hex); 54 | } 55 | 56 | public static String encodeToString(byte[] bytes) { 57 | return new String(Base64.getUrlEncoder().encode(bytes)); 58 | } 59 | 60 | public static byte[] decodeFromString(String s) { 61 | return Base64.getUrlDecoder().decode(s); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/PttpDaemon.java: -------------------------------------------------------------------------------- 1 | import java.util.Locale; 2 | 3 | public class PttpDaemon { 4 | public static void main(String[] args) throws Exception { 5 | boolean bNoSyncBlocks=false; 6 | boolean bSyncOnce=false; 7 | if(args!=null){ 8 | System.out.println("args.length:"+args.length); 9 | 10 | for(int aa=0;aa 0) { 45 | if( blocks.ppkBlock < blocks.bitcoinBlock ) 46 | System.out.println(Language.getLangLabel("Getting block")+" " + blocks.ppkBlock + "/" + blocks.bitcoinBlock); 47 | else 48 | System.out.println(Language.getLangLabel("Parsing")+" " + blocks.ppkBlock + "/" + blocks.bitcoinBlock); 49 | } else { 50 | System.out.println(blocks.statusMessage); 51 | } 52 | try { 53 | Thread.sleep(2000); 54 | } catch (InterruptedException e) { 55 | // TODO Auto-generated catch block 56 | e.printStackTrace(); 57 | } 58 | lastParsedBlock=Util.getLastParsedBlock(); 59 | } 60 | 61 | } 62 | }; 63 | 64 | progressUpdateThread.start(); 65 | */ 66 | blocks.init(); 67 | blocks.versionCheck(); 68 | blocks.follow(); 69 | 70 | System.out.println("Waiting a while for new block ......"); 71 | } 72 | 73 | if(bSyncOnce){ 74 | System.exit(-1); 75 | } 76 | Thread.sleep(8000); 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/Send.java: -------------------------------------------------------------------------------- 1 | import java.io.IOException; 2 | import java.io.UnsupportedEncodingException; 3 | import java.math.BigDecimal; 4 | import java.math.BigInteger; 5 | import java.nio.ByteBuffer; 6 | import java.sql.ResultSet; 7 | import java.sql.SQLException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Calendar; 10 | import java.util.Date; 11 | import java.util.List; 12 | import java.util.Map; 13 | import java.util.TimeZone; 14 | 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import com.fasterxml.jackson.core.JsonParseException; 19 | import com.fasterxml.jackson.core.type.TypeReference; 20 | import com.fasterxml.jackson.databind.DeserializationFeature; 21 | import com.fasterxml.jackson.databind.JsonMappingException; 22 | import com.fasterxml.jackson.databind.ObjectMapper; 23 | import org.bitcoinj.core.Transaction; 24 | import com.google.common.primitives.Ints; 25 | 26 | public class Send { 27 | static Logger logger = LoggerFactory.getLogger(Send.class); 28 | public static Integer length = 8+8; 29 | public static Integer id = 0; 30 | 31 | public static OdinTransctionData create(String source, String destination, String asset, BigInteger amount_satoshi, BigInteger fee_satoshi) throws Exception { 32 | if (!source.equals("") && !destination.equals("") && asset.equals("BTC") && amount_satoshi.compareTo(BigInteger.ZERO)>0) { 33 | OdinTransctionData txBTC = new OdinTransctionData( 34 | source, 35 | destination, 36 | amount_satoshi, 37 | fee_satoshi, 38 | "" , 39 | "" 40 | ); 41 | //Blocks blocks = Blocks.getInstance(); 42 | //Transaction txBTC = blocks.transaction(source, destination, amount_satoshi, BigInteger.valueOf(Config.ppkStandardDataFee),null, ""); 43 | 44 | return txBTC; 45 | } else { 46 | throw new Exception("Please specify a source address and destination address, and send more than 0 BTC."); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/UnspentList.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | import java.math.BigDecimal; 3 | import java.util.List; 4 | 5 | public class UnspentList { 6 | public List unspents; 7 | public BigInteger sum_satoshi; //合计金额,以satoshi为单位 8 | public int tx_num; 9 | public int tx_total_num; 10 | 11 | public UnspentList(List utxos,int num,long sum,int total_num ){ 12 | this.unspents=utxos ; 13 | this.sum_satoshi= BigInteger.valueOf( sum ); 14 | this.tx_num=num ; 15 | this.tx_total_num=total_num ; 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/UnspentOutput.java: -------------------------------------------------------------------------------- 1 | import java.math.BigInteger; 2 | 3 | public class UnspentOutput { 4 | public BigInteger amt_satoshi; //以satoshi为单位 5 | public String txid; 6 | public Integer vout; 7 | //public String type; 8 | //public Integer confirmations; 9 | 10 | public String scriptPubKeyHex; 11 | 12 | public String toString(){ 13 | return "UnspentOutput: txid="+txid+" , vout="+vout+",amt_satoshi="+amt_satoshi+" , scriptPubKeyHex="+scriptPubKeyHex; 14 | } 15 | } 16 | --------------------------------------------------------------------------------