├── .DS_Store ├── .gitignore ├── API.md ├── README.md ├── docker-compose.yaml ├── img └── system-design.png ├── nginx └── conf.d │ └── app.conf ├── spring-boot-starter ├── .gitignore ├── .travis.yml ├── Dockerfile ├── README.md ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lombok.config ├── run.sh ├── settings.gradle ├── src │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── fisco │ │ │ │ └── bcos │ │ │ │ ├── Application.java │ │ │ │ ├── autoconfigure │ │ │ │ ├── ContractConfig.java │ │ │ │ ├── EncryptTypeConfig.java │ │ │ │ ├── GroupChannelConnectionsPropertyConfig.java │ │ │ │ ├── ServiceConfig.java │ │ │ │ └── Web3jConfig.java │ │ │ │ ├── bean │ │ │ │ ├── CreditData.java │ │ │ │ └── RecordData.java │ │ │ │ ├── controller │ │ │ │ ├── CreditController.java │ │ │ │ ├── HelloController.java │ │ │ │ └── RecordController.java │ │ │ │ ├── domain │ │ │ │ ├── OriginCredit.java │ │ │ │ ├── RequiredRecord.java │ │ │ │ ├── SavedCredit.java │ │ │ │ └── SendRecord.java │ │ │ │ ├── service │ │ │ │ ├── OriginCreditRepository.java │ │ │ │ ├── RequireRecordRepository.java │ │ │ │ ├── SavedCreditRepository.java │ │ │ │ └── SendRecordRepository.java │ │ │ │ ├── solidity │ │ │ │ ├── Credit.java │ │ │ │ ├── HelloWorld.java │ │ │ │ └── Record.java │ │ │ │ ├── utils │ │ │ │ └── SolidityTools.java │ │ │ │ └── web3sdk │ │ │ │ ├── BrokerException.java │ │ │ │ ├── ErrorCode.java │ │ │ │ ├── Web3SDK2Wrapper.java │ │ │ │ ├── config │ │ │ │ └── FiscoConfig.java │ │ │ │ ├── constant │ │ │ │ └── OpenCreditConstants.java │ │ │ │ └── util │ │ │ │ ├── DataTypeUtils.java │ │ │ │ ├── KeyInfoUtils.java │ │ │ │ ├── LRUCache.java │ │ │ │ ├── SerializeUtils.java │ │ │ │ ├── StoppableTask.java │ │ │ │ ├── SystemInfoUtils.java │ │ │ │ ├── WeEventUtils.java │ │ │ │ └── Web3sdkUtils.java │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── application.yml │ │ │ ├── contract │ │ │ ├── Credit.sol │ │ │ └── HelloWorld.sol │ │ │ ├── fisco.properties │ │ │ ├── logback.groovy │ │ │ └── solidity │ │ │ ├── Credit.abi │ │ │ ├── Credit.bin │ │ │ ├── HelloWorld.abi │ │ │ └── HelloWorld.bin │ └── test │ │ ├── java │ │ └── org │ │ │ └── fisco │ │ │ └── bcos │ │ │ ├── ContractTest.java │ │ │ ├── PrecompiledServiceApiTest.java │ │ │ ├── ServiceTest.java │ │ │ ├── Web3jApiTest.java │ │ │ ├── server │ │ │ ├── Channel2Client.java │ │ │ ├── Channel2Server.java │ │ │ ├── ProxyServerTest.java │ │ │ └── PushCallback.java │ │ │ ├── solidity │ │ │ ├── HelloWorld.java │ │ │ └── SolidityFunctionWrapperGeneratorTest.java │ │ │ └── temp │ │ │ ├── Credit.java │ │ │ ├── HelloWorld.java │ │ │ └── Record.java │ │ └── resources │ │ ├── contract │ │ ├── Credit.sol │ │ ├── HelloWorld.sol │ │ └── Record.sol │ │ └── solidity │ │ ├── Credit.abi │ │ ├── Credit.bin │ │ ├── HelloWorld.abi │ │ ├── HelloWorld.bin │ │ ├── Record.abi │ │ └── Record.bin └── start.sh └── tmp_key ├── node_47.107.32.140_30303 ├── ca.crt ├── node.crt ├── node.key └── node.nodeid ├── sdk ├── ca.crt ├── node.crt └── node.key └── sdk_zwm ├── ca.crt ├── node.crt └── node.key /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanzj/openCredit/99ca39d29c115354f77ab93774b7c37bc9cac9f3/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # API document 2 | 3 | ## Credit 4 | 5 | * `{baseurl}/credit/add` 6 | - Description: Add credit infomation of a person 7 | - Method: `POST` 8 | - FORM-DATA: 9 | ``` 10 | "id":"4404420288808088888" # id string 11 | "data":"bbbc" ## credit data 12 | ``` 13 | - Return: 14 | A number(creditId) 15 | 16 | * `{baseurl}/credit/get` 17 | - Description: Get the list of credit data of a personal id 18 | - Method: `POST` 19 | - FORM-DATA: 20 | ``` 21 | "id":"4404420288808088888" # id string 22 | ``` 23 | - Return (Json): 24 | ``` JSON 25 | [ 26 | { 27 | "id": 1, 28 | "uploader": "0x68c0f317204fdc15b63409f79f420b79ec4e3609", 29 | "type": 0, 30 | "data": "0x256f0a4f6b08925e9b6dcc392a344d18f7dc0228d9c7cf57b6acb9338b626a4d", 31 | "time": "1560257591959" 32 | }, 33 | { 34 | ... 35 | } 36 | ] 37 | ``` 38 | 39 | * `{baseurl}/record/add` 40 | - Description: Add record of a specific credit 41 | - Method: `POST` 42 | - FORM-DATA: 43 | ``` 44 | "creditDataId":"4404420288808088888" # credit id string from `{baseurl}/credit/get` 45 | "uploader":"bbbc" ## `uploader` from `{baseurl}/credit/get` 46 | ``` 47 | - Return: 48 | ``` 49 | { 50 | "applicant": "0x68c0f317204fdc15b63409f79f420b79ec4e3609", 51 | "uploader": "0x0148947262ec5e21739fe3a931c29e8b84ee34a0", 52 | "id": 1, 53 | "creditDataId": 1, 54 | "time": 1560254078475, 55 | "score": 0, 56 | "sent": false, 57 | "scored": false 58 | } 59 | ``` 60 | 61 | * `{baseurl}/record/check` 62 | - Description: Checks if the record is in the block chain 63 | - Method: `POST` 64 | - FORM-DATA: 65 | ``` 66 | "applicant": 67 | "uploader": 68 | "recordId": 69 | "creditDataId": 70 | ``` 71 | - Return (Json): 72 | ``` JSON 73 | {"isSuccess":false} # if can find the record in block chain 74 | ``` 75 | 76 | * `{baseurl}/record/ifSend` 77 | - Description: The uploader decide if send the original data 78 | - Method: `POST` 79 | - FORM-DATA: 80 | ``` 81 | "recordId":"4404420288808088888" 82 | "isSend":true/false 83 | ``` 84 | - Return (Json): 85 | ``` JSON 86 | {"isSuccess":false} 87 | ``` 88 | 89 | if the response is empty 90 | 91 | ``` JSON 92 | { 93 | "timestamp": "2019-06-12T17:08:02.043+0000", 94 | "status": 500, 95 | "error": "Internal Server Error", 96 | "message": "response empty!", 97 | "path": "/credit/ifSend" 98 | } 99 | ``` 100 | 101 | * `{baseurl}/record/get` 102 | - Description: Get a record by a specific id 103 | - Method: `POST` 104 | - FORM-DATA: 105 | ``` 106 | "recordId":"4404420288808088888" 107 | ``` 108 | - Return (Json): 109 | ``` JSON 110 | { 111 | "applicant": "0x68c0f317204fdc15b63409f79f420b79ec4e3609", 112 | "uploader": "0x0148947262ec5e21739fe3a931c29e8b84ee34a0", 113 | "id": 1, 114 | "creditDataId": 1, 115 | "time": 1560254078475, 116 | "score": 0, 117 | "sent": false, 118 | "scored": false 119 | } 120 | ``` 121 | 122 | If the record not exit, get an standard error: 123 | 124 | ``` JSON 125 | { 126 | "timestamp": "2019-06-12T17:08:02.043+0000", 127 | "status": 500, 128 | "error": "Internal Server Error", 129 | "message": "NULL", 130 | "path": "/record/get" 131 | } 132 | ``` 133 | 134 | * `{baseurl}/record/score` 135 | - Description: Give the record score 136 | - Method: `POST` 137 | - FORM-DATA: 138 | ``` 139 | "recordId":"4404420288808088888" 140 | "score":60 141 | ``` 142 | - Return (Json): 143 | the same as `/credit/ifSend` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # openCredit 2 | 3 | 基于 [FISCO-BCOS](https://github.com/FISCO-BCOS/FISCO-BCOS) 区块链平台开发的去中心化征信数据平台。 4 | 5 | ## [API Document](./API.md) 6 | 7 | ## 背景 8 | 9 | 征信系统一方面可以实现了金融类信息的共享;另一方面可以通过加工数据,协助用户控制风险。处理征信数据的技术关键在于数据整合、数据挖掘和评级模型。 10 | 11 | 而目前我国个人征信业务仍处于起步阶段,以公共征信机构为主导,民营征信机构有限。由于各家机构的基因不同,因此在数据收集、评分体系方面也截然不同,相互间缺乏共享渠道和机制。 12 | 13 | 在此背景下,此项目的目的是建立一个覆盖所有与互联网金融发生联系的个人和企业、允许任何互联网金融机构接入的公共征信服务平台。 14 | 15 | ## 使用区块链技术的动机 16 | 17 | 区块链技术的发展使得这一领域产生了新的突破。由于其交易公开透明、安全可靠、难以篡改,并且自带时间戳属性,将区块链技术用于征信数据交易授权具有可行性。通过搭建联盟链的形式,由数据供方在本地存储数据,同时将数据摘要按照既定规则上链。同时为了保证数据信用评级的公平性,根据各个机构提供的数据查询次数和数据有效性,给予不同的数据信用分。这种方法搭建下的体系中,无需改变现有业务流程,并且授权记录可实时更新。随着区块链技术的发展和应用场景的不断增加,区块链技术未来还有可能在征信数据交易行业中发挥更大的作用。 18 | 19 | ## 项目架构设计 20 | 21 | ![架构示意图](./img/system-design.png) 22 | 23 | 说明: 24 | 25 | 1. `Agent A`/`Agent B` 代表两个征信机构,如果它们想要在 `openCredit` 共享数据的话,那么它们就需要申请加入平台的**联盟链**,等待平台审批完成之后才能获取到认证证书(包括私钥),连接上平台的联盟链的网络。 26 | 2. 流程(1)(2)(3):上传者(如机构A)上传征信原始数据的 Hash 到区块链上,与身份证 ID 的 Hash 进行关联。 27 | 3. 流程(4):获取者(如机构B)如果需要查询某人的征信数据,可以通过身份证 ID 的 Hash 值进行检索。 28 | 4. 流程(5):找到合适数据后,获取者调用`智能合约(Smart Contract)`请求征信原始数据,请求记录在区块链上。 29 | 5. 流程(6):上传者审批请求,结果记录在区块链上。 30 | 6. 流程(7):获取者线下通过 HTTPS 请求上传者后台接口请求原始数据,并传Token参数(自己公钥加密后的链上请求记录的ID) 31 | 7. 流程(8):上传者收到数据请求之后验证Token并根据结果发送原始数据。 32 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | nginx: 4 | container_name: openCredit-nginx 5 | image: nginx:1.13 6 | restart: always 7 | ports: 8 | - 28081:80 9 | # - 443:443 10 | volumes: 11 | - ./nginx/conf.d:/etc/nginx/conf.d 12 | # depends_on: 13 | # - app 14 | 15 | mysql: 16 | container_name: opencredit-mysql 17 | image: mysql/mysql-server:5.7 18 | environment: 19 | - MYSQL_ROOT_PASSWORD=root123 20 | - MYSQL_DATABASE=spring_app_db 21 | - MYSQL_USER=app_user 22 | - MYSQL_PASSWORD=test123 23 | # expose: 24 | # - "3306" 25 | ports: 26 | - 23306:3306 27 | restart: always 28 | 29 | # app: 30 | # container_name: opencredit-app 31 | # restart: always 32 | # build: ./spring-boot-starter 33 | # volumes: 34 | # - ./spring-boot-starter:/app 35 | # command: 36 | # ["java", "-cp", "conf/:apps/*:lib/*", "-jar", "/app/dist/apps/openCredit.jar"] 37 | # # expose: 38 | # # - "8080" 39 | # ports: 40 | # - 8080:8080 41 | # depends_on: 42 | # - mysql -------------------------------------------------------------------------------- /img/system-design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanzj/openCredit/99ca39d29c115354f77ab93774b7c37bc9cac9f3/img/system-design.png -------------------------------------------------------------------------------- /nginx/conf.d/app.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | charset utf-8; 4 | access_log off; 5 | 6 | location / { 7 | proxy_pass http://host.docker.internal:28080; 8 | proxy_set_header Host $host:$server_port; 9 | proxy_set_header X-Forwarded-Host $server_name; 10 | proxy_set_header X-Real-IP $remote_addr; 11 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 12 | } 13 | 14 | location /static { 15 | access_log off; 16 | expires 30d; 17 | 18 | alias /app/static; 19 | } 20 | } -------------------------------------------------------------------------------- /spring-boot-starter/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Java template 3 | *.class 4 | 5 | # Mobile Tools for Java (J2ME) 6 | .mtj.tmp/ 7 | 8 | # Package Files # 9 | *.war 10 | *.ear 11 | 12 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 13 | hs_err_pid* 14 | ### Gradle template 15 | .gradle 16 | /build 17 | /log 18 | /logs 19 | 20 | */out/ 21 | out/ 22 | gradle.properties 23 | 24 | # Ignore Gradle GUI config 25 | gradle-app.setting 26 | 27 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 28 | !gradle-wrapper.jar 29 | 30 | # Cache of project 31 | .gradletasknamecache 32 | 33 | # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 34 | # gradle/wrapper/gradle-wrapper.properties 35 | 36 | .idea 37 | *.iml 38 | *.crt 39 | *.key 40 | # OS X 41 | .DS_Store 42 | 43 | /target 44 | 45 | # eclipse 46 | .classpath 47 | .project 48 | .settings/ 49 | bin/ 50 | 51 | dist/ 52 | -------------------------------------------------------------------------------- /spring-boot-starter/.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - oraclejdk8 5 | 6 | sudo: false # as per http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/ 7 | 8 | # Avoid uploading cache after every build with Gradle - see https://docs.travis-ci.com/user/languages/java/#Caching 9 | before_cache: 10 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 11 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 12 | cache: 13 | directories: 14 | - $HOME/.gradle/caches/ 15 | - $HOME/.gradle/wrapper/ 16 | 17 | # Don't run integrationTests as they require a live Ethereum client to be running 18 | # Add --info to view details of autoconfigure failures 19 | script: ./gradlew --info check 20 | 21 | -------------------------------------------------------------------------------- /spring-boot-starter/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gradle:5.4-jdk8-alpine 2 | USER root 3 | WORKDIR /app/dist -------------------------------------------------------------------------------- /spring-boot-starter/README.md: -------------------------------------------------------------------------------- 1 | English / [中文](doc/README_CN.md) 2 | 3 | # Spring Boot Starter 4 | 5 | The sample spring boot project is based on [Web3SDK](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/sdk/sdk.html), which provides the basic framework and basic test cases for blockchain application and helps developers to quickly develop applications based on the FISCO BCOS blockchain. **The version only supports** [FISCO BCOS 2.0](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/introduction.html). 6 | 7 | ## Quickstart 8 | 9 | ### Precodition 10 | Build FISCO BCOS blockchain, please check out [here](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/installation.html)。 11 | 12 | ### Configuration 13 | 14 | ### Download 15 | ``` 16 | $ git clone https://github.com/FISCO-BCOS/spring-boot-starter.git 17 | ``` 18 | #### Certificate Configuration 19 | Copy the `ca.crt`, `node.crt`, and `node.key` files in the node's directory `nodes/${ip}/sdk` to the project's `src/main/resources` directory. 20 | 21 | #### Settings 22 | The `application.yml` of the spring boot project is shown below, and the commented content is modified according to the blockchain node configuration. 23 | 24 | ```yml 25 | encryptType: 0 # 0:standard, 1:guomi 26 | groupChannelConnectionsConfig: 27 | allChannelConnections: 28 | - groupId: 1 #group ID 29 | connectionsStr: 30 | - 127.0.0.1:20200 # node listen_ip:channel_listen_port 31 | - 127.0.0.1:20201 32 | - groupId: 2 33 | connectionsStr: 34 | - 127.0.0.1:20202 35 | - 127.0.0.1:20203 36 | channelService: 37 | groupId: 1 # The specified group to which the SDK connects 38 | orgID: fisco # agency name 39 | ``` 40 | A detail description of the SDK configuration for the project, please checkout [ here](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/sdk/sdk.html#sdk)。 41 | 42 | ### Run 43 | Compile and run test cases: 44 | ``` 45 | $ ./gradlew build 46 | ``` 47 | When all test cases run successfully, it means that the blockchain is running normally,and the project is connected to the blockchain through the SDK. You can develop your blockchain application based on the project。 48 | 49 | ## Test Case Introduction 50 | 51 | The sample project provides test cases for developers to use. The test cases are mainly divided into tests for [Web3j API](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/sdk/sdk.html#web3j-api), [Precompiled Serveice API](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/sdk/sdk.html#precompiled-service-api), Solidity contract file to Java contract file, deployment and call contract. 52 | 53 | ### Web3j API Test 54 | Provide `Web3jApiTest` class to test the Web3j API. The sample test is as follows: 55 | ``` 56 | @Test 57 | public void getBlockNumber() throws IOException { 58 | BigInteger blockNumber = web3j.getBlockNumber().send().getBlockNumber(); 59 | System.out.println(blockNumber); 60 | assertTrue(blockNumber.compareTo(new BigInteger("0"))>= 0); 61 | } 62 | ``` 63 | **Tips:** The `Application` class initializes the Web3j object, which can be used directly in the way where the business code needs it. The usage is as follows: 64 | ``` 65 | @Autowired 66 | private Web3j web3j 67 | ``` 68 | 69 | ### Precompiled Service API Test 70 | Provide `PrecompiledServiceApiTest` class to test the Precompiled Service API。The sample test is as follows: 71 | ```API 72 | @Test 73 | public void testSystemConfigService() throws Exception { 74 | SystemConfigSerivce systemConfigSerivce = new SystemConfigSerivce(web3j, credentials); 75 | systemConfigSerivce.setValueByKey("tx_count_limit", "2000"); 76 | String value = web3j.getSystemConfigByKey("tx_count_limit").send().getSystemConfigByKey(); 77 | System.out.println(value); 78 | assertTrue("2000".equals(value)); 79 | } 80 | ``` 81 | 82 | ### Solidity contract file to Java contract file Test 83 | Provide `SolidityFunctionWrapperGeneratorTest` class to test contract compilation. The sample test is as follows: 84 | ```API 85 | @Test 86 | public void compileSolFilesToJavaTest() throws IOException { 87 | File solFileList = new File("src/test/resources/contract"); 88 | File[] solFiles = solFileList.listFiles(); 89 | 90 | for (File solFile : solFiles) { 91 | 92 | SolidityCompiler.Result res = SolidityCompiler.compile(solFile, true, ABI, BIN, INTERFACE, METADATA); 93 | System.out.println("Out: '" + res.output + "'"); 94 | System.out.println("Err: '" + res.errors + "'"); 95 | CompilationResult result = CompilationResult.parse(res.output); 96 | System.out.println("contractname " + solFile.getName()); 97 | Path source = Paths.get(solFile.getPath()); 98 | String contractname = solFile.getName().split("\\.")[0]; 99 | CompilationResult.ContractMetadata a = result.getContract(solFile.getName().split("\\.")[0]); 100 | System.out.println("abi " + a.abi); 101 | System.out.println("bin " + a.bin); 102 | FileUtils.writeStringToFile(new File("src/test/resources/solidity/" + contractname + ".abi"), a.abi); 103 | FileUtils.writeStringToFile(new File("src/test/resources/solidity/" + contractname + ".bin"), a.bin); 104 | String binFile; 105 | String abiFile; 106 | String tempDirPath = new File("src/test/java/").getAbsolutePath(); 107 | String packageName = "org.fisco.bcos.temp"; 108 | String filename = contractname; 109 | abiFile = "src/test/resources/solidity/" + filename + ".abi"; 110 | binFile = "src/test/resources/solidity/" + filename + ".bin"; 111 | SolidityFunctionWrapperGenerator.main(Arrays.asList( 112 | "-a", abiFile, 113 | "-b", binFile, 114 | "-p", packageName, 115 | "-o", tempDirPath 116 | ).toArray(new String[0])); 117 | } 118 | System.out.println("generate successfully"); 119 | } 120 | ``` 121 | This test case converts all Solidity contract files (`HelloWorld` contract provided by default) in the `src/test/resources/contract` directory to the corresponding `abi` and `bin` files, and save them in the `src/test/resources/solidity` directory. Then convert the `abi` file and the corresponding `bin` file combination into a Java contract file, which is saved in the `src/test/java/org/fisco/bcos/temp` directory. The SDK will use the Java contract file for contract deployment and invocation. 122 | 123 | ### Deployment and Invocation Contract Test 124 | Provide `ContractTest` class to test deploy and call contracts. The sample test is as follows: 125 | ``` 126 | @Test 127 | public void deployAndCallHelloWorld() throws Exception { 128 | //deploy contract 129 | HelloWorld helloWorld = HelloWorld.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); 130 | if (helloWorld != null) { 131 | System.out.println("HelloWorld address is: " + helloWorld.getContractAddress()); 132 | //call set function 133 | helloWorld.set("Hello, World!").send(); 134 | //call get function 135 | String result = helloWorld.get().send(); 136 | System.out.println(result); 137 | assertTrue( "Hello, World!".equals(result)); 138 | } 139 | } 140 | ``` 141 | 142 | ## Related Links 143 | - For FISCO BCOS project, please check out [FISCO BCOS Documentation](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/introduction.html)。 144 | - For Web3SDK project, please check out [Web3SDK Documentation](https://fisco-bcos-documentation.readthedocs.io/zh_CN/release-2.0/docs/sdk/sdk.html)。 145 | - For Spring Boot applications, please check out [Spring Boot](https://spring.io/guides/gs/spring-boot/)。 146 | 147 | ## Community 148 | 149 | By the end of 2018, Financial Blockchain Shenzhen Consortium (FISCO) has attracted and admitted more than 100 members from 6 sectors including banking, fund management, securities brokerage, insurance, regional equity exchanges, and financial information service companies. The first members include the following organizations: Beyondsoft, Huawei, Shenzhen Securities Communications, Digital China, Forms Syntron, Tencent, WeBank, Yuexiu FinTech. 150 | 151 | - Join our WeChat [![Scan](https://img.shields.io/badge/style-Scan_QR_Code-green.svg?logo=wechat&longCache=false&style=social&label=Group)](doc/images/WeChatQR.jpeg) 152 | 153 | - Discuss in [![Gitter](https://img.shields.io/badge/style-on_gitter-green.svg?logo=gitter&longCache=false&style=social&label=Chat)](https://gitter.im/fisco-bcos/Lobby) 154 | 155 | - Read news by [![](https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Follow@FiscoBcos)](https://twitter.com/FiscoBcos) 156 | 157 | - Mail us at [![](https://img.shields.io/twitter/url/http/shields.io.svg?logo=Gmail&style=social&label=service@fisco.com.cn)](mailto:service@fisco.com.cn) -------------------------------------------------------------------------------- /spring-boot-starter/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.1.4.RELEASE' 3 | id "io.freefair.lombok" version "3.2.0" 4 | id 'java' 5 | } 6 | 7 | apply plugin: 'io.spring.dependency-management' 8 | apply plugin: 'idea' 9 | apply plugin: 'eclipse' 10 | apply plugin: 'org.springframework.boot' 11 | //apply plugin: 'war' 12 | //apply plugin: 'application' 13 | 14 | 15 | description = 'Spring Boot Starter' 16 | 17 | sourceCompatibility = 1.8 18 | targetCompatibility = 1.8 19 | 20 | 21 | repositories { 22 | maven { url "http://maven.aliyun.com/nexus/content/groups/public/" } 23 | maven { url "https://dl.bintray.com/ethereum/maven/" } 24 | mavenCentral() 25 | } 26 | 27 | dependencies { 28 | compile 'org.springframework.boot:spring-boot-starter-logging' 29 | compile('org.springframework.boot:spring-boot-starter-web') 30 | 31 | compile 'org.codehaus.groovy:groovy-all:2.5.6' 32 | implementation 'org.springframework.boot:spring-boot-starter-actuator' 33 | annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' 34 | // compileOnly "org.springframework.boot:spring-boot-configuration-processor" 35 | testImplementation 'org.springframework.boot:spring-boot-starter-test' 36 | 37 | compile 'org.fisco-bcos:web3sdk:2.0.0-rc1' 38 | compile 'org.projectlombok:lombok:1.18.6' 39 | 40 | // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...) 41 | compile 'org.springframework.boot:spring-boot-starter-data-jpa' 42 | 43 | // Use MySQL Connector-J 44 | compile 'mysql:mysql-connector-java' 45 | } 46 | 47 | configurations { 48 | all { 49 | exclude group: 'org.slf4j', module: 'slf4j-log4j12' 50 | } 51 | compileOnly { 52 | extendsFrom annotationProcessor 53 | } 54 | } 55 | 56 | sourceSets { 57 | main { 58 | java { 59 | srcDirs = ["src/main/java"] 60 | } 61 | resources { 62 | srcDirs = ["src/main/resources"] 63 | } 64 | } 65 | test { 66 | java { 67 | srcDirs = ["src/test/java"] 68 | } 69 | resources { 70 | srcDirs = ["src/test/resources"] 71 | } 72 | } 73 | } 74 | 75 | clean { 76 | delete 'dist' 77 | delete 'build' 78 | } 79 | 80 | bootJar { 81 | destinationDir file('dist/apps') 82 | archiveName project.name + '.jar' 83 | exclude '**/*.xml' 84 | // exclude '**/*.properties' 85 | 86 | doLast { 87 | copy { 88 | from file('src/main/resources/') 89 | into 'dist/conf' 90 | } 91 | copy { 92 | from file('files/') 93 | into 'dist/files' 94 | } 95 | copy { 96 | from configurations.runtime 97 | into 'dist/lib' 98 | } 99 | copy { 100 | from file('.').listFiles().findAll{File f -> (f.name.endsWith('.bat') || f.name.endsWith('.sh') || f.name.endsWith('.env'))} 101 | into 'dist' 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /spring-boot-starter/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yanzj/openCredit/99ca39d29c115354f77ab93774b7c37bc9cac9f3/spring-boot-starter/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /spring-boot-starter/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 24 23:32:45 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip 7 | -------------------------------------------------------------------------------- /spring-boot-starter/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin, switch paths to Windows format before running java 129 | if $cygwin ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=$((i+1)) 158 | done 159 | case $i in 160 | (0) set -- ;; 161 | (1) set -- "$args0" ;; 162 | (2) set -- "$args0" "$args1" ;; 163 | (3) set -- "$args0" "$args1" "$args2" ;; 164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=$(save "$@") 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 185 | cd "$(dirname "$0")" 186 | fi 187 | 188 | exec "$JAVACMD" "$@" 189 | -------------------------------------------------------------------------------- /spring-boot-starter/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem http://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /spring-boot-starter/lombok.config: -------------------------------------------------------------------------------- 1 | # This file is generated by the 'io.freefair.lombok' Gradle plugin 2 | config.stopBubbling = true 3 | -------------------------------------------------------------------------------- /spring-boot-starter/run.sh: -------------------------------------------------------------------------------- 1 | docker-compose up -d 2 | # cp ~/generator-ZWM/dir_sdk_ca/sdk/* src/main/resources 3 | # cp ~/generator-ZQH/dir_sdk_ca/sdk/* src/main/resources 4 | ./gradlew clean 5 | ./gradlew build 6 | cd dist 7 | chmod +x start.sh && ./start.sh 8 | -------------------------------------------------------------------------------- /spring-boot-starter/settings.gradle: -------------------------------------------------------------------------------- 1 | // This should not be shortened 2 | // See http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html#boot-features-custom-starter-naming 3 | rootProject.name = 'openCredit' 4 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/Application.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos; 2 | 3 | import org.fisco.bcos.channel.client.Service; 4 | import org.fisco.bcos.web3j.protocol.Web3j; 5 | import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.SpringApplication; 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; 10 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | 16 | @SpringBootApplication 17 | @EnableConfigurationProperties 18 | @RestController 19 | public class Application { 20 | @Value("${spring.application.name}") 21 | private String name; 22 | 23 | public static void main(String[] args) { 24 | SpringApplication.run(Application.class, args); 25 | } 26 | 27 | @RequestMapping(value = "/") 28 | public String name() { 29 | return "Hello world, here is "+ name; 30 | } 31 | 32 | // @Bean 33 | // public Web3j getWeb3j(Service service) throws Exception { 34 | // ChannelEthereumService channelEthereumService = new ChannelEthereumService(); 35 | // System.out.println(service.getGroupId()); 36 | // service.setGroupId(1); 37 | // service.run(); 38 | // channelEthereumService.setChannelService(service); 39 | // channelEthereumService.setTimeout(30000); 40 | // return Web3j.build(channelEthereumService,service.getGroupId()); 41 | // } 42 | } 43 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/autoconfigure/ContractConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.autoconfigure; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.apache.tomcat.jni.Error; 5 | import org.fisco.bcos.solidity.Credit; 6 | import org.fisco.bcos.solidity.Record; 7 | import org.fisco.bcos.web3j.crypto.Credentials; 8 | import org.fisco.bcos.web3j.precompile.cns.CnsInfo; 9 | import org.fisco.bcos.web3j.precompile.cns.CnsService; 10 | import org.fisco.bcos.web3j.protocol.Web3j; 11 | import org.fisco.bcos.web3j.tx.gas.StaticGasProvider; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.context.properties.ConfigurationProperties; 14 | import org.springframework.context.annotation.Bean; 15 | import org.springframework.context.annotation.Configuration; 16 | 17 | import java.math.BigInteger; 18 | import java.util.List; 19 | 20 | @Slf4j 21 | @Configuration 22 | @ConfigurationProperties(prefix = "contract-type") 23 | public class ContractConfig { 24 | 25 | private static BigInteger gasPrice = new BigInteger("300000000"); 26 | private static BigInteger gasLimit = new BigInteger("300000000"); 27 | 28 | private final String CREDIT_CONTRACT = "Credit"; 29 | private final String CREDIT_CONTRACT_VERSION = "1"; 30 | private final String RECORD_CONTRACT = "Record"; 31 | private final String RECORD_CONTRACT_VERSION = "1"; 32 | 33 | @Autowired 34 | Credentials credentials; 35 | 36 | @Autowired 37 | Web3j web3j; 38 | 39 | @Autowired 40 | CnsService cnsService; 41 | 42 | @Bean 43 | public Credit getCredit () throws Exception { 44 | Credit credit = null; 45 | List cnsInfoList = cnsService.queryCnsByName(CREDIT_CONTRACT); 46 | if (cnsInfoList.isEmpty()) { 47 | log.info("Contract Credit not found, register"); 48 | // register 49 | try { 50 | credit = Credit.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); 51 | } catch (Exception e) { 52 | System.out.println(e.toString()); 53 | log.error("Error: getCredit: " + e.toString()); 54 | throw e; 55 | } 56 | cnsService.registerCns(CREDIT_CONTRACT, CREDIT_CONTRACT_VERSION, credit.getContractAddress(), credit.getContractBinary()); 57 | } else { 58 | String addr = cnsInfoList.get(0).getAddress(); 59 | credit = Credit.load(addr, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)); 60 | } 61 | 62 | log.info("Contract Credit address = {}", credit.getContractAddress()); 63 | 64 | return credit; 65 | } 66 | 67 | @Bean 68 | public Record getRecord () throws Exception { 69 | Record record; 70 | List cnsInfoList = cnsService.queryCnsByName(RECORD_CONTRACT); 71 | if (cnsInfoList.isEmpty()) { 72 | log.info("Contract Record not found, register"); 73 | // register 74 | try { 75 | record = Record.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); 76 | } catch (Exception e) { 77 | System.out.println(e.toString()); 78 | log.error("Error: getCredit: " + e.toString()); 79 | throw e; 80 | } 81 | cnsService.registerCns(RECORD_CONTRACT, RECORD_CONTRACT_VERSION, record.getContractAddress(), record.getContractBinary()); 82 | } else { 83 | String addr = cnsInfoList.get(0).getAddress(); 84 | record = Record.load(addr, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)); 85 | } 86 | log.info("Contract Record address = {}", record.getContractAddress()); 87 | 88 | return record; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/autoconfigure/EncryptTypeConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.autoconfigure; 2 | 3 | import org.fisco.bcos.web3j.crypto.EncryptType; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | 8 | @Configuration 9 | @ConfigurationProperties(prefix = "encrypt-type") 10 | public class EncryptTypeConfig { 11 | private int encryptType; 12 | 13 | @Bean 14 | public EncryptType getEncryptType() { 15 | return new EncryptType(encryptType); 16 | } 17 | 18 | public void setEncryptType(int encryptType) { 19 | this.encryptType = encryptType; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/autoconfigure/GroupChannelConnectionsPropertyConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.autoconfigure; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.fisco.bcos.channel.client.Service; 7 | import org.fisco.bcos.channel.handler.ChannelConnections; 8 | import org.fisco.bcos.channel.handler.GroupChannelConnectionsConfig; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.context.properties.ConfigurationProperties; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | 14 | import lombok.Data; 15 | 16 | @Data 17 | @Configuration 18 | @ConfigurationProperties(prefix = "group-channel-connections-config") 19 | public class GroupChannelConnectionsPropertyConfig { 20 | 21 | List allChannelConnections = new ArrayList<>(); 22 | 23 | @Bean 24 | public GroupChannelConnectionsConfig getGroupChannelConnections() { 25 | GroupChannelConnectionsConfig groupChannelConnectionsConfig = new GroupChannelConnectionsConfig(); 26 | groupChannelConnectionsConfig.setAllChannelConnections(allChannelConnections); 27 | return groupChannelConnectionsConfig; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/autoconfigure/ServiceConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.autoconfigure; 2 | 3 | import org.fisco.bcos.channel.client.Service; 4 | import org.fisco.bcos.channel.handler.GroupChannelConnectionsConfig; 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import lombok.Data; 10 | 11 | @Data 12 | @Configuration 13 | @ConfigurationProperties(prefix = "channel-service") 14 | public class ServiceConfig { 15 | 16 | private String orgID; 17 | private Integer connectSeconds = 30; 18 | private Integer connectSleepPerMillis = 10; 19 | private GroupChannelConnectionsConfig allChannelConnections; 20 | private static int groupId = 1; 21 | 22 | @Bean 23 | public Service getService(GroupChannelConnectionsConfig groupChannelConnectionsConfig) { 24 | Service channelService = new Service(); 25 | channelService.setConnectSeconds(connectSeconds); 26 | channelService.setOrgID(orgID); 27 | channelService.setConnectSleepPerMillis(connectSleepPerMillis); 28 | channelService.setGroupId(groupId); 29 | channelService.setAllChannelConnections(groupChannelConnectionsConfig); 30 | return channelService; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/autoconfigure/Web3jConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.autoconfigure; 2 | 3 | import lombok.Data; 4 | import org.fisco.bcos.channel.client.Service; 5 | import org.fisco.bcos.web3j.crypto.Credentials; 6 | import org.fisco.bcos.web3j.crypto.gm.GenCredential; 7 | import org.fisco.bcos.web3j.crypto.gm.KeyInfo; 8 | import org.fisco.bcos.web3j.crypto.gm.KeyInfoInterface; 9 | import org.fisco.bcos.web3j.precompile.cns.CnsService; 10 | import org.fisco.bcos.web3j.protocol.Web3j; 11 | import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService; 12 | import org.fisco.bcos.web3sdk.config.FiscoConfig; 13 | import org.fisco.bcos.web3sdk.util.KeyInfoUtils; 14 | import org.springframework.boot.context.properties.ConfigurationProperties; 15 | import org.springframework.context.annotation.Bean; 16 | import org.springframework.context.annotation.Configuration; 17 | 18 | @Data 19 | @Configuration 20 | @ConfigurationProperties(prefix = "web3j-config") 21 | public class Web3jConfig { 22 | 23 | 24 | @Bean 25 | public KeyInfoUtils getKeyInfoUtils() { 26 | KeyInfoUtils keyInfoUtils = new KeyInfoUtils(); 27 | keyInfoUtils.loadPrivateKeyInfo("./node.key"); 28 | return keyInfoUtils; 29 | } 30 | 31 | @Bean 32 | public Web3j getWeb3j(Service service) throws Exception { 33 | ChannelEthereumService channelEthereumService = new ChannelEthereumService(); 34 | service.run(); 35 | channelEthereumService.setChannelService(service); 36 | channelEthereumService.setTimeout(30000); 37 | return Web3j.build(channelEthereumService,service.getGroupId()); 38 | } 39 | 40 | @Bean 41 | public Credentials getCredentials(KeyInfoUtils keyInfoUtils) { 42 | 43 | // Todo: 先写死,后期得从本地读取 private key 然后生成 44 | // return GenCredential.create("b83261efa42895c38c6c2364ca878f43e77f3cddbc922bf57d0d48070f79feb6"); 45 | Credentials credentials; 46 | try { 47 | String privateKey = keyInfoUtils.getPrivateKey(); 48 | // 取 49 | credentials = GenCredential.create(privateKey.substring(privateKey.length() - 21, privateKey.length()-1)); 50 | } catch (Exception e) { 51 | System.out.println(e.toString()); 52 | throw e; 53 | } 54 | return credentials; 55 | 56 | } 57 | 58 | @Bean 59 | public CnsService getCnsService(Web3j web3j, Credentials credentials) { 60 | CnsService cnsService = new CnsService(web3j, credentials); 61 | return cnsService; 62 | // List qcns = cnsService.queryCnsByNameAndVersion("Credit", 1); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/bean/CreditData.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.bean; 2 | 3 | import java.math.BigInteger; 4 | import java.util.List; 5 | 6 | public class CreditData { 7 | 8 | BigInteger id; 9 | String uploader; 10 | BigInteger type; 11 | String data; 12 | String time; 13 | 14 | public CreditData(BigInteger id, String uploader, String data, BigInteger type, String time) { 15 | this.id = id; 16 | this.uploader = uploader; 17 | this.data = data; 18 | this.type = type; 19 | this.time = time; 20 | } 21 | 22 | 23 | public BigInteger getId() { 24 | return id; 25 | } 26 | 27 | public void setId(BigInteger id) { 28 | this.id = id; 29 | } 30 | 31 | public String getUploader() { 32 | return uploader; 33 | } 34 | 35 | public void setUploader(String uploader) { 36 | this.uploader = uploader; 37 | } 38 | 39 | public String getData() { 40 | return data; 41 | } 42 | 43 | public void setData(String data) { 44 | this.data = data; 45 | } 46 | 47 | public String getTime() { 48 | return time; 49 | } 50 | 51 | public void setTime(String time) { 52 | this.time = time; 53 | } 54 | 55 | public BigInteger getType() { 56 | return type; 57 | } 58 | 59 | public void setType(BigInteger type) { 60 | this.type = type; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "CreditData{" + 66 | "id=" + id + 67 | ", uploader='" + uploader + '\'' + 68 | ", type=" + type + 69 | ", data='" + data + '\'' + 70 | ", time='" + time + '\'' + 71 | '}'; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/bean/RecordData.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.bean; 2 | 3 | import org.fisco.bcos.solidity.Record; 4 | import org.fisco.bcos.web3j.tuples.generated.Tuple8; 5 | 6 | import java.math.BigInteger; 7 | 8 | public class RecordData { 9 | 10 | String applicant; // the organize want the data 11 | String uploader; // the organize upload the data 12 | BigInteger id; // index 13 | BigInteger creditDataId; // the id of credit data 14 | BigInteger time; 15 | Boolean isSent; // whether the original data has been sent from the uploader 16 | BigInteger score; // the score of this record 17 | Boolean isScored; // whether the uploader has scored 18 | 19 | public RecordData() { 20 | } 21 | 22 | public RecordData(String applicant, String owner, BigInteger id, BigInteger creditDataId, BigInteger time, Boolean isSent, BigInteger score, Boolean isScored) { 23 | this.applicant = applicant; 24 | this.uploader = owner; 25 | this.id = id; 26 | this.creditDataId = creditDataId; 27 | this.time = time; 28 | this.isSent = isSent; 29 | this.score = score; 30 | this.isScored = isScored; 31 | } 32 | 33 | public RecordData(Record.AddRecordSuccessEventResponse reponse) { 34 | this.applicant = reponse._applicant; 35 | this.uploader = reponse._uploader; 36 | this.id = reponse._id; 37 | this.creditDataId = reponse._creditDataId; 38 | this.time = reponse._time; 39 | this.isSent = false; 40 | this.score = new BigInteger("0"); 41 | this.isScored = false; 42 | } 43 | 44 | public RecordData(Tuple8 result) { 45 | this.applicant = result.getValue1(); 46 | this.uploader = result.getValue2(); 47 | this.id = result.getValue3(); 48 | this.creditDataId = result.getValue4(); 49 | this.time = result.getValue5(); 50 | this.isSent = result.getValue6(); 51 | this.score = result.getValue7(); 52 | this.isScored = result.getValue8(); 53 | } 54 | 55 | public String getApplicant() { 56 | return applicant; 57 | } 58 | 59 | public void setApplicant(String applicant) { 60 | this.applicant = applicant; 61 | } 62 | 63 | public String getUploader() { 64 | return uploader; 65 | } 66 | 67 | public void setUploader(String uploader) { 68 | this.uploader = uploader; 69 | } 70 | 71 | public BigInteger getId() { 72 | return id; 73 | } 74 | 75 | public void setId(BigInteger id) { 76 | this.id = id; 77 | } 78 | 79 | public BigInteger getCreditDataId() { 80 | return creditDataId; 81 | } 82 | 83 | public void setCreditDataId(BigInteger creditDataId) { 84 | this.creditDataId = creditDataId; 85 | } 86 | 87 | public BigInteger getTime() { 88 | return time; 89 | } 90 | 91 | public void setTime(BigInteger time) { 92 | this.time = time; 93 | } 94 | 95 | public Boolean getSent() { 96 | return isSent; 97 | } 98 | 99 | public void setSent(Boolean sent) { 100 | isSent = sent; 101 | } 102 | 103 | public BigInteger getScore() { 104 | return score; 105 | } 106 | 107 | public void setScore(BigInteger score) { 108 | this.score = score; 109 | } 110 | 111 | public Boolean getScored() { 112 | return isScored; 113 | } 114 | 115 | public void setScored(Boolean scored) { 116 | isScored = scored; 117 | } 118 | 119 | @Override 120 | public String toString() { 121 | return "RecordData{" + 122 | "applicant='" + applicant + '\'' + 123 | ", uploader='" + uploader + '\'' + 124 | ", id=" + id + 125 | ", creditDataId=" + creditDataId + 126 | ", time=" + time + 127 | ", isSent=" + isSent + 128 | ", score=" + score + 129 | ", isScored=" + isScored + 130 | '}'; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/controller/CreditController.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.controller; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.fisco.bcos.bean.CreditData; 6 | import org.fisco.bcos.domain.OriginCredit; 7 | import org.fisco.bcos.domain.RequiredRecord; 8 | import org.fisco.bcos.domain.SavedCredit; 9 | import org.fisco.bcos.service.OriginCreditRepository; 10 | import org.fisco.bcos.service.RequireRecordRepository; 11 | import org.fisco.bcos.service.SavedCreditRepository; 12 | import org.fisco.bcos.solidity.Credit; 13 | import org.fisco.bcos.web3j.crypto.Hash; 14 | import org.fisco.bcos.web3j.protocol.Web3j; 15 | import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt; 16 | import org.fisco.bcos.web3j.tuples.generated.Tuple5; 17 | import org.fisco.bcos.web3j.utils.Numeric; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import java.math.BigInteger; 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | @Slf4j 26 | @CrossOrigin(origins = "http://localhost:8081") 27 | @RestController 28 | @RequestMapping(value = "/credit") 29 | public class CreditController { 30 | 31 | @Autowired 32 | Web3j web3j; 33 | 34 | @Autowired 35 | Credit credit; 36 | 37 | @Autowired 38 | OriginCreditRepository originCreditRepository; 39 | 40 | @Autowired 41 | SavedCreditRepository savedCreditRepository; 42 | 43 | @Autowired 44 | RequireRecordRepository requireRecordRepository; 45 | 46 | /** 47 | * Add a credit to the block chain 48 | * @param id people id 49 | * @param data the credit data of the people 50 | * @return 51 | * @throws Exception 52 | */ 53 | @PostMapping(value = "/add") 54 | public @ResponseBody String addCredit(@RequestParam("id") String id, 55 | @RequestParam("data") String data, 56 | @RequestParam("type") BigInteger type) throws Exception { 57 | log.info("/credit/add"); 58 | TransactionReceipt result = credit.addCreditData(id, data).sendAsync().get(); 59 | List reponses = credit.getAddCreditDataSuccessEvents(result); 60 | 61 | // Construct return 62 | JSONObject jsonObject = new JSONObject(); 63 | jsonObject.put("id", reponses.get(0).id); 64 | 65 | OriginCredit originCredit = new OriginCredit(); 66 | originCredit.setCreditId(reponses.get(0).id); 67 | originCredit.setDataOrigin(data); 68 | originCredit.setDataHash(Hash.sha3String(data)); 69 | originCredit.setType(type); 70 | 71 | originCreditRepository.save(originCredit); 72 | 73 | log.info("return: " + jsonObject.toJSONString()); 74 | return jsonObject.toJSONString(); 75 | } 76 | 77 | 78 | /** 79 | * Get the credits data on people id 80 | * @param id people id 81 | * @return List of credit data 82 | * @throws Exception 83 | */ 84 | @PostMapping(value = "/get") 85 | public @ResponseBody List getCredits(@RequestParam("id") String id 86 | ) throws Exception { 87 | // Uint256 result = new Uint256(); 88 | Tuple5, List, List, List, List> result = credit.getCreditDetialDataByPeopleId(id).sendAsync().get(); 89 | ArrayList credits = new ArrayList<>(); 90 | for (int i = 0; i < result.getValue1().size(); i++) { 91 | CreditData creditData = new CreditData(result.getValue1().get(i), 92 | result.getValue2().get(i), 93 | Numeric.toHexString(result.getValue3().get(i)), 94 | result.getValue5().get(i), 95 | String.valueOf(result.getValue4().get(0))); 96 | credits.add(creditData); 97 | } 98 | return credits; 99 | } 100 | 101 | /** 102 | * 接收其他机构传送的原始资料 103 | * @param id 104 | * @param dataOrigin 105 | * @param dataHash 106 | * @param type 107 | * @param token 108 | * @return 109 | */ 110 | @PostMapping(value = "/send") 111 | public String send(@RequestParam("id") BigInteger id, 112 | @RequestParam("dataOrigin") String dataOrigin, 113 | @RequestParam("dataHash") String dataHash, 114 | @RequestParam("type") BigInteger type, 115 | @RequestParam("token") BigInteger token) { 116 | 117 | JSONObject jsonObject = new JSONObject(); 118 | boolean isSuccess = false; 119 | try { 120 | SavedCredit sv = new SavedCredit(); 121 | sv.setCreditId(id); 122 | sv.setDataOrigin(dataOrigin); 123 | sv.setDataHash(dataHash); 124 | sv.setType(type); 125 | 126 | RequiredRecord rr = requireRecordRepository.findByCreditId(sv.getCreditId()); 127 | if (! rr.getToken().equals(token)) { 128 | throw new Exception("token is not correct"); 129 | } 130 | 131 | rr.setSent(true); 132 | rr.setDataOrigin(sv.getDataOrigin()); 133 | rr.setDataHash(sv.getDataHash()); 134 | rr.setType(type); 135 | requireRecordRepository.save(rr); 136 | savedCreditRepository.save(sv); 137 | 138 | isSuccess = true; 139 | } catch (Exception e) { 140 | jsonObject.put("error", e.toString()); 141 | } 142 | jsonObject.put("isSuccess", isSuccess); 143 | 144 | return jsonObject.toJSONString(); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.controller; 2 | 3 | import org.fisco.bcos.solidity.HelloWorld; 4 | import org.fisco.bcos.web3j.crypto.Credentials; 5 | import org.fisco.bcos.web3j.crypto.gm.GenCredential; 6 | import org.fisco.bcos.web3j.protocol.Web3j; 7 | import org.fisco.bcos.web3j.tx.gas.StaticGasProvider; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.io.IOException; 14 | import java.math.BigInteger; 15 | 16 | @RestController 17 | @RequestMapping(value = "/hello") 18 | public class HelloController { 19 | 20 | private static BigInteger gasPrice = new BigInteger("300000000"); 21 | private static BigInteger gasLimit = new BigInteger("300000000"); 22 | private Credentials credentials; 23 | 24 | @Autowired 25 | Web3j web3j; 26 | 27 | @GetMapping(value = "/") 28 | public String sayHello() throws Exception { 29 | credentials = GenCredential.create("b83261efa42895c38c6c2364ca878f43e77f3cddbc922bf57d0d48070f79feb6"); 30 | if (credentials == null) { 31 | throw new Exception("create Credentials failed"); 32 | } 33 | 34 | System.out.println("Start hello world"); 35 | String result = ""; 36 | HelloWorld helloWorld = HelloWorld.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); 37 | if (helloWorld != null) { 38 | System.out.println("HelloWorld address is: " + helloWorld.getContractAddress()); 39 | //call set function 40 | helloWorld.set("Hello, World!").send(); 41 | //call get function 42 | result = helloWorld.get().send(); 43 | System.out.println(result); 44 | 45 | } 46 | return result; 47 | } 48 | 49 | @GetMapping(value = "/getBlockNumber") 50 | public String getBlockNumber() throws IOException { 51 | BigInteger blockNumber = web3j.getBlockNumber().send().getBlockNumber(); 52 | return blockNumber.toString(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/domain/OriginCredit.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.domain; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import java.math.BigInteger; 6 | 7 | @Entity 8 | public class OriginCredit { 9 | 10 | @Id 11 | private BigInteger creditId; 12 | 13 | private String uploader; 14 | 15 | private String dataOrigin; 16 | 17 | private String dataHash; 18 | 19 | private BigInteger type; 20 | 21 | private String time; 22 | 23 | public BigInteger getCreditId() { 24 | return creditId; 25 | } 26 | 27 | public void setCreditId(BigInteger creditId) { 28 | this.creditId = creditId; 29 | } 30 | 31 | public String getDataOrigin() { 32 | return dataOrigin; 33 | } 34 | 35 | public void setDataOrigin(String dataOrigin) { 36 | this.dataOrigin = dataOrigin; 37 | } 38 | 39 | public String getDataHash() { 40 | return dataHash; 41 | } 42 | 43 | public void setDataHash(String dataHash) { 44 | this.dataHash = dataHash; 45 | } 46 | 47 | public BigInteger getType() { 48 | return type; 49 | } 50 | 51 | public void setType(BigInteger type) { 52 | this.type = type; 53 | } 54 | 55 | public String getUploader() { 56 | return uploader; 57 | } 58 | 59 | public void setUploader(String uploader) { 60 | this.uploader = uploader; 61 | } 62 | 63 | public String getTime() { 64 | return time; 65 | } 66 | 67 | public void setTime(String time) { 68 | this.time = time; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/domain/RequiredRecord.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.domain; 2 | 3 | 4 | import org.apache.commons.lang.math.RandomUtils; 5 | import org.fisco.bcos.service.OriginCreditRepository; 6 | import org.fisco.bcos.solidity.Record; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | 9 | import javax.persistence.Entity; 10 | import javax.persistence.Id; 11 | import java.math.BigInteger; 12 | import java.util.Random; 13 | 14 | @Entity 15 | public class RequiredRecord { 16 | 17 | @Id 18 | private BigInteger recordId; // index 19 | 20 | private String applicant; // the organize want the data 21 | private String uploader; // the organize upload the data 22 | private BigInteger time; 23 | 24 | private Boolean isSent; // whether the original data has been sent from the uploader 25 | 26 | private Boolean isScored; // whether the uploader has scored 27 | 28 | private BigInteger score; // the score of this record 29 | 30 | private BigInteger creditId; // the id of credit data 31 | 32 | private String dataOrigin; 33 | 34 | private String dataHash; 35 | 36 | private BigInteger type; 37 | 38 | private BigInteger token; // for sending original data 39 | 40 | public BigInteger getToken() { 41 | return token; 42 | } 43 | 44 | public void setToken(BigInteger token) { 45 | this.token = token; 46 | } 47 | 48 | public RequiredRecord() { 49 | } 50 | 51 | public RequiredRecord(Record.AddRecordSuccessEventResponse response) { 52 | recordId = response._id; 53 | applicant = response._applicant; 54 | uploader = response._uploader; 55 | creditId = response._creditDataId; 56 | time = response._time; 57 | 58 | isSent = false; 59 | isScored = false; 60 | 61 | // generate random token 62 | BigInteger maxLimit = new BigInteger("5000000000000"); 63 | BigInteger minLimit = new BigInteger("25000000000"); 64 | BigInteger bigInteger = maxLimit.subtract(minLimit); 65 | Random randNum = new Random(); 66 | int len = maxLimit.bitLength(); 67 | BigInteger res = new BigInteger(len, randNum); 68 | if (res.compareTo(minLimit) < 0) 69 | res = res.add(minLimit); 70 | if (res.compareTo(bigInteger) >= 0) 71 | res = res.mod(bigInteger).add(minLimit); 72 | 73 | token = res; 74 | } 75 | 76 | public BigInteger getCreditId() { 77 | return creditId; 78 | } 79 | 80 | public void setCreditId(BigInteger creditId) { 81 | this.creditId = creditId; 82 | } 83 | 84 | public String getDataOrigin() { 85 | return dataOrigin; 86 | } 87 | 88 | public void setDataOrigin(String dataOrigin) { 89 | this.dataOrigin = dataOrigin; 90 | } 91 | 92 | public String getDataHash() { 93 | return dataHash; 94 | } 95 | 96 | public void setDataHash(String dataHash) { 97 | this.dataHash = dataHash; 98 | } 99 | 100 | public BigInteger getType() { 101 | return type; 102 | } 103 | 104 | public void setType(BigInteger type) { 105 | this.type = type; 106 | } 107 | 108 | public BigInteger getRecordId() { 109 | return recordId; 110 | } 111 | 112 | public void setRecordId(BigInteger recordId) { 113 | this.recordId = recordId; 114 | } 115 | 116 | public String getApplicant() { 117 | return applicant; 118 | } 119 | 120 | public void setApplicant(String applicant) { 121 | this.applicant = applicant; 122 | } 123 | 124 | public String getUploader() { 125 | return uploader; 126 | } 127 | 128 | public void setUploader(String uploader) { 129 | this.uploader = uploader; 130 | } 131 | 132 | public BigInteger getTime() { 133 | return time; 134 | } 135 | 136 | public void setTime(BigInteger time) { 137 | this.time = time; 138 | } 139 | 140 | public Boolean getSent() { 141 | return isSent; 142 | } 143 | 144 | public void setSent(Boolean sent) { 145 | isSent = sent; 146 | } 147 | 148 | public Boolean getScored() { 149 | return isScored; 150 | } 151 | 152 | public void setScored(Boolean scored) { 153 | isScored = scored; 154 | } 155 | 156 | public BigInteger getScore() { 157 | return score; 158 | } 159 | 160 | public void setScore(BigInteger score) { 161 | this.score = score; 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/domain/SavedCredit.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.domain; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import java.math.BigInteger; 6 | 7 | @Entity 8 | public class SavedCredit { 9 | 10 | @Id 11 | private BigInteger creditId; 12 | 13 | private String dataOrigin; 14 | 15 | private String dataHash; 16 | 17 | private BigInteger type; 18 | 19 | public BigInteger getCreditId() { 20 | return creditId; 21 | } 22 | 23 | public void setCreditId(BigInteger creditId) { 24 | this.creditId = creditId; 25 | } 26 | 27 | public String getDataOrigin() { 28 | return dataOrigin; 29 | } 30 | 31 | public void setDataOrigin(String dataOrigin) { 32 | this.dataOrigin = dataOrigin; 33 | } 34 | 35 | public String getDataHash() { 36 | return dataHash; 37 | } 38 | 39 | public void setDataHash(String dataHash) { 40 | this.dataHash = dataHash; 41 | } 42 | 43 | public BigInteger getType() { 44 | return type; 45 | } 46 | 47 | public void setType(BigInteger type) { 48 | this.type = type; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/domain/SendRecord.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.domain; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.Id; 5 | import java.math.BigInteger; 6 | 7 | /** 8 | * 没 9 | */ 10 | @Entity 11 | public class SendRecord { 12 | 13 | @Id 14 | private BigInteger recordId; // index 15 | 16 | private String applicant; // the organize want the data 17 | private String uploader; // the organize upload the data 18 | private BigInteger time; 19 | 20 | private Boolean isChecked; 21 | private Boolean checkResult; // If the record in the block chain 22 | 23 | private Boolean isSent; // whether the original data has been sent from the uploader 24 | 25 | private Boolean isScored; // whether the uploader has scored 26 | 27 | private BigInteger score; // the score of this record 28 | 29 | private BigInteger creditId; 30 | 31 | public SendRecord() { 32 | } 33 | 34 | public SendRecord(BigInteger recordId, String applicant, String uploader, BigInteger time, Boolean checkResult, BigInteger creditId, BigInteger token) { 35 | this.recordId = recordId; 36 | this.applicant = applicant; 37 | this.uploader = uploader; 38 | this.time = time; 39 | this.isChecked = true; 40 | this.checkResult = checkResult; 41 | this.isSent = false; 42 | this.isScored = false; 43 | // this.score = score; 44 | this.creditId = creditId; 45 | this.token = token; 46 | } 47 | 48 | public BigInteger getToken() { 49 | return token; 50 | } 51 | 52 | public void setToken(BigInteger token) { 53 | this.token = token; 54 | } 55 | 56 | private BigInteger token; // for sending original data 57 | 58 | public BigInteger getRecordId() { 59 | return recordId; 60 | } 61 | 62 | public void setRecordId(BigInteger recordId) { 63 | this.recordId = recordId; 64 | } 65 | 66 | public String getApplicant() { 67 | return applicant; 68 | } 69 | 70 | public void setApplicant(String applicant) { 71 | this.applicant = applicant; 72 | } 73 | 74 | public String getUploader() { 75 | return uploader; 76 | } 77 | 78 | public void setUploader(String uploader) { 79 | this.uploader = uploader; 80 | } 81 | 82 | public BigInteger getTime() { 83 | return time; 84 | } 85 | 86 | public void setTime(BigInteger time) { 87 | this.time = time; 88 | } 89 | 90 | public Boolean getChecked() { 91 | return isChecked; 92 | } 93 | 94 | public void setChecked(Boolean checked) { 95 | isChecked = checked; 96 | } 97 | 98 | public Boolean getCheckResult() { 99 | return checkResult; 100 | } 101 | 102 | public void setCheckResult(Boolean checkResult) { 103 | this.checkResult = checkResult; 104 | } 105 | 106 | public Boolean getSent() { 107 | return isSent; 108 | } 109 | 110 | public void setSent(Boolean sent) { 111 | isSent = sent; 112 | } 113 | 114 | public Boolean getScored() { 115 | return isScored; 116 | } 117 | 118 | public void setScored(Boolean scored) { 119 | isScored = scored; 120 | } 121 | 122 | public BigInteger getScore() { 123 | return score; 124 | } 125 | 126 | public void setScore(BigInteger score) { 127 | this.score = score; 128 | } 129 | 130 | public BigInteger getCreditId() { 131 | return creditId; 132 | } 133 | 134 | public void setCreditId(BigInteger creditId) { 135 | this.creditId = creditId; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/service/OriginCreditRepository.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.service; 2 | 3 | import org.fisco.bcos.domain.OriginCredit; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | import java.math.BigInteger; 7 | 8 | public interface OriginCreditRepository extends CrudRepository { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/service/RequireRecordRepository.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.service; 2 | 3 | import org.fisco.bcos.domain.RequiredRecord; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | import java.math.BigInteger; 7 | 8 | 9 | /** 10 | * 保存本地向外请求的数据 11 | */ 12 | public interface RequireRecordRepository extends CrudRepository { 13 | Iterable findByIsSent(Boolean isSent); 14 | RequiredRecord findByCreditId(BigInteger creditId); 15 | Iterable findByIsSentAndIsScored(Boolean isSent, Boolean IsScored); 16 | } 17 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/service/SavedCreditRepository.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.service; 2 | 3 | import org.fisco.bcos.domain.SavedCredit; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | import java.math.BigInteger; 7 | 8 | public interface SavedCreditRepository extends CrudRepository { 9 | } 10 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/service/SendRecordRepository.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.service; 2 | 3 | import org.fisco.bcos.domain.SendRecord; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | import java.math.BigInteger; 7 | 8 | public interface SendRecordRepository extends CrudRepository { 9 | 10 | Iterable findByCheckResult(Boolean checkResult); 11 | } 12 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/solidity/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.solidity; 2 | 3 | import org.fisco.bcos.channel.client.TransactionSucCallback; 4 | import org.fisco.bcos.web3j.abi.TypeReference; 5 | import org.fisco.bcos.web3j.abi.datatypes.Function; 6 | import org.fisco.bcos.web3j.abi.datatypes.Type; 7 | import org.fisco.bcos.web3j.abi.datatypes.Utf8String; 8 | import org.fisco.bcos.web3j.crypto.Credentials; 9 | import org.fisco.bcos.web3j.protocol.Web3j; 10 | import org.fisco.bcos.web3j.protocol.core.RemoteCall; 11 | import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt; 12 | import org.fisco.bcos.web3j.tx.Contract; 13 | import org.fisco.bcos.web3j.tx.TransactionManager; 14 | import org.fisco.bcos.web3j.tx.gas.ContractGasProvider; 15 | 16 | import java.math.BigInteger; 17 | import java.util.Arrays; 18 | import java.util.Collections; 19 | 20 | /** 21 | *

