├── .idea ├── .name ├── encodings.xml ├── vcs.xml ├── modules.xml ├── misc.xml ├── libraries │ ├── Maven__junit_junit_4_12.xml │ ├── Maven__org_ow2_asm_asm_5_0_4.xml │ ├── Maven__org_yaml_snakeyaml_1_19.xml │ ├── Maven__net_minidev_json_smart_2_3.xml │ ├── Maven__org_objenesis_objenesis_2_6.xml │ ├── Maven__com_alibaba_fastjson_1_2_38.xml │ ├── Maven__org_slf4j_slf4j_api_1_7_25.xml │ ├── Maven__com_google_code_gson_gson_2_8_2.xml │ ├── Maven__commons_io_commons_io_1_3_2.xml │ ├── Maven__com_fasterxml_classmate_1_3_4.xml │ ├── Maven__com_google_guava_guava_24_0_jre.xml │ ├── Maven__org_hamcrest_hamcrest_core_1_3.xml │ ├── Maven__net_bytebuddy_byte_buddy_1_7_11.xml │ ├── Maven__org_assertj_assertj_core_3_9_1.xml │ ├── Maven__org_projectlombok_lombok_1_16_22.xml │ ├── Maven__org_slf4j_jul_to_slf4j_1_7_25.xml │ ├── Maven__org_xmlunit_xmlunit_core_2_5_1.xml │ ├── Maven__io_reactivex_rxjava2_rxjava_2_1_10.xml │ ├── Maven__org_skyscreamer_jsonassert_1_5_0.xml │ ├── Maven__commons_codec_commons_codec_1_11.xml │ ├── Maven__net_minidev_accessors_smart_1_2.xml │ ├── Maven__org_mockito_mockito_core_2_15_0.xml │ ├── Maven__ch_qos_logback_logback_core_1_2_3.xml │ ├── Maven__com_google_code_findbugs_jsr305_1_3_9.xml │ ├── Maven__com_jayway_jsonpath_json_path_2_4_0.xml │ ├── Maven__org_hamcrest_hamcrest_library_1_3.xml │ ├── Maven__org_apache_commons_commons_lang3_3_4.xml │ ├── Maven__io_netty_netty_codec_4_1_25_Final.xml │ ├── Maven__ch_qos_logback_logback_classic_1_2_3.xml │ ├── Maven__io_netty_netty_buffer_4_1_25_Final.xml │ ├── Maven__io_netty_netty_common_4_1_25_Final.xml │ ├── Maven__org_apache_httpcomponents_httpcore_4_4_9.xml │ ├── Maven__io_netty_netty_handler_4_1_25_Final.xml │ ├── Maven__javax_servlet_javax_servlet_api_4_0_0.xml │ ├── Maven__net_bytebuddy_byte_buddy_agent_1_7_11.xml │ ├── Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml │ ├── Maven__io_netty_netty_resolver_4_1_25_Final.xml │ ├── Maven__org_apache_httpcomponents_httpclient_4_5_6.xml │ ├── Maven__com_google_j2objc_j2objc_annotations_1_1.xml │ ├── Maven__io_lettuce_lettuce_core_5_0_4_RELEASE.xml │ ├── Maven__io_netty_netty_transport_4_1_25_Final.xml │ ├── Maven__org_reactivestreams_reactive_streams_1_0_2.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_9_6.xml │ ├── Maven__org_springframework_spring_tx_5_0_7_RELEASE.xml │ ├── Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml │ ├── Maven__javax_annotation_javax_annotation_api_1_3_2.xml │ ├── Maven__javax_validation_validation_api_2_0_1_Final.xml │ ├── Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml │ ├── Maven__org_springframework_spring_aop_5_0_7_RELEASE.xml │ ├── Maven__org_springframework_spring_jcl_5_0_7_RELEASE.xml │ ├── Maven__org_springframework_spring_oxm_5_0_7_RELEASE.xml │ ├── Maven__org_springframework_spring_web_5_0_7_RELEASE.xml │ ├── Maven__io_projectreactor_reactor_core_3_1_8_RELEASE.xml │ ├── Maven__org_springframework_spring_core_5_0_7_RELEASE.xml │ ├── Maven__org_springframework_spring_test_5_0_7_RELEASE.xml │ ├── Maven__org_checkerframework_checker_compat_qual_2_0_0.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_9_6.xml │ ├── Maven__org_springframework_spring_beans_5_0_7_RELEASE.xml │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml │ ├── Maven__org_springframework_spring_webmvc_5_0_7_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_spring_context_5_0_7_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml │ ├── Maven__org_codehaus_mojo_animal_sniffer_annotations_1_14.xml │ ├── Maven__com_google_errorprone_error_prone_annotations_2_1_3.xml │ ├── Maven__org_springframework_spring_expression_5_0_7_RELEASE.xml │ ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml │ ├── Maven__org_springframework_boot_spring_boot_test_2_0_3_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_6.xml │ ├── Maven__org_hibernate_validator_hibernate_validator_6_0_10_Final.xml │ ├── Maven__org_springframework_data_spring_data_redis_2_0_8_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_6.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_data_spring_data_commons_2_0_8_RELEASE.xml │ ├── Maven__org_springframework_spring_context_support_5_0_7_RELEASE.xml │ ├── Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml │ ├── Maven__org_springframework_data_spring_data_keyvalue_2_0_8_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_web_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_json_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_test_2_0_3_RELEASE.xml │ ├── Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_6.xml │ ├── Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_logging_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_starter_data_redis_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_properties_migrator_2_0_3_RELEASE.xml │ ├── Maven__org_springframework_boot_spring_boot_configuration_metadata_2_0_3_RELEASE.xml │ └── Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_3_RELEASE.xml └── compiler.xml ├── screenshots ├── get_info.png ├── shieldserver.01.png └── shieldserver.02.png ├── src └── main │ ├── java │ └── com │ │ └── oraclechain │ │ └── eosio │ │ ├── utils │ │ ├── PreferencesHelper.java │ │ ├── MyStringUtils.java │ │ ├── URLEncodeUtil.java │ │ ├── JsonUtils.java │ │ ├── EosEstimateRsc.java │ │ ├── EosErrorUtils.java │ │ ├── EoscGsonTypeAdapterFactory.java │ │ └── EosTxUtils.java │ │ ├── eosTypes │ │ ├── TypeScopeName.java │ │ ├── TypeExtension.java │ │ ├── TypeSharedLock.java │ │ ├── EosBuyRam.java │ │ ├── TypeWaitWeight.java │ │ ├── TypePublicKey.java │ │ ├── EosBuyRamBytes.java │ │ ├── TypePermissionName.java │ │ ├── TypeActionName.java │ │ ├── EosDelegate.java │ │ ├── TypeKeyWeight.java │ │ ├── TypeChainId.java │ │ ├── TypePermissionLevelWeight.java │ │ ├── TypeAccountName.java │ │ ├── TypePermissionLevel.java │ │ ├── EosType.java │ │ ├── TypeAuthority.java │ │ ├── TypeName.java │ │ └── EosByteReader.java │ │ ├── dto │ │ ├── EosRefValue.java │ │ ├── ReqAssetsInfo.java │ │ ├── Sparklines.java │ │ ├── RspAssetsInfo.java │ │ ├── UserAsset.java │ │ ├── NewDexTicker.java │ │ ├── ExchangeRate.java │ │ └── MessageResult.java │ │ ├── eosApi │ │ ├── GetCodeRequest.java │ │ ├── GetCurrencyInfo.java │ │ ├── AccountInfoRequest.java │ │ ├── Key.java │ │ ├── GetTableRequest.java │ │ ├── JsonToBinResponse.java │ │ ├── GetCodeResponse.java │ │ ├── GetRequiredKeys.java │ │ ├── RequiredKeysResponse.java │ │ ├── JsonToBinRequest.java │ │ ├── Permission.java │ │ ├── RequiredAuth.java │ │ ├── PushTxnResponse.java │ │ ├── EosChainInfo.java │ │ └── EosNewAccount.java │ │ ├── exceptions │ │ ├── ExceptionsFC.java │ │ ├── ExceptionsChain.java │ │ └── ErrorCodeEnumFC.java │ │ ├── chain │ │ ├── DataAccessInfo.java │ │ ├── ActionTrace.java │ │ ├── TransactionReceiptHeader.java │ │ ├── TransactionTrace.java │ │ ├── Transaction.java │ │ ├── SignedTransaction.java │ │ ├── TransactionHeader.java │ │ ├── Action.java │ │ └── PackedTransaction.java │ │ ├── service │ │ ├── RedisService.java │ │ ├── BlockServiceEos.java │ │ └── impl │ │ │ └── RedisServiceImpl.java │ │ ├── controller │ │ ├── HistoryController.java │ │ ├── AdvancedQueryController.java │ │ └── ChainController.java │ │ ├── crypto │ │ ├── ec │ │ │ ├── CurveParam.java │ │ │ └── EcCurve.java │ │ ├── digest │ │ │ ├── Sha512.java │ │ │ ├── GeneralDigest.java │ │ │ └── Sha256.java │ │ └── util │ │ │ └── CryptUtil.java │ │ ├── EosBlockchainApplication.java │ │ └── constants │ │ └── Variables.java │ └── resources │ ├── application.yml │ └── banner.txt ├── .gitignore └── pom.xml /.idea/.name: -------------------------------------------------------------------------------- 1 | eos_proxy_server -------------------------------------------------------------------------------- /screenshots/get_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OracleChain/EosProxyServer/HEAD/screenshots/get_info.png -------------------------------------------------------------------------------- /screenshots/shieldserver.01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OracleChain/EosProxyServer/HEAD/screenshots/shieldserver.01.png -------------------------------------------------------------------------------- /screenshots/shieldserver.02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OracleChain/EosProxyServer/HEAD/screenshots/shieldserver.02.png -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/PreferencesHelper.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | public class PreferencesHelper { 4 | } 5 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeScopeName.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | /** 4 | * Created by swapnibble on 2018-04-04. 5 | */ 6 | 7 | public class TypeScopeName extends TypeName { 8 | public TypeScopeName(String name) { 9 | super(name); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/EosRefValue.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | public class EosRefValue { 4 | public T data; 5 | 6 | public EosRefValue(){ 7 | data = null; 8 | } 9 | 10 | public EosRefValue(T initialVal ){ 11 | data = initialVal; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeExtension.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | /** 4 | * Created by swapnibble on 2018-05-16. 5 | */ 6 | public class TypeExtension implements EosType.Packer{ 7 | 8 | 9 | 10 | @Override 11 | public void pack(EosType.Writer writer) { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/ReqAssetsInfo.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | 4 | import lombok.Data; 5 | 6 | @Data 7 | public class ReqAssetsInfo { 8 | 9 | 10 | private String account_name; 11 | private String contract_name; 12 | private String token_symbol; 13 | private String coinmarket_id; 14 | 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeSharedLock.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | /** 6 | * Created by swapnibble on 2018-04-04. 7 | */ 8 | 9 | public class TypeSharedLock { 10 | @Expose 11 | private TypeAccountName account; 12 | 13 | @Expose 14 | private TypeScopeName scope; 15 | } 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | .DS_Store 4 | test 5 | target 6 | .idea 7 | 8 | # Log file 9 | *.log 10 | 11 | # BlueJ files 12 | *.ctxt 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files # 18 | *.jar 19 | *.war 20 | *.nar 21 | *.ear 22 | *.zip 23 | *.tar.gz 24 | *.rar 25 | 26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 27 | hs_err_pid* 28 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/GetCodeRequest.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.google.gson.annotations.SerializedName; 6 | 7 | public class GetCodeRequest { 8 | @SerializedName("account_name") 9 | @Expose 10 | private String name; 11 | 12 | public GetCodeRequest(String accountName){ 13 | name = accountName; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__junit_junit_4_12.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/GetCurrencyInfo.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GetCurrencyInfo 7 | { 8 | 9 | private String code; 10 | private String account; 11 | private String symbol; 12 | 13 | 14 | @Override 15 | public String toString() { 16 | return "GetCurrencyInfo: [code=" + code 17 | + ", account=" + account 18 | + ", symbol=" + symbol 19 | + "]"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_yaml_snakeyaml_1_19.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_minidev_json_smart_2_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_objenesis_objenesis_2_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_alibaba_fastjson_1_2_38.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_code_gson_gson_2_8_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/Sparklines.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | 4 | import lombok.Data; 5 | 6 | @Data 7 | public class Sparklines { 8 | private String sparkline_eos_png; 9 | private String sparkline_oct_png; 10 | private String sparkline_iq_png; 11 | 12 | 13 | @Override 14 | public String toString() { 15 | return "Sparklines: [sparkline_eos_png=" + sparkline_eos_png 16 | + ", sparkline_oct_png=" + sparkline_oct_png 17 | + ", sparkline_iq_png=" + sparkline_iq_png 18 | + "]"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/AccountInfoRequest.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | /** 6 | * Created by swapnibble on 2017-09-14. 7 | */ 8 | 9 | public class AccountInfoRequest { 10 | 11 | @Expose 12 | private String account_name; 13 | 14 | public AccountInfoRequest(String name) { 15 | setName(name); 16 | } 17 | 18 | public String getName() { 19 | return account_name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.account_name = name; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | spring: 4 | mvc: 5 | throw-exception-if-no-handler-found: true 6 | resources: 7 | add-mappings: false 8 | redis: 9 | host: xxx 10 | port: 6688 11 | database: 0 12 | password: xxx 13 | timeout: 3000 14 | jedis: 15 | pool: 16 | max-active: 10 17 | max-idle: 5 18 | min-idle: 1 19 | max-wait: 5000 20 | logging: 21 | path: /opt/java_logs/blockchain 22 | file: 23 | max-size: 100MB 24 | max-history: 365 25 | pattern: 26 | console: "%d{yyyy-MM-dd HH:mm:ss} - %msg%n" -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_guava_guava_24_0_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_7_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_assertj_assertj_core_3_9_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_projectlombok_lombok_1_16_22.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_5_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_reactivex_rxjava2_rxjava_2_1_10.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/RspAssetsInfo.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | import lombok.Data; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | @Data 11 | public class RspAssetsInfo { 12 | 13 | 14 | 15 | @Expose 16 | private List user_asset_list = null; 17 | 18 | public void addUserAsset(UserAsset userAsset ){ 19 | if ( null == user_asset_list) { 20 | user_asset_list = new ArrayList<>(1); 21 | } 22 | user_asset_list.add( userAsset); 23 | } 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__commons_codec_commons_codec_1_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_mockito_mockito_core_2_15_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_code_findbugs_jsr305_1_3_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/Key.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | public class Key { 7 | 8 | @Expose 9 | private String key; 10 | 11 | @Expose 12 | private Integer weight; 13 | 14 | public String getKey() { 15 | return key; 16 | } 17 | 18 | public void setKey(String key) { 19 | this.key = key; 20 | } 21 | 22 | public Integer getWeight() { 23 | return weight; 24 | } 25 | 26 | public void setWeight(Integer weight) { 27 | this.weight = weight; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_commons_commons_lang3_3_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/EosBuyRam.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | public class EosBuyRam { 4 | 5 | private String payer; 6 | 7 | private String receiver; 8 | 9 | private String quant; 10 | 11 | public String getActionName() { 12 | return "buyram"; 13 | } 14 | 15 | public EosBuyRam(String payer, String receiver, String quant ) { 16 | // this.payer = new TypeAccountName(payer); 17 | // this.receiver = new TypeAccountName(receiver); 18 | this.payer = payer; 19 | this.receiver = receiver; 20 | this.quant = quant; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_codec_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_buffer_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_common_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_httpcomponents_httpcore_4_4_9.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/GetTableRequest.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | /** 6 | * Created by swapnibble on 2017-09-15. 7 | */ 8 | 9 | public class GetTableRequest { 10 | @Expose 11 | private boolean json = true; 12 | 13 | @Expose 14 | private String scope; 15 | 16 | @Expose 17 | private String code; 18 | 19 | @Expose 20 | private String table; 21 | 22 | public GetTableRequest( String scope, String code, String table ) { 23 | this.scope = scope; 24 | this.code = code; 25 | this.table = table; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_handler_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_servlet_javax_servlet_api_4_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_7_11.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_10_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_resolver_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_httpcomponents_httpclient_4_5_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/exceptions/ExceptionsFC.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.exceptions; 2 | 3 | public class ExceptionsFC extends RuntimeException { 4 | 5 | public ExceptionsFC(ErrorCodeEnumFC errorCode) { 6 | this.errorCode = errorCode; 7 | } 8 | public ExceptionsFC(int errorCode) { 9 | this.errorCode = ErrorCodeEnumFC.getEnumById(errorCode); 10 | } 11 | 12 | private ErrorCodeEnumFC errorCode; 13 | public ErrorCodeEnumFC getErrorCode() { 14 | return errorCode; 15 | } 16 | public void setErrorCode(ErrorCodeEnumFC errorCode) { 17 | this.errorCode = errorCode; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_j2objc_j2objc_annotations_1_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_lettuce_lettuce_core_5_0_4_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeWaitWeight.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | /** 4 | * Created by swapnibble on 2018-05-17. 5 | */ 6 | public class TypeWaitWeight implements EosType.Packer { 7 | private int mWaitSec; // uint32_t 8 | private short mWeight; 9 | 10 | public TypeWaitWeight( long uint32WaitSec, int uint16Weight){ 11 | mWaitSec= (int)( uint32WaitSec & 0xFFFFFFFF ); 12 | mWeight = (short)( uint16Weight & 0xFFFF ); 13 | } 14 | 15 | @Override 16 | public void pack(EosType.Writer writer) { 17 | writer.putIntLE( mWaitSec ); 18 | writer.putShortLE( mWeight); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_netty_netty_transport_4_1_25_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/DataAccessInfo.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.eosTypes.TypeAccountName; 6 | import com.oraclechain.eosio.eosTypes.TypeScopeName; 7 | 8 | /** 9 | * Created by swapnibble on 2018-03-20. 10 | */ 11 | 12 | public class DataAccessInfo { 13 | //public enum Type { read, write }; 14 | 15 | @Expose 16 | private String type; // access type 17 | 18 | @Expose 19 | private TypeAccountName code; 20 | 21 | @Expose 22 | private TypeScopeName scope; 23 | 24 | @Expose 25 | private long sequence; // uint64_t 26 | } 27 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_reactivestreams_reactive_streams_1_0_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_9_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/ActionTrace.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by swapnibble on 2018-03-20. 9 | */ 10 | 11 | public class ActionTrace { 12 | @Expose 13 | public String receiver; 14 | 15 | @Expose 16 | public boolean context_free; 17 | 18 | @Expose 19 | public long cpu_usage; 20 | 21 | @Expose 22 | public Action act; 23 | 24 | @Expose 25 | public String console; 26 | 27 | @Expose 28 | public List data_access; 29 | 30 | @Expose 31 | public long auths_used; // uint32_t 32 | } 33 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_tx_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_2_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_annotation_javax_annotation_api_1_3_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__javax_validation_validation_api_2_0_1_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_10_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_aop_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_jcl_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_oxm_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_web_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/exceptions/ExceptionsChain.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.exceptions; 2 | 3 | public class ExceptionsChain extends RuntimeException { 4 | 5 | 6 | public ExceptionsChain(ErrorCodeEnumChain errorCode) { 7 | this.errorCode = errorCode; 8 | } 9 | 10 | public ExceptionsChain(int errorCode) { 11 | this.errorCode = ErrorCodeEnumChain.getEnumById(errorCode); 12 | } 13 | 14 | 15 | private ErrorCodeEnumChain errorCode; 16 | public ErrorCodeEnumChain getErrorCode() { 17 | return errorCode; 18 | } 19 | public void setErrorCode(ErrorCodeEnumChain errorCode) { 20 | this.errorCode = errorCode; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__io_projectreactor_reactor_core_3_1_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_core_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_test_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/UserAsset.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class UserAsset { 7 | 8 | private String account_name; 9 | private String contract_name; 10 | private String token_symbol; 11 | 12 | private String balance; 13 | private String balance_usd; 14 | private String balance_cny; 15 | 16 | private String coinmarket_id; 17 | private String asset_price_usd; 18 | private String asset_price_cny; 19 | private String asset_price_change_in_24h; 20 | private String asset_market_cap_usd; 21 | private String asset_market_cap_cny; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_checkerframework_checker_compat_qual_2_0_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_9_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_beans_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_webmvc_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_9_0.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_codehaus_mojo_animal_sniffer_annotations_1_14.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_google_errorprone_error_prone_annotations_2_1_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_expression_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_31.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/JsonToBinResponse.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by swapnibble on 2017-11-17. 9 | */ 10 | 11 | public class JsonToBinResponse { 12 | @Expose 13 | private String binargs; 14 | 15 | @Expose 16 | private List required_scope; 17 | 18 | @Expose 19 | private List required_auth; 20 | 21 | public String getBinargs() { 22 | return binargs; 23 | } 24 | 25 | public List getRequiredScope(){ 26 | return required_scope; 27 | } 28 | 29 | public List getRequiredAuth(){ 30 | return required_auth; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_9_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/GetCodeResponse.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.JsonObject; 5 | import com.google.gson.annotations.Expose; 6 | import com.oraclechain.eosio.crypto.digest.Sha256; 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | public class GetCodeResponse { 10 | @Expose 11 | private String account_name; 12 | 13 | @Expose 14 | private String wast; 15 | 16 | @Expose 17 | private String code_hash; 18 | 19 | @Expose 20 | private JsonObject abi; 21 | 22 | public JsonObject getAbi() { return abi; } 23 | 24 | public boolean isValidCode() { 25 | return ! ( StringUtils.isEmpty(code_hash) || Sha256.ZERO_HASH.toString().equals( code_hash )); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_hibernate_validator_hibernate_validator_6_0_10_Final.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_data_spring_data_redis_2_0_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_9_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_0_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_spring_context_support_5_0_7_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_data_spring_data_keyvalue_2_0_8_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/service/RedisService.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.service; 2 | 3 | public interface RedisService { 4 | 5 | 6 | 7 | public String get(String key); 8 | public void delete(String key); 9 | 10 | public void set(String key,String value); 11 | public void set(String key,String value,long expireTime); 12 | public void set(String key, Object value); 13 | public void set(String key, Object value, long expireTime); 14 | public void setnx(String key, Object value, long expireTime); 15 | public boolean exists(final String key); 16 | 17 | 18 | /** 19 | * 获取key所对应的对象 20 | * @param key 21 | * @param clazz 目标对象 22 | * @param 泛型 23 | * @return 24 | */ 25 | public T get(String key, Class clazz); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_9_6.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/GetRequiredKeys.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.chain.SignedTransaction; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by swapnibble on 2017-11-15. 12 | */ 13 | 14 | public class GetRequiredKeys { 15 | @Expose 16 | private SignedTransaction transaction; 17 | 18 | @Expose 19 | private List available_keys ; 20 | 21 | public GetRequiredKeys(SignedTransaction transaction, List keys ) { 22 | this.transaction = transaction; 23 | 24 | if ( null != keys ) { 25 | available_keys = new ArrayList<>(keys); 26 | } 27 | else { 28 | available_keys = new ArrayList<>(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | 2 | _____ ___ ____ __ 3 | /\ __`\ /\_ \ /\ _`\ /\ \ __ 4 | \ \ \/\ \ _ __ __ ___\//\ \ __ \ \ \/\_\\ \ \___ __ /\_\ ___ 5 | \ \ \ \ \/\`'__\/'__`\ /'___\\ \ \ /'__`\ \ \ \/_/_\ \ _ `\ /'__`\ \/\ \ /' _ `\ 6 | \ \ \_\ \ \ \//\ \L\.\_/\ \__/ \_\ \_/\ __/ \ \ \L\ \\ \ \ \ \/\ \L\.\_\ \ \/\ \/\ \ 7 | \ \_____\ \_\\ \__/.\_\ \____\/\____\ \____\ \ \____/ \ \_\ \_\ \__/.\_\\ \_\ \_\ \_\ 8 | \/_____/\/_/ \/__/\/_/\/____/\/____/\/____/ \/___/ \/_/\/_/\/__/\/_/ \/_/\/_/\/_/ 9 | 10 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/RequiredKeysResponse.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.crypto.ec.EosPublicKey; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by swapnibble on 2017-11-15. 12 | */ 13 | 14 | public class RequiredKeysResponse { 15 | 16 | @Expose 17 | private List required_keys ; 18 | 19 | public List getKeys() { 20 | if ( null == required_keys ){ 21 | return new ArrayList<>(); 22 | } 23 | 24 | ArrayList retKeys = new ArrayList<>(required_keys.size()); 25 | for ( String pubKey: required_keys ){ 26 | retKeys.add( new EosPublicKey( pubKey)); 27 | } 28 | 29 | return retKeys; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_redis_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/service/BlockServiceEos.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.service; 2 | 3 | import com.oraclechain.eosio.dto.ExchangeRate; 4 | import com.oraclechain.eosio.dto.UserAsset; 5 | 6 | import java.math.BigDecimal; 7 | 8 | public interface BlockServiceEos { 9 | 10 | 11 | ExchangeRate getRate(String external_id) throws Exception; 12 | 13 | BigDecimal getBalance(String baseUrl, 14 | String contractName, 15 | String tokenSymbol, 16 | String accountName) throws Exception; 17 | 18 | UserAsset getUserAssetInfo(String baseUrl, 19 | String accountName, 20 | String contractName, 21 | String tokenSymbol, 22 | String coinmarket_id) throws Exception; 23 | } 24 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_properties_migrator_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_metadata_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/JsonToBinRequest.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonParser; 6 | import com.google.gson.annotations.Expose; 7 | 8 | /** 9 | * Created by swapnibble on 2017-11-17. 10 | */ 11 | 12 | public class JsonToBinRequest { 13 | @Expose 14 | private String code; 15 | 16 | @Expose 17 | private String action; 18 | 19 | @Expose 20 | private JsonElement args; 21 | 22 | public JsonToBinRequest( String code, String action, String args ) { 23 | this.code = code; 24 | this.action = action; 25 | this.args = new JsonParser().parse( args ); 26 | } 27 | 28 | public String getArgsString() {return args.getAsString();} 29 | 30 | public void putArgs(String args) { 31 | this.args = new JsonParser().parse(args); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /.idea/libraries/Maven__org_springframework_boot_spring_boot_configuration_processor_2_0_3_RELEASE.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/Permission.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | public class Permission { 7 | 8 | @Expose 9 | private String name; 10 | 11 | @Expose 12 | private String parent; 13 | 14 | @Expose 15 | private RequiredAuth required_auth; 16 | 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setName(String name) { 23 | this.name = name; 24 | } 25 | 26 | public String getParent() { 27 | return parent; 28 | } 29 | 30 | public void setParent(String parent) { 31 | this.parent = parent; 32 | } 33 | 34 | public RequiredAuth getRequiredAuth() { 35 | return required_auth; 36 | } 37 | 38 | public void setRequiredAuth(RequiredAuth requiredAuth) { 39 | this.required_auth = requiredAuth; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/RequiredAuth.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | import java.util.List; 7 | 8 | public class RequiredAuth { 9 | 10 | @Expose 11 | private Integer threshold; 12 | 13 | @Expose 14 | private List keys = null; 15 | 16 | @Expose 17 | private List accounts = null; 18 | 19 | public Integer getThreshold() { 20 | return threshold; 21 | } 22 | 23 | public void setThreshold(Integer threshold) { 24 | this.threshold = threshold; 25 | } 26 | 27 | public List getKeys() { 28 | return keys; 29 | } 30 | 31 | public void setKeys(List keys) { 32 | this.keys = keys; 33 | } 34 | 35 | public List getAccounts() { 36 | return accounts; 37 | } 38 | 39 | public void setAccounts(List accounts) { 40 | this.accounts = accounts; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypePublicKey.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | import com.oraclechain.eosio.crypto.ec.EosPublicKey; 4 | 5 | /** 6 | * Created by swapnibble on 2018-03-20. 7 | */ 8 | 9 | public class TypePublicKey implements EosType.Packer { 10 | private static final byte PACK_VAL_CURVE_PARAM_TYPE_K1 = 0; 11 | private static final byte PACK_VAL_CURVE_PARAM_TYPE_R1 = 1; 12 | 13 | private final EosPublicKey mPubKey; 14 | 15 | public static TypePublicKey from(EosPublicKey publicKey) { 16 | return new TypePublicKey(publicKey); 17 | } 18 | 19 | public TypePublicKey( EosPublicKey publicKey ) { 20 | mPubKey = publicKey; 21 | } 22 | 23 | 24 | @Override 25 | public void pack(EosType.Writer writer) { 26 | writer.putVariableUInt( mPubKey.isCurveParamK1() ? PACK_VAL_CURVE_PARAM_TYPE_K1 : PACK_VAL_CURVE_PARAM_TYPE_R1 ); 27 | 28 | writer.putBytes( mPubKey.getBytes()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/TransactionReceiptHeader.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | /** 7 | * Created by swapnibble on 2018-04-04. 8 | */ 9 | public class TransactionReceiptHeader { 10 | 11 | // enum status_enum { 12 | // executed = 0, ///< succeed, no exceptions handler executed 13 | // soft_fail = 1, ///< objectively failed (not executed), exceptions handler executed 14 | // hard_fail = 2, ///< objectively failed and exceptions handler objectively failed thus no state change 15 | // delayed = 3 ///< transaction delayed 16 | // }; 17 | 18 | @Expose 19 | public String status ; 20 | 21 | @Expose 22 | public long max_cpu_usage_ms; ///< total billed CPU usage (microseconds) 23 | 24 | @Expose 25 | public long max_net_usage_words;///< total billed NET usage, so we can reconstruct resource state when skipping context free data... hard failures... 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/NewDexTicker.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | 4 | import lombok.Data; 5 | 6 | @Data 7 | public class NewDexTicker { 8 | // "symbol": "oct_eos", 9 | // "contract": "octtothemoon", 10 | // "currency": "OCT", 11 | // "last": 0.0237, 12 | // "change": 0.0172, 13 | // "high": 0.026, 14 | // "low": 0.0233, 15 | // "amount": 889.6848, 16 | // "volume": 21.140800000000002 17 | private String symbol; 18 | private String contract; 19 | private String currency; 20 | private String last; 21 | private String change; 22 | private String high; 23 | private String low; 24 | private String amount; 25 | private String volume; 26 | 27 | public NewDexTicker(){ 28 | symbol = ""; 29 | contract = ""; 30 | currency = ""; 31 | last = "0.0"; 32 | change = "0.0"; 33 | high = "0.0"; 34 | low = "0.0"; 35 | amount = "0.0"; 36 | volume = "0.0"; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/EosBuyRamBytes.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | import com.oraclechain.eosio.crypto.util.HexUtils; 4 | 5 | public class EosBuyRamBytes implements EosType.Packer { 6 | 7 | private TypeAccountName payer; 8 | 9 | private TypeAccountName receiver; 10 | 11 | private int bytes; 12 | 13 | public String getActionName() { 14 | return "buyrambytes"; 15 | } 16 | 17 | 18 | public EosBuyRamBytes(String payer, String receiver, int bytes) { 19 | this.payer = new TypeAccountName(payer); 20 | this.receiver = new TypeAccountName(receiver); 21 | this.bytes = bytes; 22 | } 23 | 24 | @Override 25 | public void pack(EosType.Writer writer) { 26 | payer.pack(writer); 27 | receiver.pack(writer); 28 | writer.putIntLE( bytes); 29 | } 30 | 31 | 32 | public String getAsHex() { 33 | EosType.Writer writer = new EosByteWriter(256); 34 | pack(writer); 35 | return HexUtils.toHex( writer.toBytes() ); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/MyStringUtils.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | import org.apache.commons.lang3.StringUtils; 3 | import org.springframework.util.DigestUtils; 4 | 5 | import java.util.UUID; 6 | 7 | public class MyStringUtils extends StringUtils { 8 | /** 9 | * 回去uuid 10 | * @return 11 | */ 12 | public static String getUUID() { 13 | String uuid = UUID.randomUUID().toString(); 14 | return uuid; 15 | } 16 | /** 17 | * 获取指定内容的md5值,暂时不加盐 18 | * @param source 19 | * @return 20 | */ 21 | public static String getMD5(String source) { 22 | if (source==null) { 23 | return null; 24 | } 25 | String MD5 = DigestUtils.md5DigestAsHex(source.getBytes()); 26 | return MD5; 27 | } 28 | 29 | /*public static String getMD5(String source,String salt) { 30 | if (source==null) { 31 | return null; 32 | } 33 | String MD5=null; 34 | ByteSource byteSource = ByteSource.Util.bytes(salt); 35 | MD5 = new SimpleHash("MD5", source, byteSource, 1024).toString(); 36 | return MD5; 37 | 38 | //1cha 39 | //2查 40 | //1更新 41 | //2更新 42 | } 43 | */ 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/PushTxnResponse.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | import com.oraclechain.eosio.chain.TransactionTrace; 7 | import org.apache.commons.lang3.StringUtils; 8 | 9 | public class PushTxnResponse { 10 | 11 | @Expose 12 | private String transaction_id; 13 | 14 | @Expose 15 | private TransactionTrace processed; 16 | 17 | public String getTransactionId() { 18 | return transaction_id; 19 | } 20 | 21 | public void setTransactionId(String transactionId) { 22 | this.transaction_id = transactionId; 23 | } 24 | 25 | public TransactionTrace getProcessed() { 26 | return processed; 27 | } 28 | 29 | public void setProcessed(TransactionTrace processed) { 30 | this.processed = processed; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | if (StringUtils.isEmpty(transaction_id) || (processed == null )) return ""; 36 | 37 | return "transaction: " + transaction_id + "\n" + processed.toString(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/URLEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | public class URLEncodeUtil { 6 | private final static String ENCODE = "UTF-8"; 7 | /** 8 | * URL 解码 9 | */ 10 | public static String getURLDecoderString(String str) { 11 | String result = ""; 12 | if (null == str) { 13 | return ""; 14 | } 15 | try { 16 | result = java.net.URLDecoder.decode(str, ENCODE); 17 | } catch (UnsupportedEncodingException e) { 18 | e.printStackTrace(); 19 | } 20 | return result; 21 | } 22 | /** 23 | * URL 转码 24 | */ 25 | public static String getURLEncoderString(String str) { 26 | String result = ""; 27 | if (null == str) { 28 | return ""; 29 | } 30 | try { 31 | result = java.net.URLEncoder.encode(str, ENCODE); 32 | } catch (UnsupportedEncodingException e) { 33 | e.printStackTrace(); 34 | } 35 | return result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/TransactionTrace.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.annotations.Expose; 6 | 7 | import java.util.List; 8 | 9 | public class TransactionTrace { 10 | 11 | @Expose 12 | private String id; 13 | 14 | @Expose 15 | private TransactionReceiptHeader receipt; 16 | 17 | @Expose 18 | private long elapsed; 19 | 20 | @Expose 21 | private long net_usage; // uint64_t 22 | 23 | @Expose 24 | private boolean scheduled = false; 25 | 26 | @Expose 27 | private List action_traces; 28 | 29 | @Expose 30 | private JsonElement failed_dtrx_trace; 31 | 32 | @Expose 33 | private JsonElement except; 34 | 35 | @Override 36 | public String toString(){ 37 | if ( receipt == null) { 38 | return "empty receipt"; 39 | } 40 | 41 | String result = ": " + receipt.status; 42 | 43 | if ( receipt.max_net_usage_words < 0 ) { 44 | result += ""; 45 | } 46 | else { 47 | result += (receipt.max_net_usage_words * 8 ); 48 | } 49 | result += " bytes "; 50 | 51 | 52 | if ( receipt.max_cpu_usage_ms < 0 ) { 53 | result += ""; 54 | } 55 | else { 56 | result += (receipt.max_net_usage_words * 8 ); 57 | } 58 | result += " us\n"; 59 | 60 | return result; 61 | } 62 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypePermissionName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-12. 28 | */ 29 | 30 | public class TypePermissionName extends TypeName { 31 | public TypePermissionName(String name) { 32 | super(name); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeActionName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosTypes; 26 | 27 | 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | public class TypeActionName extends TypeName { 33 | 34 | public TypeActionName(long nameAsLong) { 35 | super(nameAsLong); 36 | } 37 | 38 | public TypeActionName(String name) { 39 | super(name); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/controller/HistoryController.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.controller; 2 | 3 | import com.oraclechain.eosio.constants.Variables; 4 | import com.oraclechain.eosio.dto.MessageResult; 5 | import com.oraclechain.eosio.utils.EosErrorUtils; 6 | import com.oraclechain.eosio.utils.HttpClientUtils; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | 11 | @Slf4j 12 | @RestController 13 | public class HistoryController { 14 | 15 | //Get information related to an account. 16 | @CrossOrigin 17 | @PostMapping("get_key_accounts") 18 | public MessageResult get_key_accounts(@RequestBody String body) throws Exception { 19 | 20 | String result= HttpClientUtils.ocPost(Variables.eosHistoryUrl+ "get_key_accounts", body ); 21 | return EosErrorUtils.handleEosResponse(result, "get_key_accounts"); 22 | } 23 | 24 | 25 | //Get information related to an account. 26 | @CrossOrigin 27 | @PostMapping("get_actions") 28 | public MessageResult get_actions(@RequestBody String body) throws Exception { 29 | 30 | String result= HttpClientUtils.ocPost(Variables.eosHistoryUrl+ "get_actions", body ); 31 | return EosErrorUtils.handleEosResponse(result, "get_actions"); 32 | } 33 | 34 | //Get information related to an account. 35 | @CrossOrigin 36 | @PostMapping("get_transaction") 37 | public MessageResult get_transaction(@RequestBody String body) throws Exception { 38 | 39 | String result= HttpClientUtils.ocPost(Variables.eosHistoryUrl+ "get_transaction", body ); 40 | return EosErrorUtils.handleEosResponse(result, "get_transaction"); 41 | } 42 | 43 | 44 | 45 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/EosDelegate.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosTypes; 2 | 3 | import com.google.gson.annotations.Expose; 4 | 5 | public class EosDelegate { 6 | 7 | @Expose 8 | private String from; 9 | 10 | @Expose 11 | private String receiver; 12 | 13 | @Expose 14 | private String stake_net_quantity; 15 | 16 | @Expose 17 | private String stake_cpu_quantity; 18 | 19 | @Expose 20 | private int transfer; 21 | 22 | public String getActionName() { 23 | return "delegatebw"; 24 | } 25 | 26 | 27 | public EosDelegate(String payer, String receiver, String stake_net_quantity, String stake_cpu_quantity, Boolean transfer) { 28 | // this.from = new TypeAccountName(payer); 29 | // this.receiver = new TypeAccountName(receiver); 30 | this.from = payer; 31 | this.receiver = receiver; 32 | this.stake_net_quantity = stake_net_quantity; 33 | this.stake_cpu_quantity = stake_cpu_quantity; 34 | if(transfer){ 35 | this.transfer = 1; 36 | } 37 | else{ 38 | this.transfer = 0; 39 | } 40 | } 41 | // 42 | // @Override 43 | // public void pack(EosType.Writer writer) { 44 | // from.pack(writer); 45 | // receiver.pack(writer); 46 | // writer.putString(stake_net_quantity); 47 | // writer.putString(stake_cpu_quantity); 48 | // if(transfer != 0) transfer = 1; 49 | // writer.putVariableUInt(transfer); 50 | // } 51 | // 52 | // 53 | // public String getAsHex() { 54 | // EosType.Writer writer = new EosByteWriter(256); 55 | // pack(writer); 56 | // return HexUtils.toHex( writer.toBytes() ); 57 | // } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/ec/CurveParam.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.ec; 2 | 3 | 4 | import com.oraclechain.eosio.crypto.util.HexUtils; 5 | 6 | import java.math.BigInteger; 7 | 8 | public class CurveParam { 9 | public static final int SECP256_K1 = 0; 10 | public static final int SECP256_R1 = 1; 11 | 12 | private final int curveParamType; 13 | private final EcCurve curve; 14 | private final EcPoint G; 15 | private final BigInteger n; 16 | //private final BigInteger h; 17 | 18 | private final BigInteger HALF_CURVE_ORDER; 19 | 20 | public CurveParam( int curveParamType, String pInHex, String aInHex, String bInHex, String GxInHex, String GyInHex, String nInHex ){ 21 | this.curveParamType = curveParamType; 22 | BigInteger p = new BigInteger(pInHex, 16); //p 23 | BigInteger b = new BigInteger(bInHex , 16); 24 | BigInteger a = new BigInteger( aInHex, 16); 25 | curve = new EcCurve(p, a, b); 26 | 27 | G = curve.decodePoint( HexUtils.toBytes("04" + GxInHex + GyInHex) ); 28 | n = new BigInteger(nInHex, 16); 29 | //h = BigInteger.ONE; 30 | 31 | HALF_CURVE_ORDER = n.shiftRight(1); 32 | } 33 | 34 | public int getCurveParamType() { 35 | return curveParamType; 36 | } 37 | 38 | public boolean isType(int paramType ) { 39 | return curveParamType == paramType; 40 | } 41 | 42 | 43 | public EcPoint G() { 44 | return this.G; 45 | } 46 | 47 | public BigInteger n() { 48 | return this.n; 49 | } 50 | 51 | public BigInteger halfCurveOrder() { 52 | return HALF_CURVE_ORDER; 53 | } 54 | 55 | public EcCurve getCurve() { 56 | return curve; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeKeyWeight.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | /** 26 | * Created by swapnibble on 2017-09-12. 27 | */ 28 | 29 | public class TypeKeyWeight implements EosType.Packer { 30 | private TypePublicKey mPubKey; 31 | private short mWeight = 0; 32 | 33 | public TypeKeyWeight(TypePublicKey pubKey, short weight) { 34 | mPubKey = pubKey; 35 | mWeight = weight; 36 | } 37 | 38 | 39 | @Override 40 | public void pack(EosType.Writer writer) { 41 | 42 | mPubKey.pack( writer ); 43 | 44 | writer.putShortLE( mWeight); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeChainId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosTypes; 26 | 27 | 28 | import com.oraclechain.eosio.crypto.digest.Sha256; 29 | import com.oraclechain.eosio.utils.HexUtils; 30 | 31 | /** 32 | * Created by swapnibble on 2017-10-30. 33 | */ 34 | 35 | public class TypeChainId { 36 | private Sha256 mId; 37 | 38 | public TypeChainId() { 39 | mId = Sha256.ZERO_HASH; 40 | } 41 | 42 | public TypeChainId(String sha256_string) { 43 | mId = new Sha256(HexUtils.toBytes(sha256_string)); 44 | } 45 | 46 | public byte[] getBytes() { 47 | return mId.getBytes(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/ExchangeRate.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ExchangeRate { 7 | // "id": "oraclechain", 8 | // "name": "OracleChain", 9 | // "symbol": "OCT", 10 | // "rank": "357", 11 | // "price_usd": "0.851606", 12 | // "price_btc": "0.00007631", 13 | // "24h_volume_usd": "179394.0", 14 | // "market_cap_usd": "25548180.0", 15 | // "available_supply": "30000000.0", 16 | // "total_supply": "30000000.0", 17 | // "max_supply": null, 18 | // "percent_change_1h": "-0.48", 19 | // "percent_change_24h": "5.61", 20 | // "percent_change_7d": "11.73", 21 | // "last_updated": "1516886057", 22 | // "price_cny": "5.3843845341", 23 | // "24h_volume_cny": "1134240.80986", 24 | // "market_cap_cny": "161531536.0" 25 | private String id; 26 | private String price_usd; 27 | private String price_cny; 28 | private String percent_change_24h; 29 | private String market_cap_usd; 30 | private String market_cap_cny; 31 | 32 | 33 | public ExchangeRate(){ 34 | id= "0"; 35 | price_usd = "0"; 36 | price_cny = "0"; 37 | percent_change_24h = "0"; 38 | market_cap_usd = "0"; 39 | market_cap_cny = "0"; 40 | 41 | } 42 | 43 | 44 | @Override 45 | public String toString() { 46 | return "ExchangeRate: [id=" + id 47 | + ", price_usd=" + price_usd 48 | + ", price_cny=" + price_cny 49 | + ", percent_change_24h=" + percent_change_24h 50 | + ", market_cap_usd=" + market_cap_usd 51 | + ", market_cap_cny=" + market_cap_cny 52 | + "]"; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | 4 | import com.fasterxml.jackson.core.JsonParseException; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.JavaType; 7 | import com.fasterxml.jackson.databind.JsonMappingException; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | 10 | import java.io.IOException; 11 | import java.util.List; 12 | 13 | public class JsonUtils { 14 | 15 | private static final ObjectMapper OBJECT_MAPPER=new ObjectMapper(); 16 | /** 17 | * 将对象转成json 18 | * @param object 19 | * @return 20 | */ 21 | public static String objectToJson(Object object) { 22 | try { 23 | String json = OBJECT_MAPPER.writeValueAsString(object); 24 | return json; 25 | } catch (JsonProcessingException e) { 26 | 27 | e.printStackTrace(); 28 | } 29 | return null; 30 | } 31 | /** 32 | * 将json转成普通对象 33 | * @param json 34 | * @param type 35 | * @return 36 | */ 37 | public static T jsonToObject(String json,Class type ) { 38 | try { 39 | T t = OBJECT_MAPPER.readValue(json, type); 40 | return t; 41 | } catch (IOException e) { 42 | // TODO Auto-generated catch block 43 | e.printStackTrace(); 44 | } 45 | return null; 46 | } 47 | /* 48 | * 将json转成list集合 49 | */ 50 | public static List jsonToList(String json,Class valueType){ 51 | try { 52 | JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructParametricType(List.class, valueType); 53 | List list = OBJECT_MAPPER.readValue(json, javaType); 54 | return list; 55 | } catch (JsonParseException e) { 56 | // TODO Auto-generated catch block 57 | e.printStackTrace(); 58 | } catch (JsonMappingException e) { 59 | // TODO Auto-generated catch block 60 | e.printStackTrace(); 61 | } catch (IOException e) { 62 | // TODO Auto-generated catch block 63 | e.printStackTrace(); 64 | } 65 | return null; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypePermissionLevelWeight.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | 26 | /** 27 | * Created by swapnibble on 2017-09-12. 28 | */ 29 | 30 | public class TypePermissionLevelWeight implements EosType.Packer { 31 | private TypePermissionLevel mPermission; 32 | private short mWeight; 33 | 34 | /** 35 | * single active permissin 용 생성자 36 | * @param nameForActive 37 | */ 38 | TypePermissionLevelWeight(String nameForActive ) { 39 | this( nameForActive, (short)1); 40 | } 41 | 42 | TypePermissionLevelWeight(String nameForActive, short weight ) { 43 | mPermission = new TypePermissionLevel( nameForActive, "active"); 44 | mWeight = weight; 45 | } 46 | 47 | @Override 48 | public void pack(EosType.Writer writer) { 49 | 50 | mPermission.pack(writer); 51 | 52 | writer.putShortLE( mWeight); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeAccountName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosTypes; 26 | 27 | import org.apache.commons.lang3.StringUtils; 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | 33 | public class TypeAccountName extends TypeName { 34 | private static final int MAX_ACCOUNT_NAME_LEN = 12; 35 | 36 | private static final char CHAR_NOT_ALLOWED = '.'; 37 | 38 | public TypeAccountName(String name) { 39 | super(name); 40 | 41 | if (! StringUtils.isEmpty( name )) { 42 | if (name.length() > MAX_ACCOUNT_NAME_LEN ) { 43 | throw new IllegalArgumentException("account name can only be 12 chars long: " + name) ; // changed from dawn3 44 | } 45 | 46 | if ( (name.indexOf( CHAR_NOT_ALLOWED) >= 0) && ! name.startsWith("eosio.") ){ 47 | throw new IllegalArgumentException("account name must not contain '.': " + name); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/digest/Sha512.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.digest; 2 | 3 | 4 | import com.google.common.base.Preconditions; 5 | import com.google.common.primitives.Ints; 6 | import com.oraclechain.eosio.crypto.util.HexUtils; 7 | 8 | import java.security.MessageDigest; 9 | import java.security.NoSuchAlgorithmException; 10 | import java.util.Arrays; 11 | 12 | public class Sha512 implements Comparable { 13 | 14 | public static final int HASH_LENGTH = 64; 15 | public static final Sha512 ZERO_HASH = new Sha512(new byte[HASH_LENGTH]); 16 | 17 | final private byte[] mHashBytes; 18 | 19 | public Sha512(byte[] bytes) { 20 | Preconditions.checkArgument(bytes.length == HASH_LENGTH); 21 | this.mHashBytes = bytes; 22 | } 23 | 24 | public static Sha512 from(byte[] data) { 25 | MessageDigest digest; 26 | try { 27 | digest = MessageDigest.getInstance("SHA-512"); 28 | } catch (NoSuchAlgorithmException e) { 29 | throw new RuntimeException(e); //cannot happen 30 | } 31 | 32 | digest.update(data, 0, data.length); 33 | 34 | return new Sha512(digest.digest()); 35 | } 36 | 37 | 38 | private Sha512(byte[] bytes, int offset) { 39 | //defensive copy, since incoming bytes is of arbitrary length 40 | mHashBytes = new byte[HASH_LENGTH]; 41 | System.arraycopy(bytes, offset, mHashBytes, 0, HASH_LENGTH); 42 | } 43 | 44 | @Override 45 | public boolean equals(Object other) { 46 | if (other == this) { 47 | return true; 48 | } 49 | if (!(other instanceof Sha512)) 50 | return false; 51 | return Arrays.equals(mHashBytes, ((Sha512) other).mHashBytes); 52 | } 53 | 54 | 55 | @Override 56 | public String toString() { 57 | return HexUtils.toHex(mHashBytes); 58 | } 59 | 60 | public byte[] getBytes() { 61 | return mHashBytes; 62 | } 63 | 64 | @Override 65 | public int compareTo(Sha512 o) { 66 | for (int i = 0; i < HASH_LENGTH; i++) { 67 | byte myByte = mHashBytes[i]; 68 | byte otherByte = o.mHashBytes[i]; 69 | 70 | final int compare = Ints.compare(myByte, otherByte); 71 | if (compare != 0) 72 | return compare; 73 | } 74 | return 0; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/EosEstimateRsc.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | 4 | import com.oraclechain.eosio.chain.PackedTransaction; 5 | import com.oraclechain.eosio.chain.SignedTransaction; 6 | 7 | public class EosEstimateRsc { 8 | 9 | private static final long DEFAULT_EXTRA_KCPU = 1000; 10 | 11 | private long tx_cf_cpu_usage; 12 | private long tx_net_usage; 13 | 14 | // public long estimateTrxCtxFreeKiloCpuUsage(final SignedTransaction txn, long extraKcpu){ 15 | // // TODO add "tx_cf_cpu_usage" to preference! 16 | // if (tx_cf_cpu_usage != 0) { 17 | // return (tx_cf_cpu_usage + 1023 ) / 1024 ; 18 | // } 19 | // 20 | // long estimated_per_action_usage = Consts.DEFAULT_BASE_PER_ACTION_CPU_USAGE * 10; 21 | // return extraKcpu + ( txn.getContextFreeActionCount() * estimated_per_action_usage + 1023 ) / 1024 ; 22 | // } 23 | // 24 | // public long estimateTrxNetUsageWords( final SignedTransaction txn, PackedTransaction.CompressType compressType, int keyCount ){ 25 | // if (tx_net_usage != 0) { 26 | // return tx_net_usage / 8; 27 | // } 28 | // 29 | // long sigs = 5 + // the maximum encoded size of the unsigned_int for the size of the signature block 30 | // (keyCount * 72); // 72 == sizeof(signature_type) 31 | // 32 | // long packed_size_drift = PackedTransaction.CompressType.none.equals( compressType ) ? 33 | // 4 : // there is 1 variably encoded ints we haven't set yet, this size it can grow by 4 bytes 34 | // 256; // allow for drift in the compression due to new data 35 | // 36 | // PackedTransaction packedTransaction = new PackedTransaction( txn ); 37 | // 38 | // long estimated_packed_size = packedTransaction.getDataSize() + packed_size_drift; 39 | // 40 | // return (sigs + estimated_packed_size + txn.getCtxFreeDataCount() + 7) / 8; 41 | // } 42 | 43 | public SignedTransaction estimate(final SignedTransaction txn, PackedTransaction.CompressType compressType, int keyCount) { 44 | // TODO 2018-04-06 45 | txn.putKcpuUsage( 0 ); 46 | txn.putNetUsageWords( 0 ); 47 | 48 | // txn.putKcpuUsage( estimateTrxCtxFreeKiloCpuUsage( txn, DEFAULT_EXTRA_KCPU ) ); 49 | // txn.putNetUsageWords( estimateTrxNetUsageWords( txn, compressType, keyCount) ); 50 | 51 | return txn; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/EosErrorUtils.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONArray; 5 | import com.alibaba.fastjson.JSONObject; 6 | import com.oraclechain.eosio.dto.MessageResult; 7 | import com.oraclechain.eosio.exceptions.*; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.apache.commons.lang3.StringUtils; 10 | 11 | @Slf4j 12 | public class EosErrorUtils { 13 | 14 | public static MessageResult handleEosResponse(String contents, String component_name) throws Exception { 15 | 16 | 17 | //fc层异常 18 | JSONObject fcJsonObject = (JSONObject) JSON.parse(contents); 19 | Integer fc_code_int = (Integer) fcJsonObject.get("code"); 20 | if (fc_code_int != null) { 21 | //chain层异常 22 | String fc_error_string = JSON.toJSONString(fcJsonObject.get("error")); 23 | JSONObject chainJsonObject = (JSONObject) JSON.parse(fc_error_string); 24 | Integer chain_code_int = (Integer) chainJsonObject.get("code"); 25 | if (chain_code_int != null) { 26 | String chain_details_string = JSON.toJSONString(chainJsonObject.get("details")); 27 | 28 | JSONArray contractJsonArray = JSON.parseArray(chain_details_string); 29 | String contract_detail_message_string = contractJsonArray.getJSONObject(0).get("message").toString(); 30 | 31 | if(contract_detail_message_string == null){ 32 | String chain_msg_string = ErrorCodeEnumChain.getMsgById(chain_code_int); 33 | log.info("--->" + component_name + " failed:" + contents); 34 | return MessageResult.error(chain_msg_string, chain_code_int); 35 | } 36 | else{ 37 | log.info("--->" + component_name + " failed:" + contents); 38 | return MessageResult.error(contract_detail_message_string, chain_code_int); 39 | } 40 | } 41 | log.info("--->" + component_name + " failed:" + contents); 42 | String fc_msg_string = ErrorCodeEnumFC.getMsgById(fc_code_int); 43 | return MessageResult.error(fc_msg_string, fc_code_int, ""); 44 | } 45 | 46 | log.info("--->" + component_name + " success:" + fcJsonObject.toString()); 47 | return MessageResult.success(fcJsonObject); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/Transaction.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.eosTypes.EosType; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | * Created by swapnibble on 2018-03-19. 12 | */ 13 | 14 | public class Transaction extends TransactionHeader { 15 | @Expose 16 | private List context_free_actions = new ArrayList<>(); 17 | 18 | @Expose 19 | private List actions = null; 20 | 21 | // Extentions are prefixed with type and are a buffer that can be interpreted by code that is aware and ignored by unaware code. 22 | @Expose 23 | private List transaction_extensions = new ArrayList<>(); 24 | 25 | public Transaction(){ 26 | super(); 27 | } 28 | 29 | 30 | public Transaction( Transaction other) { 31 | super(other); 32 | this.context_free_actions = deepCopyOnlyContainer( other.context_free_actions ); 33 | this.actions = deepCopyOnlyContainer( other.actions ); 34 | this.transaction_extensions = other.transaction_extensions; 35 | } 36 | 37 | public void addAction(Action msg ){ 38 | if ( null == actions) { 39 | actions = new ArrayList<>(1); 40 | } 41 | 42 | actions.add( msg); 43 | } 44 | 45 | 46 | public List getActions() { 47 | return actions; 48 | } 49 | 50 | public void setActions(List actions) { 51 | this.actions = actions; 52 | } 53 | 54 | public int getContextFreeActionCount(){ return ( actions == null ? 0 : actions.size());} 55 | 56 | 57 | List deepCopyOnlyContainer(List srcList){ 58 | if ( null == srcList ){ 59 | return null; 60 | } 61 | 62 | List newList = new ArrayList<>( srcList.size() ); 63 | newList.addAll( srcList); 64 | 65 | return newList; 66 | } 67 | 68 | @Override 69 | public void pack(EosType.Writer writer) { 70 | super.pack(writer); 71 | 72 | writer.putCollection(context_free_actions); 73 | writer.putCollection(actions); 74 | //writer.putCollection(transaction_extensions); 75 | writer.putVariableUInt( transaction_extensions.size()); 76 | if ( transaction_extensions.size() > 0 ){ 77 | // TODO 구체적 코드가 나오면 확인후 구현할 것. 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/service/impl/RedisServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.service.impl; 2 | 3 | import com.oraclechain.eosio.service.RedisService; 4 | import com.oraclechain.eosio.utils.JsonUtils; 5 | import org.springframework.data.redis.core.RedisTemplate; 6 | import org.springframework.stereotype.Service; 7 | 8 | import javax.annotation.Resource; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | @Service 12 | public class RedisServiceImpl implements RedisService { 13 | 14 | 15 | @Resource 16 | private RedisTemplate redisTemplate; 17 | 18 | 19 | @Override 20 | public void delete(String key) { 21 | redisTemplate.delete(key); 22 | } 23 | 24 | @Override 25 | public String get(String key) { 26 | Object o = redisTemplate.opsForValue().get(key); 27 | if (o==null){ 28 | return null; 29 | } 30 | return o.toString(); 31 | } 32 | 33 | 34 | 35 | @Override 36 | public void set(String key, String value) 37 | { 38 | redisTemplate.opsForValue().set(key,value); 39 | } 40 | 41 | @Override 42 | public void set(String key, String value, long expireTime) 43 | { 44 | redisTemplate.opsForValue().set(key,value,expireTime, TimeUnit.SECONDS); 45 | } 46 | 47 | @Override 48 | public void set(String key, Object value) 49 | { 50 | redisTemplate.opsForValue().set(key, JsonUtils.objectToJson(value)); 51 | } 52 | 53 | @Override 54 | public void set(String key, Object value, long expireTime) 55 | { 56 | redisTemplate.opsForValue().set(key,JsonUtils.objectToJson(value),expireTime,TimeUnit.SECONDS ); 57 | } 58 | 59 | 60 | @Override 61 | public void setnx(String key, Object value, long expireTime) 62 | { 63 | Object o = redisTemplate.opsForValue().get(key); 64 | if (o==null){ 65 | redisTemplate.opsForValue().set(key,JsonUtils.objectToJson(value),expireTime,TimeUnit.SECONDS); 66 | } 67 | } 68 | 69 | @Override 70 | public boolean exists(String key) 71 | { 72 | return redisTemplate.hasKey(key); 73 | } 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | @Override 83 | public T get(String key, Class clazz) 84 | { 85 | String s = get(key); 86 | if (s == null) { 87 | return null; 88 | } 89 | return JsonUtils.jsonToObject(s,clazz); 90 | } 91 | 92 | 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypePermissionLevel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | 26 | import com.google.gson.annotations.Expose; 27 | 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | 33 | public class TypePermissionLevel implements EosType.Packer { 34 | 35 | @Expose 36 | private TypeAccountName actor; 37 | 38 | @Expose 39 | private TypePermissionName permission; 40 | 41 | public TypePermissionLevel(String accountName, String permissionName) { 42 | actor = new TypeAccountName(accountName); 43 | permission = new TypePermissionName(permissionName); 44 | } 45 | 46 | public String getAccount(){ 47 | return actor.toString(); 48 | } 49 | 50 | public void setAccount(String accountName ){ 51 | actor = new TypeAccountName(accountName); 52 | } 53 | 54 | public String getPermission(){ 55 | return permission.toString(); 56 | } 57 | 58 | public void setPermission(String permissionName ){ 59 | permission = new TypePermissionName(permissionName); 60 | } 61 | 62 | @Override 63 | public void pack(EosType.Writer writer) { 64 | 65 | actor.pack(writer); 66 | permission.pack(writer); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/dto/MessageResult.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.dto; 2 | 3 | 4 | import java.io.Serializable; 5 | public class MessageResult implements Serializable { 6 | private static final long serialVersionUID = -58782578272943999L; 7 | //状态码 8 | private int code; 9 | //消息 10 | private String message; 11 | //结果数据 12 | private Object data; 13 | 14 | public static long getSerialVersionUID() { 15 | return serialVersionUID; 16 | } 17 | 18 | public int getCode() { 19 | return code; 20 | } 21 | 22 | public void setCode(int code) { 23 | this.code = code; 24 | } 25 | 26 | public String getMessage() { 27 | return message; 28 | } 29 | 30 | public void setMessage(String message) { 31 | this.message = message; 32 | } 33 | 34 | public Object getData() { 35 | return data; 36 | } 37 | 38 | public void setData(Object data) { 39 | this.data = data; 40 | } 41 | 42 | public MessageResult() { 43 | } 44 | 45 | public MessageResult(String message, int code, Object data) { 46 | this.code = code; 47 | this.message = message; 48 | this.data = data; 49 | } 50 | 51 | public static MessageResult success(String message, int code, Object data){ 52 | return new MessageResult(message,code,data); 53 | } 54 | 55 | public static MessageResult success(String message, int code){ 56 | return new MessageResult(message,code,null); 57 | } 58 | 59 | public static MessageResult success(Object data){ 60 | return new MessageResult("ok",0,data); 61 | } 62 | 63 | // public static MessageResult success(){ 64 | // return new MessageResult("ok",0,null); 65 | // } 66 | // 67 | // public static MessageResult success(String message, Object data){ 68 | // return new MessageResult(message,0, data); 69 | // } 70 | // 71 | 72 | public static MessageResult error(String message,int code, Object data){ 73 | return new MessageResult(message,code,data); 74 | } 75 | 76 | 77 | 78 | public static MessageResult error(String message,int code){ 79 | return new MessageResult(message,code,null); 80 | } 81 | 82 | public static MessageResult error(String message){ 83 | return new MessageResult(message,1,null); 84 | } 85 | 86 | public static MessageResult error(){ 87 | 88 | return new MessageResult("system busy...please try again later",1,null); 89 | } 90 | 91 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/exceptions/ErrorCodeEnumFC.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.exceptions; 2 | 3 | 4 | public enum ErrorCodeEnumFC { 5 | 6 | /** 7 | * exceptions code based on e87d245da 8 | */ 9 | 10 | //FROM libraries/fc/include/fc/exception/exception.hpp 11 | unspecified_exception_code(3990000, "unspecified"), 12 | unhandled_exception_code(3990001, "unhandled 3rd party exceptions"), ///< for unhandled 3rd party exceptions 13 | timeout_exception_code(3990002, "Timeout"), 14 | file_not_found_exception_code(3990003, "File Not Found"), 15 | parse_error_exception_code(3990004, "Parse Error"), 16 | invalid_arg_exception_code(3990005, "Invalid Argument"), 17 | key_not_found_exception_code(3990006, "Key Not Found"), 18 | bad_cast_exception_code(3990007, "Bad Cast"), 19 | out_of_range_exception_code(3990008, "Out of Range"), 20 | canceled_exception_code(3990009, "Canceled"), 21 | assert_exception_code(3990010, "Assert Exception"), 22 | eof_exception_code(3990011, "End Of File"), 23 | std_exception_code(3990013, "STD Exception"),//self made 24 | invalid_operation_exception_code(3990014, "Invalid Operation"), 25 | unknown_host_exception_code(3990015, "Unknown Host"), 26 | null_optional_code(3990016, "null optional"), 27 | udt_error_code(3990017, "UDT exceptions"), 28 | aes_error_code(3990018, "AES exceptions"), 29 | overflow_code(3990019, "Integer Overflow"), 30 | underflow_code(3990020, "Integer Underflow"), 31 | divide_by_zero_code(3990021, "Integer Divide By Zero"); 32 | 33 | 34 | private int msg_id; 35 | private String msg; 36 | 37 | 38 | private ErrorCodeEnumFC(int msg_id, String msg) { 39 | this.msg = msg; 40 | this.msg_id = msg_id; 41 | } 42 | 43 | public int getMsg_id() { 44 | return msg_id; 45 | } 46 | 47 | public String getMsg() { 48 | return msg; 49 | } 50 | 51 | public static String getMsgById(int msg_id) { 52 | 53 | for (ErrorCodeEnumFC b : ErrorCodeEnumFC.values()) { 54 | if (b.msg_id == msg_id) { 55 | return b.msg; 56 | } 57 | } 58 | return unspecified_exception_code.getMsg(); 59 | } 60 | 61 | public static ErrorCodeEnumFC getEnumById(int msg_id) { 62 | 63 | for (ErrorCodeEnumFC b : ErrorCodeEnumFC.values()) { 64 | if (b.msg_id == msg_id + 3990000) { 65 | return b; 66 | } 67 | } 68 | 69 | return unspecified_exception_code; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/SignedTransaction.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.crypto.digest.Sha256; 6 | import com.oraclechain.eosio.crypto.ec.EcDsa; 7 | import com.oraclechain.eosio.crypto.ec.EcSignature; 8 | import com.oraclechain.eosio.crypto.ec.EosPrivateKey; 9 | import com.oraclechain.eosio.eosTypes.EosByteWriter; 10 | import com.oraclechain.eosio.eosTypes.TypeChainId; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by swapnibble on 2017-09-11. 17 | */ 18 | 19 | public class SignedTransaction extends Transaction { 20 | 21 | @Expose 22 | private List signatures = null; 23 | 24 | @Expose 25 | private List context_free_data = new ArrayList<>(); 26 | 27 | 28 | public SignedTransaction(){ 29 | super(); 30 | } 31 | 32 | public SignedTransaction( SignedTransaction anotherTxn){ 33 | super(anotherTxn); 34 | this.signatures = deepCopyOnlyContainer( anotherTxn.signatures ); 35 | this.context_free_data = context_free_data; 36 | } 37 | 38 | public List getSignatures() { 39 | return signatures; 40 | } 41 | 42 | public void putSignatures(List signatures) { 43 | this.signatures = signatures; 44 | } 45 | 46 | public int getCtxFreeDataCount() { 47 | return ( context_free_data == null ) ? 0 : context_free_data.size(); 48 | } 49 | 50 | public List getCtxFreeData() { 51 | return context_free_data; 52 | } 53 | 54 | 55 | private Sha256 getDigestForSignature(TypeChainId chainId) { 56 | EosByteWriter writer = new EosByteWriter(255); 57 | 58 | // data layout to sign : 59 | // [ {chainId}, {Transaction( parent class )}, {hash of context_free_data only when exists ] 60 | 61 | writer.putBytes(chainId.getBytes()); 62 | pack( writer); 63 | if (context_free_data.size() > 0 ) { 64 | } 65 | else { 66 | writer.putBytes( Sha256.ZERO_HASH.getBytes()); 67 | } 68 | 69 | return Sha256.from(writer.toBytes()); 70 | } 71 | 72 | public void sign(EosPrivateKey privateKey, TypeChainId chainId) { 73 | if ( null == this.signatures){ 74 | this.signatures = new ArrayList<>(); 75 | } 76 | 77 | EcSignature signature = EcDsa.sign(getDigestForSignature( chainId ), privateKey); 78 | this.signatures.add( signature.toString()); 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/util/CryptUtil.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.util; 2 | 3 | 4 | import javax.crypto.*; 5 | import javax.crypto.spec.IvParameterSpec; 6 | import javax.crypto.spec.SecretKeySpec; 7 | import java.security.InvalidAlgorithmParameterException; 8 | import java.security.InvalidKeyException; 9 | import java.security.NoSuchAlgorithmException; 10 | import java.util.Arrays; 11 | 12 | public class CryptUtil { 13 | 14 | public static byte[] aesEncrypt( byte[] key, byte[] data, byte[] iv ) { 15 | 16 | byte[] encrypted = null; 17 | 18 | try { 19 | 20 | SecretKey secureKey = new SecretKeySpec(key, "AES"); 21 | Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); 22 | 23 | c.init(Cipher.ENCRYPT_MODE, secureKey, new IvParameterSpec(iv)); 24 | 25 | encrypted = c.doFinal(data); 26 | 27 | } catch (NoSuchPaddingException e) { 28 | e.printStackTrace(); 29 | } catch (InvalidAlgorithmParameterException e) { 30 | e.printStackTrace(); 31 | } catch (NoSuchAlgorithmException e) { 32 | e.printStackTrace(); 33 | } catch (InvalidKeyException e) { 34 | e.printStackTrace(); 35 | } catch (BadPaddingException e) { 36 | e.printStackTrace(); 37 | } catch (IllegalBlockSizeException e) { 38 | e.printStackTrace(); 39 | } 40 | 41 | return encrypted; 42 | } 43 | 44 | public static byte[] aesDecrypt( byte[] key, byte[] data, byte[] iv) { 45 | byte[] decrypted = null; 46 | try { 47 | SecretKey secureKey = new SecretKeySpec(key, "AES"); 48 | Cipher c = Cipher.getInstance("AES/CBC/PKCS5Padding"); 49 | 50 | if ( iv.length > 16 ) { 51 | iv = Arrays.copyOf( iv, 16 ); // aes/cbc 에선 iv 는 16-byte ! 52 | } 53 | 54 | c.init(Cipher.DECRYPT_MODE, secureKey, new IvParameterSpec(iv)); 55 | 56 | decrypted = c.doFinal(data); 57 | 58 | } catch (NoSuchPaddingException e) { 59 | e.printStackTrace(); 60 | } catch (InvalidAlgorithmParameterException e) { 61 | e.printStackTrace(); 62 | } catch (NoSuchAlgorithmException e) { 63 | e.printStackTrace(); 64 | } catch (InvalidKeyException e) { 65 | e.printStackTrace(); 66 | } catch (BadPaddingException e) { 67 | e.printStackTrace(); 68 | } catch (IllegalBlockSizeException e) { 69 | e.printStackTrace(); 70 | } 71 | 72 | return decrypted; 73 | } 74 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/EosBlockchainApplication.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio; 2 | 3 | //import com.github.pagehelper.PageHelper; 4 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 5 | import com.fasterxml.jackson.annotation.PropertyAccessor; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.builder.SpringApplicationBuilder; 10 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.data.redis.connection.RedisConnectionFactory; 13 | import org.springframework.data.redis.core.RedisTemplate; 14 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 15 | import org.springframework.data.redis.serializer.RedisSerializer; 16 | import org.springframework.data.redis.serializer.StringRedisSerializer; 17 | 18 | 19 | @SpringBootApplication 20 | public class EosBlockchainApplication extends SpringBootServletInitializer { 21 | 22 | public static void main(String[] args) 23 | { 24 | SpringApplication.run(EosBlockchainApplication.class, args); 25 | } 26 | 27 | 28 | 29 | //serializer from other project, use to make validation of transaction 30 | @Bean 31 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) { 32 | RedisTemplate redisTemplate = new RedisTemplate<>(); 33 | redisTemplate.setConnectionFactory(redisConnectionFactory); 34 | 35 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class); 36 | 37 | ObjectMapper objectMapper = new ObjectMapper(); 38 | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 39 | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 40 | 41 | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); 42 | 43 | redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); 44 | redisTemplate.setKeySerializer(new StringRedisSerializer()); 45 | 46 | redisTemplate.setHashKeySerializer(jackson2JsonRedisSerializer); 47 | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); 48 | 49 | redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer); 50 | redisTemplate.setEnableDefaultSerializer(true); 51 | redisTemplate.afterPropertiesSet(); 52 | return redisTemplate; 53 | } 54 | 55 | 56 | 57 | @Override 58 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { 59 | return application.sources(EosBlockchainApplication.class); 60 | } 61 | 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/EosType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosTypes; 26 | 27 | import java.util.Collection; 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | 33 | public interface EosType { 34 | class InsufficientBytesException extends Exception { 35 | 36 | private static final long serialVersionUID = 1L; 37 | } 38 | 39 | interface Packer { 40 | void pack(EosType.Writer writer); 41 | } 42 | 43 | interface Unpacker { 44 | void unpack(EosType.Reader reader) throws EosType.InsufficientBytesException; 45 | } 46 | 47 | interface Reader { 48 | byte get() throws EosType.InsufficientBytesException; 49 | int getShortLE() throws EosType.InsufficientBytesException; 50 | int getIntLE() throws EosType.InsufficientBytesException; 51 | long getLongLE() throws EosType.InsufficientBytesException; 52 | byte[] getBytes(int size) throws EosType.InsufficientBytesException; 53 | String getString() throws EosType.InsufficientBytesException; 54 | 55 | long getVariableUint() throws EosType.InsufficientBytesException; 56 | } 57 | 58 | interface Writer { 59 | void put(byte b); 60 | void putShortLE(short value); 61 | void putIntLE(int value); 62 | void putLongLE(long value); 63 | void putBytes(byte[] value); 64 | void putString(String value); 65 | byte[] toBytes(); 66 | int length(); 67 | 68 | void putCollection(Collection collection); 69 | 70 | void putVariableUInt(long val); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/constants/Variables.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.constants; 2 | 3 | public final class Variables { 4 | 5 | //EOS TOKEN 6 | public static final String EOS_TOKEN_CONTRACT_NAME = "eosio.token"; 7 | public static final String EOS_TOKEN_CONTRACT_SYMBOL = "EOS"; 8 | public static final String SYSTEM_CONTRACT_NAME_EOS = "eosio"; 9 | //OCT TOKEN 10 | public static final String OCT_TOKEN_CONTRACT_NAME = "octtothemoon"; 11 | public static final String OCT_TOKEN_CONTRACT_SYMBOL = "OCT"; 12 | 13 | //区块链常量 14 | public static final Integer TX_EXPIRATION_IN_MILSEC = 30000; 15 | 16 | //THIRD PARTY 17 | public static final String COINMARKETCAP_ID_EOS = "eos"; 18 | public static final String COINMARKETCAP_TICKER = "https://api.coinmarketcap.com/v1/ticker/"; 19 | public static final String COINMARKETCAP_SPARKLINES_EOS = "https://s2.coinmarketcap.com/generated/sparklines/web/7d/usd/1765.png"; 20 | public static final String COINMARKETCAP_SPARKLINES_OCT = "https://s2.coinmarketcap.com/generated/sparklines/web/7d/usd/1838.png"; 21 | public static final String COINMARKETCAP_SPARKLINES_IQ = "https://s2.coinmarketcap.com/generated/sparklines/web/7d/usd/2930.png"; 22 | public static final String NEWDEX_TICKER = "https://api.newdex.io/v1/ticker"; 23 | 24 | 25 | //JAVA 26 | public static final Integer conTimeOut = 3000; 27 | public static final Integer reqTimeOut = 5000; 28 | public static final Integer moneyPrecision = 4; 29 | 30 | 31 | //REDIS 32 | public static final Integer redisCacheTimeout = 60 * 30; //min 33 | public static final String redisKeyPrefixBlockchain = "Blockchain:"; 34 | public static final String redisKeyPrefixPersonalHead = "Personal:"; 35 | public static final String redisKeyEosCoinmarketcapMid = "ExchangeRate"; 36 | public static final String redisKeyEosNewdexMid = "NewdexTicker"; 37 | public static final String redisKeyPrefixPersonalTailFreeAccount = "xxx"; 38 | public static final String redisKeyPrefixPersonalTailVipAccount = "xxx"; 39 | 40 | //chain 41 | public static final String eosChainUrl = "http://api.oraclechain.io/v1/chain/"; 42 | public static final String eosHistoryUrl = "http://api.oraclechain.io/v1/history/"; 43 | public static final String eosAccount = "octgenerator"; 44 | public static final String eosPrivateKey = "xxx"; 45 | public static final String eosAccountVip = "vipgenerator"; 46 | public static final String eosPrivateKeyVip = "xxx"; 47 | 48 | public static final Integer SYSTEM_CONTRACT_BUYRAM_BYSIZE = 4000; 49 | public static final String SYSTEM_CONTRACT_DELEGATEBW_NET_BYEOS = "0.0050 EOS"; 50 | public static final String SYSTEM_CONTRACT_DELEGATEBW_CPU_BYEOS = "0.0400 EOS"; 51 | public static final Boolean SYSTEM_CONTRACT_DELEGATEBW_ISTRANSFER = false; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/digest/GeneralDigest.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.digest; 2 | 3 | 4 | /** 5 | * base implementation of MD4 family style digest as outlined in 6 | * "Handbook of Applied Cryptography", pages 344 - 347. 7 | */ 8 | public abstract class GeneralDigest { 9 | private static final int BYTE_LENGTH = 64; 10 | private byte[] xBuf; 11 | private int xBufOff; 12 | 13 | private long byteCount; 14 | 15 | /** 16 | * Standard constructor 17 | */ 18 | protected GeneralDigest() { 19 | xBuf = new byte[4]; 20 | xBufOff = 0; 21 | } 22 | 23 | /** 24 | * Copy constructor. We are using copy constructors in place of the 25 | * Object.clone() interface as this interface is not supported by J2ME. 26 | */ 27 | protected GeneralDigest(GeneralDigest t) { 28 | xBuf = new byte[t.xBuf.length]; 29 | System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length); 30 | 31 | xBufOff = t.xBufOff; 32 | byteCount = t.byteCount; 33 | } 34 | 35 | public void update(byte in) { 36 | xBuf[xBufOff++] = in; 37 | 38 | if (xBufOff == xBuf.length) { 39 | processWord(xBuf, 0); 40 | xBufOff = 0; 41 | } 42 | 43 | byteCount++; 44 | } 45 | 46 | public void update(byte[] in, int inOff, int len) { 47 | // 48 | // fill the current word 49 | // 50 | while ((xBufOff != 0) && (len > 0)) { 51 | update(in[inOff]); 52 | 53 | inOff++; 54 | len--; 55 | } 56 | 57 | // 58 | // process whole words. 59 | // 60 | while (len > xBuf.length) { 61 | processWord(in, inOff); 62 | 63 | inOff += xBuf.length; 64 | len -= xBuf.length; 65 | byteCount += xBuf.length; 66 | } 67 | 68 | // 69 | // load in the remainder. 70 | // 71 | while (len > 0) { 72 | update(in[inOff]); 73 | 74 | inOff++; 75 | len--; 76 | } 77 | } 78 | 79 | public void finish() { 80 | long bitLength = (byteCount << 3); 81 | 82 | // 83 | // add the pad bytes. 84 | // 85 | update((byte) 128); 86 | 87 | while (xBufOff != 0) { 88 | update((byte) 0); 89 | } 90 | 91 | processLength(bitLength); 92 | 93 | processBlock(); 94 | } 95 | 96 | public void reset() { 97 | byteCount = 0; 98 | 99 | xBufOff = 0; 100 | for (int i = 0; i < xBuf.length; i++) { 101 | xBuf[i] = 0; 102 | } 103 | } 104 | 105 | public int getByteLength() { 106 | return BYTE_LENGTH; 107 | } 108 | 109 | protected abstract void processWord(byte[] in, int inOff); 110 | 111 | protected abstract void processLength(long bitLength); 112 | 113 | protected abstract void processBlock(); 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/controller/AdvancedQueryController.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.controller; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.oraclechain.eosio.constants.Variables; 5 | import com.oraclechain.eosio.dto.*; 6 | import com.oraclechain.eosio.exceptions.ErrorCodeEnumChain; 7 | import com.oraclechain.eosio.exceptions.ExceptionsChain; 8 | import com.oraclechain.eosio.service.BlockServiceEos; 9 | import com.oraclechain.eosio.service.RedisService; 10 | import com.oraclechain.eosio.utils.HttpClientUtils; 11 | import lombok.extern.slf4j.Slf4j; 12 | import org.springframework.web.bind.annotation.*; 13 | import javax.annotation.Resource; 14 | import javax.validation.Valid; 15 | 16 | @Slf4j 17 | @RestController 18 | public class AdvancedQueryController { 19 | 20 | 21 | 22 | @Resource 23 | private RedisService redisService; 24 | 25 | @Resource 26 | private BlockServiceEos blockServiceEos; 27 | 28 | 29 | //Get asset information related to an array of accounts. 30 | @CrossOrigin 31 | @PostMapping("get_account_assets") 32 | public MessageResult get_account_assets(@Valid @RequestBody ReqAssetsInfo[] reqAssetsInfos) throws Exception 33 | { 34 | 35 | RspAssetsInfo rspAssetsInfo = new RspAssetsInfo(); 36 | for(int i = 0; i< reqAssetsInfos.length; i++){ 37 | ReqAssetsInfo reqAssetsInfo = reqAssetsInfos[i]; 38 | 39 | UserAsset userAssetInfo = blockServiceEos.getUserAssetInfo( 40 | Variables.eosChainUrl, 41 | reqAssetsInfo.getAccount_name(), 42 | reqAssetsInfo.getContract_name(), 43 | reqAssetsInfo.getToken_symbol(), 44 | reqAssetsInfo.getCoinmarket_id() 45 | ); 46 | rspAssetsInfo.addUserAsset(userAssetInfo); 47 | } 48 | log.info("--->get_account_assets success:" + rspAssetsInfo.toString()); 49 | return MessageResult.success(rspAssetsInfo); 50 | } 51 | 52 | 53 | 54 | 55 | //Get latest information related to a node 56 | @CrossOrigin 57 | @PostMapping("get_rate") 58 | public MessageResult get_rate(@RequestParam(value = "coinmarket_id", required = true) String coinmarket_id) throws Exception 59 | { 60 | 61 | ExchangeRate coinMarketTicker = blockServiceEos.getRate(coinmarket_id); 62 | log.info("--->get_rate success:" + coinMarketTicker.toString()); 63 | return MessageResult.success(coinMarketTicker); 64 | } 65 | 66 | 67 | 68 | 69 | //Get coinmarketcap sparklines of eos and oct 70 | @CrossOrigin 71 | @GetMapping("get_sparklines") 72 | public MessageResult get_sparklines() throws Exception 73 | { 74 | Sparklines sparklines = new Sparklines(); 75 | sparklines.setSparkline_eos_png(Variables.COINMARKETCAP_SPARKLINES_EOS); 76 | sparklines.setSparkline_oct_png(Variables.COINMARKETCAP_SPARKLINES_OCT); 77 | sparklines.setSparkline_iq_png(Variables.COINMARKETCAP_SPARKLINES_IQ); 78 | log.info("--->get_sparklines success:" + sparklines.toString()); 79 | return MessageResult.success(sparklines); 80 | } 81 | 82 | 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeAuthority.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosTypes; 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | 29 | /** 30 | * Created by swapnibble on 2017-09-12. 31 | */ 32 | 33 | public class TypeAuthority implements EosType.Packer { 34 | 35 | private int mThreshold; 36 | private List mKeys; 37 | private List mAccounts; 38 | private List mWaits; 39 | 40 | public TypeAuthority(int threshold, List keyWeight, 41 | List permissionLevelWeight, List waitWeight) { 42 | mThreshold = threshold; 43 | mKeys = keyWeight; 44 | 45 | mAccounts = permissionLevelWeight; 46 | mWaits = waitWeight; 47 | } 48 | 49 | private static List createList(T item ) { 50 | ArrayList retList = new ArrayList<>(); 51 | retList.add( item ); 52 | 53 | return retList; 54 | } 55 | 56 | 57 | public TypeAuthority(TypeKeyWeight oneKey, long uint32DelaySec) { 58 | this( 1, createList(oneKey), null, null); 59 | 60 | if ( uint32DelaySec > 0 ) { 61 | mThreshold = 2; 62 | mWaits = createList( new TypeWaitWeight(uint32DelaySec, 1)); 63 | } 64 | } 65 | 66 | public TypeAuthority(int threshold, TypePublicKey pubKey, String permission) { 67 | this( threshold 68 | ,( null == pubKey ? null: createList(new TypeKeyWeight( pubKey, (short)1)) ) 69 | ,( null == permission ? null : createList(new TypePermissionLevelWeight(permission))), null ); 70 | } 71 | 72 | @Override 73 | public void pack(EosType.Writer writer) { 74 | 75 | writer.putIntLE( mThreshold); 76 | 77 | // keys 78 | writer.putCollection( mKeys ); 79 | 80 | // accounts 81 | writer.putCollection( mAccounts ); 82 | 83 | // waits 84 | writer.putCollection( mWaits ); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/EoscGsonTypeAdapterFactory.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.TypeAdapter; 5 | import com.google.gson.TypeAdapterFactory; 6 | import com.google.gson.reflect.TypeToken; 7 | import com.google.gson.stream.JsonReader; 8 | import com.google.gson.stream.JsonToken; 9 | import com.google.gson.stream.JsonWriter; 10 | import com.oraclechain.eosio.eosTypes.*; 11 | 12 | import java.io.IOException; 13 | import java.lang.reflect.Constructor; 14 | import java.lang.reflect.InvocationTargetException; 15 | import java.util.LinkedHashMap; 16 | import java.util.Map; 17 | 18 | 19 | public class EoscGsonTypeAdapterFactory implements TypeAdapterFactory { 20 | 21 | private Map, TypeAdapter> adapters = new LinkedHashMap<>(); 22 | 23 | { 24 | adapters.put(TypeName.class, new TypeNameAdapter<>( TypeName.class)); 25 | adapters.put(TypeAccountName.class, new TypeNameAdapter<>( TypeAccountName.class)); 26 | adapters.put(TypeActionName.class, new TypeNameAdapter<>( TypeActionName.class)); 27 | adapters.put(TypePermissionName.class, new TypeNameAdapter<>( TypePermissionName.class)); 28 | adapters.put(TypeScopeName.class, new TypeNameAdapter<>( TypeScopeName.class)); 29 | 30 | adapters.put( TypeAsset.class, new TypeNameAdapter<>(TypeAsset.class)); 31 | } 32 | 33 | @Override 34 | public TypeAdapter create(Gson gson, TypeToken typeToken) { 35 | TypeAdapter typeAdapter = null; 36 | Class currentType = Object.class; 37 | for (Class type : adapters.keySet()) { 38 | if (type.isAssignableFrom(typeToken.getRawType())) { 39 | if (currentType.isAssignableFrom(type)) { 40 | currentType = type; 41 | typeAdapter = (TypeAdapter)adapters.get(type); 42 | } 43 | } 44 | } 45 | return typeAdapter; 46 | } 47 | 48 | public static class TypeNameAdapter extends TypeAdapter { 49 | 50 | private Class clazz; 51 | 52 | public TypeNameAdapter(Class clazz){ 53 | this.clazz = clazz; 54 | } 55 | 56 | @Override 57 | public C read(JsonReader in) throws IOException { 58 | if (in.peek() == JsonToken.NULL) { 59 | in.nextNull(); 60 | return null; 61 | } 62 | 63 | try { 64 | Constructor constructor = clazz.getConstructor( String.class ); 65 | return constructor.newInstance( in.nextString()); 66 | } catch (NoSuchMethodException e) { 67 | e.printStackTrace(); 68 | } catch (IllegalAccessException e) { 69 | e.printStackTrace(); 70 | } catch (InstantiationException e) { 71 | e.printStackTrace(); 72 | } catch (InvocationTargetException e) { 73 | e.printStackTrace(); 74 | } 75 | 76 | return null; 77 | } 78 | 79 | @Override 80 | public void write(JsonWriter out, C value) throws IOException { 81 | if (value == null) { 82 | out.nullValue(); 83 | return; 84 | } 85 | 86 | out.value(value.toString()); 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/digest/Sha256.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.digest; 2 | 3 | import com.google.common.base.Preconditions; 4 | import com.oraclechain.eosio.utils.HexUtils; 5 | 6 | import java.security.MessageDigest; 7 | import java.security.NoSuchAlgorithmException; 8 | import java.util.Arrays; 9 | 10 | public class Sha256 { 11 | 12 | public static final int HASH_LENGTH = 32; 13 | public static final Sha256 ZERO_HASH = new Sha256(new byte[HASH_LENGTH]); 14 | 15 | final private byte[] mHashBytes; 16 | 17 | /** 18 | * create Sha256 from raw hash bytes. 19 | * @param bytes 20 | */ 21 | public Sha256(byte[] bytes) { 22 | Preconditions.checkArgument(bytes.length == HASH_LENGTH); 23 | this.mHashBytes = bytes; 24 | } 25 | 26 | private static MessageDigest getSha256Digest() { 27 | try { 28 | return MessageDigest.getInstance( "SHA-256" ); 29 | } catch (NoSuchAlgorithmException e) { 30 | throw new RuntimeException(e); //cannot happen 31 | } 32 | } 33 | 34 | public static Sha256 from(byte[] data) { 35 | MessageDigest digest; 36 | digest = getSha256Digest(); 37 | digest.update(data, 0, data.length); 38 | return new Sha256(digest.digest()); 39 | } 40 | 41 | public static Sha256 from(byte[] data, int offset, int length) { 42 | MessageDigest digest; 43 | digest = getSha256Digest(); 44 | digest.update(data, offset, length); 45 | return new Sha256(digest.digest()); 46 | } 47 | 48 | public static Sha256 from(byte[] data1, byte[] data2) { 49 | MessageDigest digest; 50 | digest = getSha256Digest(); 51 | digest.update(data1, 0, data1.length); 52 | digest.update(data2, 0, data2.length); 53 | return new Sha256(digest.digest()); 54 | 55 | } 56 | 57 | public static Sha256 doubleHash(byte[] data, int offset, int length) { 58 | MessageDigest digest; 59 | digest = getSha256Digest(); 60 | digest.update(data, offset, length); 61 | return new Sha256(digest.digest(digest.digest())); 62 | } 63 | 64 | 65 | 66 | @Override 67 | public boolean equals(Object other) { 68 | if (other == this) { 69 | return true; 70 | } 71 | if (!(other instanceof Sha256)) 72 | return false; 73 | return Arrays.equals(mHashBytes, ((Sha256) other).mHashBytes); 74 | } 75 | 76 | 77 | @Override 78 | public String toString() { 79 | return HexUtils.toHex(mHashBytes); 80 | } 81 | 82 | public byte[] getBytes() { 83 | return mHashBytes; 84 | } 85 | 86 | public boolean equalsFromOffset(byte[] toCompareData, int offsetInCompareData, int len ) { 87 | if ( ( null == toCompareData) || ( offsetInCompareData < 0) 88 | || ( len < 0) || ( mHashBytes.length <= len ) 89 | || ( toCompareData.length <= offsetInCompareData) ) { 90 | return false; 91 | } 92 | 93 | for (int i = 0; i < len; i++) { 94 | 95 | if ( mHashBytes[i] != toCompareData[ offsetInCompareData + i] ) { 96 | return false; 97 | } 98 | } 99 | 100 | return true; 101 | } 102 | 103 | public int length() { 104 | return HASH_LENGTH; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/EosChainInfo.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.eosApi; 2 | 3 | 4 | import com.google.gson.annotations.Expose; 5 | 6 | import java.text.DateFormat; 7 | import java.text.ParseException; 8 | import java.text.SimpleDateFormat; 9 | import java.util.Calendar; 10 | import java.util.Date; 11 | 12 | public class EosChainInfo { 13 | 14 | @Expose 15 | private String server_version; 16 | 17 | @Expose 18 | private String chain_id; 19 | 20 | @Expose 21 | private Integer head_block_num; 22 | 23 | @Expose 24 | private Integer last_irreversible_block_num; 25 | 26 | @Expose 27 | private String last_irreversible_block_id; 28 | 29 | @Expose 30 | private String head_block_id; 31 | 32 | @Expose 33 | private String head_block_time; 34 | 35 | @Expose 36 | private String head_block_producer; 37 | 38 | @Expose 39 | private long virtual_block_cpu_limit; 40 | 41 | @Expose 42 | private long virtual_block_net_limit; 43 | 44 | @Expose 45 | private long block_cpu_limit; 46 | 47 | @Expose 48 | private long block_net_limit; 49 | 50 | public String getChain_id() { 51 | return chain_id; 52 | } 53 | 54 | public Integer getHeadBlockNum() { 55 | return head_block_num; 56 | } 57 | 58 | public void setHeadBlockNum(Integer headBlockNum) { 59 | this.head_block_num = headBlockNum; 60 | } 61 | 62 | public Integer getLastIrreversibleBlockNum() { 63 | return last_irreversible_block_num; 64 | } 65 | 66 | public void setLastIrreversibleBlockNum(Integer lastIrreversibleBlockNum) { 67 | this.last_irreversible_block_num = lastIrreversibleBlockNum; 68 | } 69 | 70 | public String getHeadBlockId() { 71 | return head_block_id; 72 | } 73 | 74 | public void setHeadBlockId(String headBlockId) { 75 | this.head_block_id = headBlockId; 76 | } 77 | 78 | public String getHeadBlockTime() { 79 | return head_block_time; 80 | } 81 | 82 | public void setHeadBlockTime(String headBlockTime) { 83 | this.head_block_time = headBlockTime; 84 | } 85 | 86 | public String getTimeAfterHeadBlockTime(int diffInMilSec) { 87 | DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 88 | try { 89 | Date date = sdf.parse( this.head_block_time); 90 | 91 | Calendar c = Calendar.getInstance(); 92 | c.setTime(date); 93 | c.add( Calendar.MILLISECOND, diffInMilSec); 94 | date = c.getTime(); 95 | 96 | return sdf.format(date); 97 | 98 | } catch (ParseException e) { 99 | e.printStackTrace(); 100 | return this.head_block_time; 101 | } 102 | } 103 | 104 | public String getHeadBlockProducer() { 105 | return head_block_producer; 106 | } 107 | 108 | public void setHeadBlockProducer(String headBlockProducer) { 109 | this.head_block_producer = headBlockProducer; 110 | } 111 | 112 | 113 | public String getBrief(){ 114 | return "server_version: " + server_version 115 | + "\nhead block num: " + head_block_num 116 | + "\nlast irreversible block: " + last_irreversible_block_num 117 | + "\nhead block time: " + head_block_time 118 | + "\nhead block producer: " + head_block_producer ; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosApi/EosNewAccount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package com.oraclechain.eosio.eosApi; 26 | 27 | import com.oraclechain.eosio.crypto.util.HexUtils; 28 | import com.oraclechain.eosio.eosTypes.*; 29 | 30 | /** 31 | * Created by swapnibble on 2017-09-12. 32 | */ 33 | 34 | public class EosNewAccount implements EosType.Packer { 35 | private TypeAccountName mCreator; 36 | private TypeAccountName mNewName; 37 | private TypeAuthority mOwner; 38 | private TypeAuthority mActive; 39 | private TypeWaitWeight mWaitWeight; 40 | 41 | public String getActionName() { 42 | return "newaccount"; 43 | } 44 | 45 | public EosNewAccount(String creator, 46 | String newName, 47 | TypeAuthority owner, 48 | TypeAuthority active) 49 | { 50 | 51 | this( new TypeAccountName(creator), 52 | new TypeAccountName(newName), 53 | owner, 54 | active); 55 | } 56 | 57 | public EosNewAccount(String creator, 58 | String newName, 59 | TypePublicKey ownerPubKey, 60 | TypePublicKey activePubKey) 61 | { 62 | 63 | this( new TypeAccountName(creator), 64 | new TypeAccountName(newName), 65 | new TypeAuthority(1, ownerPubKey, null), 66 | new TypeAuthority(1, activePubKey, null)); 67 | } 68 | 69 | public EosNewAccount(TypeAccountName creator, 70 | TypeAccountName newName, 71 | TypeAuthority owner, 72 | TypeAuthority active) 73 | { 74 | 75 | mCreator = creator; 76 | mNewName = newName; 77 | mOwner = owner; 78 | mActive = active; 79 | } 80 | 81 | public String getCreatorName(){ 82 | return mCreator.toString(); 83 | } 84 | 85 | @Override 86 | public void pack(EosType.Writer writer) { 87 | 88 | mCreator.pack(writer); 89 | mNewName.pack(writer); 90 | mOwner.pack(writer); 91 | mActive.pack(writer); 92 | } 93 | 94 | public String getAsHex() { 95 | EosType.Writer writer = new EosByteWriter(256); 96 | 97 | pack(writer); 98 | return HexUtils.toHex( writer.toBytes() ); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/TypeName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | 26 | import java.util.Arrays; 27 | 28 | /** 29 | * Created by swapnibble on 2017-09-12. 30 | */ 31 | 32 | public class TypeName implements EosType.Packer { 33 | private static final String CHAR_MAP = ".12345abcdefghijklmnopqrstuvwxyz"; 34 | 35 | private static final int MAX_NAME_IDX = 12; 36 | 37 | private long mValue; 38 | 39 | static byte char_to_symbol( char c ){ 40 | if( c >= 'a' && c <= 'z' ) 41 | return (byte)((c - 'a') + 6); 42 | if( c >= '1' && c <= '5' ) 43 | return (byte)((c - '1') + 1); 44 | 45 | return (byte)0; 46 | } 47 | 48 | static public long string_to_name( String str ) { 49 | if ( null == str ) { 50 | return 0L; 51 | } 52 | 53 | int len = str.length(); 54 | long value = 0; 55 | 56 | for (int i = 0; i <= MAX_NAME_IDX; i++) { 57 | long c = 0; 58 | 59 | if( i < len && i <= MAX_NAME_IDX) c = char_to_symbol( str.charAt(i) ); 60 | 61 | if( i < MAX_NAME_IDX) { 62 | c &= 0x1f; 63 | c <<= 64-5*(i+1); 64 | } 65 | else { 66 | c &= 0x0f; 67 | } 68 | 69 | value |= c; 70 | } 71 | 72 | return value; 73 | } 74 | 75 | static public String name_to_string( long nameAsLong ) { 76 | long tmp = nameAsLong; 77 | 78 | char[] result = new char[MAX_NAME_IDX + 1]; 79 | Arrays.fill( result, ' '); 80 | 81 | for( int i = 0; i <= MAX_NAME_IDX; ++i ) { 82 | char c = CHAR_MAP.charAt( (int)(tmp & (i == 0 ? 0x0f : 0x1f)) ); 83 | result[MAX_NAME_IDX-i] = c; 84 | tmp >>= (i == 0 ? 4 : 5); 85 | } 86 | 87 | return String.valueOf( result ).replaceAll("[.]+$", ""); // remove trailing dot 88 | } 89 | 90 | public TypeName(long nameAsLong) { 91 | mValue = nameAsLong; 92 | } 93 | 94 | public TypeName(String name) { 95 | mValue = string_to_name( name); 96 | } 97 | 98 | @Override 99 | public void pack(EosType.Writer writer) { 100 | writer.putLongLE( mValue); 101 | } 102 | 103 | @Override 104 | public String toString(){ 105 | return name_to_string( mValue ); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/TransactionHeader.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.crypto.util.BitUtils; 6 | import com.oraclechain.eosio.crypto.util.HexUtils; 7 | import com.oraclechain.eosio.eosTypes.EosType; 8 | 9 | import java.math.BigInteger; 10 | import java.text.DateFormat; 11 | import java.text.ParseException; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.TimeZone; 15 | 16 | /** 17 | * Created by swapnibble on 2018-03-19. 18 | */ 19 | 20 | public class TransactionHeader implements EosType.Packer { 21 | @Expose 22 | private String expiration; 23 | 24 | @Expose 25 | private int ref_block_num = 0; // uint16_t 26 | 27 | @Expose 28 | private long ref_block_prefix= 0;// uint32_t 29 | 30 | @Expose 31 | private long net_usage_words; // fc::unsigned_int 32 | 33 | @Expose 34 | private long max_cpu_usage_ms; // fc::unsigned_int 35 | 36 | @Expose 37 | private long delay_sec; // fc::unsigned_int 38 | 39 | public TransactionHeader(){ 40 | } 41 | 42 | public TransactionHeader( TransactionHeader other ){ 43 | this.expiration = other.expiration; 44 | this.ref_block_num = other.ref_block_num; 45 | this.ref_block_prefix = other.ref_block_prefix; 46 | this.net_usage_words = other.net_usage_words; 47 | this.max_cpu_usage_ms = other.max_cpu_usage_ms; 48 | this.delay_sec = other.delay_sec; 49 | } 50 | 51 | public String getExpiration() { 52 | return expiration; 53 | } 54 | 55 | public void setExpiration(String expiration) { 56 | this.expiration = expiration; 57 | } 58 | 59 | public void setReferenceBlock( String refBlockIdAsSha256 ) { 60 | ref_block_num = new BigInteger( 1, HexUtils.toBytes(refBlockIdAsSha256.substring(0,8))).intValue(); 61 | 62 | ref_block_prefix = //new BigInteger( 1, HexUtils.toBytesReversed( refBlockIdAsSha256.substring(16,24))).longValue(); 63 | BitUtils.uint32ToLong(HexUtils.toBytes(refBlockIdAsSha256.substring(16,24)), 0); // BitUtils treats bytes in little endian. 64 | // so, no need to reverse bytes. 65 | } 66 | 67 | public int getRefBlockNum() { 68 | return ref_block_num; 69 | } 70 | public long getRefBlockPrefix() { 71 | return ref_block_prefix; 72 | } 73 | 74 | 75 | private Date getExpirationAsDate(String dateStr) { 76 | DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 77 | try { 78 | sdf.setTimeZone(TimeZone.getTimeZone("UTC")); 79 | return sdf.parse( dateStr); 80 | 81 | } catch (ParseException e) { 82 | e.printStackTrace(); 83 | return new Date(); 84 | } 85 | } 86 | 87 | public void putNetUsageWords(long netUsage) { 88 | this.net_usage_words = netUsage; 89 | } 90 | 91 | public void putKcpuUsage(long kCpuUsage) { 92 | this.max_cpu_usage_ms = kCpuUsage; 93 | } 94 | 95 | @Override 96 | public void pack(EosType.Writer writer) { 97 | writer.putIntLE( (int)(getExpirationAsDate(expiration).getTime() / 1000) ); // ms -> sec 98 | 99 | writer.putShortLE( (short)(ref_block_num & 0xFFFF) ); // uint16 100 | writer.putIntLE( (int)( ref_block_prefix & 0xFFFFFFFF) );// uint32 101 | 102 | // fc::unsigned_int 103 | writer.putVariableUInt( net_usage_words); 104 | writer.putVariableUInt( max_cpu_usage_ms); 105 | writer.putVariableUInt( delay_sec); 106 | } 107 | } -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/Action.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.JsonElement; 5 | import com.google.gson.JsonPrimitive; 6 | import com.google.gson.annotations.Expose; 7 | import com.oraclechain.eosio.crypto.util.HexUtils; 8 | import com.oraclechain.eosio.eosTypes.EosType; 9 | import com.oraclechain.eosio.eosTypes.TypeAccountName; 10 | import com.oraclechain.eosio.eosTypes.TypeActionName; 11 | import com.oraclechain.eosio.eosTypes.TypePermissionLevel; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | /** 18 | * Created by swapnibble on 2017-09-11. 19 | */ 20 | 21 | public class Action implements EosType.Packer { 22 | @Expose 23 | private TypeAccountName account; 24 | 25 | @Expose 26 | private TypeActionName name; 27 | 28 | @Expose 29 | private List authorization = null; 30 | 31 | @Expose 32 | private JsonElement data; 33 | 34 | public Action(String account, String name, TypePermissionLevel authorization, String data){ 35 | this.account = new TypeAccountName(account); 36 | this.name = new TypeActionName(name); 37 | this.authorization = new ArrayList<>(); 38 | if ( null != authorization ) { 39 | this.authorization.add(authorization); 40 | } 41 | 42 | if ( null != data ) { 43 | this.data = new JsonPrimitive(data); 44 | } 45 | } 46 | 47 | public Action(String account, String name) { 48 | this (account, name, null, null); 49 | } 50 | 51 | public Action(){ 52 | this ( null, null, null, null); 53 | } 54 | 55 | public String getAccount() { 56 | return account.toString(); 57 | } 58 | 59 | public void setAccount(String account) { 60 | this.account = new TypeAccountName(account); 61 | } 62 | 63 | public String getName() { 64 | return name.toString(); 65 | } 66 | 67 | public void setName(String name) { 68 | this.name = new TypeActionName(name); 69 | } 70 | 71 | public List getAuthorization() { 72 | return authorization; 73 | } 74 | 75 | public void setAuthorization(List authorization) { 76 | this.authorization = authorization; 77 | } 78 | 79 | public void setAuthorization(TypePermissionLevel[] authorization) { 80 | this.authorization.addAll( Arrays.asList( authorization) ); 81 | } 82 | 83 | public void setAuthorization(String[] accountWithPermLevel) { 84 | if ( null == accountWithPermLevel){ 85 | return; 86 | } 87 | 88 | for ( String permissionStr : accountWithPermLevel ) { 89 | String[] split = permissionStr.split("@", 2); 90 | authorization.add( new TypePermissionLevel(split[0], split[1]) ); 91 | } 92 | } 93 | 94 | public JsonElement getData() { 95 | return data; 96 | } 97 | 98 | public void setData(String data) { 99 | this.data = new JsonPrimitive(data); 100 | } 101 | 102 | @Override 103 | public void pack(EosType.Writer writer) { 104 | account.pack(writer); 105 | name.pack(writer); 106 | 107 | writer.putCollection( authorization ); 108 | 109 | if ( null != data ) { 110 | byte[] dataAsBytes = HexUtils.toBytes( data.getAsString()); 111 | writer.putVariableUInt(dataAsBytes.length); 112 | writer.putBytes( dataAsBytes ); 113 | } 114 | else { 115 | writer.putVariableUInt(0); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/crypto/ec/EcCurve.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.crypto.ec; 2 | 3 | 4 | import java.math.BigInteger; 5 | 6 | /** 7 | * An elliptic curve 8 | */ 9 | public class EcCurve { 10 | 11 | private EcFieldElement _a; 12 | private EcFieldElement _b; 13 | private BigInteger _q; 14 | private EcPoint _infinity; 15 | 16 | public EcCurve(BigInteger q, BigInteger a, BigInteger b) { 17 | this._q = q; 18 | this._a = fromBigInteger(a); 19 | this._b = fromBigInteger(b); 20 | this._infinity = new EcPoint(this, null, null); 21 | } 22 | 23 | public EcFieldElement getA() { 24 | return _a; 25 | } 26 | 27 | public EcFieldElement getB() { 28 | return _b; 29 | } 30 | 31 | public BigInteger getQ() { 32 | return _q; 33 | } 34 | 35 | public EcPoint getInfinity() { 36 | return _infinity; 37 | } 38 | 39 | public int getFieldSize() { 40 | return _q.bitLength(); 41 | } 42 | 43 | public EcFieldElement fromBigInteger(BigInteger x) { 44 | return new EcFieldElement(this._q, x); 45 | } 46 | 47 | 48 | public EcPoint decodePoint(byte[] encodedPoint) { 49 | EcPoint p = null; 50 | // Switch on encoding type 51 | switch (encodedPoint[0]) { 52 | case 0x00: 53 | p = getInfinity(); 54 | break; 55 | case 0x02: 56 | case 0x03: 57 | int ytilde = encodedPoint[0] & 1; 58 | byte[] i = new byte[encodedPoint.length - 1]; 59 | System.arraycopy(encodedPoint, 1, i, 0, i.length); 60 | EcFieldElement x = new EcFieldElement(this._q, new BigInteger(1, i)); 61 | EcFieldElement alpha = x.multiply(x.square().add(_a)).add(_b); 62 | EcFieldElement beta = alpha.sqrt(); 63 | if (beta == null) { 64 | throw new RuntimeException("Invalid compression"); 65 | } 66 | int bit0 = (beta.toBigInteger().testBit(0) ? 1 : 0); 67 | if (bit0 == ytilde) { 68 | p = new EcPoint(this, x, beta, true); 69 | } else { 70 | p = new EcPoint(this, x, new EcFieldElement(this._q, _q.subtract(beta.toBigInteger())), true); 71 | } 72 | break; 73 | case 0x04: 74 | case 0x06: 75 | case 0x07: 76 | byte[] xEnc = new byte[(encodedPoint.length - 1) / 2]; 77 | byte[] yEnc = new byte[(encodedPoint.length - 1) / 2]; 78 | System.arraycopy(encodedPoint, 1, xEnc, 0, xEnc.length); 79 | System.arraycopy(encodedPoint, xEnc.length + 1, yEnc, 0, yEnc.length); 80 | p = new EcPoint(this, new EcFieldElement(this._q, new BigInteger(1, xEnc)), new EcFieldElement(this._q, 81 | new BigInteger(1, yEnc))); 82 | break; 83 | default: 84 | throw new RuntimeException("Invalid encoding 0x" + Integer.toString(encodedPoint[0], 16)); 85 | } 86 | return p; 87 | } 88 | 89 | @Override 90 | public boolean equals(Object obj) { 91 | if (obj == this) { 92 | return true; 93 | } 94 | if (!(obj instanceof EcCurve)) { 95 | return false; 96 | } 97 | EcCurve other = (EcCurve) obj; 98 | return this._q.equals(other._q) && _a.equals(other._a) && _b.equals(other._b); 99 | } 100 | 101 | @Override 102 | public int hashCode() { 103 | return _a.hashCode() ^ _b.hashCode() ^ _q.hashCode(); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/eosTypes/EosByteReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017-2018 PLACTAL. 3 | * 4 | * The MIT License 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package com.oraclechain.eosio.eosTypes; 25 | 26 | public class EosByteReader implements EosType.Reader{ 27 | 28 | private byte[] _buf; 29 | private int _index; 30 | 31 | public EosByteReader(byte[] buf) { 32 | _buf = buf; 33 | _index = 0; 34 | } 35 | 36 | public EosByteReader(byte[] buf, int index) { 37 | _buf = buf; 38 | _index = index; 39 | } 40 | 41 | @Override 42 | public byte get() throws EosType.InsufficientBytesException { 43 | checkAvailable(1); 44 | return _buf[_index++]; 45 | } 46 | 47 | 48 | @Override 49 | public int getShortLE() throws EosType.InsufficientBytesException { 50 | checkAvailable(2); 51 | return (((_buf[_index++] & 0xFF)) | ((_buf[_index++] & 0xFF) << 8)) & 0xFFFF; 52 | } 53 | 54 | @Override 55 | public int getIntLE() throws EosType.InsufficientBytesException { 56 | checkAvailable(4); 57 | return ((_buf[_index++] & 0xFF)) | ((_buf[_index++] & 0xFF) << 8) | ((_buf[_index++] & 0xFF) << 16) 58 | | ((_buf[_index++] & 0xFF) << 24); 59 | } 60 | 61 | 62 | @Override 63 | public long getLongLE() throws EosType.InsufficientBytesException { 64 | checkAvailable(8); 65 | return ((_buf[_index++] & 0xFFL)) | ((_buf[_index++] & 0xFFL) << 8) | ((_buf[_index++] & 0xFFL) << 16) 66 | | ((_buf[_index++] & 0xFFL) << 24) | ((_buf[_index++] & 0xFFL) << 32) | ((_buf[_index++] & 0xFFL) << 40) 67 | | ((_buf[_index++] & 0xFFL) << 48) | ((_buf[_index++] & 0xFFL) << 56); 68 | } 69 | 70 | @Override 71 | public byte[] getBytes(int size) throws EosType.InsufficientBytesException { 72 | checkAvailable(size); 73 | byte[] bytes = new byte[size]; 74 | System.arraycopy(_buf, _index, bytes, 0, size); 75 | _index += size; 76 | return bytes; 77 | } 78 | 79 | @Override 80 | public String getString() throws EosType.InsufficientBytesException { 81 | int size = (int)(getVariableUint() & 0x7FFFFFFF); // put 에서 variable uint 로 넣음. 82 | byte[] bytes = getBytes(size); 83 | return new String(bytes); 84 | } 85 | 86 | @Override 87 | public long getVariableUint() throws EosType.InsufficientBytesException { 88 | 89 | long v = 0; 90 | byte b, by = 0; 91 | do { 92 | b = get(); 93 | v |= ( b & 0x7F) << by; 94 | by +=7; 95 | } 96 | while ( (b & 0x80) != 0 ); 97 | 98 | return v; 99 | } 100 | 101 | 102 | private void checkAvailable(int num) throws EosType.InsufficientBytesException { 103 | if (_buf.length - _index < num) { 104 | throw new EosType.InsufficientBytesException(); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/controller/ChainController.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.controller; 2 | 3 | import com.oraclechain.eosio.constants.Variables; 4 | import com.oraclechain.eosio.dto.*; 5 | import com.oraclechain.eosio.utils.EosErrorUtils; 6 | import com.oraclechain.eosio.utils.HttpClientUtils; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | 11 | @Slf4j 12 | @RestController 13 | public class ChainController { 14 | 15 | 16 | 17 | //Get latest information related to a node 18 | @CrossOrigin 19 | @GetMapping("get_info") 20 | public MessageResult get_info() throws Exception { 21 | 22 | String result= HttpClientUtils.ocGet(Variables.eosChainUrl+ "get_info" ); 23 | return EosErrorUtils.handleEosResponse(result, "get_info"); 24 | } 25 | 26 | 27 | //Get information related to a block. 28 | @CrossOrigin 29 | @PostMapping("get_block") 30 | public MessageResult get_block(@RequestBody String body) throws Exception { 31 | 32 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_block", body ); 33 | return EosErrorUtils.handleEosResponse(result, "get_block"); 34 | } 35 | 36 | 37 | //Get required keys to sign a transaction from list of your keys. 38 | @CrossOrigin 39 | @PostMapping("get_required_keys") 40 | public MessageResult get_required_keys(@RequestBody String body) throws Exception { 41 | 42 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_required_keys", body ); 43 | return EosErrorUtils.handleEosResponse(result, "get_required_keys"); 44 | } 45 | 46 | 47 | //Serialize json to binary hex. 48 | @CrossOrigin 49 | @PostMapping("abi_json_to_bin") 50 | public MessageResult abi_json_to_bin(@RequestBody String body) throws Exception { 51 | 52 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "abi_json_to_bin", body ); 53 | return EosErrorUtils.handleEosResponse(result, "abi_json_to_bin"); 54 | } 55 | 56 | //Deserialize binary hex to json. 57 | @CrossOrigin 58 | @PostMapping(value = "abi_bin_to_json") 59 | public MessageResult abi_bin_to_json(@RequestBody String body) throws Exception { 60 | 61 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "abi_bin_to_json", body ); 62 | return EosErrorUtils.handleEosResponse(result, "abi_bin_to_json"); 63 | } 64 | 65 | //Get information related to an account. 66 | @CrossOrigin 67 | @PostMapping("get_account") 68 | public MessageResult get_account(@RequestBody String body) throws Exception { 69 | 70 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_account", body ); 71 | return EosErrorUtils.handleEosResponse(result, "get_account"); 72 | } 73 | 74 | 75 | //Fetch smart contract data from an account. 76 | @CrossOrigin 77 | @PostMapping("get_table_rows") 78 | public MessageResult get_table_rows(@RequestBody String body) throws Exception { 79 | 80 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_table_rows", body ); 81 | return EosErrorUtils.handleEosResponse(result, "get_table_rows"); 82 | } 83 | 84 | 85 | //Get asset information 86 | @CrossOrigin 87 | @PostMapping("get_currency_stats") 88 | public MessageResult get_currency_stats(@RequestBody String body) throws Exception { 89 | 90 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_currency_stats", body ); 91 | return EosErrorUtils.handleEosResponse(result, "get_currency_stats"); 92 | } 93 | 94 | //Get balance information 95 | @CrossOrigin 96 | @PostMapping("get_currency_balance") 97 | public MessageResult get_currency_balance(@RequestBody String body) throws Exception { 98 | 99 | String result= HttpClientUtils.ocPost(Variables.eosChainUrl+ "get_currency_balance", body ); 100 | return EosErrorUtils.handleEosResponse(result, "get_currency_balance"); 101 | } 102 | 103 | 104 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | com.oraclechain 7 | eos_proxy_server 8 | 1.0-SNAPSHOT 9 | 10 | UTF-8 11 | UTF-8 12 | 1.8 13 | 14 | 15 | 16 | 17 | org.springframework.boot 18 | spring-boot-starter-parent 19 | 2.0.3.RELEASE 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-configuration-processor 34 | true 35 | 36 | 37 | 38 | 39 | 40 | org.apache.commons 41 | commons-io 42 | 1.3.2 43 | 44 | 45 | org.apache.commons 46 | commons-lang3 47 | 3.4 48 | 49 | 50 | org.apache.httpcomponents 51 | httpclient 52 | 4.5.6 53 | 54 | 55 | 56 | 57 | 58 | org.projectlombok 59 | lombok 60 | 1.16.22 61 | 62 | 63 | com.google.code.gson 64 | gson 65 | 2.8.2 66 | 67 | 68 | com.alibaba 69 | fastjson 70 | 1.2.38 71 | 72 | 73 | javax.servlet 74 | javax.servlet-api 75 | 4.0.0 76 | 77 | 78 | org.springframework.boot 79 | spring-boot-starter-data-redis 80 | 81 | 82 | 83 | 84 | io.reactivex.rxjava2 85 | rxjava 86 | 2.1.10 87 | 88 | 89 | com.google.guava 90 | guava 91 | 24.0-jre 92 | 93 | 94 | 95 | org.springframework.boot 96 | spring-boot-properties-migrator 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | org.springframework.boot 106 | spring-boot-maven-plugin 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/utils/EosTxUtils.java: -------------------------------------------------------------------------------- 1 | package com.oraclechain.eosio.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.oraclechain.eosio.chain.PackedTransaction; 5 | import com.oraclechain.eosio.eosApi.EosChainInfo; 6 | import com.oraclechain.eosio.chain.Action; 7 | import com.oraclechain.eosio.chain.SignedTransaction; 8 | import com.oraclechain.eosio.constants.Variables; 9 | import com.oraclechain.eosio.crypto.ec.EosPrivateKey; 10 | import com.oraclechain.eosio.eosApi.JsonToBinRequest; 11 | import com.oraclechain.eosio.eosApi.JsonToBinResponse; 12 | import com.oraclechain.eosio.eosTypes.TypeChainId; 13 | import com.oraclechain.eosio.exceptions.ErrorCodeEnumChain; 14 | import com.oraclechain.eosio.exceptions.ExceptionsChain; 15 | 16 | import java.math.BigDecimal; 17 | import java.util.ArrayList; 18 | 19 | public class EosTxUtils { 20 | 21 | 22 | public static SignedTransaction createTransaction(String contract, 23 | String actionName, 24 | String dataAsHex, 25 | String[] permissions, 26 | EosChainInfo chainInfo) throws Exception { 27 | 28 | try{ 29 | 30 | Action action = new Action(contract, actionName); 31 | action.setAuthorization(permissions); 32 | action.setData( dataAsHex ); 33 | 34 | 35 | SignedTransaction txn = new SignedTransaction(); 36 | txn.addAction(action); 37 | txn.putSignatures(new ArrayList<>()); 38 | 39 | 40 | if (null != chainInfo) { 41 | txn.setReferenceBlock(chainInfo.getHeadBlockId()); 42 | txn.setExpiration(chainInfo.getTimeAfterHeadBlockTime(Variables.TX_EXPIRATION_IN_MILSEC)); 43 | } 44 | 45 | return txn; 46 | } 47 | catch (Exception e) 48 | { 49 | throw new ExceptionsChain(ErrorCodeEnumChain.request_format_exception); 50 | } 51 | 52 | } 53 | 54 | 55 | public static String[] getActivePermission(String accountName) { 56 | return new String[]{accountName + "@active"}; 57 | } 58 | 59 | 60 | public static SignedTransaction signTransaction(SignedTransaction tx_for_sign, String oracle_key, String chainId) throws Exception { 61 | 62 | try{ 63 | //sign 64 | EosPrivateKey private_key = new EosPrivateKey(oracle_key); 65 | tx_for_sign.sign(private_key, new TypeChainId(chainId)); 66 | 67 | return tx_for_sign; 68 | } 69 | catch (Exception e) 70 | { 71 | throw new ExceptionsChain(ErrorCodeEnumChain.request_format_exception); 72 | } 73 | } 74 | 75 | public static BigDecimal translateToken(String quantity, String symbol){ 76 | String[] tokenHolderArray = quantity.split(" "); 77 | if(tokenHolderArray[1].equals(symbol)) 78 | { 79 | return new BigDecimal(tokenHolderArray[0]); 80 | } 81 | return new BigDecimal(0); 82 | } 83 | public static SignedTransaction addAction(SignedTransaction txn, 84 | String contract, 85 | String actionName, 86 | String dataAsHex, 87 | String[] permissions, 88 | EosChainInfo chainInfo) { 89 | Action action = new Action(contract, actionName); 90 | action.setAuthorization(permissions); 91 | action.setData( dataAsHex ); 92 | 93 | 94 | txn.addAction(action); 95 | txn.putSignatures(new ArrayList<>()); 96 | 97 | //TODO zen add exception here 98 | if (null != chainInfo) { 99 | txn.setReferenceBlock(chainInfo.getHeadBlockId()); 100 | txn.setExpiration(chainInfo.getTimeAfterHeadBlockTime(Variables.TX_EXPIRATION_IN_MILSEC)); 101 | } 102 | 103 | return txn; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/oraclechain/eosio/chain/PackedTransaction.java: -------------------------------------------------------------------------------- 1 | 2 | package com.oraclechain.eosio.chain; 3 | 4 | import com.google.gson.annotations.Expose; 5 | import com.oraclechain.eosio.crypto.util.HexUtils; 6 | import com.oraclechain.eosio.eosTypes.EosByteWriter; 7 | 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.IOException; 10 | import java.util.List; 11 | import java.util.zip.DataFormatException; 12 | import java.util.zip.Deflater; 13 | import java.util.zip.Inflater; 14 | 15 | /** 16 | * Created by swapnibble on 2018-03-19. 17 | */ 18 | 19 | public class PackedTransaction { 20 | public enum CompressType{ none, zlib } 21 | 22 | @Expose 23 | final List signatures ; 24 | 25 | @Expose 26 | final String compression; 27 | 28 | @Expose 29 | private String packed_context_free_data; 30 | 31 | @Expose 32 | private String packed_trx; 33 | 34 | public PackedTransaction(SignedTransaction stxn, CompressType compressType){ 35 | compression = compressType.name(); 36 | signatures = stxn.getSignatures(); 37 | 38 | packed_trx = HexUtils.toHex( packTransaction( stxn, compressType) ); 39 | 40 | byte[] packed_ctx_free_bytes = packContextFreeData( stxn.getCtxFreeData(), compressType ); 41 | packed_context_free_data = ( packed_ctx_free_bytes.length == 0 ) ? "" : HexUtils.toHex( packed_ctx_free_bytes ); 42 | } 43 | 44 | private byte[] packTransaction( Transaction transaction, CompressType compressType ) { 45 | EosByteWriter byteWriter = new EosByteWriter(512); 46 | transaction.pack(byteWriter); 47 | 48 | // pack -> compress 49 | return compress( byteWriter.toBytes(), compressType ) ; 50 | } 51 | 52 | 53 | private byte[] packContextFreeData( List ctxFreeData, CompressType compressType ){ 54 | EosByteWriter byteWriter = new EosByteWriter(64); 55 | 56 | int ctxFreeDataCount = ( ctxFreeData == null ) ? 0 : ctxFreeData.size(); 57 | if ( ctxFreeDataCount == 0 ){ 58 | return byteWriter.toBytes(); 59 | } 60 | 61 | byteWriter.putVariableUInt( ctxFreeDataCount); 62 | 63 | for ( String hexData : ctxFreeData ) { 64 | byteWriter.putBytes( HexUtils.toBytes( hexData)); 65 | } 66 | 67 | return compress( byteWriter.toBytes(), compressType ) ; 68 | } 69 | 70 | 71 | public PackedTransaction(SignedTransaction stxn){ 72 | this( stxn, CompressType.none); 73 | } 74 | 75 | // public long getDataSize() { 76 | // return data.length() / 2; // hex -> raw bytes 77 | // } 78 | 79 | private byte[] compress( byte[] uncompressedBytes, CompressType compressType) { 80 | if ( compressType == null || !CompressType.zlib.equals( compressType)) { 81 | return uncompressedBytes; 82 | } 83 | 84 | // zip! 85 | Deflater deflater = new Deflater( Deflater.BEST_COMPRESSION ); 86 | deflater.setInput( uncompressedBytes ); 87 | 88 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream( uncompressedBytes.length); 89 | deflater.finish(); 90 | byte[] buffer = new byte[1024]; 91 | while (!deflater.finished()) { 92 | int count = deflater.deflate(buffer); // returns the generated code... index 93 | outputStream.write(buffer, 0, count); 94 | } 95 | 96 | try { 97 | outputStream.close(); 98 | } 99 | catch (IOException e) { 100 | e.printStackTrace(); 101 | return uncompressedBytes; 102 | } 103 | 104 | return outputStream.toByteArray(); 105 | } 106 | 107 | private byte[] decompress( byte [] compressedBytes ) { 108 | Inflater inflater = new Inflater(); 109 | inflater.setInput( compressedBytes ); 110 | 111 | ByteArrayOutputStream outputStream = new ByteArrayOutputStream( compressedBytes.length); 112 | byte[] buffer = new byte[1024]; 113 | 114 | try { 115 | while (!inflater.finished()) { 116 | int count = inflater.inflate(buffer); 117 | outputStream.write(buffer, 0, count); 118 | } 119 | outputStream.close(); 120 | } 121 | catch (DataFormatException | IOException e) { 122 | e.printStackTrace(); 123 | return compressedBytes; 124 | } 125 | 126 | 127 | return outputStream.toByteArray(); 128 | } 129 | } 130 | --------------------------------------------------------------------------------