Auto generated code. 22 | *

Do not modify! 23 | *

Please use the web3j command line tools, 24 | * or the org.fisco.bcos.web3j.codegen.SolidityFunctionWrapperGenerator in the 25 | * codegen module to update. 26 | * 27 | *

Generated with web3j version none. 28 | */ 29 | @SuppressWarnings("unchecked") 30 | public class HelloWorld extends Contract { 31 | private static final String BINARY = "608060405234801561001057600080fd5b506040805190810160405280600d81526020017f48656c6c6f2c20576f726c6421000000000000000000000000000000000000008152506000908051906020019061005c929190610062565b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100515780636d4ce63c146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf610164565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610160929190610206565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101fc5780601f106101d1576101008083540402835291602001916101fc565b820191906000526020600020905b8154815290600101906020018083116101df57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a723058207db3c5650aebcb400ad30326c3e8e16f104b9c8d3d0931ff64ec6a8bb247d7db0029"; 32 | 33 | public static final String FUNC_SET = "set"; 34 | 35 | public static final String FUNC_GET = "get"; 36 | 37 | @Deprecated 38 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 39 | super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); 40 | } 41 | 42 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 43 | super(BINARY, contractAddress, web3j, credentials, contractGasProvider); 44 | } 45 | 46 | @Deprecated 47 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 48 | super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); 49 | } 50 | 51 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 52 | super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); 53 | } 54 | 55 | public RemoteCall set(String n) { 56 | final Function function = new Function( 57 | FUNC_SET, 58 | Arrays.asList(new Utf8String(n)), 59 | Collections.>emptyList()); 60 | return executeRemoteCallTransaction(function); 61 | } 62 | 63 | public void set(String n, TransactionSucCallback callback) { 64 | final Function function = new Function( 65 | FUNC_SET, 66 | Arrays.asList(new Utf8String(n)), 67 | Collections.>emptyList()); 68 | asyncExecuteTransaction(function, callback); 69 | } 70 | 71 | public RemoteCall get() { 72 | final Function function = new Function(FUNC_GET, 73 | Arrays.asList(), 74 | Arrays.>asList(new TypeReference() {})); 75 | return executeRemoteCallSingleValueReturn(function, String.class); 76 | } 77 | 78 | @Deprecated 79 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 80 | return new HelloWorld(contractAddress, web3j, credentials, gasPrice, gasLimit); 81 | } 82 | 83 | @Deprecated 84 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 85 | return new HelloWorld(contractAddress, web3j, transactionManager, gasPrice, gasLimit); 86 | } 87 | 88 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 89 | return new HelloWorld(contractAddress, web3j, credentials, contractGasProvider); 90 | } 91 | 92 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 93 | return new HelloWorld(contractAddress, web3j, transactionManager, contractGasProvider); 94 | } 95 | 96 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 97 | return deployRemoteCall(HelloWorld.class, web3j, credentials, contractGasProvider, BINARY, ""); 98 | } 99 | 100 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 101 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, contractGasProvider, BINARY, ""); 102 | } 103 | 104 | @Deprecated 105 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 106 | return deployRemoteCall(HelloWorld.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); 107 | } 108 | 109 | @Deprecated 110 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 111 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/utils/SolidityTools.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.utils; 2 | 3 | import org.fisco.bcos.web3j.abi.datatypes.generated.Bytes32; 4 | import org.fisco.bcos.web3j.abi.datatypes.generated.Uint256; 5 | 6 | public class SolidityTools { 7 | 8 | private static final String ALPHA_NUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 9 | 10 | /** 11 | * String to bytes 32. 12 | * 13 | * @param string the string 14 | * @return the bytes 32 15 | */ 16 | public static Bytes32 stringToBytes32(String string) { 17 | byte[] byteValue = string.getBytes(); 18 | byte[] byteValueLen32 = new byte[32]; 19 | System.arraycopy(byteValue, 0, byteValueLen32, 0, byteValue.length); 20 | return new Bytes32(byteValueLen32); 21 | } 22 | 23 | /** 24 | * Uint 256 to int. 25 | * 26 | * @param value the value 27 | * @return the int 28 | */ 29 | public static int uint256ToInt(Uint256 value) { 30 | return value.getValue().intValue(); 31 | } 32 | 33 | 34 | /** 35 | * Convert a Byte32 data to Java String. IMPORTANT NOTE: Byte to String is not 1:1 mapped. So - 36 | * Know your data BEFORE do the actual transform! For example, Deximal SolidityTools, or ASCII SolidityTools are 37 | * OK to be in Java String, but Encrypted Data, or raw Signature, are NOT OK. 38 | * 39 | * @param bytes32 the bytes 32 40 | * @return String 41 | */ 42 | public static String bytes32ToString(Bytes32 bytes32) { 43 | byte[] strs = bytes32.getValue(); 44 | String str = new String(strs); 45 | return str.trim(); 46 | } 47 | 48 | public static String bytesToString(byte[] bytes) { 49 | String str = new String(bytes); 50 | return str.trim(); 51 | } 52 | 53 | public static String hexToASCII(String hexValue) { 54 | StringBuilder output = new StringBuilder(""); 55 | for (int i = 0; i < hexValue.length(); i += 2) 56 | { 57 | String str = hexValue.substring(i, i + 2); 58 | output.append((char) Integer.parseInt(str, 16)); 59 | } 60 | return output.toString(); 61 | } 62 | 63 | public static String randomAlphaNumeric(int count) { 64 | StringBuilder builder = new StringBuilder(); 65 | while (count-- != 0) { 66 | int character = (int)(Math.random()*ALPHA_NUMERIC_STRING.length()); 67 | builder.append(ALPHA_NUMERIC_STRING.charAt(character)); 68 | } 69 | return builder.toString(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/BrokerException.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk; 2 | 3 | /** 4 | * Broker's exception. 5 | * code in (100000, 200000) meanings client side error. 6 | * code in (200000, 300000) meanings server side error. 7 | * 8 | * @author matthewliu 9 | * @since 2018/11/08 10 | */ 11 | public class BrokerException extends Exception { 12 | private final static String WIKIUrl = "https://github.com/webankopen/weevent-broker/wiki/faq"; 13 | 14 | /** 15 | * Error code. 16 | */ 17 | protected int code; 18 | 19 | /** 20 | * Error message. 21 | */ 22 | protected String message; 23 | 24 | public int getCode() { 25 | return this.code; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | /** 33 | * getText 34 | * 35 | * @param code the code 36 | * @param message the message 37 | * @return java.lang.String 38 | */ 39 | private static String getText(int code, String message) { 40 | StringBuilder sb = new StringBuilder(); 41 | sb.append("Code: "); 42 | sb.append(code); 43 | sb.append(", Message: "); 44 | sb.append(message); 45 | sb.append("\nFor more information, please visit wiki: "); 46 | sb.append(WIKIUrl); 47 | return sb.toString(); 48 | } 49 | 50 | /** 51 | * Construction. 52 | * 53 | * @param message the message 54 | * @param cause the cause 55 | */ 56 | public BrokerException(String message, Throwable cause) { 57 | super(getText(-1, message), cause); 58 | this.code = -1; 59 | this.message = message; 60 | } 61 | 62 | /** 63 | * Construction. 64 | * 65 | * @param message the message 66 | */ 67 | public BrokerException(String message) { 68 | super(getText(-1, message)); 69 | this.code = -1; 70 | this.message = message; 71 | } 72 | 73 | /** 74 | * Construction. 75 | * 76 | * @param errorCode the code and message 77 | */ 78 | public BrokerException(ErrorCode errorCode) { 79 | super(getText(errorCode.getCode(), errorCode.getCodeDesc())); 80 | this.code = errorCode.getCode(); 81 | this.message = errorCode.getCodeDesc(); 82 | } 83 | 84 | /** 85 | * Construction. 86 | * 87 | * @param code the code 88 | * @param message reason 89 | */ 90 | public BrokerException(int code, String message) { 91 | super(message); 92 | this.code = code; 93 | this.message = message; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk; 2 | 3 | /** 4 | * client error code in (100000, 200000) 5 | * server error code in (200000, 300000) 6 | */ 7 | public enum ErrorCode { 8 | 9 | SUCCESS(0, "success"), 10 | 11 | //client error(100000, 200000) 12 | TOPIC_ALREADY_EXIST(100100, "topic already exist"), 13 | 14 | TOPIC_NOT_EXIST(100101, "topic not exist"), 15 | 16 | TOPIC_EXCEED_MAX_LENGTH(100102, "topic name exceeds max length[64 bytes]"), 17 | 18 | TOPIC_IS_BLANK(100103, "topic name is blank"), 19 | 20 | TOPIC_PAGE_INDEX_INVALID(100104, "page index should be an integer start from 0"), 21 | 22 | TOPIC_MODEL_MAP_IS_NULL(100105, "topic model map is empty or has empty value"), 23 | 24 | TOPIC_CONTAIN_INVALID_CHAR(100106, "topic name contain invalid char, Ascii must be in[32, 128]"), 25 | 26 | TOPIC_PAGE_SIZE_INVALID(100107, "page size should be an integer in(1, 100)"), 27 | 28 | TOPIC_NOT_MATCH(100108, "topic name not match with last"), 29 | 30 | EVENT_CONTENT_IS_BLANK(100200, "event content is blank"), 31 | 32 | EVENT_CONTENT_EXCEEDS_MAX_LENGTH(100201, "event content exceeds max length[10k bytes]"), 33 | 34 | SEND_CALL_BACK_IS_NULL(100202, "send call back instance is null"), 35 | 36 | EVENT_CONTENT_CHARSET(100203, "event content must be utf-8"), 37 | 38 | EVENT_EXTENSIONS_EXCEEDS_MAX_LENGTH(100204, "event extensions exceeds max length[1k bytes]"), 39 | 40 | EVENT_ID_IS_BLANK(100300, "eventId is blank"), 41 | 42 | EVENT_ID_EXCEEDS_MAX_LENGTH(100301, "eventId exceeds max length[32 bytes]"), 43 | 44 | EVENT_ID_IS_ILLEGAL(100302, "eventId is illegal"), 45 | 46 | EVENT_ID_NOT_EXIST(100303, "eventId is not exist"), 47 | 48 | EVENT_ID_IS_MISMATCH(100304, "eventId is mismatch with block chain"), 49 | 50 | EVENT_GROUP_ID_NOT_FOUND(100305, "event groupid is notfound"), 51 | 52 | EVENT_GROUP_ID_INVALID(100306, "event groupid should be an string start from 1"), 53 | 54 | OFFSET_IS_BLANK(100500, "subscribe interface offset param is blank"), 55 | 56 | URL_INVALID_FORMAT(100501, "invalid url format"), 57 | 58 | URL_CONNECT_FAILED(100502, "failed to connect url"), 59 | 60 | SUBSCRIPTIONID_IS_BLANK(100503, "subscribe interface subscription id is blank"), 61 | 62 | SUBSCRIPTIONID_NOT_EXIST(100504, "subscribe id is not exist"), 63 | 64 | SUBSCRIPTIONID_FORMAT_INVALID(100505, "subscribe id format invalid"), 65 | 66 | MQTT_NO_BROKER_URL(100600, "no mqtt.broker.url configuration, can't support mqtt"), 67 | 68 | CGI_SUBSCRIPTION_NO_ZOOKEEPER(100601, "no broker.zookeeper.ip configuration, can't support CGI subscription"), 69 | 70 | HA_ROUTE_TO_MASTER_FAILED(100602, "route request to master failed"), 71 | 72 | SDK_TLS_INIT_FAILED(101001, "init tsl ca failed"), 73 | 74 | SDK_JMS_INIT_FAILED(101002, "init jms connection factory failed"), 75 | 76 | SDK_JMS_EXCEPTION_STOMP_EXECUTE(101003, "stomp command execute failed"), 77 | 78 | SDK_JMS_EXCEPTION_STOMP_TIMEOUT(101004, "stomp command invoke timeout"), 79 | 80 | SDK_JMS_EXCEPTION_JSON_ENCODE(101005, "encode WeEvent to json failed"), 81 | 82 | SDK_JMS_EXCEPTION_JSON_DECODE(101006, "decode WeEvent from json failed"), 83 | 84 | SDK_JMS_EXCEPTION(101010, "jms exception"), 85 | 86 | //server error(200000, 300000) 87 | TOPIC_CONTROLLER_IS_NULL(200100, "init failed, see fisco.topic-controller.contract-address in properties"), 88 | 89 | CONSUMER_ALREADY_STARTED(200102, "consumer already started"), 90 | 91 | PRODUCER_SEND_CALLBACK_IS_NULL(200103, "producer send callback is null"), 92 | 93 | CONSUMER_LISTENER_IS_NULL(200104, "consumer listener is null"), 94 | 95 | TRANSACTION_TIMEOUT(200201, "the transaction is timeout."), 96 | 97 | TRANSACTION_EXECUTE_ERROR(200202, "the transaction does not correctly executed."), 98 | 99 | UNKNOWN_ERROR(200203, "unknown error, please check error log."), 100 | 101 | EVENT_COMPRESS_ERROR(200204, "event compress error"), 102 | 103 | GET_BLOCK_HEIGHT_ERROR(200205, "get block height failed due to InterruptedException|ExecutionException|TimeoutException|RuntimeException"), 104 | 105 | TRANSACTION_RECEIPT_IS_NULL(200206, "transaction reception is null"), 106 | 107 | DEPLOY_CONTRACT_ERROR(200207, "deploy contract failed"), 108 | 109 | LOAD_CONTRACT_ERROR(200208, "load contract failed"), 110 | 111 | WE3SDK_INIT_ERROR(200209, "init web3sdk failed"), 112 | 113 | WE3SDK_VERRSION_NOT_SUPPORT(200210, "FISCO-BCOS 1.x, do not support group"), 114 | 115 | WE3SDK_UNKONWN_GROUP(200210, "FISCO-BCOS 2.x, unknown group id"), 116 | ; 117 | 118 | /** 119 | * error code 120 | */ 121 | private int code; 122 | 123 | /** 124 | * error message 125 | */ 126 | private String codeDesc; 127 | 128 | /** 129 | * Error Code Constructor. 130 | * 131 | * @param code The ErrorCode 132 | * @param codeDesc The ErrorCode Description 133 | */ 134 | ErrorCode(int code, String codeDesc) { 135 | this.code = code; 136 | this.codeDesc = codeDesc; 137 | } 138 | 139 | /** 140 | * Get the Error Code. 141 | * 142 | * @return the ErrorCode 143 | */ 144 | public int getCode() { 145 | return code; 146 | } 147 | 148 | /** 149 | * Gets the ErrorCode Description. 150 | * 151 | * @return the ErrorCode Description 152 | */ 153 | public String getCodeDesc() { 154 | return codeDesc; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/config/FiscoConfig.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.config; 2 | 3 | import java.io.InputStream; 4 | import java.lang.reflect.Field; 5 | import java.util.Properties; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | import lombok.Data; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.springframework.beans.factory.annotation.Value; 12 | import org.springframework.context.annotation.PropertySource; 13 | 14 | /** 15 | * FISCO-BCOS Config that loaded by java, not spring. 16 | * Because Web3sdkUtils.main is a pure java process, no spring ApplicationContext. 17 | * 18 | * @author matthewliu 19 | * @version 1.0 20 | * @since 2019/1/28 21 | */ 22 | @Slf4j 23 | @Data 24 | @PropertySource(value = "classpath:fisco.properties", encoding = "UTF-8") 25 | public class FiscoConfig { 26 | @Value("${version:}") 27 | private String version; 28 | 29 | @Value("${orgid:}") 30 | private String orgId; 31 | 32 | @Value("${nodes:}") 33 | private String nodes; 34 | 35 | @Value("${account:}") 36 | private String account; 37 | 38 | @Value("${topic-controller.address:}") 39 | private String topicControllerAddress; 40 | 41 | @Value("${web3sdk.timeout:10000}") 42 | private Integer web3sdkTimeout; 43 | 44 | @Value("${web3sdk.core-pool-size:100}") 45 | private Integer web3sdkCorePoolSize; 46 | 47 | @Value("${web3sdk.max-pool-size:200}") 48 | private Integer web3sdkMaxPoolSize; 49 | 50 | @Value("${web3sdk.queue-capacity:1000}") 51 | private Integer web3sdkQueueSize; 52 | 53 | @Value("${web3sdk.keep-alive-seconds:60}") 54 | private Integer web3sdkKeepAliveSeconds; 55 | 56 | @Value("${ca-crt-path:./ca.crt}") 57 | private String CaCrtPath; 58 | 59 | @Value("${node-crt-path:./node.crt}") 60 | private String NodeCrtPath; 61 | 62 | @Value("${node-key-path:./node.key}") 63 | private String NodeKeyPath; 64 | 65 | /** 66 | * load configuration without spring 67 | * 68 | * @return true if success, else false 69 | */ 70 | public boolean load() { 71 | if (!FiscoConfig.class.isAnnotationPresent(PropertySource.class)) { 72 | log.error("set configuration file name use @PropertySource"); 73 | return false; 74 | } 75 | 76 | PropertySource propertySource = FiscoConfig.class.getAnnotation(PropertySource.class); 77 | String[] files = propertySource.value(); 78 | if (!files[0].startsWith("classpath:")) { 79 | log.error("configuration file must be in classpath"); 80 | return false; 81 | } 82 | log.info("load properties from file: {}", files[0]); 83 | 84 | // be careful the path 85 | String file = "/" + files[0].replace("classpath:", ""); 86 | try (InputStream inputStream = FiscoConfig.class.getResourceAsStream(file)) { 87 | Properties properties = new Properties(); 88 | properties.load(inputStream); 89 | 90 | Field[] fields = FiscoConfig.class.getDeclaredFields(); 91 | for (Field field : fields) { 92 | if (field.isAnnotationPresent(Value.class)) { 93 | Value value = field.getAnnotation(Value.class); 94 | 95 | //String.split can not support this regex 96 | Pattern pattern = Pattern.compile("\\$\\{(\\S+):(\\S*)}"); 97 | Matcher matcher = pattern.matcher(value.value()); 98 | String k = ""; 99 | String v = ""; 100 | if (matcher.find()) { 101 | if (matcher.groupCount() >= 1) { 102 | 103 | k = matcher.group(1); 104 | } 105 | if (matcher.groupCount() >= 2) { 106 | v = matcher.group(2); 107 | } 108 | } 109 | 110 | if (properties.containsKey(k)) { 111 | v = properties.getProperty(k); 112 | } 113 | field.setAccessible(true); 114 | Object obj = field.getType().getConstructor(String.class).newInstance(v); 115 | field.set(this, obj); 116 | } 117 | } 118 | } catch (Exception e) { 119 | log.error("load properties failed", e); 120 | return false; 121 | } 122 | 123 | log.info("read from fisco.properties: {}", this); 124 | return true; 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/constant/OpenCreditConstants.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.constant; 2 | 3 | import java.math.BigInteger; 4 | 5 | public class OpenCreditConstants { 6 | /** 7 | * The Constant GAS_PRICE. 8 | */ 9 | public static final BigInteger GAS_PRICE = new BigInteger("99999999999"); 10 | 11 | /** 12 | * The Constant Address Empty. 13 | */ 14 | public static final String ADDRESS_EMPTY = "0x0000000000000000000000000000000000000000"; 15 | 16 | /** 17 | * The Constant CallContract Timeout. 18 | */ 19 | public static final Integer TIME_OUT = 102; 20 | 21 | /** 22 | * The Constant GAS_LIMIT. 23 | */ 24 | public static final BigInteger GAS_LIMIT = new BigInteger("9999999999999"); 25 | 26 | /** 27 | * The Constant for default deploy contracts timeout. 28 | */ 29 | public static final Integer DEFAULT_DEPLOY_CONTRACTS_TIMEOUT_IN_SECONDS = 15; 30 | 31 | /** 32 | * The Constant INIIIAL_VALUE. 33 | */ 34 | public static final BigInteger INILITIAL_VALUE = new BigInteger("0"); 35 | 36 | /** 37 | * The Constant default timeout for getting transaction. 38 | */ 39 | public static final Integer TRANSACTION_RECEIPT_TIMEOUT = 13; 40 | 41 | /** 42 | * Max length for topic name. 43 | */ 44 | public static final Integer TOPIC_NAME_MAX_LENGTH = 64; 45 | 46 | /** 47 | * topic name encode length. 48 | */ 49 | public static final Integer TOPIC_NAME_ENCODE_LENGTH = 8; 50 | 51 | /** 52 | * hash length. 53 | */ 54 | public static final Integer HASH_LENGTH = 32; 55 | 56 | /** 57 | * Max length for event id. 58 | */ 59 | public static final Integer EVENT_ID_MAX_LENGTH = 64; 60 | 61 | /** 62 | * Max length for event content. 63 | */ 64 | public static final Integer EVENT_CONTENT_MAX_LENGTH = 10240; 65 | 66 | /** 67 | * Max length for event extensions. 68 | */ 69 | public static final Integer EVENT_EXTENSIONS_MAX_LENGTH = 1024; 70 | /** 71 | * Event ID split char. 72 | */ 73 | public static final String EVENT_ID_SPLIT_CHAR = "-"; 74 | 75 | /** 76 | * Extensions prefix char. 77 | */ 78 | public static final String EXTENSIONS_PREFIX_CHAR = "weevent-"; 79 | 80 | /** 81 | * Extensions groupid. 82 | */ 83 | public static final String EXTENSIONS_GROUP_ID = "weevent-groupid"; 84 | 85 | /** 86 | * Extensions default groupid. 87 | */ 88 | public static final Long DEFAULT_GROUP_ID = 1L; 89 | 90 | /** 91 | * Extensions eventid. 92 | */ 93 | public static final String EXTENSIONS_EVENT_ID = "weevent-eventid"; 94 | 95 | /** 96 | * Extensions receivedtopic. 97 | */ 98 | public static final String EXTENSIONS_RECEIVED_TOPIC = "weevent-receivedtopic"; 99 | 100 | /** 101 | * event topic. 102 | */ 103 | public static final String EVENT_TOPIC = "topic"; 104 | 105 | /** 106 | * event topic. 107 | */ 108 | public static final String EVENT_GROUP_ID = "groupId"; 109 | 110 | /** 111 | * event content. 112 | */ 113 | public static final String EVENT_CONTENT = "content"; 114 | 115 | } 116 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/DataTypeUtils.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | import java.util.List; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.bouncycastle.util.encoders.Hex; 9 | import org.fisco.bcos.web3sdk.BrokerException; 10 | import org.fisco.bcos.web3sdk.ErrorCode; 11 | import org.fisco.bcos.web3sdk.constant.OpenCreditConstants; 12 | 13 | /** 14 | * Data type conversion utilities between solidity data type and java data type. 15 | */ 16 | @Slf4j 17 | public final class DataTypeUtils { 18 | /** 19 | * encode eventId 20 | * 21 | * @param topicName 22 | * @param eventBlockNumber blockchain blocknumber 23 | * @param eventSeq eventSeq number 24 | * @return encodeString 25 | */ 26 | public static String encodeEventId(String topicName, int eventBlockNumber, int eventSeq) { 27 | StringBuilder sb = new StringBuilder(); 28 | sb.append(genTopicNameHash(topicName)); 29 | sb.append(OpenCreditConstants.EVENT_ID_SPLIT_CHAR); 30 | sb.append(eventSeq); 31 | sb.append(OpenCreditConstants.EVENT_ID_SPLIT_CHAR); 32 | sb.append(eventBlockNumber); 33 | return sb.toString(); 34 | } 35 | 36 | /** 37 | * generate topicName hash 38 | * 39 | * @param topicName 40 | * @return substring left 4bit hash data to hex encode 41 | */ 42 | public static String genTopicNameHash(String topicName) { 43 | String encodeData = ""; 44 | try { 45 | MessageDigest md = MessageDigest.getInstance("SHA-256"); 46 | byte[] messageDigest = md.digest(topicName.getBytes()); 47 | encodeData = new String(Hex.encode(messageDigest)).substring(0, OpenCreditConstants.TOPIC_NAME_ENCODE_LENGTH); 48 | } catch (NoSuchAlgorithmException e) { 49 | log.error("NoSuchAlgorithmException:{}", e.getMessage()); 50 | } 51 | return encodeData; 52 | } 53 | 54 | /** 55 | * decode eventId get seq 56 | * 57 | * @param eventId 58 | * @return seq 59 | */ 60 | public static Long decodeSeq(String eventId) throws BrokerException { 61 | String[] tokens = eventId.split(OpenCreditConstants.EVENT_ID_SPLIT_CHAR); 62 | if (tokens.length != 3) { 63 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 64 | } 65 | 66 | if (tokens[0].length() != OpenCreditConstants.TOPIC_NAME_ENCODE_LENGTH) { 67 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 68 | } 69 | return DataTypeUtils.String2Long(tokens[1]); 70 | } 71 | 72 | /** 73 | * decode eventId get blockNumber 74 | * 75 | * @param eventId 76 | * @return blockNumber 77 | */ 78 | public static Long decodeBlockNumber(String eventId) throws BrokerException { 79 | String[] tokens = eventId.split(OpenCreditConstants.EVENT_ID_SPLIT_CHAR); 80 | if (tokens.length != 3) { 81 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 82 | } 83 | if (tokens[0].length() != OpenCreditConstants.TOPIC_NAME_ENCODE_LENGTH) { 84 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 85 | } 86 | return DataTypeUtils.String2Long(tokens[2]); 87 | } 88 | 89 | /** 90 | * decode eventId get topicName hash 91 | * 92 | * @param eventId 93 | * @return topicName hash 94 | */ 95 | public static String decodeTopicNameHash(String eventId) throws BrokerException { 96 | String[] tokens = eventId.split(OpenCreditConstants.EVENT_ID_SPLIT_CHAR); 97 | if (tokens.length != 3) { 98 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 99 | } 100 | if (tokens[0].length() != OpenCreditConstants.TOPIC_NAME_ENCODE_LENGTH) { 101 | throw new BrokerException(ErrorCode.EVENT_ID_IS_ILLEGAL); 102 | } 103 | return tokens[0]; 104 | } 105 | 106 | /** 107 | * String2Long, return 0L if exception. 108 | * 109 | * @param value the value 110 | * @return java.lang.Long 111 | */ 112 | public static Long String2Long(String value) { 113 | try { 114 | return Long.valueOf(value); 115 | } catch (NumberFormatException e) { 116 | return 0L; 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/LRUCache.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | import java.util.concurrent.locks.ReentrantLock; 6 | 7 | /** 8 | * L2 cache based on Redis 9 | * @author v_wbhwliu 10 | * 11 | */ 12 | public class LRUCache extends LinkedHashMap { 13 | 14 | private static final long serialVersionUID = -6798470043940063152L; 15 | private Integer capacity; 16 | private final ReentrantLock lock = new ReentrantLock(); 17 | 18 | public LRUCache(Integer capacity) { 19 | super(capacity, 0.75f, true); 20 | this.capacity = capacity; 21 | } 22 | 23 | @Override 24 | public V putIfAbsent(K key, V value) { 25 | try { 26 | this.lock.lock(); 27 | return super.putIfAbsent(key, value); 28 | } finally { 29 | this.lock.unlock(); 30 | } 31 | } 32 | 33 | @Override 34 | public V get(Object key) { 35 | try { 36 | this.lock.lock(); 37 | return super.get(key); 38 | } finally { 39 | this.lock.unlock(); 40 | } 41 | } 42 | 43 | @Override 44 | public boolean removeEldestEntry(Map.Entry eldest) { 45 | if(size() > capacity) { 46 | return true; 47 | } 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/SerializeUtils.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.IOException; 6 | import java.io.ObjectInputStream; 7 | import java.io.ObjectOutputStream; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | /** 14 | * serialize object for redis to read and write data 15 | */ 16 | @Slf4j 17 | @SuppressWarnings(value = "unchecked") 18 | public class SerializeUtils { 19 | /** 20 | * serialize object to bytes 21 | * 22 | * @param object object 23 | * @return buf 24 | */ 25 | public static byte[] serialize(T object) { 26 | if (object == null) { 27 | throw new NullPointerException("Can't serialize null"); 28 | } 29 | 30 | try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); 31 | ObjectOutputStream os = new ObjectOutputStream(bos)) { 32 | os.writeObject(object); 33 | return bos.toByteArray(); 34 | } catch (IOException e) { 35 | log.error("Exception happened while serialize", e); 36 | throw new RuntimeException(e); 37 | } 38 | } 39 | 40 | /** 41 | * deserialize bytes to object 42 | * 43 | * @param in buf 44 | * @return object 45 | */ 46 | public static T deserialize(byte[] in) { 47 | if (in != null) { 48 | try (ByteArrayInputStream bis = new ByteArrayInputStream(in); 49 | ObjectInputStream is = new ObjectInputStream(bis)) { 50 | 51 | 52 | return (T) is.readObject(); 53 | } catch (IOException | ClassNotFoundException e) { 54 | log.error("Exception happened while deserialize", e); 55 | throw new RuntimeException(e); 56 | } 57 | } 58 | 59 | return null; 60 | } 61 | 62 | /** 63 | * serialize object list to bytes 64 | * 65 | * @param objectList object list 66 | * @return buf 67 | */ 68 | public static byte[] serializeList(List objectList) { 69 | if (objectList == null) { 70 | throw new NullPointerException("Can't serialize null"); 71 | } 72 | 73 | try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); 74 | ObjectOutputStream os = new ObjectOutputStream(bos)) { 75 | for (T object : objectList) { 76 | os.writeObject(object); 77 | } 78 | os.writeObject(null); 79 | return bos.toByteArray(); 80 | } catch (IOException e) { 81 | log.error("Exception happened while serialize", e); 82 | throw new RuntimeException(e); 83 | } 84 | } 85 | 86 | /** 87 | * deserialize bytes to object list 88 | * 89 | * @param in buf 90 | * @return object list 91 | */ 92 | public static List deserializeList(byte[] in) { 93 | List objectList = new ArrayList<>(); 94 | 95 | if (in != null) { 96 | try (ByteArrayInputStream bis = new ByteArrayInputStream(in); 97 | ObjectInputStream is = new ObjectInputStream(bis)) { 98 | while (true) { 99 | T obj = (T) is.readObject(); 100 | if (obj == null) { 101 | break; 102 | } else { 103 | objectList.add(obj); 104 | } 105 | } 106 | } catch (IOException | ClassNotFoundException e) { 107 | log.error("Exception happened while deserialize", e); 108 | throw new RuntimeException(e); 109 | } 110 | } 111 | 112 | return objectList; 113 | } 114 | 115 | } 116 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/StoppableTask.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.fisco.bcos.Application; 6 | 7 | /** 8 | * Task can be stopped by flag setting and InterruptedException. 9 | * Prefer to flag setting. 10 | * 11 | * @author matthewliu 12 | * @since 2018/11/09 13 | */ 14 | @Slf4j 15 | public abstract class StoppableTask extends Thread { 16 | private volatile boolean exit = false; 17 | 18 | public StoppableTask(String name) { 19 | super(name); 20 | } 21 | 22 | public boolean isExit() { 23 | return this.exit; 24 | } 25 | 26 | // public void doExit() { 27 | // log.info("doExit enter"); 28 | // 29 | // this.exit = true; 30 | // 31 | // int idleTime = Application..getConsumerIdleTime(); 32 | // for (int i = 0; i < 15; i++) { 33 | // try { 34 | // log.debug("idle to graceful exit"); 35 | // Thread.sleep(idleTime); 36 | // } catch (InterruptedException e) { 37 | // log.error("doExit failed, due to InterruptedException"); 38 | // Thread.currentThread().interrupt(); 39 | // } 40 | // 41 | // if (!isAlive()) { 42 | // log.info("doExit exit while not alive"); 43 | // return; 44 | // } 45 | // } 46 | // 47 | // // Force terminate, Web3sdk will throw NullPointException if interrupt() 48 | // //this.interrupt(); 49 | // log.info("doExit force exit after wait"); 50 | // } 51 | 52 | private void onExit() { 53 | } 54 | 55 | protected abstract void taskOnceLoop() throws InterruptedException; 56 | 57 | @Override 58 | public void run() { 59 | log.info("task thread enter, name: {}", this.getName()); 60 | 61 | try { 62 | while (!this.exit) { 63 | if (isInterrupted()) { 64 | break; 65 | } 66 | this.taskOnceLoop(); 67 | } 68 | } catch (InterruptedException e) { 69 | log.info("catch InterruptedException to exit."); 70 | Thread.currentThread().interrupt(); 71 | } 72 | 73 | this.onExit(); 74 | log.info("task thread exit, name: {}", this.getName()); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/SystemInfoUtils.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | import java.net.Inet4Address; 4 | import java.net.InetAddress; 5 | import java.net.NetworkInterface; 6 | import java.net.SocketException; 7 | import java.util.Enumeration; 8 | 9 | /** 10 | * @author websterchen@webank.com 11 | * @version 1.0 12 | * @since 2019/4/1 13 | */ 14 | public class SystemInfoUtils { 15 | public static String getCurrentIp() { 16 | try { 17 | Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); 18 | while (networkInterfaces.hasMoreElements()) { 19 | NetworkInterface ni = (NetworkInterface) networkInterfaces.nextElement(); 20 | Enumeration nias = ni.getInetAddresses(); 21 | while (nias.hasMoreElements()) { 22 | InetAddress ia = (InetAddress) nias.nextElement(); 23 | if (!ia.isLinkLocalAddress() && !ia.isLoopbackAddress() && ia instanceof Inet4Address) { 24 | return ia.getHostAddress(); 25 | } 26 | } 27 | } 28 | } catch (SocketException e) { 29 | } 30 | return null; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/WeEventUtils.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | //import com.webank.weevent.broker.fisco.constant.WeEventConstants; 7 | //import com.webank.weevent.sdk.BrokerException; 8 | 9 | import lombok.extern.slf4j.Slf4j; 10 | 11 | //import static com.webank.weevent.sdk.ErrorCode.EVENT_GROUP_ID_INVALID; 12 | @Slf4j 13 | public class WeEventUtils { 14 | // public static Map getExtensions(Map eventData) throws BrokerException { 15 | // Map extensions = new HashMap<>(); 16 | // for (Map.Entry extension : eventData.entrySet()) { 17 | // if (extension.getKey().startsWith(WeEventConstants.EXTENSIONS_PREFIX_CHAR)) { 18 | // extensions.put(extension.getKey(), extension.getValue()); 19 | // } 20 | // } 21 | // return extensions; 22 | // } 23 | // 24 | // public static Map getObjectExtensions(Map eventData) throws BrokerException { 25 | // Map extensions = new HashMap<>(); 26 | // for (Map.Entry extension : eventData.entrySet()) { 27 | // if (extension.getKey().startsWith(WeEventConstants.EXTENSIONS_PREFIX_CHAR)) { 28 | // extensions.put(extension.getKey(), extension.getValue().toString()); 29 | // } 30 | // } 31 | // return extensions; 32 | // } 33 | // 34 | // public static Long getGroupId(String strGroupId) throws BrokerException { 35 | // Long groupId = WeEventConstants.DEFAULT_GROUP_ID; 36 | // if (strGroupId != null && !strGroupId.isEmpty()) { 37 | // try { 38 | // groupId = Long.parseLong(strGroupId); 39 | // } catch (Exception e) { 40 | // log.error("{}",EVENT_GROUP_ID_INVALID.getCodeDesc()); 41 | // throw new BrokerException(EVENT_GROUP_ID_INVALID); 42 | // } 43 | // } 44 | // return groupId; 45 | // } 46 | } 47 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/java/org/fisco/bcos/web3sdk/util/Web3sdkUtils.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.web3sdk.util; 2 | 3 | 4 | import java.io.FileWriter; 5 | import java.io.IOException; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.fisco.bcos.web3sdk.config.FiscoConfig; 9 | import org.fisco.bcos.web3sdk.Web3SDK2Wrapper; 10 | 11 | 12 | /** 13 | * Utils 4 web3sdk. 14 | * 15 | * @author matthewliu 16 | * @since 2019/02/12 17 | */ 18 | @Slf4j 19 | public class Web3sdkUtils { 20 | private static void writeAddressToFile(String filePath, String contractName, String contractAddress) { 21 | try (FileWriter fileWritter = new FileWriter(filePath, false)) { 22 | String content = String.format("%s=%s", contractName, contractAddress); 23 | fileWritter.write(content); 24 | fileWritter.flush(); 25 | } catch (IOException e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | 30 | /** 31 | * tool to generate system contract, 'TopicController'. 32 | * 33 | * @param args optional param, save data into file if set. 34 | * Usage: 35 | * java -Xbootclasspath/a:./config -cp weevent-broker-2.0.0.jar -Dloader.main=com.webank.weevent.broker.fisco.util.Web3sdkUtils org.springframework.boot.loader.PropertiesLauncher ./address.txt [1] 36 | */ 37 | public static void main(String[] args) { 38 | try { 39 | FiscoConfig fiscoConfig = new FiscoConfig(); 40 | fiscoConfig.load(); 41 | 42 | String address; 43 | if (args.length >= 2) { 44 | // 2.0x 45 | org.fisco.bcos.web3j.crypto.Credentials credentials = Web3SDK2Wrapper.getCredentials(fiscoConfig); 46 | org.fisco.bcos.web3j.protocol.Web3j web3j = Web3SDK2Wrapper.initWeb3j(Long.valueOf(args[1]), fiscoConfig); 47 | // address = Web3SDK2Wrapper.deployTopicControl(web3j, credentials); 48 | } else { 49 | // 1.x 50 | throw new Exception("Argument too short"); 51 | } 52 | 53 | // System.out.println("deploy contract[TopicController] success, address: " + address); 54 | if (args.length >= 1) { 55 | // writeAddressToFile(args[0], "TopicController", address); 56 | } 57 | } catch (Exception e) { 58 | log.error("detect exception", e); 59 | System.exit(1); 60 | } 61 | 62 | // web3sdk can't exit gracefully 63 | System.exit(0); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=update 2 | spring.datasource.url=jdbc:mysql://localhost:23306/spring_app_db 3 | spring.datasource.username=app_user 4 | spring.datasource.password=test123 -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | encrypt-type: 0 # 0:standard, 1:guomi 2 | group-channel-connections-config: 3 | all-channel-connections: 4 | - group-id: 1 #group ID 5 | connections-str: 6 | - 47.107.32.140:20202 # node listen_ip:channel_listen_port 7 | # - 106.14.15.186:20202 8 | 9 | channel-service: 10 | group-id: 1 # The specified group to which the SDK connects 11 | # org-id: AgentZWM # agency name 12 | org-id: AgentZQH 13 | 14 | spring: 15 | application: 16 | name: openCredit 17 | 18 | server: 19 | port: 28080 -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/contract/Credit.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.0 <0.7.0; 2 | // pragma experimental ABIEncoderV2; 3 | 4 | contract Credit { 5 | 6 | struct CreditData { 7 | address uploader; 8 | bytes32 id; // 256 bits hashed id by keccak256() 9 | bytes32 data; // hashed credit data 10 | uint time; // time the data upload 11 | } 12 | 13 | struct RecordData { 14 | address requirer; // the organize want the data 15 | CreditData creditData; // the address of credit data 16 | uint time; 17 | bool isSent; // is the original data be sent from the uploader 18 | } 19 | 20 | mapping(bytes32 => CreditData[]) public credits; // key = id 21 | mapping(address => RecordData[]) records; // key = requirer address 22 | bytes32[] public idArray; 23 | address[] public requirerArray; 24 | 25 | function addCreditData(string memory id_string, string memory data_string) public { 26 | bytes32 id = keccak256(abi.encodePacked(id_string)); 27 | CreditData memory credit = CreditData(msg.sender, id, keccak256(abi.encodePacked(data_string)), now); 28 | credits[id].push(credit); 29 | idArray.push(id); 30 | } 31 | 32 | // 问题: 数据量太大怎么办? 先不考虑 33 | function getCreditDataById(string memory id_string) public view returns( address[] memory, 34 | //bytes32[] memory, 35 | bytes32[] memory, 36 | uint[] memory){ 37 | CreditData[] memory credit_array = credits[keccak256(abi.encodePacked(id_string))]; 38 | uint credit_array_length = credit_array.length; 39 | address[] memory uploaders = new address[](credit_array_length); 40 | //bytes32[] memory ids = new bytes32[](credit_array_length); 41 | bytes32[] memory datas = new bytes32[](credit_array_length); 42 | uint[] memory times = new uint[](credit_array_length); 43 | for (uint i = 0; i < credit_array.length; ++i) { 44 | uploaders[i] = credit_array[i].uploader; 45 | //ids[i] = credit_array[i].id; 46 | datas[i] = credit_array[i].data; 47 | times[i] = credit_array[i].time; 48 | } 49 | return (uploaders, datas, times); 50 | } 51 | 52 | 53 | // function addRecordData(addr name) { 54 | 55 | // } 56 | 57 | // function getRecordData() public view returns(records){ 58 | 59 | // } 60 | 61 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/contract/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | contract HelloWorld{ 4 | string name; 5 | constructor() public{ 6 | name = "Hello, World!"; 7 | } 8 | 9 | function get()constant public returns(string){ 10 | return name; 11 | } 12 | 13 | function set(string n) public{ 14 | name = n; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/fisco.properties: -------------------------------------------------------------------------------- 1 | #fisco 2 | version=2.0 3 | topic-controller.address=1:0x23df89a2893120f686a4aa03b41acf6836d11e5d; 4 | #version=1.3 5 | #topic-controller.address=0xddddd42da68a40784f5f63ada7ead9b36a38d2e3 6 | orgid=fisco 7 | nodes=127.0.0.1:30701 8 | #account 9 | account=bcec428d5205abe0f0cc8a734083908d9eb8563e31f943d760786edf42ad67dd 10 | #web3sdk 11 | web3sdk.timeout=10000 12 | web3sdk.core-pool-size=100 13 | web3sdk.max-pool-size=200 14 | web3sdk.queue-capacity=1000 15 | web3sdk.keep-alive-seconds=60 -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/logback.groovy: -------------------------------------------------------------------------------- 1 | import static ch.qos.logback.classic.Level.ERROR 2 | import static ch.qos.logback.classic.Level.INFO 3 | import static ch.qos.logback.core.spi.FilterReply.ACCEPT 4 | import static ch.qos.logback.core.spi.FilterReply.DENY 5 | 6 | import java.nio.charset.Charset 7 | 8 | import ch.qos.logback.classic.encoder.PatternLayoutEncoder 9 | import ch.qos.logback.classic.filter.LevelFilter 10 | import ch.qos.logback.classic.filter.ThresholdFilter 11 | import ch.qos.logback.core.ConsoleAppender 12 | import ch.qos.logback.core.rolling.RollingFileAppender 13 | import ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP 14 | import ch.qos.logback.core.rolling.TimeBasedRollingPolicy 15 | 16 | appender("CONSOLE", ConsoleAppender) { 17 | filter(LevelFilter) { 18 | level = INFO 19 | } 20 | encoder(PatternLayoutEncoder) { 21 | pattern = "%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n" 22 | charset = Charset.forName("UTF-8") 23 | } 24 | } 25 | appender("FILE_INFO", RollingFileAppender) { 26 | filter(LevelFilter) { 27 | level = ERROR 28 | onMatch = DENY 29 | onMismatch = ACCEPT 30 | } 31 | rollingPolicy(TimeBasedRollingPolicy) { 32 | fileNamePattern = "logs/spring-boot-starter/info.created_on_%d{yyyy-MM-dd}.part_%i.log" 33 | maxHistory = 90 34 | timeBasedFileNamingAndTriggeringPolicy(SizeAndTimeBasedFNATP) { 35 | maxFileSize = "20MB" 36 | } 37 | } 38 | encoder(PatternLayoutEncoder) { 39 | pattern = "%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n" 40 | charset = Charset.forName("UTF-8") 41 | } 42 | } 43 | appender("FILE_ERROR", RollingFileAppender) { 44 | filter(ThresholdFilter) { 45 | level = ERROR 46 | } 47 | rollingPolicy(TimeBasedRollingPolicy) { 48 | fileNamePattern = "logs/spring-boot-starter/error.created_on_%d{yyyy-MM-dd}.part_%i.log" 49 | maxHistory = 90 50 | timeBasedFileNamingAndTriggeringPolicy(SizeAndTimeBasedFNATP) { 51 | maxFileSize = "20MB" 52 | } 53 | } 54 | encoder(PatternLayoutEncoder) { 55 | pattern = "%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n" 56 | charset = Charset.forName("UTF-8") 57 | } 58 | } 59 | root(INFO, [ 60 | "CONSOLE", 61 | "FILE_INFO", 62 | "FILE_ERROR" 63 | ]) -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/solidity/Credit.abi: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"idArray","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"id_string","type":"string"}],"name":"getCreditDataById","outputs":[{"name":"","type":"address[]"},{"name":"","type":"bytes32[]"},{"name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"requirerArray","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes32"},{"name":"","type":"uint256"}],"name":"credits","outputs":[{"name":"uploader","type":"address"},{"name":"id","type":"bytes32"},{"name":"data","type":"bytes32"},{"name":"time","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"id_string","type":"string"},{"name":"data_string","type":"string"}],"name":"addCreditData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/solidity/Credit.bin: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b50610b5d806100206000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806368440dc6146100725780637c6cc9ff146100bb5780639139ac3614610209578063a8ef778714610276578063e4c4e4e214610316575b600080fd5b34801561007e57600080fd5b5061009d600480360381019080803590602001909291905050506103c5565b60405180826000191660001916815260200191505060405180910390f35b3480156100c757600080fd5b50610122600480360381019080803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506103e8565b60405180806020018060200180602001848103845287818151815260200191508051906020019060200280838360005b8381101561016d578082015181840152602081019050610152565b50505050905001848103835286818151815260200191508051906020019060200280838360005b838110156101af578082015181840152602081019050610194565b50505050905001848103825285818151815260200191508051906020019060200280838360005b838110156101f15780820151818401526020810190506101d6565b50505050905001965050505050505060405180910390f35b34801561021557600080fd5b5061023460048036038101908080359060200190929190505050610765565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561028257600080fd5b506102af6004803603810190808035600019169060200190929190803590602001909291905050506107a3565b604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018460001916600019168152602001836000191660001916815260200182815260200194505050505060405180910390f35b34801561032257600080fd5b506103c3600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061080f565b005b6002818154811015156103d457fe5b906000526020600020016000915090505481565b6060806060806000606080606060008060008b6040516020018082805190602001908083835b602083101515610433578051825260208201915060208101905060208303925061040e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310151561049c5780518252602082019150602081019050602083039250610477565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902060001916600019168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156105b65783829060005260206000209060040201608060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600182015460001916600019168152602001600282015460001916600019168152602001600382015481525050815260200190600101906104ff565b50505050955085519450846040519080825280602002602001820160405280156105ef5781602001602082028038833980820191505090505b509350846040519080825280602002602001820160405280156106215781602001602082028038833980820191505090505b509250846040519080825280602002602001820160405280156106535781602001602082028038833980820191505090505b509150600090505b855181101561074f57858181518110151561067257fe5b9060200190602002015160000151848281518110151561068e57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505085818151811015156106d857fe5b906020019060200201516040015183828151811015156106f457fe5b906020019060200201906000191690816000191681525050858181518110151561071a57fe5b9060200190602002015160600151828281518110151561073657fe5b906020019060200201818152505080600101905061065b565b8383839850985098505050505050509193909250565b60038181548110151561077457fe5b906000526020600020016000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000602052816000526040600020818154811015156107be57fe5b9060005260206000209060040201600091509150508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010154908060020154908060030154905084565b6000610819610aec565b836040516020018082805190602001908083835b602083101515610852578051825260208201915060208101905060208303925061082d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831015156108bb5780518252602082019150602081019050602083039250610896565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902091506080604051908101604052803373ffffffffffffffffffffffffffffffffffffffff16815260200183600019168152602001846040516020018082805190602001908083835b6020831015156109555780518252602082019150602081019050602083039250610930565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831015156109be5780518252602082019150602081019050602083039250610999565b6001836020036101000a03801982511681845116808217855250505050505090500191505060405180910390206000191681526020014281525090506000808360001916600019168152602001908152602001600020819080600181540180825580915050906001820390600052602060002090600402016000909192909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550602082015181600101906000191690556040820151816002019060001916905560608201518160030155505050600282908060018154018082558091505090600182039060005260206000200160009091929091909150906000191690555050505050565b608060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160008019168152602001600080191681526020016000815250905600a165627a7a72305820a49f3ff535caa53ddf617fa9c60e74c4713e504c624afcd444a2d1c83b6e347f0029 -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/solidity/HelloWorld.abi: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"n","type":"string"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] -------------------------------------------------------------------------------- /spring-boot-starter/src/main/resources/solidity/HelloWorld.bin: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b506040805190810160405280600d81526020017f48656c6c6f2c20576f726c6421000000000000000000000000000000000000008152506000908051906020019061005c929190610062565b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100515780636d4ce63c146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf610164565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610160929190610206565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101fc5780601f106101d1576101008083540402835291602001916101fc565b820191906000526020600020905b8154815290600101906020018083116101df57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a723058207db3c5650aebcb400ad30326c3e8e16f104b9c8d3d0931ff64ec6a8bb247d7db0029 -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/ContractTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos; 2 | 3 | 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import java.math.BigInteger; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | import lombok.extern.java.Log; 12 | import org.fisco.bcos.bean.CreditData; 13 | import org.fisco.bcos.temp.Credit; 14 | import org.fisco.bcos.temp.HelloWorld; 15 | import org.fisco.bcos.utils.SolidityTools; 16 | import org.fisco.bcos.web3j.abi.EventEncoder; 17 | import org.fisco.bcos.web3j.abi.TypeReference; 18 | import org.fisco.bcos.web3j.abi.datatypes.Address; 19 | import org.fisco.bcos.web3j.abi.datatypes.Event; 20 | import org.fisco.bcos.web3j.crypto.Credentials; 21 | import org.fisco.bcos.web3j.crypto.Hash; 22 | import org.fisco.bcos.web3j.crypto.SHA3Digest; 23 | import org.fisco.bcos.web3j.crypto.gm.GenCredential; 24 | import org.fisco.bcos.web3j.protocol.Web3j; 25 | import org.fisco.bcos.web3j.protocol.core.DefaultBlockParameterName; 26 | import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt; 27 | import org.fisco.bcos.web3j.tuples.generated.Tuple5; 28 | import org.fisco.bcos.web3j.tx.gas.StaticGasProvider; 29 | import org.fisco.bcos.web3j.utils.Numeric; 30 | import org.junit.After; 31 | import org.junit.Before; 32 | import org.junit.Test; 33 | import org.junit.runner.RunWith; 34 | import org.springframework.beans.factory.annotation.Autowired; 35 | import org.springframework.boot.test.context.SpringBootTest; 36 | import org.springframework.test.context.junit4.SpringRunner; 37 | import rx.functions.Action1; 38 | 39 | @RunWith(SpringRunner.class) 40 | @SpringBootTest(classes = Application.class) 41 | public class ContractTest { 42 | 43 | private static BigInteger gasPrice = new BigInteger("300000000"); 44 | private static BigInteger gasLimit = new BigInteger("300000000"); 45 | private Credentials credentials; 46 | private Credentials credentials2; 47 | 48 | @Autowired 49 | Web3j web3j; 50 | 51 | @Before 52 | public void setUp() throws Exception { 53 | credentials = GenCredential.create("b83261efa42895c38c6c2364ca878f43e77f3cddbc922bf57d0d48070f79feb6"); 54 | credentials2 = GenCredential.create("b83261efa42895c38c6c2364ca878f43e77f3cddbc922bf57d0d48070f79feb7"); 55 | if (credentials == null || credentials2 == null) { 56 | throw new Exception("create Credentials failed"); 57 | } 58 | } 59 | 60 | @After 61 | public void tearDown() { 62 | 63 | } 64 | 65 | @Test 66 | public void deployAndCallHelloWorld() throws Exception { 67 | //deploy contract 68 | System.out.println("Start hello world"); 69 | HelloWorld helloWorld = HelloWorld.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).sendAsync().get(60000, TimeUnit.MILLISECONDS); 70 | if (helloWorld != null) { 71 | System.out.println("HelloWorld address is: " + helloWorld.getContractAddress()); 72 | //call set function 73 | helloWorld.set("Hello, World!").sendAsync().get(60000, TimeUnit.MILLISECONDS); 74 | //call get function 75 | String result = helloWorld.get().sendAsync().get(60000, TimeUnit.MILLISECONDS); 76 | System.out.println(result); 77 | assertTrue( "Hello, World!".equals(result)); 78 | } 79 | } 80 | 81 | /** 82 | * Test the credit contract 83 | * The way to decode output is hard to find 84 | * @throws Exception 85 | */ 86 | @Test 87 | public void deployAndCallCreditAdd() throws Exception { 88 | //deploy contract 89 | System.out.println("Start Credit Add"); 90 | Credit credit = Credit.deploy(web3j, credentials, new StaticGasProvider(gasPrice, gasLimit)).send(); 91 | 92 | if (credit != null) { 93 | System.out.println("Credit address is: " + credit.getContractAddress()); 94 | String id = String.valueOf((int)Math.random()); 95 | String data = SolidityTools.randomAlphaNumeric((int)Math.random()); 96 | //call set function 97 | TransactionReceipt receipt = credit.addCreditData( id, data).sendAsync().get(); 98 | List reponses = credit.getAddCreditDataSuccessEvents(receipt); 99 | System.out.println("reponse"); 100 | for (int i = 0; i < reponses.size(); i++) { 101 | System.out.println(reponses.get(i).id); 102 | } 103 | //call get function 104 | Tuple5, List, List, List, List> result = credit.getCreditDetialDataByPeopleId(id).send(); 105 | System.out.println("Uploader: " + result.getValue1().toString()); 106 | List ids = result.getValue1(); 107 | List uploaders = result.getValue2(); 108 | List datas = result.getValue3(); 109 | List types = result.getValue4(); 110 | List times = result.getValue5(); 111 | System.out.println("ids.get(0) = " + ids.get(0)); 112 | System.out.println("uploaders.get(0) = " + uploaders.get(0)); 113 | System.out.println("datas.get(0) = " + Numeric.toHexString(datas.get(0))); 114 | System.out.println("times.get(0) = " + times.get(0)); 115 | CreditData creditData = new CreditData(result.getValue1().get(0), 116 | result.getValue2().get(0), 117 | Numeric.toHexString(datas.get(0)), 118 | types.get(0), 119 | String.valueOf(result.getValue5().get(0))); 120 | 121 | String printed = Numeric.toHexString(datas.get(0)); 122 | // [-84, -81, 50, -119, -41, -74, 1, -53, -47, 20, -5, 54, -60, -46, -100, -123, -69, -3, 94, 19, 63, 20, -53, 53, 92, 63, -40, -39, -109, 103, -106, 79] 123 | 124 | // Hash.sha3("EVWithdraw(address,uint256,bytes32)".getBytes(StandardCharsets.UTF_8)); 125 | byte[] here2 = (new SHA3Digest()).hash(data).getBytes(); 126 | String here2_raw = (new SHA3Digest()).hash(data); 127 | String here_raw = Hash.sha3String(data); 128 | byte[] here = Hash.sha3String(data).getBytes(); 129 | String herePrinted = Numeric.toHexString(here); 130 | String herePrinted2 = Numeric.toHexString(here2); 131 | // [48, 120, 97, 99, 97, 102, 51, 50, 56, 57, 100, 55, 98, 54, 48, 49, 99, 98, 100, 49, 49, 52, 102, 98, 51, 54, 99, 52, 100, 50, 57, 99, 56, 53, 98, 98, 102, 100, 53, 101, 49, 51, 51, 102, 49, 52, 99, 98, 51, 53, 53, 99, 51, 102, 100, 56, 100, 57, 57, 51, 54, 55, 57, 54, 52, 102] 132 | 133 | System.out.println("Datas: " + printed); 134 | System.out.println("Datas here: " + herePrinted); 135 | System.out.println("Datas here raw: " + here_raw); 136 | System.out.println("Datas here2: " + herePrinted2); 137 | System.out.println("Datas here2 raw: " + here2_raw); 138 | System.out.println("Time: " + creditData.getTime()); 139 | System.out.println(creditData.toString()); 140 | System.out.println("getBlockNumber:" + web3j.getBlockNumber().send().getBlockNumber()); 141 | 142 | assertTrue(printed.equals(here_raw)); 143 | } 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/PrecompiledServiceApiTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import org.fisco.bcos.web3j.crypto.Credentials; 6 | import org.fisco.bcos.web3j.crypto.gm.GenCredential; 7 | import org.fisco.bcos.web3j.precompile.config.SystemConfigSerivce; 8 | import org.fisco.bcos.web3j.protocol.Web3j; 9 | import org.junit.After; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.test.context.junit4.SpringRunner; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest(classes = Application.class) 19 | public class PrecompiledServiceApiTest { 20 | 21 | private Credentials credentials; 22 | 23 | 24 | 25 | @Before 26 | public void setUp() throws Exception { 27 | credentials = GenCredential.create("b83261efa42895c38c6c2364ca878f43e77f3cddbc922bf57d0d48070f79feb6"); 28 | if (credentials == null) { 29 | throw new Exception("create Credentials failed"); 30 | } 31 | } 32 | 33 | @After 34 | public void tearDown() { 35 | 36 | } 37 | 38 | @Autowired 39 | Web3j web3j; 40 | 41 | @Test 42 | public void testSystemConfigService() throws Exception { 43 | SystemConfigSerivce systemConfigSerivce = new SystemConfigSerivce(web3j, credentials); 44 | systemConfigSerivce.setValueByKey("tx_count_limit", "2000"); 45 | String value = web3j.getSystemConfigByKey("tx_count_limit").send().getSystemConfigByKey(); 46 | System.out.println(value); 47 | assertTrue("2000".equals(value)); 48 | } 49 | 50 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos; 2 | 3 | import org.fisco.bcos.channel.client.Service; 4 | import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import static org.junit.Assert.assertTrue; 12 | 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest(classes = Application.class) 15 | public class ServiceTest { 16 | 17 | @Autowired 18 | Service service; 19 | 20 | @Test 21 | public void getWeb3j() throws Exception { 22 | ChannelEthereumService channelEthereumService = new ChannelEthereumService(); 23 | System.out.println(service.getGroupId()); 24 | service.run(); 25 | channelEthereumService.setChannelService(service); 26 | channelEthereumService.setTimeout(30000); 27 | assertTrue(service.getGroupId() == 1); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/Web3jApiTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos; 2 | 3 | import static org.junit.Assert.assertTrue; 4 | 5 | import java.io.IOException; 6 | import java.math.BigInteger; 7 | 8 | import org.fisco.bcos.web3j.protocol.Web3j; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.boot.test.context.SpringBootTest; 15 | import org.springframework.test.context.junit4.SpringRunner; 16 | 17 | import lombok.extern.slf4j.Slf4j; 18 | 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest(classes = Application.class) 21 | @Slf4j 22 | public class Web3jApiTest { 23 | 24 | @Autowired 25 | Web3j web3j; 26 | 27 | @Test 28 | public void getBlockNumber() throws IOException { 29 | BigInteger blockNumber = web3j.getBlockNumber().send().getBlockNumber(); 30 | log.info("blockNumber is {}", blockNumber); 31 | assertTrue(blockNumber.compareTo(new BigInteger("0")) >= 0); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/server/Channel2Client.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.server; 2 | 3 | import org.fisco.bcos.Application; 4 | import org.fisco.bcos.channel.client.Service; 5 | import org.fisco.bcos.channel.dto.ChannelRequest; 6 | import org.fisco.bcos.channel.dto.ChannelResponse; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import java.time.LocalDateTime; 14 | import java.time.format.DateTimeFormatter; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest(classes = Application.class) 18 | public class Channel2Client { 19 | 20 | @Autowired 21 | Service service; 22 | 23 | @Test 24 | public void channel2ClientTest() throws Exception { 25 | 26 | String topic = "topic"; 27 | Integer count = Integer.parseInt("2"); 28 | 29 | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 30 | 31 | System.out.println("3s ..."); 32 | Thread.sleep(1000); 33 | System.out.println("2s ..."); 34 | Thread.sleep(1000); 35 | System.out.println("1s ..."); 36 | Thread.sleep(1000); 37 | 38 | System.out.println("start test"); 39 | System.out.println("==================================================================="); 40 | 41 | for(Integer i = 0; i < count; ++i) { 42 | Thread.sleep(2000); 43 | ChannelRequest request = new ChannelRequest(); 44 | request.setToTopic(topic); 45 | request.setMessageID(service.newSeq()); 46 | request.setTimeout(5000); 47 | 48 | request.setContent("request seq:" + request.getMessageID()); 49 | 50 | System.out.println(df.format(LocalDateTime.now()) + " request seq:" + String.valueOf(request.getMessageID()) + ", Content:" + request.getContent()); 51 | 52 | ChannelResponse response = service.sendChannelMessage2(request); 53 | 54 | System.out.println(df.format(LocalDateTime.now()) + "response seq:" + String.valueOf(response.getMessageID()) + ", ErrorCode:" + response.getErrorCode() + ", Content:" + response.getContent()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/server/Channel2Server.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.server; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.fisco.bcos.Application; 7 | import org.fisco.bcos.channel.client.Service; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | @RunWith(SpringRunner.class) 15 | @SpringBootTest(classes = Application.class) 16 | public class Channel2Server { 17 | 18 | @Autowired 19 | Service service; 20 | 21 | @Test 22 | public void channel2ServerTest() throws Exception { 23 | 24 | 25 | String topic = "topic"; 26 | Set topics = new HashSet<>(); 27 | topics.add(topic); 28 | service.setTopics(topics); 29 | 30 | PushCallback cb = new PushCallback(); 31 | 32 | service.setPushCallback(cb); 33 | 34 | System.out.println("3s..."); 35 | Thread.sleep(1000); 36 | System.out.println("2s..."); 37 | Thread.sleep(1000); 38 | System.out.println("1s..."); 39 | Thread.sleep(1000); 40 | 41 | System.out.println("start test"); 42 | System.out.println("==================================================================="); 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/server/ProxyServerTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.server; 2 | 3 | import org.fisco.bcos.Application; 4 | import org.fisco.bcos.channel.handler.ChannelConnections; 5 | import org.fisco.bcos.channel.proxy.Server; 6 | import org.junit.Ignore; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import javax.net.ssl.SSLException; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | @RunWith(SpringRunner.class) 18 | @SpringBootTest(classes = Application.class) 19 | public class ProxyServerTest { 20 | @Ignore 21 | @Test 22 | public void proxyServerTest() throws SSLException { 23 | Server server = new Server(); 24 | ChannelConnections channelConnections = new ChannelConnections(); 25 | List ilist = new ArrayList<>(); 26 | ilist.add("10.107.105.138:30901"); 27 | channelConnections.setConnectionsStr(ilist); 28 | server.setRemoteConnections(channelConnections); 29 | 30 | server.setThreadPool(new ThreadPoolTaskExecutor()); 31 | server.setBindPort(8830); 32 | server.run(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/server/PushCallback.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.server; 2 | 3 | import java.time.LocalDateTime; 4 | import java.time.format.DateTimeFormatter; 5 | 6 | import org.fisco.bcos.channel.client.ChannelPushCallback; 7 | import org.fisco.bcos.channel.dto.ChannelPush; 8 | import org.fisco.bcos.channel.dto.ChannelResponse; 9 | 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | @Slf4j 13 | class PushCallback extends ChannelPushCallback { 14 | 15 | @Override 16 | public void onPush(ChannelPush push) { 17 | DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 18 | log.debug("push:" + push.getContent()); 19 | 20 | System.out.println(df.format(LocalDateTime.now()) + "server:push:" + push.getContent()); 21 | ChannelResponse response = new ChannelResponse(); 22 | response.setContent("receive request seq:" + String.valueOf(push.getMessageID())); 23 | response.setErrorCode(0); 24 | 25 | push.sendResponse(response); 26 | } 27 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/solidity/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.solidity; 2 | 3 | import java.math.BigInteger; 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import org.fisco.bcos.channel.client.TransactionSucCallback; 7 | import org.fisco.bcos.web3j.abi.TypeReference; 8 | import org.fisco.bcos.web3j.abi.datatypes.Function; 9 | import org.fisco.bcos.web3j.abi.datatypes.Type; 10 | import org.fisco.bcos.web3j.abi.datatypes.Utf8String; 11 | import org.fisco.bcos.web3j.crypto.Credentials; 12 | import org.fisco.bcos.web3j.protocol.Web3j; 13 | import org.fisco.bcos.web3j.protocol.core.RemoteCall; 14 | import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt; 15 | import org.fisco.bcos.web3j.tx.Contract; 16 | import org.fisco.bcos.web3j.tx.TransactionManager; 17 | import org.fisco.bcos.web3j.tx.gas.ContractGasProvider; 18 | 19 | /** 20 | *

Auto generated code. 21 | *

Do not modify! 22 | *

Please use the web3j command line tools, 23 | * or the org.fisco.bcos.web3j.codegen.SolidityFunctionWrapperGenerator in the 24 | * codegen module to update. 25 | * 26 | *

Generated with web3j version none. 27 | */ 28 | @SuppressWarnings("unchecked") 29 | public class HelloWorld extends Contract { 30 | private static final String BINARY = "608060405234801561001057600080fd5b506040805190810160405280600d81526020017f48656c6c6f2c20576f726c6421000000000000000000000000000000000000008152506000908051906020019061005c929190610062565b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100515780636d4ce63c146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf610164565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610160929190610206565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101fc5780601f106101d1576101008083540402835291602001916101fc565b820191906000526020600020905b8154815290600101906020018083116101df57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a723058207db3c5650aebcb400ad30326c3e8e16f104b9c8d3d0931ff64ec6a8bb247d7db0029"; 31 | 32 | public static final String FUNC_SET = "set"; 33 | 34 | public static final String FUNC_GET = "get"; 35 | 36 | @Deprecated 37 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 38 | super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); 39 | } 40 | 41 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 42 | super(BINARY, contractAddress, web3j, credentials, contractGasProvider); 43 | } 44 | 45 | @Deprecated 46 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 47 | super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); 48 | } 49 | 50 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 51 | super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); 52 | } 53 | 54 | public RemoteCall set(String n) { 55 | final Function function = new Function( 56 | FUNC_SET, 57 | Arrays.asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 58 | Collections.>emptyList()); 59 | return executeRemoteCallTransaction(function); 60 | } 61 | 62 | public void set(String n, TransactionSucCallback callback) { 63 | final Function function = new Function( 64 | FUNC_SET, 65 | Arrays.asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 66 | Collections.>emptyList()); 67 | asyncExecuteTransaction(function, callback); 68 | } 69 | 70 | public RemoteCall get() { 71 | final Function function = new Function(FUNC_GET, 72 | Arrays.asList(), 73 | Arrays.>asList(new TypeReference() {})); 74 | return executeRemoteCallSingleValueReturn(function, String.class); 75 | } 76 | 77 | @Deprecated 78 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 79 | return new HelloWorld(contractAddress, web3j, credentials, gasPrice, gasLimit); 80 | } 81 | 82 | @Deprecated 83 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 84 | return new HelloWorld(contractAddress, web3j, transactionManager, gasPrice, gasLimit); 85 | } 86 | 87 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 88 | return new HelloWorld(contractAddress, web3j, credentials, contractGasProvider); 89 | } 90 | 91 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 92 | return new HelloWorld(contractAddress, web3j, transactionManager, contractGasProvider); 93 | } 94 | 95 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 96 | return deployRemoteCall(HelloWorld.class, web3j, credentials, contractGasProvider, BINARY, ""); 97 | } 98 | 99 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 100 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, contractGasProvider, BINARY, ""); 101 | } 102 | 103 | @Deprecated 104 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 105 | return deployRemoteCall(HelloWorld.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); 106 | } 107 | 108 | @Deprecated 109 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 110 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/solidity/SolidityFunctionWrapperGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.solidity; 2 | 3 | import static org.fisco.bcos.web3j.solidity.compiler.SolidityCompiler.Options.ABI; 4 | import static org.fisco.bcos.web3j.solidity.compiler.SolidityCompiler.Options.BIN; 5 | import static org.fisco.bcos.web3j.solidity.compiler.SolidityCompiler.Options.INTERFACE; 6 | import static org.fisco.bcos.web3j.solidity.compiler.SolidityCompiler.Options.METADATA; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.util.Arrays; 11 | 12 | import org.apache.commons.io.FileUtils; 13 | import org.fisco.bcos.web3j.codegen.SolidityFunctionWrapperGenerator; 14 | import org.fisco.bcos.web3j.solidity.compiler.CompilationResult; 15 | import org.fisco.bcos.web3j.solidity.compiler.SolidityCompiler; 16 | import org.junit.Test; 17 | import org.springframework.core.io.ClassPathResource; 18 | 19 | import lombok.extern.slf4j.Slf4j; 20 | 21 | @Slf4j 22 | public class SolidityFunctionWrapperGeneratorTest { 23 | 24 | protected String tempDirPath = new File("src/test/java/").getAbsolutePath(); 25 | protected String packageName = "org.fisco.bcos.solidity"; 26 | 27 | @Test 28 | public void generateClassFromABIForHelloWorld() throws Exception { 29 | 30 | String binFile1 = new ClassPathResource("solidity/HelloWorld.bin").getFile().getAbsolutePath(); 31 | String abiFile1 = new ClassPathResource("solidity/HelloWorld.abi").getFile().getAbsolutePath(); 32 | SolidityFunctionWrapperGenerator.main(Arrays.asList( 33 | "-b", binFile1, 34 | "-a", abiFile1, 35 | "-p", packageName, 36 | "-o", tempDirPath 37 | ).toArray(new String[0])); 38 | } 39 | 40 | 41 | 42 | @Test 43 | public void compileSolFilesToJavaTest() throws IOException { 44 | File solFileList = new File("src/test/resources/contract"); 45 | File[] solFiles = solFileList.listFiles(); 46 | 47 | for (File solFile : solFiles) { 48 | 49 | SolidityCompiler.Result res = SolidityCompiler.compile(solFile, true, ABI, BIN, INTERFACE, METADATA); 50 | log.info("Out: '{}'" , res.output ); 51 | log.info("Err: '{}'" , res.errors ); 52 | CompilationResult result = CompilationResult.parse(res.output); 53 | log.info("contractname {}" , solFile.getName()); 54 | String contractname = solFile.getName().split("\\.")[0]; 55 | CompilationResult.ContractMetadata a = result.getContract(solFile.getName().split("\\.")[0]); 56 | log.info("abi {}" , a.abi); 57 | log.info("bin {}" , a.bin); 58 | FileUtils.writeStringToFile(new File("src/test/resources/solidity/" + contractname + ".abi"), a.abi); 59 | FileUtils.writeStringToFile(new File("src/test/resources/solidity/" + contractname + ".bin"), a.bin); 60 | String binFile; 61 | String abiFile; 62 | String tempDirPath = new File("src/test/java/").getAbsolutePath(); 63 | String packageName = "org.fisco.bcos.temp"; 64 | String filename = contractname; 65 | abiFile = "src/test/resources/solidity/" + filename + ".abi"; 66 | binFile = "src/test/resources/solidity/" + filename + ".bin"; 67 | SolidityFunctionWrapperGenerator.main(Arrays.asList( 68 | "-a", abiFile, 69 | "-b", binFile, 70 | "-p", packageName, 71 | "-o", tempDirPath 72 | ).toArray(new String[0])); 73 | } 74 | System.out.println("generate successfully"); 75 | } 76 | 77 | public SolidityFunctionWrapperGeneratorTest() throws IOException { 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/java/org/fisco/bcos/temp/HelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.fisco.bcos.temp; 2 | 3 | import java.math.BigInteger; 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | import org.fisco.bcos.channel.client.TransactionSucCallback; 7 | import org.fisco.bcos.web3j.abi.TypeReference; 8 | import org.fisco.bcos.web3j.abi.datatypes.Function; 9 | import org.fisco.bcos.web3j.abi.datatypes.Type; 10 | import org.fisco.bcos.web3j.abi.datatypes.Utf8String; 11 | import org.fisco.bcos.web3j.crypto.Credentials; 12 | import org.fisco.bcos.web3j.protocol.Web3j; 13 | import org.fisco.bcos.web3j.protocol.core.RemoteCall; 14 | import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt; 15 | import org.fisco.bcos.web3j.tx.Contract; 16 | import org.fisco.bcos.web3j.tx.TransactionManager; 17 | import org.fisco.bcos.web3j.tx.gas.ContractGasProvider; 18 | 19 | /** 20 | *

Auto generated code. 21 | *

Do not modify! 22 | *

Please use the web3j command line tools, 23 | * or the org.fisco.bcos.web3j.codegen.SolidityFunctionWrapperGenerator in the 24 | * codegen module to update. 25 | * 26 | *

Generated with web3j version none. 27 | */ 28 | @SuppressWarnings("unchecked") 29 | public class HelloWorld extends Contract { 30 | private static final String BINARY = "608060405234801561001057600080fd5b506040805190810160405280600d81526020017f48656c6c6f2c20576f726c6421000000000000000000000000000000000000008152506000908051906020019061005c929190610062565b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100515780636d4ce63c146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf610164565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610160929190610206565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101fc5780601f106101d1576101008083540402835291602001916101fc565b820191906000526020600020905b8154815290600101906020018083116101df57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a723058207db3c5650aebcb400ad30326c3e8e16f104b9c8d3d0931ff64ec6a8bb247d7db0029"; 31 | 32 | public static final String FUNC_SET = "set"; 33 | 34 | public static final String FUNC_GET = "get"; 35 | 36 | @Deprecated 37 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 38 | super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); 39 | } 40 | 41 | protected HelloWorld(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 42 | super(BINARY, contractAddress, web3j, credentials, contractGasProvider); 43 | } 44 | 45 | @Deprecated 46 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 47 | super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); 48 | } 49 | 50 | protected HelloWorld(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 51 | super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); 52 | } 53 | 54 | public RemoteCall set(String n) { 55 | final Function function = new Function( 56 | FUNC_SET, 57 | Arrays.asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 58 | Collections.>emptyList()); 59 | return executeRemoteCallTransaction(function); 60 | } 61 | 62 | public void set(String n, TransactionSucCallback callback) { 63 | final Function function = new Function( 64 | FUNC_SET, 65 | Arrays.asList(new org.fisco.bcos.web3j.abi.datatypes.Utf8String(n)), 66 | Collections.>emptyList()); 67 | asyncExecuteTransaction(function, callback); 68 | } 69 | 70 | public RemoteCall get() { 71 | final Function function = new Function(FUNC_GET, 72 | Arrays.asList(), 73 | Arrays.>asList(new TypeReference() {})); 74 | return executeRemoteCallSingleValueReturn(function, String.class); 75 | } 76 | 77 | @Deprecated 78 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 79 | return new HelloWorld(contractAddress, web3j, credentials, gasPrice, gasLimit); 80 | } 81 | 82 | @Deprecated 83 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 84 | return new HelloWorld(contractAddress, web3j, transactionManager, gasPrice, gasLimit); 85 | } 86 | 87 | public static HelloWorld load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 88 | return new HelloWorld(contractAddress, web3j, credentials, contractGasProvider); 89 | } 90 | 91 | public static HelloWorld load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 92 | return new HelloWorld(contractAddress, web3j, transactionManager, contractGasProvider); 93 | } 94 | 95 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { 96 | return deployRemoteCall(HelloWorld.class, web3j, credentials, contractGasProvider, BINARY, ""); 97 | } 98 | 99 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { 100 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, contractGasProvider, BINARY, ""); 101 | } 102 | 103 | @Deprecated 104 | public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { 105 | return deployRemoteCall(HelloWorld.class, web3j, credentials, gasPrice, gasLimit, BINARY, ""); 106 | } 107 | 108 | @Deprecated 109 | public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { 110 | return deployRemoteCall(HelloWorld.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, ""); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/contract/Credit.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.0 <0.7.0; 2 | 3 | contract Credit { 4 | 5 | // ?上次遗留:如果不 map到一个数组,如何读取历史记录,如何高效查找数据 6 | // ?如果要修改一个数组的一个值,如何修改? 直接取出来是放在内存里的,修改完之后会自动覆盖在数组上面吗?还是会重新建一个数组? 7 | mapping(bytes32 => CreditData[]) private credits; // key = peopleId 8 | bytes32[] private idArray; 9 | uint private id; // 初始化为 0 10 | 11 | struct CreditData { 12 | uint id; // index 13 | address uploader; 14 | bytes32 peopleId; // 256 bits hashed id by keccak256() 15 | bytes32 data; // hashed credit data 16 | uint time; // time the data upload 17 | uint8 _type; // the type of the data, 0 for not sure 18 | } 19 | 20 | event addCreditDataSuccess(uint id); 21 | 22 | function addCreditData(string memory id_string, string memory data_string) 23 | public 24 | { 25 | id = id + 1; 26 | bytes32 peopleId = keccak256(abi.encodePacked(id_string)); 27 | CreditData memory credit = CreditData(id, msg.sender, peopleId, 28 | keccak256(abi.encodePacked(data_string)), 29 | now, 0); 30 | credits[peopleId].push(credit); 31 | idArray.push(peopleId); 32 | emit addCreditDataSuccess(credit.id); // send the success signal 33 | } 34 | 35 | // 问题: 数据量太大怎么办? 先不考虑 36 | function getCreditDetialDataByPeopleId(string memory id_string) 37 | public 38 | view 39 | returns( 40 | uint[] memory, // id 41 | address[] memory, // uploader, 返回为二进制,如何辨识 42 | bytes32[] memory, // datas 43 | uint[] memory, // times 44 | uint8[] memory) 45 | { 46 | bytes32 peopleId = keccak256(abi.encodePacked(id_string)); 47 | CreditData[] memory credit_array = credits[peopleId]; 48 | uint credit_array_length = credit_array.length; 49 | uint[] memory ids = new uint[](credit_array_length); 50 | address[] memory uploaders = new address[](credit_array_length); 51 | bytes32[] memory datas = new bytes32[](credit_array_length); 52 | uint[] memory times = new uint[](credit_array_length); 53 | uint8[] memory types = new uint8[](credit_array_length); 54 | for (uint i = 0; i < credit_array.length; ++i) { 55 | ids[i] = credit_array[i].id; 56 | uploaders[i] = credit_array[i].uploader; 57 | datas[i] = credit_array[i].data; 58 | times[i] = credit_array[i].time; 59 | types[i] = credit_array[i]._type; 60 | } 61 | return (ids, uploaders, datas, times, types); 62 | } 63 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/contract/HelloWorld.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.24; 2 | 3 | contract HelloWorld{ 4 | string name; 5 | constructor() public{ 6 | name = "Hello, World!"; 7 | } 8 | 9 | function get()constant public returns(string){ 10 | return name; 11 | } 12 | 13 | function set(string n) public{ 14 | name = n; 15 | } 16 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/contract/Record.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.4.0 <0.7.0; 2 | 3 | contract Record { 4 | mapping(address => RecordData[]) private records; // key = applicant address 5 | address[] private applicantArray; // stores the organizes that applied the data 6 | uint private id; 7 | 8 | struct RecordData { 9 | address applicant; // the organize want the data 10 | address uploader; // the organize upload the data 11 | uint id; // index 12 | uint creditDataId; // the id of credit data 13 | uint time; 14 | bool isSent; // whether the original data has been sent from the uploader 15 | uint8 score; // the score of this record 16 | bool isScored; // whether the uploader has scored 17 | } 18 | 19 | event addRecordSuccess(address _applicant, 20 | address _uploader, 21 | uint _id, 22 | uint _creditDataId, 23 | uint _time); 24 | 25 | // Add Record Data 26 | function addRecordData(uint creditDataId, address uploader) 27 | public 28 | { 29 | require(uploader != msg.sender, "The onwner of the data could not be the applicant!"); 30 | id = id + 1; 31 | RecordData memory record = RecordData(msg.sender, 32 | uploader, 33 | id, 34 | creditDataId, 35 | now, 36 | false, 37 | 0, 38 | false); 39 | records[msg.sender].push(record); 40 | applicantArray.push(msg.sender); 41 | emit addRecordSuccess (record.applicant, record.uploader, record.id, record.creditDataId, record.time); 42 | } 43 | 44 | // Check if the record is stored. 45 | function checkRecordExist(address applicant, 46 | address uploader, 47 | uint recordId, 48 | uint creditDataId) public view 49 | returns (bool) { 50 | for (uint j = 0; j < records[applicant].length; j++) { 51 | if (records[applicant][j].applicant == applicant && 52 | records[applicant][j].uploader == uploader && 53 | records[applicant][j].id == recordId && 54 | records[applicant][j].creditDataId == creditDataId) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | } 60 | 61 | // Get the RecordData detail by recordId 62 | function getRecordDataById(uint recordId) public view 63 | returns (address, address, uint, uint, uint, bool, uint8, bool) { 64 | for (uint i = 0; i < applicantArray.length; i ++) { 65 | for (uint j = 0; j < records[applicantArray[i]].length; j++) { 66 | if (records[applicantArray[i]][j].id == recordId) { 67 | RecordData memory tmp = records[applicantArray[i]][j]; 68 | return (tmp.applicant, 69 | tmp.uploader, 70 | tmp.id, 71 | tmp.creditDataId, 72 | tmp.time, 73 | tmp.isSent, 74 | tmp.score, 75 | tmp.isScored); 76 | } 77 | } 78 | } 79 | return (msg.sender, msg.sender, 0, 0, now, false, 0, false); 80 | // return a zero record to imply can't find the record 81 | } 82 | 83 | event sendRecordDataSuccess(bool yn); 84 | // 发送原始数据之后,将数据标为已发送 85 | // 需要对 CreditData 进行查找, 时间与空间的如何选择? 只能遍历 86 | function sendRecordData(uint recordId, bool yn) 87 | public 88 | { 89 | for (uint i = 0; i < applicantArray.length; i ++) { 90 | for (uint j = 0; j < records[applicantArray[i]].length; j++) { 91 | if (records[applicantArray[i]][j].id == recordId) { 92 | require( 93 | records[applicantArray[i]][j].uploader == msg.sender, 94 | "Only the owner of the data can choose whether to send."); 95 | require( 96 | records[applicantArray[i]][j].isSent == false, 97 | "This data has been sent."); 98 | records[applicantArray[i]][j].isSent = yn; 99 | emit sendRecordDataSuccess(true); 100 | } 101 | } 102 | } 103 | emit sendRecordDataSuccess(false); 104 | } 105 | 106 | event scoreRecordDataSuccess(bool yn); 107 | // 机构评分 RecordData 108 | function scoreRecordData(uint recordId, uint8 score) 109 | public 110 | { 111 | for (uint i = 0; i < applicantArray.length; i ++) { 112 | for (uint j = 0; j < records[applicantArray[i]].length; j++) { 113 | if (records[applicantArray[i]][j].id == recordId) { 114 | require(records[applicantArray[i]][j].isSent == true, "Only recieved data has been scored."); 115 | require(records[applicantArray[i]][j].applicant == msg.sender, "Only the applicant of the record can score the data."); 116 | require(records[applicantArray[i]][j].isScored == false, "This data has been recorded."); 117 | records[applicantArray[i]][j].score = score; 118 | records[applicantArray[i]][j].isScored = true; 119 | emit scoreRecordDataSuccess(true); 120 | } 121 | } 122 | } 123 | emit scoreRecordDataSuccess(false); 124 | } 125 | } -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/Credit.abi: -------------------------------------------------------------------------------- 1 | [{"constant":true,"inputs":[{"name":"id_string","type":"string"}],"name":"getCreditDetialDataByPeopleId","outputs":[{"name":"","type":"uint256[]"},{"name":"","type":"address[]"},{"name":"","type":"bytes32[]"},{"name":"","type":"uint256[]"},{"name":"","type":"uint8[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"id_string","type":"string"},{"name":"data_string","type":"string"}],"name":"addCreditData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"id","type":"uint256"}],"name":"addCreditDataSuccess","type":"event"}] -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/Credit.bin: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b50610b58806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806366da417f14610051578063e4c4e4e21461022f575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f01602080910402602001604051908101604052809392919081815260200183838082843782019150505050505091929192905050506102de565b60405180806020018060200180602001806020018060200186810386528b818151815260200191508051906020019060200280838360005b8381101561010b5780820151818401526020810190506100f0565b5050505090500186810385528a818151815260200191508051906020019060200280838360005b8381101561014d578082015181840152602081019050610132565b50505050905001868103845289818151815260200191508051906020019060200280838360005b8381101561018f578082015181840152602081019050610174565b50505050905001868103835288818151815260200191508051906020019060200280838360005b838110156101d15780820151818401526020810190506101b6565b50505050905001868103825287818151815260200191508051906020019060200280838360005b838110156102135780820151818401526020810190506101f8565b505050509050019a505050505050505050505060405180910390f35b34801561023b57600080fd5b506102dc600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610775565b005b6060806060806060600060606000606080606080606060008e6040516020018082805190602001908083835b60208310151561032f578051825260208201915060208101905060208303925061030a565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831015156103985780518252602082019150602081019050602083039250610373565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051809103902098506000808a60001916600019168152602001908152602001600020805480602002602001604051908101604052809291908181526020016000905b828210156104df578382906000526020600020906006020160c06040519081016040529081600082015481526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001600282015460001916600019168152602001600382015460001916600019168152602001600482015481526020016005820160009054906101000a900460ff1660ff1660ff168152505081526020019060010190610401565b50505050975087519650866040519080825280602002602001820160405280156105185781602001602082028038833980820191505090505b5095508660405190808252806020026020018201604052801561054a5781602001602082028038833980820191505090505b5094508660405190808252806020026020018201604052801561057c5781602001602082028038833980820191505090505b509350866040519080825280602002602001820160405280156105ae5781602001602082028038833980820191505090505b509250866040519080825280602002602001820160405280156105e05781602001602082028038833980820191505090505b509150600090505b87518110156107545787818151811015156105ff57fe5b9060200190602002015160000151868281518110151561061b57fe5b9060200190602002018181525050878181518110151561063757fe5b9060200190602002015160200151858281518110151561065357fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050878181518110151561069d57fe5b906020019060200201516060015184828151811015156106b957fe5b90602001906020020190600019169081600019168152505087818151811015156106df57fe5b906020019060200201516080015183828151811015156106fb57fe5b9060200190602002018181525050878181518110151561071757fe5b9060200190602002015160a00151828281518110151561073357fe5b9060200190602002019060ff16908160ff16815250508060010190506105e8565b85858585859d509d509d509d509d5050505050505050505091939590929450565b600061077f610ad6565b600160025401600281905550836040516020018082805190602001908083835b6020831015156107c4578051825260208201915060208101905060208303925061079f565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b60208310151561082d5780518252602082019150602081019050602083039250610808565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020915060c06040519081016040528060025481526020013373ffffffffffffffffffffffffffffffffffffffff16815260200183600019168152602001846040516020018082805190602001908083835b6020831015156108cf57805182526020820191506020810190506020830392506108aa565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040526040518082805190602001908083835b6020831015156109385780518252602082019150602081019050602083039250610913565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040518091039020600019168152602001428152602001600060ff168152509050600080836000191660001916815260200190815260200160002081908060018154018082558091505090600182039060005260206000209060060201600090919290919091506000820151816000015560208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020190600019169055606082015181600301906000191690556080820151816004015560a08201518160050160006101000a81548160ff021916908360ff16021790555050505060018290806001815401808255809150509060018203906000526020600020016000909192909190915090600019169055507fcc2d97dd2f0f2bb0d039b4928216d0ec45229cb1f8e22dfe466081e61161b06a81600001516040518082815260200191505060405180910390a150505050565b60c06040519081016040528060008152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600080191681526020016000801916815260200160008152602001600060ff16815250905600a165627a7a72305820a4174f287b66e39a62462f9894ea4e0be24301b140ff189d46ff997ee0a041480029 -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/HelloWorld.abi: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"n","type":"string"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/HelloWorld.bin: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b506040805190810160405280600d81526020017f48656c6c6f2c20576f726c6421000000000000000000000000000000000000008152506000908051906020019061005c929190610062565b50610107565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100a357805160ff19168380011785556100d1565b828001600101855582156100d1579182015b828111156100d05782518255916020019190600101906100b5565b5b5090506100de91906100e2565b5090565b61010491905b808211156101005760008160009055506001016100e8565b5090565b90565b6102d7806101166000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680634ed3885e146100515780636d4ce63c146100ba575b600080fd5b34801561005d57600080fd5b506100b8600480360381019080803590602001908201803590602001908080601f016020809104026020016040519081016040528093929190818152602001838380828437820191505050505050919291929050505061014a565b005b3480156100c657600080fd5b506100cf610164565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561010f5780820151818401526020810190506100f4565b50505050905090810190601f16801561013c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b8060009080519060200190610160929190610206565b5050565b606060008054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156101fc5780601f106101d1576101008083540402835291602001916101fc565b820191906000526020600020905b8154815290600101906020018083116101df57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061024757805160ff1916838001178555610275565b82800160010185558215610275579182015b82811115610274578251825591602001919060010190610259565b5b5090506102829190610286565b5090565b6102a891905b808211156102a457600081600090555060010161028c565b5090565b905600a165627a7a723058207db3c5650aebcb400ad30326c3e8e16f104b9c8d3d0931ff64ec6a8bb247d7db0029 -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/Record.abi: -------------------------------------------------------------------------------- 1 | [{"constant":false,"inputs":[{"name":"creditDataId","type":"uint256"},{"name":"uploader","type":"address"}],"name":"addRecordData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"applicant","type":"address"},{"name":"uploader","type":"address"},{"name":"recordId","type":"uint256"},{"name":"creditDataId","type":"uint256"}],"name":"checkRecordExist","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"recordId","type":"uint256"},{"name":"score","type":"uint8"}],"name":"scoreRecordData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"recordId","type":"uint256"}],"name":"getRecordDataById","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"bool"},{"name":"","type":"uint8"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"recordId","type":"uint256"},{"name":"yn","type":"bool"}],"name":"sendRecordData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_applicant","type":"address"},{"indexed":false,"name":"_uploader","type":"address"},{"indexed":false,"name":"_id","type":"uint256"},{"indexed":false,"name":"_creditDataId","type":"uint256"},{"indexed":false,"name":"_time","type":"uint256"}],"name":"addRecordSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"yn","type":"bool"}],"name":"sendRecordDataSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"yn","type":"bool"}],"name":"scoreRecordDataSuccess","type":"event"}] -------------------------------------------------------------------------------- /spring-boot-starter/src/test/resources/solidity/Record.bin: -------------------------------------------------------------------------------- 1 | 608060405234801561001057600080fd5b5061199d806100206000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638eb69e8114610072578063943d0677146100bf578063b31b33f61461014e578063bd74960914610188578063c30f79a814610260575b600080fd5b34801561007e57600080fd5b506100bd60048036038101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610299565b005b3480156100cb57600080fd5b50610134600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610694565b604051808215151515815260200191505060405180910390f35b34801561015a57600080fd5b5061018660048036038101908080359060200190929190803560ff16906020019092919050505061093a565b005b34801561019457600080fd5b506101b360048036038101908080359060200190929190505050611048565b604051808973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001878152602001868152602001858152602001841515151581526020018360ff1660ff168152602001821515151581526020019850505050505050505060405180910390f35b34801561026c57600080fd5b50610297600480360381019080803590602001909291908035151590602001909291905050506113dd565b005b6102a16118f8565b3373ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415151561036b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260328152602001807f546865206f6e776e6572206f6620746865206461746120636f756c64206e6f7481526020017f20626520746865206170706c6963616e7421000000000000000000000000000081525060400191505060405180910390fd5b600160025401600281905550610100604051908101604052803373ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020016002548152602001848152602001428152602001600015158152602001600060ff1681526020016000151581525090506000803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819080600181540180825580915050906001820390600052602060002090600602016000909192909190915060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020155606082015181600301556080820151816004015560a08201518160050160006101000a81548160ff02191690831515021790555060c08201518160050160016101000a81548160ff021916908360ff16021790555060e08201518160050160026101000a81548160ff02191690831515021790555050505060013390806001815401808255809150509060018203906000526020600020016000909192909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550507fa6a338f2b4280fe9c40640ec744427ec4efa8acc5be76b8fd647bbd8288afd6881600001518260200151836040015184606001518560800151604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018381526020018281526020019550505050505060405180910390a1505050565b600080600090505b6000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905081101561092c578573ffffffffffffffffffffffffffffffffffffffff166000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110151561074757fe5b906000526020600020906006020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614801561084357508473ffffffffffffffffffffffffffffffffffffffff166000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811015156107f957fe5b906000526020600020906006020160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16145b80156108aa5750836000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110151561089657fe5b906000526020600020906006020160020154145b80156109115750826000808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811015156108fd57fe5b906000526020600020906006020160030154145b1561091f5760019150610931565b808060010191505061069c565b600091505b50949350505050565b600080600091505b60018054905082101561100657600090505b60008060018481548110151561096657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002080549050811015610ff957836000806001858154811015156109e957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610a5b57fe5b9060005260206000209060060201600201541415610fec5760011515600080600185815481101515610a8957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610afb57fe5b906000526020600020906006020160050160009054906101000a900460ff161515141515610bb7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001807f4f6e6c79207265636965766564206461746120686173206265656e2073636f7281526020017f65642e000000000000000000000000000000000000000000000000000000000081525060400191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16600080600185815481101515610be057fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610c5257fe5b906000526020600020906006020160000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610d35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001807f4f6e6c7920746865206170706c6963616e74206f6620746865207265636f726481526020017f2063616e2073636f72652074686520646174612e00000000000000000000000081525060400191505060405180910390fd5b60001515600080600185815481101515610d4b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610dbd57fe5b906000526020600020906006020160050160029054906101000a900460ff161515141515610e53576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f54686973206461746120686173206265656e207265636f726465642e0000000081525060200191505060405180910390fd5b82600080600185815481101515610e6657fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610ed857fe5b906000526020600020906006020160050160016101000a81548160ff021916908360ff1602179055506001600080600185815481101515610f1557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002082815481101515610f8757fe5b906000526020600020906006020160050160026101000a81548160ff0219169083151502179055507f71c3634aa990a16a9da4df60686edbe51accebe978cdbc1a050ec9a62c50fe356001604051808215151515815260200191505060405180910390a15b8080600101915050610954565b8180600101925050610942565b7f71c3634aa990a16a9da4df60686edbe51accebe978cdbc1a050ec9a62c50fe356000604051808215151515815260200191505060405180910390a150505050565b60008060008060008060008060008061105f6118f8565b600092505b6001805490508310156113aa57600091505b60008060018581548110151561108857fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054905082101561139d578b60008060018681548110151561110b57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208381548110151561117d57fe5b9060005260206000209060060201600201541415611390576000806001858154811015156111a757fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110151561121957fe5b906000526020600020906006020161010060405190810160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820154815260200160038201548152602001600482015481526020016005820160009054906101000a900460ff161515151581526020016005820160019054906101000a900460ff1660ff1660ff1681526020016005820160029054906101000a900460ff1615151515815250509050806000015181602001518260400151836060015184608001518560a001518660c001518760e001519a509a509a509a509a509a509a509a506113cf565b8180600101925050611076565b8280600101935050611064565b33336000804260008060008595508494508191509a509a509a509a509a509a509a509a505b505050919395975091939597565b600080600091505b6001805490508210156118b657600090505b60008060018481548110151561140957fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020805490508110156118a9578360008060018581548110151561148c57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811015156114fe57fe5b906000526020600020906006020160020154141561189c573373ffffffffffffffffffffffffffffffffffffffff1660008060018581548110151561153f57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020828154811015156115b157fe5b906000526020600020906006020160010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515611694576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260368152602001807f4f6e6c7920746865206f776e6572206f662074686520646174612063616e206381526020017f686f6f7365207768657468657220746f2073656e642e0000000000000000000081525060400191505060405180910390fd5b600015156000806001858154811015156116aa57fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110151561171c57fe5b906000526020600020906006020160050160009054906101000a900460ff1615151415156117b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260188152602001807f54686973206461746120686173206265656e2073656e742e000000000000000081525060200191505060405180910390fd5b826000806001858154811015156117c557fe5b9060005260206000200160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208281548110151561183757fe5b906000526020600020906006020160050160006101000a81548160ff0219169083151502179055507f80e7f65d4e2321dd4a9c8326dd975ebdc2ba697bdc08e0036f7831c562f464c36001604051808215151515815260200191505060405180910390a15b80806001019150506113f7565b81806001019250506113e5565b7f80e7f65d4e2321dd4a9c8326dd975ebdc2ba697bdc08e0036f7831c562f464c36000604051808215151515815260200191505060405180910390a150505050565b61010060405190810160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081526020016000815260200160008152602001600015158152602001600060ff16815260200160001515815250905600a165627a7a72305820eff48841dc29a09bd80d2b8caab53c1cd638bc25f060f8be421f53957bd39da90029 -------------------------------------------------------------------------------- /spring-boot-starter/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | APP_MAIN=apps/openCredit.jar 4 | CLASSPATH='conf/:apps/*:lib/*' 5 | CURRENT_DIR=`pwd` 6 | LOG_DIR=${CURRENT_DIR}/log 7 | 8 | if [ ! -d "log" ]; then 9 | mkdir -p log 10 | fi 11 | 12 | tradePortalPID=0 13 | getTradeProtalPID(){ 14 | javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAIN` 15 | if [ -n "$javaps" ]; then 16 | tradePortalPID=`echo $javaps | awk '{print $1}'` 17 | else 18 | tradePortalPID=0 19 | fi 20 | } 21 | 22 | start(){ 23 | getTradeProtalPID 24 | echo "===============================================================================================" 25 | if [ $tradePortalPID -ne 0 ]; then 26 | echo "$APP_MAIN is already started(PID=$tradePortalPID)" 27 | kill -9 $tradePortalPID 28 | start 29 | echo "===============================================================================================" 30 | else 31 | echo -n "Starting $APP_MAIN " 32 | nohup $JAVA_HOME/bin/java -cp $CLASSPATH -jar $APP_MAIN >> $LOG_DIR/browser.out 2>&1 & 33 | sleep 5 34 | getTradeProtalPID 35 | if [ $tradePortalPID -ne 0 ]; then 36 | echo "(PID=$tradePortalPID)...[Success]" 37 | echo "===============================================================================================" 38 | else 39 | echo "[Failed]" 40 | echo "===============================================================================================" 41 | fi 42 | fi 43 | } 44 | 45 | start -------------------------------------------------------------------------------- /tmp_key/node_47.107.32.140_30303/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDSzCCAjOgAwIBAgIJANUZGSPSgbePMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 3 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 4 | Y2hhaW4wHhcNMTkwMzIxMDMyNTQ4WhcNMjkwMzE4MDMyNTQ4WjA8MRUwEwYDVQQD 5 | DAxkaXJfY2hhaW5fY2ExEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsMBWNo 6 | YWluMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLoKbnj4XK3nyuE2 7 | n5C+kCwhNKJEYsNxIheSsJ5y+3bs5FYraR6fx+BalvzRRIz1OwkVArntRO2hlhzl 8 | xOgMoQ3crI8AgSoyigrznMkWoaahKW2kTJyVJx56X9RYH69+4AHmmMy4Y2zj/38c 9 | WRTfbkHhqHgVko5xFU2tVKRxGGybMi3YiQaxsUiFMI6QHX2+dKs+QI4tjOKrbdGP 10 | LFdceHABS0WQW+YZCV7xm5eovZkEXNdkRHowVIz3ho3PhcH2AxC5A7s3gf3mltej 11 | DDGmN6x3BSZN0PxZP5xfnGQ2gHMHsVqUttRuXmU896sdluRmyVqiEDkPk5hOs/bk 12 | Ib7N2QIDAQABo1AwTjAdBgNVHQ4EFgQUrFmvf12j8FBXhboiick5KNT+1JMwHwYD 13 | VR0jBBgwFoAUrFmvf12j8FBXhboiick5KNT+1JMwDAYDVR0TBAUwAwEB/zANBgkq 14 | hkiG9w0BAQsFAAOCAQEAB2cythKVPeiPU94s26dvkMRlt1gvPa8cQNUb1m4S42Jd 15 | OZfwpSYNAco7Pv1ZaYx/TM3/ml0xTVHX0DHe2EvvxMF0x2wr6zaS73G9zaIzM6O1 16 | VkUKV0X1qttgwZhOyABg6DhFhF9oyIG9BX7BpPql+uM1BI4idjpS6S/PExrJuIYz 17 | Qbfds7IEe3N3BBgXGss3+G1fvAJoLIcfcdHUe06TRK1tSbCyLcRYKy57e0Bm6rgL 18 | /Ro3IgQaFmaLgeJEV1u7WX+nbqxmzryQnQaJMfXfikOssqNHuWI75C/HMC8d+tLK 19 | fwHdjbj2ZuTUXQYYaL+5OFh3C3wm4sxPTxImxPQJuw== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tmp_key/node_47.107.32.140_30303/node.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICTzCCATegAwIBAgIJALy8EiyIGv2xMA0GCSqGSIb3DQEBCwUAMDkxETAPBgNV 3 | BAMMCEFnZW50WlFIMRMwEQYDVQQKDApmaXNjby1iY29zMQ8wDQYDVQQLDAZhZ2Vu 4 | Y3kwHhcNMTkwMzIxMDQwMTI4WhcNMjkwMzE4MDQwMTI4WjBHMSEwHwYDVQQDDBhu 5 | b2RlXzQ3LjEwNy4zMi4xNDBfMzAzMDMxEzARBgNVBAoMCmZpc2NvLWJjb3MxDTAL 6 | BgNVBAsMBG5vZGUwVjAQBgcqhkjOPQIBBgUrgQQACgNCAARFkELh/8VStgvNhzUf 7 | lwsAz2HZFYoVsctDhBcD3tE7uZGrZuw2VL/V/vWr3XdOVp2vQRJlD8y7Am/UUbq1 8 | Aa5IoxowGDAJBgNVHRMEAjAAMAsGA1UdDwQEAwIF4DANBgkqhkiG9w0BAQsFAAOC 9 | AQEAt7MRRGcDcsKj4a13scuWE6f8dLWXOzwjOQy8boAHspu5I8P4BDeC4g+waeeL 10 | /akZ/WJ4v5Yb++MQBywO5FydiQlheVPtBrEY61+c8rk1mktinrHs1OCcAG/ojN8c 11 | 99LpZiVs1kfRTjm7iwpQ2T/ke2q1t65fzgpvfLp70fA4TF38KzLUHV+WtDzIwqtL 12 | TzuML/qoWei2p2C6uo7q/hTPRpMTVJGGBlwkMvdhDOJ3Pw2P9dRzigAJKPnXROzS 13 | tQdHM84DkCEAyGtUvmneKGc3FlLVIlkoIYVPSx9lHQ4DoqjTy0fy3gY2waPOIDp8 14 | tnhcvAr6Zq+Tbp7bExj2wI1OmA== 15 | -----END CERTIFICATE----- 16 | -----BEGIN CERTIFICATE----- 17 | MIIDCDCCAfCgAwIBAgIJAMZoDfkToxMlMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 18 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 19 | Y2hhaW4wHhcNMTkwMzIxMDM1NjQ5WhcNMjkwMzE4MDM1NjQ5WjA5MREwDwYDVQQD 20 | DAhBZ2VudFpRSDETMBEGA1UECgwKZmlzY28tYmNvczEPMA0GA1UECwwGYWdlbmN5 21 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0IqpmlqJ/NN3tGoT9RCp 22 | xwjkeMI3Y+idhPZrl7r+ccyv/mseMVTCufeygggKETvc7J/fTT+an3INgKPKcugP 23 | Ox5jEk4flKNdF0mhKVTFHjLxUnOX2Timi5PclMZjMiUTJ26Ap/tBHAkXmDoL4k04 24 | AOSR1ct0Vm9iWG3zN31I69+yW1RDjAvu/Zchj6cCOPXWCH8jkgn6tvFRn3OV9WN9 25 | fiVY+XlBgjGGtdYzUuWAVsGTEunJDmqBU1HYIZvYHG6AEEt1QNgorrORsK6L12tv 26 | YV7jxazOQLp3rxR1zRD2+9w6J6actRDN+bdBj+zZVmQ000kr5D824/7hDWYVovCz 27 | aQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAS39O4 28 | kNHjK4IAASpENeknevwxoiny5Zj6KaCIhkmXthcvsy+klGrLLLGDJGGGYlyditVA 29 | kDK7RV2NGDys4zwSDPUQvHd3iElasGryDc2lJYvLjPLxZUz7J/lqq7Z1yr50fpt6 30 | q+c6AHbYMaliYUerwigoLBge1X2O31m+Xj4jdiNDuphG0KZgRA3x3O9b0GYF6AM0 31 | 15nf/XkhQD1uox3j11k875zSgulMydWvMKWGi86NaiAFVfBYcIwQhxEJ3pR3CHYf 32 | ayqj5RBjN8H81rUquGN800bLnkNbUrE2mRu0DGT6wK6e1y0Bc8o06dTnLNTMuga6 33 | 7hlesFguSX8fRWui 34 | -----END CERTIFICATE----- 35 | -------------------------------------------------------------------------------- /tmp_key/node_47.107.32.140_30303/node.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgvMIoqDe5HG3i10Y4tjC8 3 | 5MDhap/NTtTFFKoGXEyrtW2hRANCAARFkELh/8VStgvNhzUflwsAz2HZFYoVsctD 4 | hBcD3tE7uZGrZuw2VL/V/vWr3XdOVp2vQRJlD8y7Am/UUbq1Aa5I 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /tmp_key/node_47.107.32.140_30303/node.nodeid: -------------------------------------------------------------------------------- 1 | 459042e1ffc552b60bcd87351f970b00cf61d9158a15b1cb43841703ded13bb991ab66ec3654bfd5fef5abdd774e569daf4112650fccbb026fd451bab501ae48 2 | -------------------------------------------------------------------------------- /tmp_key/sdk/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDSzCCAjOgAwIBAgIJANUZGSPSgbePMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 3 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 4 | Y2hhaW4wHhcNMTkwMzIxMDMyNTQ4WhcNMjkwMzE4MDMyNTQ4WjA8MRUwEwYDVQQD 5 | DAxkaXJfY2hhaW5fY2ExEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsMBWNo 6 | YWluMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLoKbnj4XK3nyuE2 7 | n5C+kCwhNKJEYsNxIheSsJ5y+3bs5FYraR6fx+BalvzRRIz1OwkVArntRO2hlhzl 8 | xOgMoQ3crI8AgSoyigrznMkWoaahKW2kTJyVJx56X9RYH69+4AHmmMy4Y2zj/38c 9 | WRTfbkHhqHgVko5xFU2tVKRxGGybMi3YiQaxsUiFMI6QHX2+dKs+QI4tjOKrbdGP 10 | LFdceHABS0WQW+YZCV7xm5eovZkEXNdkRHowVIz3ho3PhcH2AxC5A7s3gf3mltej 11 | DDGmN6x3BSZN0PxZP5xfnGQ2gHMHsVqUttRuXmU896sdluRmyVqiEDkPk5hOs/bk 12 | Ib7N2QIDAQABo1AwTjAdBgNVHQ4EFgQUrFmvf12j8FBXhboiick5KNT+1JMwHwYD 13 | VR0jBBgwFoAUrFmvf12j8FBXhboiick5KNT+1JMwDAYDVR0TBAUwAwEB/zANBgkq 14 | hkiG9w0BAQsFAAOCAQEAB2cythKVPeiPU94s26dvkMRlt1gvPa8cQNUb1m4S42Jd 15 | OZfwpSYNAco7Pv1ZaYx/TM3/ml0xTVHX0DHe2EvvxMF0x2wr6zaS73G9zaIzM6O1 16 | VkUKV0X1qttgwZhOyABg6DhFhF9oyIG9BX7BpPql+uM1BI4idjpS6S/PExrJuIYz 17 | Qbfds7IEe3N3BBgXGss3+G1fvAJoLIcfcdHUe06TRK1tSbCyLcRYKy57e0Bm6rgL 18 | /Ro3IgQaFmaLgeJEV1u7WX+nbqxmzryQnQaJMfXfikOssqNHuWI75C/HMC8d+tLK 19 | fwHdjbj2ZuTUXQYYaL+5OFh3C3wm4sxPTxImxPQJuw== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tmp_key/sdk/node.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICOjCCASKgAwIBAgIJALy8EiyIGv2zMA0GCSqGSIb3DQEBCwUAMDkxETAPBgNV 3 | BAMMCEFnZW50WlFIMRMwEQYDVQQKDApmaXNjby1iY29zMQ8wDQYDVQQLDAZhZ2Vu 4 | Y3kwHhcNMTkwMzIxMDQwNDA3WhcNMjkwMzE4MDQwNDA3WjAyMQwwCgYDVQQDDANz 5 | ZGsxEzARBgNVBAoMCmZpc2NvLWJjb3MxDTALBgNVBAsMBG5vZGUwVjAQBgcqhkjO 6 | PQIBBgUrgQQACgNCAARrX0Dn5Bo5ipVEgctGctMiid2Qc90RZsvKn0MfkYS10d+q 7 | Zz3XKSe4wm+xjhcIb3XjJ1XCib1QAkYOQiVGHNl+oxowGDAJBgNVHRMEAjAAMAsG 8 | A1UdDwQEAwIF4DANBgkqhkiG9w0BAQsFAAOCAQEAnf8LqtnvRyzLT5xY2PNPEOfM 9 | BcLSGXPn/39+FQGysO6tA0DRp5SSh0XA8LaGthrMS1iErb8FZk/iW8/+Ur9kq9xa 10 | YNMtm+QmAlhz7v3pK2v7msTWdB3bsg5y3ZBgMPksHftsU4ynpr1SApO0RQ5eMIBx 11 | Yubp0InGiXim4iJTgBhdvbDo9U5026nBCXR2X1QyXkks0t7+GZLUzoA6t7VOVw31 12 | Tegj0Dg8jQ7V25xW2rFDn2T4kk3Am1TYIfpiaE1dzBWfjpvhDo5/Imu/PeZ63esa 13 | YTGGX1OLtiqIVxOFUW6cKABALHodyrVKEDgxUsocOUhU3eF0+SvIiK5agetqHw== 14 | -----END CERTIFICATE----- 15 | -----BEGIN CERTIFICATE----- 16 | MIIDCDCCAfCgAwIBAgIJAMZoDfkToxMlMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 17 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 18 | Y2hhaW4wHhcNMTkwMzIxMDM1NjQ5WhcNMjkwMzE4MDM1NjQ5WjA5MREwDwYDVQQD 19 | DAhBZ2VudFpRSDETMBEGA1UECgwKZmlzY28tYmNvczEPMA0GA1UECwwGYWdlbmN5 20 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0IqpmlqJ/NN3tGoT9RCp 21 | xwjkeMI3Y+idhPZrl7r+ccyv/mseMVTCufeygggKETvc7J/fTT+an3INgKPKcugP 22 | Ox5jEk4flKNdF0mhKVTFHjLxUnOX2Timi5PclMZjMiUTJ26Ap/tBHAkXmDoL4k04 23 | AOSR1ct0Vm9iWG3zN31I69+yW1RDjAvu/Zchj6cCOPXWCH8jkgn6tvFRn3OV9WN9 24 | fiVY+XlBgjGGtdYzUuWAVsGTEunJDmqBU1HYIZvYHG6AEEt1QNgorrORsK6L12tv 25 | YV7jxazOQLp3rxR1zRD2+9w6J6actRDN+bdBj+zZVmQ000kr5D824/7hDWYVovCz 26 | aQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAS39O4 27 | kNHjK4IAASpENeknevwxoiny5Zj6KaCIhkmXthcvsy+klGrLLLGDJGGGYlyditVA 28 | kDK7RV2NGDys4zwSDPUQvHd3iElasGryDc2lJYvLjPLxZUz7J/lqq7Z1yr50fpt6 29 | q+c6AHbYMaliYUerwigoLBge1X2O31m+Xj4jdiNDuphG0KZgRA3x3O9b0GYF6AM0 30 | 15nf/XkhQD1uox3j11k875zSgulMydWvMKWGi86NaiAFVfBYcIwQhxEJ3pR3CHYf 31 | ayqj5RBjN8H81rUquGN800bLnkNbUrE2mRu0DGT6wK6e1y0Bc8o06dTnLNTMuga6 32 | 7hlesFguSX8fRWui 33 | -----END CERTIFICATE----- 34 | -------------------------------------------------------------------------------- /tmp_key/sdk/node.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgt0MiUtuiAf9QyVexHmL3 3 | guaG2HmgXyO7sHUzSn8xN2uhRANCAARrX0Dn5Bo5ipVEgctGctMiid2Qc90RZsvK 4 | n0MfkYS10d+qZz3XKSe4wm+xjhcIb3XjJ1XCib1QAkYOQiVGHNl+ 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /tmp_key/sdk_zwm/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDSzCCAjOgAwIBAgIJANUZGSPSgbePMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 3 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 4 | Y2hhaW4wHhcNMTkwMzIxMDMyNTQ4WhcNMjkwMzE4MDMyNTQ4WjA8MRUwEwYDVQQD 5 | DAxkaXJfY2hhaW5fY2ExEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsMBWNo 6 | YWluMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApLoKbnj4XK3nyuE2 7 | n5C+kCwhNKJEYsNxIheSsJ5y+3bs5FYraR6fx+BalvzRRIz1OwkVArntRO2hlhzl 8 | xOgMoQ3crI8AgSoyigrznMkWoaahKW2kTJyVJx56X9RYH69+4AHmmMy4Y2zj/38c 9 | WRTfbkHhqHgVko5xFU2tVKRxGGybMi3YiQaxsUiFMI6QHX2+dKs+QI4tjOKrbdGP 10 | LFdceHABS0WQW+YZCV7xm5eovZkEXNdkRHowVIz3ho3PhcH2AxC5A7s3gf3mltej 11 | DDGmN6x3BSZN0PxZP5xfnGQ2gHMHsVqUttRuXmU896sdluRmyVqiEDkPk5hOs/bk 12 | Ib7N2QIDAQABo1AwTjAdBgNVHQ4EFgQUrFmvf12j8FBXhboiick5KNT+1JMwHwYD 13 | VR0jBBgwFoAUrFmvf12j8FBXhboiick5KNT+1JMwDAYDVR0TBAUwAwEB/zANBgkq 14 | hkiG9w0BAQsFAAOCAQEAB2cythKVPeiPU94s26dvkMRlt1gvPa8cQNUb1m4S42Jd 15 | OZfwpSYNAco7Pv1ZaYx/TM3/ml0xTVHX0DHe2EvvxMF0x2wr6zaS73G9zaIzM6O1 16 | VkUKV0X1qttgwZhOyABg6DhFhF9oyIG9BX7BpPql+uM1BI4idjpS6S/PExrJuIYz 17 | Qbfds7IEe3N3BBgXGss3+G1fvAJoLIcfcdHUe06TRK1tSbCyLcRYKy57e0Bm6rgL 18 | /Ro3IgQaFmaLgeJEV1u7WX+nbqxmzryQnQaJMfXfikOssqNHuWI75C/HMC8d+tLK 19 | fwHdjbj2ZuTUXQYYaL+5OFh3C3wm4sxPTxImxPQJuw== 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /tmp_key/sdk_zwm/node.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICOjCCASKgAwIBAgIJAOXcwoorWU7ZMA0GCSqGSIb3DQEBCwUAMDkxETAPBgNV 3 | BAMMCEFnZW50WldNMRMwEQYDVQQKDApmaXNjby1iY29zMQ8wDQYDVQQLDAZhZ2Vu 4 | Y3kwHhcNMTkwMzIxMDQwNDE1WhcNMjkwMzE4MDQwNDE1WjAyMQwwCgYDVQQDDANz 5 | ZGsxEzARBgNVBAoMCmZpc2NvLWJjb3MxDTALBgNVBAsMBG5vZGUwVjAQBgcqhkjO 6 | PQIBBgUrgQQACgNCAATTdrDaLs6SNCyUZLNl5OlVsb0Jb4kJuBpCNi10eMTe/9VL 7 | 8oTPTYLSbSgYUpzLhTZq3Pyb3J0MMCE5hFzO2k9UoxowGDAJBgNVHRMEAjAAMAsG 8 | A1UdDwQEAwIF4DANBgkqhkiG9w0BAQsFAAOCAQEAlENlMdjviZZpYBB44d15IV69 9 | aF9td6c5Uom4BhYT7aD13IwOyxpzpnr7MeEhsmyP2qHcGv+nBsxFzguBkod9irD2 10 | H1hnJXUH6vbfx3KcngUzGrz8MGO/NMHVE6LVoGUaVNa0Kg8sjytxcmx96UyLmm6X 11 | wH1hDEjKYy7BuFrxJohWVs6I6n7QN+B+CgKU7Avij02YHG8mP76egrZ2TWJMn9h4 12 | iMsj9GSIkTjL6i7jZwrlWjOMnVGdcPIGB8RRKjwsqjmBE8+jW7Zxx59iEFVm9iVG 13 | M+QrhXYQ8XonohNdjtmESXQB+qloFxDoKOu2j8ojzAxFIo4N9pgrUfQWbdTx7g== 14 | -----END CERTIFICATE----- 15 | -----BEGIN CERTIFICATE----- 16 | MIIDCDCCAfCgAwIBAgIJALAhlZgMj0+AMA0GCSqGSIb3DQEBCwUAMDwxFTATBgNV 17 | BAMMDGRpcl9jaGFpbl9jYTETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwF 18 | Y2hhaW4wHhcNMTkwMzIxMDQwMTU1WhcNMjkwMzE4MDQwMTU1WjA5MREwDwYDVQQD 19 | DAhBZ2VudFpXTTETMBEGA1UECgwKZmlzY28tYmNvczEPMA0GA1UECwwGYWdlbmN5 20 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvZoJV47sZxWb6EYSnOT1 21 | Pvs0IFuY5qPYJfTZjI0CAs3qsWZhTibZxJf2nqnNCpMZUtEfvLnFm0EqvTCdjG/5 22 | bOga797jVENXrl/d8w/gzpQp7KhZKr+OL0VBbrY/YzdP8fH5eAqNlRXPWfoqCMoG 23 | KckNZRjp52fpCra1/bKFqwPds1uAisC3uHNNG/Mi+GBgNQZNvNBNkrN8xXxhQ9dc 24 | KjzcxpAPs/wm8cNHBB9FUULGoHqCK8dF8Izbu+8mB+XxpyKBMPNeNfSQSFi1Lhck 25 | IH2XT/8cUMgz4fZfOiFHBPSKM8SlmmYrhSlFQmKUiUNugENzQdd+LxT2MPkd1dEe 26 | pQIDAQABoxAwDjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCJ6SGn 27 | vZjEpvBf5izE6svKNA4/n4+cZAoADVVaJE8l+I/xCirY3o9yeMp/5oeeGkrcIGih 28 | bqSr5vuPC/Z4WgITCpbLy2PouUS2cRTUUemFB5k78cSSdGPQ0pvrKG3DLCwXGLkF 29 | klM6Bb6Hj3geXQe2V84hZonznOUS5HlvSd5Hzirxwj6eJvW75jr9nI/lOfjo8V9u 30 | zjDWUlnju+ePBGhkrFztUWFpluPLiCQgAfEaDRQVbCYK18WDZ+8HQ/SO7DeSV3V1 31 | 0MDPopSEq+O1744xKX2KlK1N0TeP91tDg5y+jxl1nltVEF9js4EwkhMy3O21VLT1 32 | eRb3TB8N7N0xkud8 33 | -----END CERTIFICATE----- 34 | -------------------------------------------------------------------------------- /tmp_key/sdk_zwm/node.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgZkCQuuJqjGqfZj9jYfZd 3 | gLkfakyFpaxEQj0eIpNNJtyhRANCAATTdrDaLs6SNCyUZLNl5OlVsb0Jb4kJuBpC 4 | Ni10eMTe/9VL8oTPTYLSbSgYUpzLhTZq3Pyb3J0MMCE5hFzO2k9U 5 | -----END PRIVATE KEY----- 6 | --------------------------------------------------------------------------------