react-native-nitro-bsx 0.0.0-stage → 0.2.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +7 -2
- package/android/CMakeLists.txt +28 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +35 -0
- package/android/src/main/cpp/cpp-adapter.cpp +12 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmReceiver.kt +29 -0
- package/android/src/main/java/com/nitrobsx/BSXAlarmScheduler.kt +112 -0
- package/android/src/main/java/com/nitrobsx/BSXForegroundService.kt +78 -0
- package/android/src/main/java/com/nitrobsx/BSXNotifications.kt +47 -0
- package/android/src/main/java/com/nitrobsx/BSXServiceController.kt +90 -0
- package/android/src/main/java/com/nitrobsx/BSXWakeWorker.kt +136 -0
- package/android/src/main/java/com/nitrobsx/HeadlessJsTaskSupportShim.kt +41 -0
- package/android/src/main/java/com/nitrobsx/NitroBSXPackage.kt +28 -0
- package/android/src/main/res/drawable/bsx_ic_stat_swap.xml +9 -0
- package/cpp/BSXContext.cpp +263 -0
- package/cpp/BSXContext.h +49 -0
- package/cpp/BSXModule.cpp +21191 -0
- package/cpp/BSXModule.h +1523 -0
- package/cpp/CMakeLists.txt +463 -0
- package/cpp/HybridNitroBSX.cpp +1483 -0
- package/cpp/HybridNitroBSX.hpp +173 -0
- package/cpp/arith_uint256.cpp +232 -0
- package/cpp/arith_uint256.h +277 -0
- package/cpp/bsx/event.cpp +48 -0
- package/cpp/bsx/event.h +29 -0
- package/cpp/bsx/swap.h +293 -0
- package/cpp/bsx/types.cpp +486 -0
- package/cpp/bsx/types.h +308 -0
- package/cpp/bsx_db.cpp +4951 -0
- package/cpp/bsx_db.h +465 -0
- package/cpp/chain_client.h +143 -0
- package/cpp/cmake/GenVersion.cmake +52 -0
- package/cpp/coin_config.h.in +12 -0
- package/cpp/coins/block_index.cpp +33 -0
- package/cpp/coins/block_index.h +35 -0
- package/cpp/coins/btc/chainparams.cpp +70 -0
- package/cpp/coins/btc/chainparams.h +23 -0
- package/cpp/coins/btc/interface.h +30 -0
- package/cpp/coins/btc_base/interface.cpp +2200 -0
- package/cpp/coins/btc_base/interface.h +225 -0
- package/cpp/coins/btc_base/primitives.cpp +560 -0
- package/cpp/coins/btc_base/primitives.h +157 -0
- package/cpp/coins/btc_base/psbt.cpp +150 -0
- package/cpp/coins/btc_base/psbt.h +52 -0
- package/cpp/coins/btc_base/script.cpp +304 -0
- package/cpp/coins/btc_base/script.h +181 -0
- package/cpp/coins/chainparams.cpp +47 -0
- package/cpp/coins/chainparams.h +58 -0
- package/cpp/coins/firo/chainparams.cpp +52 -0
- package/cpp/coins/firo/chainparams.h +24 -0
- package/cpp/coins/firo/firo.cpp +118 -0
- package/cpp/coins/firo/firo.h +79 -0
- package/cpp/coins/firo/primitives.cpp +109 -0
- package/cpp/coins/firo/primitives.h +47 -0
- package/cpp/coins/interface.cpp +1815 -0
- package/cpp/coins/interface.h +554 -0
- package/cpp/coins/ltc/chainparams.cpp +70 -0
- package/cpp/coins/ltc/chainparams.h +22 -0
- package/cpp/coins/ltc/ltc.cpp +69 -0
- package/cpp/coins/ltc/ltc.h +82 -0
- package/cpp/coins/ltc/primitives.cpp +20 -0
- package/cpp/coins/ltc/primitives.h +18 -0
- package/cpp/coins/part/chainparams.cpp +89 -0
- package/cpp/coins/part/chainparams.h +47 -0
- package/cpp/coins/part/part.cpp +905 -0
- package/cpp/coins/part/part.h +164 -0
- package/cpp/coins/part/primitives.cpp +548 -0
- package/cpp/coins/part/primitives.h +187 -0
- package/cpp/coins/part/stake.cpp +330 -0
- package/cpp/coins/part/stake.h +92 -0
- package/cpp/coins/primitives.h +125 -0
- package/cpp/coins/registry.cpp +99 -0
- package/cpp/coins/registry.h +32 -0
- package/cpp/coins/script.h +18 -0
- package/cpp/coins/types.cpp +60 -0
- package/cpp/coins/types.h +41 -0
- package/cpp/coins/xmr/chainparams.cpp +28 -0
- package/cpp/coins/xmr/chainparams.h +24 -0
- package/cpp/coins/xmr/tx.cpp +670 -0
- package/cpp/coins/xmr/tx.h +77 -0
- package/cpp/coins/xmr/xmr.cpp +639 -0
- package/cpp/coins/xmr/xmr.h +223 -0
- package/cpp/compat/byteswap.h +74 -0
- package/cpp/compat/endian.h +98 -0
- package/cpp/compat/mbedtls/threading_alt.h +20 -0
- package/cpp/compat/sockets.h +160 -0
- package/cpp/contrib/mbedtls/CMakeLists.txt +566 -0
- package/cpp/contrib/mbedtls/LICENSE +553 -0
- package/cpp/contrib/mbedtls/cmake/MbedTLSConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_encdec.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_hashing.h +30 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_mainpage.h +52 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_rng.h +27 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_ssltls.h +37 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_tcpip.h +32 -0
- package/cpp/contrib/mbedtls/doxygen/input/doc_x509.h +31 -0
- package/cpp/contrib/mbedtls/doxygen/mbedtls.doxyfile +56 -0
- package/cpp/contrib/mbedtls/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/include/CMakeLists.txt +21 -0
- package/cpp/contrib/mbedtls/include/mbedtls/build_info.h +93 -0
- package/cpp/contrib/mbedtls/include/mbedtls/debug.h +120 -0
- package/cpp/contrib/mbedtls/include/mbedtls/error.h +39 -0
- package/cpp/contrib/mbedtls/include/mbedtls/mbedtls_config.h +1189 -0
- package/cpp/contrib/mbedtls/include/mbedtls/net_sockets.h +299 -0
- package/cpp/contrib/mbedtls/include/mbedtls/oid.h +304 -0
- package/cpp/contrib/mbedtls/include/mbedtls/pkcs7.h +250 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_ssl.h +84 -0
- package/cpp/contrib/mbedtls/include/mbedtls/private/config_adjust_x509.h +35 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl.h +5622 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cache.h +187 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ciphersuites.h +303 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_cookie.h +90 -0
- package/cpp/contrib/mbedtls/include/mbedtls/ssl_ticket.h +186 -0
- package/cpp/contrib/mbedtls/include/mbedtls/timing.h +105 -0
- package/cpp/contrib/mbedtls/include/mbedtls/version.h +69 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509.h +503 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crl.h +180 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_crt.h +1174 -0
- package/cpp/contrib/mbedtls/include/mbedtls/x509_csr.h +368 -0
- package/cpp/contrib/mbedtls/library/CMakeLists.txt +375 -0
- package/cpp/contrib/mbedtls/library/Makefile +334 -0
- package/cpp/contrib/mbedtls/library/debug.c +285 -0
- package/cpp/contrib/mbedtls/library/debug_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/error.c +505 -0
- package/cpp/contrib/mbedtls/library/mbedtls_check_config.h +376 -0
- package/cpp/contrib/mbedtls/library/mbedtls_common.h +51 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config.c +40 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_before.h +1769 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/library/mbedtls_config_check_user.h +2436 -0
- package/cpp/contrib/mbedtls/library/mbedtls_platform_requirements.h +55 -0
- package/cpp/contrib/mbedtls/library/mbedtls_utils.h +23 -0
- package/cpp/contrib/mbedtls/library/mps_common.h +181 -0
- package/cpp/contrib/mbedtls/library/mps_error.h +89 -0
- package/cpp/contrib/mbedtls/library/mps_reader.c +538 -0
- package/cpp/contrib/mbedtls/library/mps_reader.h +366 -0
- package/cpp/contrib/mbedtls/library/mps_trace.c +112 -0
- package/cpp/contrib/mbedtls/library/mps_trace.h +154 -0
- package/cpp/contrib/mbedtls/library/net_sockets.c +684 -0
- package/cpp/contrib/mbedtls/library/pkcs7.c +784 -0
- package/cpp/contrib/mbedtls/library/ssl_cache.c +409 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites.c +996 -0
- package/cpp/contrib/mbedtls/library/ssl_ciphersuites_internal.h +108 -0
- package/cpp/contrib/mbedtls/library/ssl_client.c +1019 -0
- package/cpp/contrib/mbedtls/library/ssl_client.h +18 -0
- package/cpp/contrib/mbedtls/library/ssl_cookie.c +251 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers.h +83 -0
- package/cpp/contrib/mbedtls/library/ssl_debug_helpers_generated.c +243 -0
- package/cpp/contrib/mbedtls/library/ssl_misc.h +2851 -0
- package/cpp/contrib/mbedtls/library/ssl_msg.c +6275 -0
- package/cpp/contrib/mbedtls/library/ssl_ticket.c +453 -0
- package/cpp/contrib/mbedtls/library/ssl_tls.c +9048 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_client.c +3054 -0
- package/cpp/contrib/mbedtls/library/ssl_tls12_server.c +3546 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_client.c +3202 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_generic.c +1773 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_invasive.h +23 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.c +1860 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_keys.h +668 -0
- package/cpp/contrib/mbedtls/library/ssl_tls13_server.c +3602 -0
- package/cpp/contrib/mbedtls/library/timing.c +76 -0
- package/cpp/contrib/mbedtls/library/version.c +30 -0
- package/cpp/contrib/mbedtls/library/version_features.c +244 -0
- package/cpp/contrib/mbedtls/library/x509.c +1848 -0
- package/cpp/contrib/mbedtls/library/x509_create.c +747 -0
- package/cpp/contrib/mbedtls/library/x509_crl.c +701 -0
- package/cpp/contrib/mbedtls/library/x509_crt.c +3278 -0
- package/cpp/contrib/mbedtls/library/x509_csr.c +642 -0
- package/cpp/contrib/mbedtls/library/x509_internal.h +97 -0
- package/cpp/contrib/mbedtls/library/x509_oid.c +603 -0
- package/cpp/contrib/mbedtls/library/x509_oid.h +150 -0
- package/cpp/contrib/mbedtls/library/x509write.c +171 -0
- package/cpp/contrib/mbedtls/library/x509write_crt.c +637 -0
- package/cpp/contrib/mbedtls/library/x509write_csr.c +317 -0
- package/cpp/contrib/mbedtls/pkgconfig/CMakeLists.txt +25 -0
- package/cpp/contrib/mbedtls/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedcrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedtls.pc.in +11 -0
- package/cpp/contrib/mbedtls/pkgconfig/mbedx509.pc.in +11 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/CMakeLists.txt +584 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/LICENSE +552 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/cmake/TF-PSA-CryptoConfig.cmake.in +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/CMakeLists.txt +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/alignment.h +700 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/check_crypto_config.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/crypto-library.make +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto.c +9820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_client.c +22 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core.h +972 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_core_common.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers.h +3395 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_driver_wrappers_no_static.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_invasive.h +85 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_its.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.c +168 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random.h +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_random_impl.h +215 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.c +998 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_slot_management.h +330 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.c +400 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_crypto_storage.h +201 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_its_file.c +254 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/psa_util.c +295 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_check_config.h +598 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_common.h +628 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config.c +72 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_before.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_final.h +12 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_config_check_user.h +1220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_platform_requirements.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/core/tf_psa_crypto_version.c +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/dispatch/psa_crypto_driver_wrappers_no_static.h +31 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/input/doc_mainpage.h.in +51 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/doxygen/tfpsacrypto.doxyfile.in +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/CMakeLists.txt +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aes.h +607 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/aria.h +342 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/bignum.h +1137 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/block_cipher.h +76 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/camellia.h +302 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ccm.h +523 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chacha20.h +230 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/chachapoly.h +339 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cipher.h +1173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/cmac.h +209 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/config_adjust_test_accelerators.h +111 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_enable_builtins.h +820 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_adjust_config_tweak_builtins.h +203 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_composites.h +278 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_key_derivation.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/crypto_builtin_primitives.h +136 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ctr_drbg.h +554 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecdsa.h +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecjpake.h +296 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ecp.h +1452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/entropy.h +253 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/error_common.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/gcm.h +382 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/hmac_drbg.h +426 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/md5.h +169 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/pkcs5.h +123 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/poly1305.h +165 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/ripemd160.h +120 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/rsa.h +821 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha1.h +196 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha256.h +180 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha3.h +189 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private/sha512.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/include/mbedtls/private_access.h +53 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aes.c +2236 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.c +624 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesce.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.c +846 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aesni.h +162 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/aria.c +966 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum.c +2635 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.c +1242 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core.h +885 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_core_invasive.h +38 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_internal.h +164 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.c +394 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod.h +452 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.c +276 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw.h +416 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bignum_mod_raw_invasive.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher.c +207 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/block_cipher_internal.h +99 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/bn_mul.h +1094 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/camellia.c +1055 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ccm.c +773 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20.c +576 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chacha20_neon.h +62 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/chachapoly.c +479 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher.c +1126 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_invasive.h +28 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.c +1937 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cipher_wrap.h +173 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/cmac.c +911 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr.h +35 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ctr_drbg.c +1017 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecdsa.c +826 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecjpake.c +1206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp.c +3478 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_curves.c +4798 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ecp_invasive.h +220 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy.c +677 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.c +89 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/entropy_poll.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/gcm.c +1314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/hmac_drbg.c +639 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md5.c +419 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/md_psa.h +26 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/poly1305.c +488 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.c +648 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_aead.h +499 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.c +752 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_cipher.h +314 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.c +921 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ecp.h +516 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.c +781 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_ffdh.h +131 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_hash.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.c +495 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_mac.h +264 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.c +568 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_pake.h +159 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.c +698 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_rsa.h +321 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.c +149 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_crypto_xof.h +155 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.c +282 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/psa_util_internal.h +132 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/ripemd160.c +482 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa.c +2720 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.c +294 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_alt_helpers.h +185 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_internal.h +172 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/rsa_invasive.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha1.c +473 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha256.c +956 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha3.c +951 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/builtin/src/sha512.c +1089 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/driver.cmake +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/CMakeLists.txt +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/README.md +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/Hacl_Curve25519.h +25 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt128.h +124 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.h +280 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlib.h +29 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/c_endianness.h +206 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/builtin.h +16 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/callconv.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/compat.h +34 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/debug.h +57 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/target.h +102 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/types.h +61 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/kremlin/internal/wasmsupport.h +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/vs2013/Hacl_Curve25519.h +21 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/include/tf-psa-crypto/private/everest/x25519.h +48 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519.c +760 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/Hacl_Curve25519_joined.c +50 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt128_extracted.c +413 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/kremlib/FStar_UInt64_FStar_UInt32_FStar_UInt16_FStar_UInt8.c +100 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/legacy/Hacl_Curve25519.c +805 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/everest/library/x25519.c +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/CMakeLists.txt +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/Makefile.inc +5 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/README.md +4 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/README.md +544 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.c +1514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m/p256-m.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.c +312 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/p256-m/p256-m_driver_entrypoints.h +219 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/CMakeLists.txt +14 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/Makefile.inc +6 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/include/tf-psa-crypto/private/crypto_struct_pqcp.h +52 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/fips202_psa.h +117 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/pqcp-config.h +68 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.c +528 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/psa_crypto_mldsa.h +301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.c +66 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/drivers/pqcp/src/wrap_mldsa_native.h +37 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.c +768 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lmots.h +272 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/lms.c +772 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md.c +1182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/md_wrap.h +46 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/nist_kw.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk.c +1464 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_ecc.c +175 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_internal.h +188 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_rsa.c +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.c +667 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pk_wrap.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkparse.c +1351 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.c +574 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/extras/pkwrite.h +101 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/CMakeLists.txt +1 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/framework/LICENSE +553 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/CMakeLists.txt +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1.h +623 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/asn1write.h +397 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/base64.h +81 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/compat-3-crypto.h +43 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/constant_time.h +36 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/lms.h +431 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/md.h +538 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/memory_buffer_alloc.h +142 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/nist_kw.h +106 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pem.h +157 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/pk.h +888 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform.h +513 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_time.h +79 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/platform_util.h +197 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/private/pk_private.h +150 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/psa_util.h +199 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/mbedtls/threading.h +412 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto.h +6082 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_compat.h +74 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_config.h +2073 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_common.h +42 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h +182 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_key_derivation.h +54 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_driver_random.h +49 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_extra.h +2115 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_platform.h +94 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_sizes.h +1301 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_struct.h +682 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_types.h +466 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/psa/crypto_values.h +2827 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/build_info.h +193 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_auto_enabled.h +23 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_dependencies.h +58 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_derived.h +135 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_key_pair_types.h +93 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_support.h +211 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/private/crypto_adjust_config_synonyms.h +41 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/include/tf-psa-crypto/version.h +44 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/objlib.cmake +71 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/CMakeLists.txt +15 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/JoinPaths.cmake +27 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/pkgconfig/tfpsacrypto.pc.in +10 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/memory_buffer_alloc.c +751 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform.c +362 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/platform_util.c +428 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading.c +311 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/platform/threading_internal.h +75 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/CMakeLists.txt +3 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1parse.c +483 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/asn1write.c +465 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64.c +322 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/base64_internal.h +45 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time.c +247 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_impl.h +514 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/constant_time_internal.h +540 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/crypto_oid.h +354 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/oid.c +469 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pem.c +458 -0
- package/cpp/contrib/mbedtls/tf-psa-crypto/utilities/pkcs5.c +475 -0
- package/cpp/contrib/monero/LICENSE +41 -0
- package/cpp/contrib/monero/bsx/common/perf_timer.h +15 -0
- package/cpp/contrib/monero/bsx/common/threadpool.h +43 -0
- package/cpp/contrib/monero/bsx/hex.h +25 -0
- package/cpp/contrib/monero/bsx/misc_log_ex.h +61 -0
- package/cpp/contrib/monero/bsx/random.cpp +20 -0
- package/cpp/contrib/monero/contrib/epee/include/int-util.h +320 -0
- package/cpp/contrib/monero/contrib/epee/include/memwipe.h +81 -0
- package/cpp/contrib/monero/contrib/epee/include/misc_language.h +109 -0
- package/cpp/contrib/monero/contrib/epee/include/mlocker.h +89 -0
- package/cpp/contrib/monero/contrib/epee/include/span.h +189 -0
- package/cpp/contrib/monero/contrib/epee/include/warnings.h +31 -0
- package/cpp/contrib/monero/contrib/epee/src/memwipe.c +115 -0
- package/cpp/contrib/monero/contrib/epee/src/mlocker.cpp +197 -0
- package/cpp/contrib/monero/src/common/aligned.c +139 -0
- package/cpp/contrib/monero/src/common/aligned.h +42 -0
- package/cpp/contrib/monero/src/common/base58.cpp +259 -0
- package/cpp/contrib/monero/src/common/base58.h +46 -0
- package/cpp/contrib/monero/src/common/pod-class.h +43 -0
- package/cpp/contrib/monero/src/common/varint.h +138 -0
- package/cpp/contrib/monero/src/crypto/chacha.h +96 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops-data.c +881 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.c +3891 -0
- package/cpp/contrib/monero/src/crypto/crypto-ops.h +167 -0
- package/cpp/contrib/monero/src/crypto/crypto.cpp +792 -0
- package/cpp/contrib/monero/src/crypto/crypto.h +359 -0
- package/cpp/contrib/monero/src/crypto/generic-ops.h +103 -0
- package/cpp/contrib/monero/src/crypto/hash-ops.h +105 -0
- package/cpp/contrib/monero/src/crypto/hash.c +57 -0
- package/cpp/contrib/monero/src/crypto/hash.h +110 -0
- package/cpp/contrib/monero/src/crypto/keccak.c +239 -0
- package/cpp/contrib/monero/src/crypto/keccak.h +40 -0
- package/cpp/contrib/monero/src/crypto/random.h +46 -0
- package/cpp/contrib/monero/src/crypto/tree-hash.c +257 -0
- package/cpp/contrib/monero/src/crypto/wallet/crypto.h +57 -0
- package/cpp/contrib/monero/src/crypto/wallet/ops.h +32 -0
- package/cpp/contrib/monero/src/cryptonote_config.h +365 -0
- package/cpp/contrib/monero/src/device/device.cpp +105 -0
- package/cpp/contrib/monero/src/device/device.hpp +274 -0
- package/cpp/contrib/monero/src/device/device_default.cpp +343 -0
- package/cpp/contrib/monero/src/device/device_default.hpp +156 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.cc +1097 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs.h +51 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.cc +1120 -0
- package/cpp/contrib/monero/src/ringct/bulletproofs_plus.h +49 -0
- package/cpp/contrib/monero/src/ringct/multiexp.cc +708 -0
- package/cpp/contrib/monero/src/ringct/multiexp.h +72 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.c +221 -0
- package/cpp/contrib/monero/src/ringct/rctCryptoOps.h +37 -0
- package/cpp/contrib/monero/src/ringct/rctOps.cpp +727 -0
- package/cpp/contrib/monero/src/ringct/rctOps.h +191 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.cpp +1652 -0
- package/cpp/contrib/monero/src/ringct/rctSigs.h +143 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.cpp +338 -0
- package/cpp/contrib/monero/src/ringct/rctTypes.h +842 -0
- package/cpp/contrib/monero/src/serialization/binary_archive.h +243 -0
- package/cpp/contrib/monero/src/serialization/container.h +146 -0
- package/cpp/contrib/monero/src/serialization/containers.h +127 -0
- package/cpp/contrib/monero/src/serialization/crypto.h +97 -0
- package/cpp/contrib/monero/src/serialization/debug_archive.h +53 -0
- package/cpp/contrib/monero/src/serialization/json_archive.h +193 -0
- package/cpp/contrib/monero/src/serialization/serialization.h +328 -0
- package/cpp/contrib/monero/src/serialization/variant.h +50 -0
- package/cpp/contrib/nlohmann/LICENSE.MIT +21 -0
- package/cpp/contrib/nlohmann/json.hpp +25526 -0
- package/cpp/contrib/nlohmann/json_fwd.hpp +187 -0
- package/cpp/contrib/notes.txt +96 -0
- package/cpp/contrib/secp256k1/CHANGELOG.md +214 -0
- package/cpp/contrib/secp256k1/CMakeLists.txt +392 -0
- package/cpp/contrib/secp256k1/CMakePresets.json +18 -0
- package/cpp/contrib/secp256k1/CONTRIBUTING.md +111 -0
- package/cpp/contrib/secp256k1/COPYING +19 -0
- package/cpp/contrib/secp256k1/Makefile.am +332 -0
- package/cpp/contrib/secp256k1/README.md +176 -0
- package/cpp/contrib/secp256k1/SECURITY.md +15 -0
- package/cpp/contrib/secp256k1/autogen.sh +3 -0
- package/cpp/contrib/secp256k1/ci/ci.sh +147 -0
- package/cpp/contrib/secp256k1/ci/linux-debian.Dockerfile +84 -0
- package/cpp/contrib/secp256k1/ci/travis.sh +68 -0
- package/cpp/contrib/secp256k1/cmake/CheckArm32Assembly.cmake +6 -0
- package/cpp/contrib/secp256k1/cmake/CheckMemorySanitizer.cmake +18 -0
- package/cpp/contrib/secp256k1/cmake/CheckStringOptionValue.cmake +10 -0
- package/cpp/contrib/secp256k1/cmake/CheckX86_64Assembly.cmake +15 -0
- package/cpp/contrib/secp256k1/cmake/DiscoverTests.cmake +71 -0
- package/cpp/contrib/secp256k1/cmake/FindValgrind.cmake +41 -0
- package/cpp/contrib/secp256k1/cmake/GeneratePkgConfigFile.cmake +8 -0
- package/cpp/contrib/secp256k1/cmake/TryAppendCFlags.cmake +24 -0
- package/cpp/contrib/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/cmake/config.cmake.in +5 -0
- package/cpp/contrib/secp256k1/cmake/source_arm32.s +9 -0
- package/cpp/contrib/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake +3 -0
- package/cpp/contrib/secp256k1/configure.ac +590 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.c +148 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_parsing.h +97 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.c +112 -0
- package/cpp/contrib/secp256k1/contrib/lax_der_privatekey_parsing.h +95 -0
- package/cpp/contrib/secp256k1/doc/ellswift.md +483 -0
- package/cpp/contrib/secp256k1/doc/musig.md +54 -0
- package/cpp/contrib/secp256k1/doc/release-process.md +94 -0
- package/cpp/contrib/secp256k1/doc/safegcd_implementation.md +819 -0
- package/cpp/contrib/secp256k1/examples/CMakeLists.txt +33 -0
- package/cpp/contrib/secp256k1/examples/EXAMPLES_COPYING +121 -0
- package/cpp/contrib/secp256k1/examples/ecdh.c +121 -0
- package/cpp/contrib/secp256k1/examples/ecdsa.c +138 -0
- package/cpp/contrib/secp256k1/examples/ellswift.c +122 -0
- package/cpp/contrib/secp256k1/examples/examples_util.h +108 -0
- package/cpp/contrib/secp256k1/examples/musig.c +261 -0
- package/cpp/contrib/secp256k1/examples/schnorr.c +154 -0
- package/cpp/contrib/secp256k1/include/secp256k1.h +877 -0
- package/cpp/contrib/secp256k1/include/secp256k1_dleag.h +150 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdh.h +63 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ecdsaotves.h +55 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ed25519.h +239 -0
- package/cpp/contrib/secp256k1/include/secp256k1_ellswift.h +200 -0
- package/cpp/contrib/secp256k1/include/secp256k1_extrakeys.h +250 -0
- package/cpp/contrib/secp256k1/include/secp256k1_generator.h +106 -0
- package/cpp/contrib/secp256k1/include/secp256k1_hash.h +45 -0
- package/cpp/contrib/secp256k1/include/secp256k1_musig.h +588 -0
- package/cpp/contrib/secp256k1/include/secp256k1_preallocated.h +134 -0
- package/cpp/contrib/secp256k1/include/secp256k1_recovery.h +123 -0
- package/cpp/contrib/secp256k1/include/secp256k1_schnorrsig.h +190 -0
- package/cpp/contrib/secp256k1/include/visibility.h +58 -0
- package/cpp/contrib/secp256k1/libsecp256k1.pc.in +12 -0
- package/cpp/contrib/secp256k1/sage/gen_exhaustive_groups.sage +156 -0
- package/cpp/contrib/secp256k1/sage/gen_split_lambda_constants.sage +123 -0
- package/cpp/contrib/secp256k1/sage/group_prover.sage +353 -0
- package/cpp/contrib/secp256k1/sage/prove_group_implementations.sage +285 -0
- package/cpp/contrib/secp256k1/sage/secp256k1_params.sage +39 -0
- package/cpp/contrib/secp256k1/sage/weierstrass_prover.sage +275 -0
- package/cpp/contrib/secp256k1/src/CMakeLists.txt +253 -0
- package/cpp/contrib/secp256k1/src/asm/field_10x26_arm.s +916 -0
- package/cpp/contrib/secp256k1/src/assumptions.h +87 -0
- package/cpp/contrib/secp256k1/src/checkmem.h +117 -0
- package/cpp/contrib/secp256k1/src/ecdsa.h +21 -0
- package/cpp/contrib/secp256k1/src/ecdsa_impl.h +312 -0
- package/cpp/contrib/secp256k1/src/eckey.h +28 -0
- package/cpp/contrib/secp256k1/src/eckey_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/ecmult.h +64 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table.h +16 -0
- package/cpp/contrib/secp256k1/src/ecmult_compute_table_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/ecmult_const.h +38 -0
- package/cpp/contrib/secp256k1/src/ecmult_const_impl.h +402 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen.h +144 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table.h +14 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_compute_table_impl.h +108 -0
- package/cpp/contrib/secp256k1/src/ecmult_gen_impl.h +341 -0
- package/cpp/contrib/secp256k1/src/ecmult_impl.h +869 -0
- package/cpp/contrib/secp256k1/src/field.h +354 -0
- package/cpp/contrib/secp256k1/src/field_10x26.h +57 -0
- package/cpp/contrib/secp256k1/src/field_10x26_impl.h +1234 -0
- package/cpp/contrib/secp256k1/src/field_5x52.h +62 -0
- package/cpp/contrib/secp256k1/src/field_5x52_impl.h +524 -0
- package/cpp/contrib/secp256k1/src/field_5x52_int128_impl.h +274 -0
- package/cpp/contrib/secp256k1/src/field_impl.h +462 -0
- package/cpp/contrib/secp256k1/src/group.h +224 -0
- package/cpp/contrib/secp256k1/src/group_impl.h +1024 -0
- package/cpp/contrib/secp256k1/src/hash.h +54 -0
- package/cpp/contrib/secp256k1/src/hash_impl.h +360 -0
- package/cpp/contrib/secp256k1/src/hsort.h +33 -0
- package/cpp/contrib/secp256k1/src/hsort_impl.h +125 -0
- package/cpp/contrib/secp256k1/src/int128.h +90 -0
- package/cpp/contrib/secp256k1/src/int128_impl.h +18 -0
- package/cpp/contrib/secp256k1/src/int128_native.h +19 -0
- package/cpp/contrib/secp256k1/src/int128_native_impl.h +94 -0
- package/cpp/contrib/secp256k1/src/int128_struct.h +14 -0
- package/cpp/contrib/secp256k1/src/int128_struct_impl.h +205 -0
- package/cpp/contrib/secp256k1/src/modinv32.h +43 -0
- package/cpp/contrib/secp256k1/src/modinv32_impl.h +725 -0
- package/cpp/contrib/secp256k1/src/modinv64.h +47 -0
- package/cpp/contrib/secp256k1/src/modinv64_impl.h +780 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/main_impl.h +1073 -0
- package/cpp/contrib/secp256k1/src/modules/dleag/tests_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/bench_impl.h +54 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/main_impl.h +79 -0
- package/cpp/contrib/secp256k1/src/modules/ecdh/tests_impl.h +218 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/Makefile.am.include +3 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/main_impl.h +365 -0
- package/cpp/contrib/secp256k1/src/modules/ecdsaotves/tests_impl.h +49 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/Makefile.am.include +16 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/common.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/core_ed25519.h +229 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/main_impl.h +98 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/common.h +21 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10.h +2698 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_25_5.h +1056 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/ed25519_ref10_fe_51.h +518 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base.h +1344 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/base2.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/constants.h +40 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/ref10/fe_25_5/fe.h +220 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/scalarmult_ed25519_ref10.h +417 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512.h +14 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/sha512/hash_sha512_cp.h +287 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/tests_impl.h +109 -0
- package/cpp/contrib/secp256k1/src/modules/ed25519/utils.h +97 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/bench_impl.h +106 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/main_impl.h +581 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_exhaustive_impl.h +39 -0
- package/cpp/contrib/secp256k1/src/modules/ellswift/tests_impl.h +544 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/Makefile.am.include +4 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/main_impl.h +285 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h +68 -0
- package/cpp/contrib/secp256k1/src/modules/extrakeys/tests_impl.h +484 -0
- package/cpp/contrib/secp256k1/src/modules/generator/Makefile.am.include +9 -0
- package/cpp/contrib/secp256k1/src/modules/generator/main_impl.h +271 -0
- package/cpp/contrib/secp256k1/src/modules/generator/tests_impl.h +227 -0
- package/cpp/contrib/secp256k1/src/modules/musig/Makefile.am.include +8 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg.h +32 -0
- package/cpp/contrib/secp256k1/src/modules/musig/keyagg_impl.h +275 -0
- package/cpp/contrib/secp256k1/src/modules/musig/main_impl.h +12 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session.h +24 -0
- package/cpp/contrib/secp256k1/src/modules/musig/session_impl.h +795 -0
- package/cpp/contrib/secp256k1/src/modules/musig/tests_impl.h +1161 -0
- package/cpp/contrib/secp256k1/src/modules/musig/vectors.h +346 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/bench_impl.h +62 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/main_impl.h +159 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_exhaustive_impl.h +148 -0
- package/cpp/contrib/secp256k1/src/modules/recovery/tests_impl.h +339 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/Makefile.am.include +5 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/bench_impl.h +104 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/main_impl.h +263 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h +214 -0
- package/cpp/contrib/secp256k1/src/modules/schnorrsig/tests_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult.c +91 -0
- package/cpp/contrib/secp256k1/src/precompute_ecmult_gen.c +101 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.c +16456 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult.h +40 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.c +1779 -0
- package/cpp/contrib/secp256k1/src/precomputed_ecmult_gen.h +28 -0
- package/cpp/contrib/secp256k1/src/scalar.h +108 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_4x64_impl.h +1010 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32.h +19 -0
- package/cpp/contrib/secp256k1/src/scalar_8x32_impl.h +830 -0
- package/cpp/contrib/secp256k1/src/scalar_impl.h +321 -0
- package/cpp/contrib/secp256k1/src/scalar_low.h +24 -0
- package/cpp/contrib/secp256k1/src/scalar_low_impl.h +215 -0
- package/cpp/contrib/secp256k1/src/scratch.h +44 -0
- package/cpp/contrib/secp256k1/src/scratch_impl.h +99 -0
- package/cpp/contrib/secp256k1/src/secp256k1.c +896 -0
- package/cpp/contrib/secp256k1/src/selftest.h +35 -0
- package/cpp/contrib/secp256k1/src/testrand.h +45 -0
- package/cpp/contrib/secp256k1/src/testrand_impl.h +162 -0
- package/cpp/contrib/secp256k1/src/testutil.h +161 -0
- package/cpp/contrib/secp256k1/src/unit_test.c +479 -0
- package/cpp/contrib/secp256k1/src/unit_test.h +147 -0
- package/cpp/contrib/secp256k1/src/util.h +469 -0
- package/cpp/contrib/secp256k1/src/util_local_visibility.h +12 -0
- package/cpp/contrib/secp256k1/tools/check-abi.sh +67 -0
- package/cpp/contrib/secp256k1/tools/symbol-check.py +72 -0
- package/cpp/contrib/secp256k1/tools/test_vectors_musig2_generate.py +656 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdh.py +166 -0
- package/cpp/contrib/secp256k1/tools/tests_wycheproof_generate_ecdsa.py +111 -0
- package/cpp/contrib/secp256k1/tools/wycheproof_utils.py +12 -0
- package/cpp/contrib/secp256k1/wasm/test_module.html +320 -0
- package/cpp/contrib/secp256k1/wasm/wrap.cpp +331 -0
- package/cpp/contrib/sqlite3.h +14349 -0
- package/cpp/contrib/sqlite3mc_amalgamation.c +369890 -0
- package/cpp/contrib/sqlite3mc_amalgamation.h +15548 -0
- package/cpp/contrib/unilib/uninorms.cpp +393 -0
- package/cpp/contrib/unilib/uninorms.h +56 -0
- package/cpp/contrib/unilib/utf8.cpp +78 -0
- package/cpp/contrib/unilib/utf8.h +260 -0
- package/cpp/contrib/update_mbedtls.sh +85 -0
- package/cpp/crypto/aes.cpp +141 -0
- package/cpp/crypto/aes.h +67 -0
- package/cpp/crypto/chacha20.cpp +342 -0
- package/cpp/crypto/chacha20.h +82 -0
- package/cpp/crypto/chacha20poly1305.cpp +91 -0
- package/cpp/crypto/chacha20poly1305.h +46 -0
- package/cpp/crypto/common.h +85 -0
- package/cpp/crypto/ctaes/COPYING +21 -0
- package/cpp/crypto/ctaes/README.md +41 -0
- package/cpp/crypto/ctaes/bench.c +170 -0
- package/cpp/crypto/ctaes/ctaes.c +556 -0
- package/cpp/crypto/ctaes/ctaes.h +41 -0
- package/cpp/crypto/ctaes/test.c +110 -0
- package/cpp/crypto/extkey.cpp +257 -0
- package/cpp/crypto/extkey.h +66 -0
- package/cpp/crypto/hmac_sha512.cpp +37 -0
- package/cpp/crypto/hmac_sha512.h +32 -0
- package/cpp/crypto/merkle.cpp +47 -0
- package/cpp/crypto/merkle.h +20 -0
- package/cpp/crypto/poly1305.cpp +223 -0
- package/cpp/crypto/poly1305.h +59 -0
- package/cpp/crypto/ripemd160.cpp +292 -0
- package/cpp/crypto/ripemd160.h +28 -0
- package/cpp/crypto/scrypt-sse2.cpp +141 -0
- package/cpp/crypto/scrypt.cpp +336 -0
- package/cpp/crypto/scrypt.h +49 -0
- package/cpp/crypto/sealed_key.cpp +62 -0
- package/cpp/crypto/sealed_key.h +34 -0
- package/cpp/crypto/secure_bytes.h +16 -0
- package/cpp/crypto/sha512.cpp +206 -0
- package/cpp/crypto/sha512.h +29 -0
- package/cpp/crypto/util.cpp +77 -0
- package/cpp/crypto/util.h +32 -0
- package/cpp/debug_rpc.cpp +703 -0
- package/cpp/debug_rpc.h +63 -0
- package/cpp/electrum.cpp +931 -0
- package/cpp/electrum.h +169 -0
- package/cpp/engine/xmr_engine.cpp +463 -0
- package/cpp/engine/xmr_engine.h +84 -0
- package/cpp/engine/xmr_engine_c.cpp +141 -0
- package/cpp/engine/xmr_engine_c.h +35 -0
- package/cpp/fees.cpp +270 -0
- package/cpp/fees.h +60 -0
- package/cpp/height_search.cpp +64 -0
- package/cpp/height_search.h +27 -0
- package/cpp/main.cpp +146 -0
- package/cpp/messages_npb.cpp +701 -0
- package/cpp/messages_npb.h +667 -0
- package/cpp/mnemonic/mnemonic.cpp +715 -0
- package/cpp/mnemonic/mnemonic.h +52 -0
- package/cpp/mnemonic/wordlists/english.h +1103 -0
- package/cpp/mnemonic/wordlists/japanese.h +2212 -0
- package/cpp/network/bridge.cpp +232 -0
- package/cpp/network/bridge.h +115 -0
- package/cpp/network/ca_roots.cpp +114 -0
- package/cpp/network/ca_roots.h +12 -0
- package/cpp/network/http_client.cpp +261 -0
- package/cpp/network/http_client.h +33 -0
- package/cpp/network/pem.cpp +84 -0
- package/cpp/network/pem.h +22 -0
- package/cpp/network/psa_user_config.h +15 -0
- package/cpp/network/socks5.cpp +180 -0
- package/cpp/network/socks5.h +26 -0
- package/cpp/network/tls_transport.cpp +502 -0
- package/cpp/network/tls_transport.h +62 -0
- package/cpp/network/transport.cpp +169 -0
- package/cpp/network/transport.h +115 -0
- package/cpp/network/url.cpp +88 -0
- package/cpp/network/url.h +25 -0
- package/cpp/network/websocket.cpp +253 -0
- package/cpp/network/websocket.h +68 -0
- package/cpp/network/ws_transport.cpp +361 -0
- package/cpp/network/ws_transport.h +72 -0
- package/cpp/node_client.cpp +1196 -0
- package/cpp/node_client.h +209 -0
- package/cpp/node_scan.h +35 -0
- package/cpp/schema.cpp +1249 -0
- package/cpp/schema.h +132 -0
- package/cpp/smsg.cpp +453 -0
- package/cpp/smsg.h +43 -0
- package/cpp/support/allocators/secure.h +85 -0
- package/cpp/support/cleanse.cpp +35 -0
- package/cpp/support/cleanse.h +15 -0
- package/cpp/support/coop.cpp +319 -0
- package/cpp/support/coop.h +157 -0
- package/cpp/support/lockedpool.cpp +406 -0
- package/cpp/support/lockedpool.h +240 -0
- package/cpp/uint256.cpp +62 -0
- package/cpp/uint256.h +121 -0
- package/cpp/util/base58.cpp +181 -0
- package/cpp/util/base58.h +45 -0
- package/cpp/util/bech32.cpp +578 -0
- package/cpp/util/bech32.h +96 -0
- package/cpp/util/debug.cpp +23 -0
- package/cpp/util/debug.h +12 -0
- package/cpp/util/int.cpp +118 -0
- package/cpp/util/int.h +18 -0
- package/cpp/util/json.h +26 -0
- package/cpp/util/log.cpp +137 -0
- package/cpp/util/log.h +37 -0
- package/cpp/util/mutex.h +89 -0
- package/cpp/util/platform.cpp +90 -0
- package/cpp/util/platform.h +17 -0
- package/cpp/util/random.cpp +136 -0
- package/cpp/util/random.h +28 -0
- package/cpp/util/rpc.cpp +192 -0
- package/cpp/util/rpc.h +454 -0
- package/cpp/util/str.cpp +254 -0
- package/cpp/util/str.h +54 -0
- package/cpp/util/thread.cpp +17 -0
- package/cpp/util/thread.h +12 -0
- package/cpp/util/time.cpp +30 -0
- package/cpp/util/time.h +30 -0
- package/cpp/util/tinyformat.h +1163 -0
- package/cpp/util/vector.h +83 -0
- package/cpp/version.h.in +12 -0
- package/cpp/view_key_chain.h +283 -0
- package/cpp/wallet/account_wallet.cpp +668 -0
- package/cpp/wallet/account_wallet.h +136 -0
- package/cpp/wallet/base_wallet.cpp +302 -0
- package/cpp/wallet/base_wallet.h +129 -0
- package/cpp/wallet/debug_wallet.cpp +40 -0
- package/cpp/wallet/debug_wallet.h +36 -0
- package/cpp/wallet/encrypted_seed.cpp +96 -0
- package/cpp/wallet/encrypted_seed.h +41 -0
- package/cpp/wallet/host_wallet.cpp +85 -0
- package/cpp/wallet/host_wallet.h +51 -0
- package/cpp/wallet/native_wallet.cpp +34 -0
- package/cpp/wallet/native_wallet.h +28 -0
- package/cpp/wallet/xmr/account_wallet.cpp +803 -0
- package/cpp/wallet/xmr/account_wallet.h +139 -0
- package/cpp/wallet/xmr/builder.cpp +568 -0
- package/cpp/wallet/xmr/builder.h +65 -0
- package/cpp/wallet/xmr/chain.cpp +1437 -0
- package/cpp/wallet/xmr/chain.h +213 -0
- package/cpp/wallet/xmr/daemon.cpp +583 -0
- package/cpp/wallet/xmr/daemon.h +153 -0
- package/cpp/wallet/xmr/decoys.cpp +197 -0
- package/cpp/wallet/xmr/decoys.h +64 -0
- package/cpp/wallet/xmr/epee.cpp +448 -0
- package/cpp/wallet/xmr/epee.h +25 -0
- package/cpp/wallet/xmr/fee.cpp +169 -0
- package/cpp/wallet/xmr/fee.h +61 -0
- package/cpp/wallet/xmr/reserve_proof.cpp +169 -0
- package/cpp/wallet/xmr/reserve_proof.h +24 -0
- package/cpp/wallet/xmr/scanner.cpp +860 -0
- package/cpp/wallet/xmr/scanner.h +239 -0
- package/lib/commonjs/NativeNitroBSX.js +128 -0
- package/lib/commonjs/NativeNitroBSX.js.map +1 -0
- package/lib/commonjs/format.js +21 -0
- package/lib/commonjs/format.js.map +1 -0
- package/lib/commonjs/index.js +50 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/service.js +75 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js +6 -0
- package/lib/commonjs/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/module/NativeNitroBSX.js +124 -0
- package/lib/module/NativeNitroBSX.js.map +1 -0
- package/lib/module/format.js +15 -0
- package/lib/module/format.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/service.js +66 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/specs/NitroBSX.nitro.js +4 -0
- package/lib/module/specs/NitroBSX.nitro.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/commonjs/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/format.d.ts +3 -0
- package/lib/typescript/commonjs/src/format.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +5 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/service.d.ts +28 -0
- package/lib/typescript/commonjs/src/service.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/commonjs/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts +94 -0
- package/lib/typescript/module/src/NativeNitroBSX.d.ts.map +1 -0
- package/lib/typescript/module/src/format.d.ts +3 -0
- package/lib/typescript/module/src/format.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +5 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/service.d.ts +28 -0
- package/lib/typescript/module/src/service.d.ts.map +1 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts +251 -0
- package/lib/typescript/module/src/specs/NitroBSX.nitro.d.ts.map +1 -0
- package/nitro.json +19 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroBSX+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.cpp +49 -0
- package/nitrogen/generated/android/NitroBSXOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrobsx/NitroBSXOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroBSX+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroBSX-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NitroBSXAutolinking.swift +16 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.cpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroBSXSpec.hpp +142 -0
- package/nitrogen/generated/shared/c++/NotificationPair.hpp +87 -0
- package/nitrogen/generated/shared/c++/SignOutcome.hpp +80 -0
- package/nitrogen/generated/shared/c++/SignTxResult.hpp +89 -0
- package/package.json +172 -4
- package/react-native-nitro-bsx.podspec +33 -0
- package/react-native.config.js +26 -0
- package/scripts/build-ios.sh +49 -0
- package/src/NativeNitroBSX.ts +203 -0
- package/src/format.ts +14 -0
- package/src/index.ts +4 -0
- package/src/service.ts +77 -0
- package/src/specs/NitroBSX.nitro.ts +300 -0
|
@@ -0,0 +1,1196 @@
|
|
|
1
|
+
/*Copyright (c) 2026 The Basicswap developers
|
|
2
|
+
Distributed under the MIT software license, see the accompanying
|
|
3
|
+
file LICENSE or http://www.opensource.org/licenses/mit-license.php.*/
|
|
4
|
+
|
|
5
|
+
#include "node_client.h"
|
|
6
|
+
#include "coins/chainparams.h"
|
|
7
|
+
#include "coins/interface.h"
|
|
8
|
+
#include "coins/primitives.h"
|
|
9
|
+
#include "crypto/util.h"
|
|
10
|
+
#include "network/http_client.h"
|
|
11
|
+
#include "network/url.h"
|
|
12
|
+
#include "support/cleanse.h"
|
|
13
|
+
#include "uint256.h"
|
|
14
|
+
#include "util/log.h"
|
|
15
|
+
#include "util/str.h"
|
|
16
|
+
#include "util/tinyformat.h"
|
|
17
|
+
|
|
18
|
+
#include <mbedtls/base64.h>
|
|
19
|
+
|
|
20
|
+
#include <algorithm>
|
|
21
|
+
#include <climits>
|
|
22
|
+
#include <fstream>
|
|
23
|
+
#include <iterator>
|
|
24
|
+
#include <tuple>
|
|
25
|
+
#include <utility>
|
|
26
|
+
|
|
27
|
+
using nlohmann::json;
|
|
28
|
+
|
|
29
|
+
namespace bsx {
|
|
30
|
+
|
|
31
|
+
namespace {
|
|
32
|
+
|
|
33
|
+
constexpr int HEADERS_MAX = 2016;
|
|
34
|
+
// Block hashes kept to see a reorg by, deeper than any swap waits
|
|
35
|
+
constexpr int REORG_DEPTH = 300;
|
|
36
|
+
// As a wallet's rescan: a block's time can run this far behind its place in the chain
|
|
37
|
+
constexpr int64_t TIMESTAMP_WINDOW = 2 * 60 * 60;
|
|
38
|
+
|
|
39
|
+
std::string basicAuthorization(const char *credentials, size_t credentials_len)
|
|
40
|
+
{
|
|
41
|
+
std::vector<unsigned char> out(4 * ((credentials_len + 2) / 3) + 1);
|
|
42
|
+
size_t len = 0;
|
|
43
|
+
if (0 != mbedtls_base64_encode(out.data(), out.size(), &len,
|
|
44
|
+
reinterpret_cast<const unsigned char *>(credentials),
|
|
45
|
+
credentials_len)) {
|
|
46
|
+
return std::string();
|
|
47
|
+
}
|
|
48
|
+
std::string header = "Authorization: Basic " +
|
|
49
|
+
std::string(reinterpret_cast<const char *>(out.data()), len) + "\r\n";
|
|
50
|
+
memory_cleanse(out.data(), out.size());
|
|
51
|
+
return header;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
json errorReply(int code, const std::string &message)
|
|
55
|
+
{
|
|
56
|
+
return json{{"error", {{"code", code}, {"message", message}}}};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace
|
|
60
|
+
|
|
61
|
+
NodeClient::NodeClient(std::shared_ptr<TimeKeeper> time_keeper) : ChainClient(time_keeper)
|
|
62
|
+
{
|
|
63
|
+
m_have_verbose_tx = false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
NodeClient::~NodeClient()
|
|
67
|
+
{
|
|
68
|
+
stop();
|
|
69
|
+
memory_cleanse(m_authorization.data(), m_authorization.size());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
int NodeClient::initialise(const std::string &url, CoinInterface *ci, int id,
|
|
73
|
+
const std::string &cookie_file)
|
|
74
|
+
{
|
|
75
|
+
// Refused unlogged: a login in the URL would be a password in the log
|
|
76
|
+
const size_t authority = url.find("://");
|
|
77
|
+
if (authority != std::string::npos && url.find('@', authority) < url.find('/', authority + 3)) {
|
|
78
|
+
LOGE("NodeClient::initialise: a node URL takes no login; give the rpc user and password,"
|
|
79
|
+
" or its cookie file");
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
Url parsed;
|
|
83
|
+
std::string str_error;
|
|
84
|
+
if (0 != parseUrl(url, parsed, str_error)) {
|
|
85
|
+
LOGE("NodeClient::initialise %s: %s", url.c_str(), str_error.c_str());
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
if (parsed.protocol != "http") {
|
|
89
|
+
LOGE("NodeClient::initialise %s: only http:// is supported", url.c_str());
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
m_protocol = "tcp";
|
|
93
|
+
m_url = url;
|
|
94
|
+
m_host = parsed.host;
|
|
95
|
+
m_port = parsed.port;
|
|
96
|
+
m_ci = ci;
|
|
97
|
+
m_client_id = id;
|
|
98
|
+
m_cookie_file = cookie_file;
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void NodeClient::setLogin(const std::string &user, const SecureString &password)
|
|
103
|
+
{
|
|
104
|
+
{
|
|
105
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
106
|
+
m_user = user;
|
|
107
|
+
m_password = password;
|
|
108
|
+
m_login_changed = true;
|
|
109
|
+
}
|
|
110
|
+
m_ready = false;
|
|
111
|
+
m_cv.notify_all();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
int NodeClient::start(int64_t)
|
|
115
|
+
{
|
|
116
|
+
{
|
|
117
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
118
|
+
if (m_running || !m_ci) {
|
|
119
|
+
return 1;
|
|
120
|
+
}
|
|
121
|
+
m_running = true;
|
|
122
|
+
}
|
|
123
|
+
m_next_poll = 0;
|
|
124
|
+
m_worker = CoopThread(&NodeClient::worker, this);
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void NodeClient::requestStop()
|
|
129
|
+
{
|
|
130
|
+
{
|
|
131
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
132
|
+
m_running = false;
|
|
133
|
+
m_requests.clear();
|
|
134
|
+
m_pending.clear();
|
|
135
|
+
++m_generation;
|
|
136
|
+
}
|
|
137
|
+
m_cv.notify_all();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
int NodeClient::stop()
|
|
141
|
+
{
|
|
142
|
+
requestStop();
|
|
143
|
+
if (m_worker.joinable()) {
|
|
144
|
+
m_worker.join();
|
|
145
|
+
}
|
|
146
|
+
if (m_transport) {
|
|
147
|
+
m_transport->close();
|
|
148
|
+
m_transport.reset();
|
|
149
|
+
}
|
|
150
|
+
m_ready = false;
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
int NodeClient::clearPending()
|
|
155
|
+
{
|
|
156
|
+
{
|
|
157
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
158
|
+
m_requests.clear();
|
|
159
|
+
m_pending.clear();
|
|
160
|
+
++m_generation;
|
|
161
|
+
}
|
|
162
|
+
BSX_SCOPED_LOCK lock(m_mtx_response);
|
|
163
|
+
m_responses.clear();
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
bool NodeClient::running() const
|
|
168
|
+
{
|
|
169
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
170
|
+
return m_running;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
std::string NodeClient::lastError() const
|
|
174
|
+
{
|
|
175
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
176
|
+
return m_last_error;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
void NodeClient::setError(const std::string &error)
|
|
180
|
+
{
|
|
181
|
+
{
|
|
182
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
183
|
+
if (m_last_error == error) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
m_last_error = error;
|
|
187
|
+
}
|
|
188
|
+
if (!error.empty()) {
|
|
189
|
+
LOGW("NodeClient %s %s: %s", m_ci->coinTicker(), m_url.c_str(), error.c_str());
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
bool NodeClient::live(int64_t now)
|
|
194
|
+
{
|
|
195
|
+
return m_ready && now - m_last_answer.load() <= 3 * m_poll_seconds;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
int NodeClient::queue(Request request)
|
|
199
|
+
{
|
|
200
|
+
{
|
|
201
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
202
|
+
if (!m_running || !m_ready) {
|
|
203
|
+
return 1;
|
|
204
|
+
}
|
|
205
|
+
request.m_id = m_next_id++;
|
|
206
|
+
request.m_generation = m_generation;
|
|
207
|
+
request.m_message.m_time = getTime();
|
|
208
|
+
m_pending.insert(
|
|
209
|
+
{request.m_message.m_watched_id, static_cast<int>(request.m_message.m_message_type)});
|
|
210
|
+
m_requests.push_back(std::move(request));
|
|
211
|
+
}
|
|
212
|
+
m_cv.notify_one();
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
bool NodeClient::waitingForResponse(int64_t watched_id, ElectrumMessageTypes message_type) const
|
|
217
|
+
{
|
|
218
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
219
|
+
return m_pending.count({watched_id, static_cast<int>(message_type)}) > 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
int NodeClient::estimateFee(int conf_target, ElectrumMessageTypes msg_type)
|
|
223
|
+
{
|
|
224
|
+
Request request;
|
|
225
|
+
request.m_call = Calls::FEE;
|
|
226
|
+
request.m_number = conf_target;
|
|
227
|
+
request.m_message.m_message_type = msg_type;
|
|
228
|
+
request.m_message.m_watched_id = 0;
|
|
229
|
+
return queue(std::move(request));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
int NodeClient::relayFee()
|
|
233
|
+
{
|
|
234
|
+
Request request;
|
|
235
|
+
request.m_call = Calls::RELAY_FEE;
|
|
236
|
+
request.m_message.m_message_type = ElectrumMessageTypes::RELAY_FEE;
|
|
237
|
+
request.m_message.m_watched_id = 0;
|
|
238
|
+
return queue(std::move(request));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
int NodeClient::queueScript(Calls call, int64_t watched_id,
|
|
242
|
+
const std::vector<unsigned char> &script_pk,
|
|
243
|
+
ElectrumMessageTypes message_type)
|
|
244
|
+
{
|
|
245
|
+
{
|
|
246
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
247
|
+
m_watches.try_emplace(script_pk);
|
|
248
|
+
}
|
|
249
|
+
Request request;
|
|
250
|
+
request.m_call = call;
|
|
251
|
+
request.m_data = script_pk;
|
|
252
|
+
request.m_message.m_message_type = message_type;
|
|
253
|
+
request.m_message.m_watched_id = watched_id;
|
|
254
|
+
return queue(std::move(request));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
int NodeClient::listUnspent(int64_t watched_id, const std::vector<unsigned char> &script_pk,
|
|
258
|
+
ElectrumMessageTypes message_type)
|
|
259
|
+
{
|
|
260
|
+
return queueScript(Calls::UNSPENT, watched_id, script_pk, message_type);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
int NodeClient::getHistory(int64_t watched_id, const std::vector<unsigned char> &script_pk,
|
|
264
|
+
ElectrumMessageTypes message_type)
|
|
265
|
+
{
|
|
266
|
+
return queueScript(Calls::HISTORY, watched_id, script_pk, message_type);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
int NodeClient::subscribeScripthash(int64_t watched_id, const std::vector<unsigned char> &script_pk,
|
|
270
|
+
ElectrumMessageTypes message_type)
|
|
271
|
+
{
|
|
272
|
+
{
|
|
273
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
274
|
+
m_subscriptions[script_pk] = Subscription{watched_id, message_type, "", false};
|
|
275
|
+
}
|
|
276
|
+
return queueScript(Calls::STATUS, watched_id, script_pk, message_type);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
int NodeClient::forgetScripthash(const std::vector<unsigned char> &script_pk)
|
|
280
|
+
{
|
|
281
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
282
|
+
return m_subscriptions.erase(script_pk) ? 0 : 2;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
int NodeClient::unsubscribeScripthash(const std::vector<unsigned char> &script_pk)
|
|
286
|
+
{
|
|
287
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
288
|
+
m_subscriptions.erase(script_pk);
|
|
289
|
+
return 0;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
void NodeClient::watchSince(const std::vector<unsigned char> &script_pk, int64_t since)
|
|
293
|
+
{
|
|
294
|
+
if (since <= 0) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
298
|
+
ScriptWatch &watch = m_watches[script_pk];
|
|
299
|
+
if (watch.m_since == 0 || since < watch.m_since) {
|
|
300
|
+
// Placed again from the earlier time, so scanned again from there
|
|
301
|
+
watch.m_since = since;
|
|
302
|
+
watch.m_from = -1;
|
|
303
|
+
watch.m_done = false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
bool NodeClient::scanned(const std::vector<unsigned char> &script_pk) const
|
|
308
|
+
{
|
|
309
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
310
|
+
const auto it = m_watches.find(script_pk);
|
|
311
|
+
return it != m_watches.end() && it->second.m_done;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
int NodeClient::heightAtTime(int64_t time, int tip)
|
|
315
|
+
{
|
|
316
|
+
int low = 1, high = std::max(1, tip);
|
|
317
|
+
while (low < high) {
|
|
318
|
+
const int middle = low + (high - low) / 2;
|
|
319
|
+
json hash, header, error;
|
|
320
|
+
if (!call("getblockhash", json::array({middle}), hash, error) || !error.is_null() ||
|
|
321
|
+
!hash.is_string() ||
|
|
322
|
+
!call("getblockheader", json::array({hash, true}), header, error) || !error.is_null() ||
|
|
323
|
+
!header.is_object() || !header.contains("time")) {
|
|
324
|
+
return -1;
|
|
325
|
+
}
|
|
326
|
+
if (header["time"].get<int64_t>() >= time - TIMESTAMP_WINDOW) {
|
|
327
|
+
high = middle;
|
|
328
|
+
} else {
|
|
329
|
+
low = middle + 1;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
return low;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
void NodeClient::indexTx(const std::vector<unsigned char> &tx_data, int height)
|
|
336
|
+
{
|
|
337
|
+
std::set<std::vector<unsigned char>> watched;
|
|
338
|
+
{
|
|
339
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
340
|
+
for (const auto &[script, watch] : m_watches) {
|
|
341
|
+
watched.insert(script);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
auto tx = m_ci->getTransaction();
|
|
345
|
+
std::vector<unsigned char> txid_bytes(32);
|
|
346
|
+
if ((int)tx_data.size() != tx->from_bytes(tx_data.data(), tx_data.size()) ||
|
|
347
|
+
0 != tx->getTxid(txid_bytes.data())) {
|
|
348
|
+
LOGW("NodeClient %s %s: a tx at height %d doesn't parse", m_ci->coinTicker(), m_url.c_str(),
|
|
349
|
+
height);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const std::string txid = hex_str(txid_bytes);
|
|
353
|
+
for (size_t n = 0; n < tx->m_vout.size(); ++n) {
|
|
354
|
+
const auto *script = tx->m_vout[n]->script();
|
|
355
|
+
if (!script || !watched.count(*script)) {
|
|
356
|
+
continue;
|
|
357
|
+
}
|
|
358
|
+
m_scan_changed = true;
|
|
359
|
+
Funded &funded = m_outputs[{txid, (int)n}];
|
|
360
|
+
funded.m_script = *script;
|
|
361
|
+
funded.m_value = tx->m_vout[n]->value();
|
|
362
|
+
funded.m_height = height;
|
|
363
|
+
m_history[*script][txid] = height;
|
|
364
|
+
}
|
|
365
|
+
for (const auto &input : tx->m_vin) {
|
|
366
|
+
std::vector<unsigned char> prev(input->txid(), input->txid() + 32);
|
|
367
|
+
reverse_in_place(prev.data(), prev.size());
|
|
368
|
+
const auto it = m_outputs.find({hex_str(prev), input->vout()});
|
|
369
|
+
if (it == m_outputs.end()) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
it->second.m_spent_by = txid;
|
|
373
|
+
it->second.m_spent_height = height;
|
|
374
|
+
m_history[it->second.m_script][txid] = height;
|
|
375
|
+
m_scan_changed = true;
|
|
376
|
+
}
|
|
377
|
+
if (height > 0) {
|
|
378
|
+
m_unmined.erase(txid);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
void NodeClient::rewind(int height)
|
|
383
|
+
{
|
|
384
|
+
for (auto it = m_outputs.begin(); it != m_outputs.end();) {
|
|
385
|
+
if (it->second.m_spent_height >= height) {
|
|
386
|
+
it->second.m_spent_by.clear();
|
|
387
|
+
it->second.m_spent_height = -1;
|
|
388
|
+
}
|
|
389
|
+
it = it->second.m_height >= height ? m_outputs.erase(it) : std::next(it);
|
|
390
|
+
}
|
|
391
|
+
for (auto &[script, txs] : m_history) {
|
|
392
|
+
std::erase_if(txs, [&](const auto &entry) { return entry.second >= height; });
|
|
393
|
+
}
|
|
394
|
+
m_block_hashes.erase(m_block_hashes.lower_bound(height), m_block_hashes.end());
|
|
395
|
+
m_scanned_height = std::min(m_scanned_height, height - 1);
|
|
396
|
+
m_scan_changed = true;
|
|
397
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
398
|
+
for (auto &[script, watch] : m_watches) {
|
|
399
|
+
watch.m_done = false;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
void NodeClient::scanBlocks()
|
|
404
|
+
{
|
|
405
|
+
const int tip = m_tip_height;
|
|
406
|
+
std::map<std::vector<unsigned char>, ScriptWatch> watches;
|
|
407
|
+
{
|
|
408
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
409
|
+
watches = m_watches;
|
|
410
|
+
}
|
|
411
|
+
if (watches.empty()) {
|
|
412
|
+
m_scanned_height = tip;
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
std::vector<std::tuple<std::vector<unsigned char>, int64_t, int>> placed;
|
|
416
|
+
for (const auto &[script, watch] : watches) {
|
|
417
|
+
if (watch.m_from >= 0) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const int from = watch.m_since > 0 ? heightAtTime(watch.m_since, tip) : std::max(1, tip);
|
|
421
|
+
if (from < 0) {
|
|
422
|
+
// All or none: one placed without its rewind would miss the blocks already scanned
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
placed.emplace_back(script, watch.m_since, from);
|
|
426
|
+
}
|
|
427
|
+
int start = m_scanned_height + 1;
|
|
428
|
+
if (!placed.empty()) {
|
|
429
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
430
|
+
for (const auto &[script, since, from] : placed) {
|
|
431
|
+
const auto it = m_watches.find(script);
|
|
432
|
+
// Moved earlier by watchSince meanwhile: placed from its new time next pass
|
|
433
|
+
if (it != m_watches.end() && it->second.m_from < 0 && it->second.m_since == since) {
|
|
434
|
+
it->second.m_from = from;
|
|
435
|
+
start = std::min(start, from);
|
|
436
|
+
m_scan_changed = true;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (start <= m_scanned_height) {
|
|
441
|
+
rewind(start);
|
|
442
|
+
}
|
|
443
|
+
if (m_scanned_height < 0) {
|
|
444
|
+
int lowest = -1;
|
|
445
|
+
{
|
|
446
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
447
|
+
for (const auto &[script, watch] : m_watches) {
|
|
448
|
+
if (watch.m_from >= 0 && (lowest < 0 || watch.m_from < lowest)) {
|
|
449
|
+
lowest = watch.m_from;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (lowest < 0) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
m_scanned_height = lowest - 1;
|
|
457
|
+
}
|
|
458
|
+
json error;
|
|
459
|
+
for (int height = m_scanned_height + 1, n = 0;
|
|
460
|
+
height <= tip && n < m_scan_blocks_per_pass && running(); ++height, ++n) {
|
|
461
|
+
json hash, block;
|
|
462
|
+
if (!call("getblockhash", json::array({height}), hash, error) || !error.is_null() ||
|
|
463
|
+
!hash.is_string() || !call("getblock", json::array({hash, 2}), block, error)) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (!error.is_null()) {
|
|
467
|
+
const std::string message = error.value("message", "");
|
|
468
|
+
json info;
|
|
469
|
+
if (message.find("pruned") == std::string::npos ||
|
|
470
|
+
!call("getblockchaininfo", json::array(), info, error) || !error.is_null() ||
|
|
471
|
+
!info.contains("pruneheight")) {
|
|
472
|
+
setError("The node did not give block " + std::to_string(height) + ": " + message);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
// As basicswap: on from the prune height, the watches before it missing what it held
|
|
476
|
+
const int prune_height = info["pruneheight"].get<int>();
|
|
477
|
+
LOGE("NodeClient %s %s: block %d is pruned, scanning on from %d", m_ci->coinTicker(),
|
|
478
|
+
m_url.c_str(), height, prune_height);
|
|
479
|
+
m_scanned_height = std::max(m_scanned_height, prune_height - 1);
|
|
480
|
+
height = m_scanned_height;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
const auto below = m_block_hashes.find(height - 1);
|
|
484
|
+
if (below != m_block_hashes.end() &&
|
|
485
|
+
below->second != block.value("previousblockhash", "")) {
|
|
486
|
+
LOGI("NodeClient %s %s: block %d doesn't follow the one scanned below it",
|
|
487
|
+
m_ci->coinTicker(), m_url.c_str(), height);
|
|
488
|
+
rewind(height - 1);
|
|
489
|
+
height = m_scanned_height;
|
|
490
|
+
continue;
|
|
491
|
+
}
|
|
492
|
+
if (!block.contains("tx") || !block["tx"].is_array()) {
|
|
493
|
+
setError("The node's getblock gave no transactions");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
for (const auto &tx : block["tx"]) {
|
|
497
|
+
std::vector<unsigned char> data;
|
|
498
|
+
if (!tx.is_object() || !tx.contains("hex") || !tx["hex"].is_string() ||
|
|
499
|
+
0 != decode_hex(data, tx["hex"].get<std::string>())) {
|
|
500
|
+
setError("The node's getblock gave a transaction without its hex");
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
indexTx(data, height);
|
|
504
|
+
}
|
|
505
|
+
m_block_hashes[height] = hash.get<std::string>();
|
|
506
|
+
m_block_hashes.erase(m_block_hashes.begin(),
|
|
507
|
+
m_block_hashes.lower_bound(height - REORG_DEPTH));
|
|
508
|
+
m_scanned_height = height;
|
|
509
|
+
m_scan_changed = true;
|
|
510
|
+
}
|
|
511
|
+
if (m_scanned_height < tip) {
|
|
512
|
+
// On straight after the queued requests
|
|
513
|
+
m_next_poll = getTime();
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
517
|
+
for (auto &[script, watch] : m_watches) {
|
|
518
|
+
if (watch.m_from >= 0) {
|
|
519
|
+
watch.m_done = true;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
void NodeClient::dropUnmined()
|
|
525
|
+
{
|
|
526
|
+
if (m_scanned_height < m_tip_height) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
for (auto it = m_unmined.begin(); it != m_unmined.end();) {
|
|
530
|
+
json entry, error;
|
|
531
|
+
if (!call("getmempoolentry", json::array({*it}), entry, error)) {
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
if (error.is_null()) {
|
|
535
|
+
++it;
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
const std::string txid = *it;
|
|
539
|
+
LOGI("NodeClient %s %s: tx %s left the node's mempool unmined", m_ci->coinTicker(),
|
|
540
|
+
m_url.c_str(), txid.c_str());
|
|
541
|
+
for (auto out = m_outputs.begin(); out != m_outputs.end();) {
|
|
542
|
+
if (out->second.m_spent_by == txid && out->second.m_spent_height == 0) {
|
|
543
|
+
out->second.m_spent_by.clear();
|
|
544
|
+
out->second.m_spent_height = -1;
|
|
545
|
+
}
|
|
546
|
+
out = out->first.first == txid && out->second.m_height == 0 ? m_outputs.erase(out)
|
|
547
|
+
: std::next(out);
|
|
548
|
+
}
|
|
549
|
+
for (auto &[script, txs] : m_history) {
|
|
550
|
+
const auto found = txs.find(txid);
|
|
551
|
+
if (found != txs.end() && found->second == 0) {
|
|
552
|
+
txs.erase(found);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
it = m_unmined.erase(it);
|
|
556
|
+
m_scan_changed = true;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
void NodeClient::restoreScan(const NodeScan &scan)
|
|
561
|
+
{
|
|
562
|
+
m_block_hashes = scan.m_block_hashes;
|
|
563
|
+
m_scanned_height = m_block_hashes.empty() ? -1 : m_block_hashes.rbegin()->first;
|
|
564
|
+
m_outputs.clear();
|
|
565
|
+
m_history.clear();
|
|
566
|
+
m_unmined.clear();
|
|
567
|
+
for (const auto &output : scan.m_outputs) {
|
|
568
|
+
m_outputs[{output.m_txid, output.m_n}] =
|
|
569
|
+
Funded{output.m_script, output.m_value, output.m_height, output.m_spent_by,
|
|
570
|
+
output.m_spent_height};
|
|
571
|
+
m_history[output.m_script][output.m_txid] = output.m_height;
|
|
572
|
+
if (output.m_height == 0) {
|
|
573
|
+
m_unmined.insert(output.m_txid);
|
|
574
|
+
}
|
|
575
|
+
if (!output.m_spent_by.empty()) {
|
|
576
|
+
m_history[output.m_script][output.m_spent_by] = output.m_spent_height;
|
|
577
|
+
if (output.m_spent_height == 0) {
|
|
578
|
+
m_unmined.insert(output.m_spent_by);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
583
|
+
for (const auto &[script, watch] : scan.m_watches) {
|
|
584
|
+
ScriptWatch &restored = m_watches[script];
|
|
585
|
+
restored.m_since = watch.m_since;
|
|
586
|
+
restored.m_from = watch.m_from;
|
|
587
|
+
// Done once the scan reaches the node's tip, which has moved on since the scan was kept
|
|
588
|
+
restored.m_done = false;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
void NodeClient::publishScan()
|
|
593
|
+
{
|
|
594
|
+
if (!m_scan_changed) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
m_scan_changed = false;
|
|
598
|
+
auto scan = std::make_shared<NodeScan>();
|
|
599
|
+
scan->m_block_hashes = m_block_hashes;
|
|
600
|
+
for (const auto &[outpoint, funded] : m_outputs) {
|
|
601
|
+
scan->m_outputs.push_back(NodeScan::Output{outpoint.first, outpoint.second, funded.m_script,
|
|
602
|
+
funded.m_value, funded.m_height,
|
|
603
|
+
funded.m_spent_by, funded.m_spent_height});
|
|
604
|
+
}
|
|
605
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
606
|
+
for (const auto &[script, watch] : m_watches) {
|
|
607
|
+
if (watch.m_from >= 0) {
|
|
608
|
+
scan->m_watches[script] = NodeScan::Watch{watch.m_since, watch.m_from};
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
m_published_scan = std::move(scan);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
std::shared_ptr<const NodeScan> NodeClient::takeScan()
|
|
615
|
+
{
|
|
616
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
617
|
+
return std::exchange(m_published_scan, nullptr);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
int NodeClient::foundHeight(const std::string &txid) const
|
|
621
|
+
{
|
|
622
|
+
for (const auto &[script, txs] : m_history) {
|
|
623
|
+
const auto it = txs.find(txid);
|
|
624
|
+
if (it != txs.end() && it->second > 0) {
|
|
625
|
+
return it->second;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return -1;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
json NodeClient::historyOf(const std::vector<unsigned char> &script_pk) const
|
|
632
|
+
{
|
|
633
|
+
std::vector<std::pair<int, std::string>> entries;
|
|
634
|
+
const auto it = m_history.find(script_pk);
|
|
635
|
+
if (it != m_history.end()) {
|
|
636
|
+
for (const auto &[txid, height] : it->second) {
|
|
637
|
+
entries.push_back({height, txid});
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
// Electrum's order: by height, unmined last
|
|
641
|
+
std::sort(entries.begin(), entries.end(), [](const auto &a, const auto &b) {
|
|
642
|
+
const int ha = a.first > 0 ? a.first : INT_MAX, hb = b.first > 0 ? b.first : INT_MAX;
|
|
643
|
+
return ha != hb ? ha < hb : a.second < b.second;
|
|
644
|
+
});
|
|
645
|
+
json history = json::array();
|
|
646
|
+
for (const auto &[height, txid] : entries) {
|
|
647
|
+
history.push_back({{"tx_hash", txid}, {"height", height}});
|
|
648
|
+
}
|
|
649
|
+
return history;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
json NodeClient::unspentOf(const std::vector<unsigned char> &script_pk) const
|
|
653
|
+
{
|
|
654
|
+
json unspent = json::array();
|
|
655
|
+
for (const auto &[outpoint, funded] : m_outputs) {
|
|
656
|
+
if (funded.m_script == script_pk && funded.m_spent_by.empty()) {
|
|
657
|
+
unspent.push_back({{"tx_hash", outpoint.first},
|
|
658
|
+
{"tx_pos", outpoint.second},
|
|
659
|
+
{"height", funded.m_height},
|
|
660
|
+
{"value", funded.m_value}});
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return unspent;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
json NodeClient::statusOf(const std::vector<unsigned char> &script_pk) const
|
|
667
|
+
{
|
|
668
|
+
// As an Electrum server's: the hash of each tx_hash:height: in history order, or null
|
|
669
|
+
const json history = historyOf(script_pk);
|
|
670
|
+
if (history.empty()) {
|
|
671
|
+
return json();
|
|
672
|
+
}
|
|
673
|
+
std::string joined;
|
|
674
|
+
for (const auto &entry : history) {
|
|
675
|
+
joined += entry["tx_hash"].get<std::string>() + ":" +
|
|
676
|
+
std::to_string(entry["height"].get<int>()) + ":";
|
|
677
|
+
}
|
|
678
|
+
std::vector<unsigned char> digest(32);
|
|
679
|
+
sha256(digest.data(), reinterpret_cast<const unsigned char *>(joined.data()), joined.size());
|
|
680
|
+
return hex_str(digest);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
void NodeClient::notifyStatuses()
|
|
684
|
+
{
|
|
685
|
+
std::vector<std::pair<std::vector<unsigned char>, Subscription>> told;
|
|
686
|
+
{
|
|
687
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
688
|
+
for (const auto &[script, subscription] : m_subscriptions) {
|
|
689
|
+
const auto watch = m_watches.find(script);
|
|
690
|
+
if (subscription.m_told && watch != m_watches.end() && watch->second.m_done) {
|
|
691
|
+
told.push_back({script, subscription});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
for (const auto &[script, subscription] : told) {
|
|
696
|
+
const json status = statusOf(script);
|
|
697
|
+
const std::string now = status.is_string() ? status.get<std::string>() : "";
|
|
698
|
+
if (now == subscription.m_status) {
|
|
699
|
+
continue;
|
|
700
|
+
}
|
|
701
|
+
{
|
|
702
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
703
|
+
const auto it = m_subscriptions.find(script);
|
|
704
|
+
if (it == m_subscriptions.end()) {
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
it->second.m_status = now;
|
|
708
|
+
}
|
|
709
|
+
Request notice;
|
|
710
|
+
notice.m_id = static_cast<size_t>(-1);
|
|
711
|
+
notice.m_message.m_message_type = subscription.m_message_type;
|
|
712
|
+
notice.m_message.m_watched_id = subscription.m_watched_id;
|
|
713
|
+
notice.m_message.m_time = getTime();
|
|
714
|
+
respond(notice, json{{"result", status}});
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
int NodeClient::getTransaction(int64_t watched_id, const std::vector<unsigned char> &txid,
|
|
719
|
+
ElectrumMessageTypes message_type)
|
|
720
|
+
{
|
|
721
|
+
Request request;
|
|
722
|
+
request.m_call = Calls::TRANSACTION;
|
|
723
|
+
request.m_data = txid;
|
|
724
|
+
request.m_message.m_message_type = message_type;
|
|
725
|
+
request.m_message.m_watched_id = watched_id;
|
|
726
|
+
request.m_message.m_txid = txid;
|
|
727
|
+
return queue(std::move(request));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
int NodeClient::getBlockHeader(int64_t watched_id, int block_height,
|
|
731
|
+
ElectrumMessageTypes message_type)
|
|
732
|
+
{
|
|
733
|
+
Request request;
|
|
734
|
+
request.m_call = Calls::HEADER;
|
|
735
|
+
request.m_number = block_height;
|
|
736
|
+
request.m_message.m_message_type = message_type;
|
|
737
|
+
request.m_message.m_watched_id = watched_id;
|
|
738
|
+
request.m_message.m_height = block_height;
|
|
739
|
+
return queue(std::move(request));
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
int NodeClient::getBlockHeaders(int64_t watched_id, int start_height, int count,
|
|
743
|
+
ElectrumMessageTypes message_type)
|
|
744
|
+
{
|
|
745
|
+
if (count <= 0) {
|
|
746
|
+
return 1;
|
|
747
|
+
}
|
|
748
|
+
Request request;
|
|
749
|
+
request.m_call = Calls::HEADERS;
|
|
750
|
+
request.m_number = start_height;
|
|
751
|
+
request.m_count = std::min(count, HEADERS_MAX);
|
|
752
|
+
request.m_message.m_message_type = message_type;
|
|
753
|
+
request.m_message.m_watched_id = watched_id;
|
|
754
|
+
request.m_message.m_height = start_height;
|
|
755
|
+
return queue(std::move(request));
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
int NodeClient::getStakeProofs(int64_t, int, int, int, ElectrumMessageTypes) { return 1; }
|
|
759
|
+
|
|
760
|
+
int NodeClient::getMerklePath(int64_t, const std::vector<unsigned char> &, int,
|
|
761
|
+
ElectrumMessageTypes)
|
|
762
|
+
{
|
|
763
|
+
return 1;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
int NodeClient::submitTransaction(int64_t action_id, const std::vector<unsigned char> &tx_data)
|
|
767
|
+
{
|
|
768
|
+
Request request;
|
|
769
|
+
request.m_call = Calls::BROADCAST;
|
|
770
|
+
request.m_data = tx_data;
|
|
771
|
+
request.m_message.m_message_type = ElectrumMessageTypes::BROADCAST_TRANSACTION;
|
|
772
|
+
request.m_message.m_watched_id = action_id;
|
|
773
|
+
std::vector<unsigned char> tx_bytes(tx_data);
|
|
774
|
+
if (0 != m_ci->getTxid(request.m_message.m_txid, tx_bytes)) {
|
|
775
|
+
request.m_message.m_txid.clear();
|
|
776
|
+
}
|
|
777
|
+
return queue(std::move(request));
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
bool NodeClient::post(const json &body, json &reply)
|
|
781
|
+
{
|
|
782
|
+
if (!m_transport || !m_transport->isActive()) {
|
|
783
|
+
m_transport = makeTransport(m_protocol, nullptr, {}, m_proxy);
|
|
784
|
+
if (!m_transport || !m_transport->setAddress(m_host.c_str(), m_port) ||
|
|
785
|
+
!m_transport->connect()) {
|
|
786
|
+
m_transport.reset();
|
|
787
|
+
setError("Could not connect to the node");
|
|
788
|
+
return false;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
HttpResponse http;
|
|
792
|
+
std::string str_error;
|
|
793
|
+
const std::string host = m_host + ":" + std::to_string(m_port);
|
|
794
|
+
if (0 != httpRequest(
|
|
795
|
+
http, *m_transport, "POST", host, "/", body.dump(),
|
|
796
|
+
static_cast<int>(m_request_timeout * 1000), 64 * 1024 * 1024, str_error,
|
|
797
|
+
[this] { return !running(); }, m_authorization)) {
|
|
798
|
+
m_transport->close();
|
|
799
|
+
m_transport.reset();
|
|
800
|
+
setError("The node did not answer: " + str_error);
|
|
801
|
+
return false;
|
|
802
|
+
}
|
|
803
|
+
if (!http.keep_alive) {
|
|
804
|
+
m_transport->close();
|
|
805
|
+
m_transport.reset();
|
|
806
|
+
}
|
|
807
|
+
if (http.status == 401 || http.status == 403) {
|
|
808
|
+
setError("The node refused the RPC login");
|
|
809
|
+
return false;
|
|
810
|
+
}
|
|
811
|
+
reply = json::parse(http.body, nullptr, false);
|
|
812
|
+
if (reply.is_discarded()) {
|
|
813
|
+
setError("The node's reply is not JSON (HTTP " + std::to_string(http.status) + ")");
|
|
814
|
+
return false;
|
|
815
|
+
}
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
bool NodeClient::call(const std::string &method, const json ¶ms, json &result, json &error)
|
|
820
|
+
{
|
|
821
|
+
json reply;
|
|
822
|
+
if (!post(json{{"jsonrpc", "1.0"}, {"id", 0}, {"method", method}, {"params", params}}, reply) ||
|
|
823
|
+
!reply.is_object()) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
error = reply.value("error", json());
|
|
827
|
+
result = reply.value("result", json());
|
|
828
|
+
return true;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
bool NodeClient::connectToNode()
|
|
832
|
+
{
|
|
833
|
+
if (!m_cookie_file.empty()) {
|
|
834
|
+
std::ifstream file(m_cookie_file);
|
|
835
|
+
std::string cookie((std::istreambuf_iterator<char>(file)),
|
|
836
|
+
std::istreambuf_iterator<char>());
|
|
837
|
+
while (!cookie.empty() && (cookie.back() == '\n' || cookie.back() == '\r')) {
|
|
838
|
+
cookie.pop_back();
|
|
839
|
+
}
|
|
840
|
+
if (cookie.empty()) {
|
|
841
|
+
setError("Could not read the cookie file " + m_cookie_file);
|
|
842
|
+
return false;
|
|
843
|
+
}
|
|
844
|
+
m_authorization = basicAuthorization(cookie.data(), cookie.size());
|
|
845
|
+
memory_cleanse(cookie.data(), cookie.size());
|
|
846
|
+
} else {
|
|
847
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
848
|
+
SecureString login(m_user.begin(), m_user.end());
|
|
849
|
+
login += ':';
|
|
850
|
+
login += m_password;
|
|
851
|
+
m_authorization = basicAuthorization(login.data(), login.size());
|
|
852
|
+
}
|
|
853
|
+
json result, error;
|
|
854
|
+
if (!call("getblockhash", json::array({0}), result, error)) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
const ChainParams *params = m_ci->chainParams();
|
|
858
|
+
if (!error.is_null() || !result.is_string() || !params) {
|
|
859
|
+
setError("The node did not give its genesis block");
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
if (result.get<std::string>() != params->m_genesis_hash.ToString()) {
|
|
863
|
+
setError("The node is on another chain: its genesis block is " + result.get<std::string>());
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
866
|
+
m_tip_hash.clear();
|
|
867
|
+
return true;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
void NodeClient::pollTip()
|
|
871
|
+
{
|
|
872
|
+
json info, error;
|
|
873
|
+
if (!call("getblockchaininfo", json::array(), info, error)) {
|
|
874
|
+
m_ready = false;
|
|
875
|
+
return;
|
|
876
|
+
}
|
|
877
|
+
if (!error.is_null() || !info.is_object() || !info.contains("blocks") ||
|
|
878
|
+
!info.contains("bestblockhash")) {
|
|
879
|
+
setError("The node's getblockchaininfo reply is malformed");
|
|
880
|
+
m_ready = false;
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
if (info.value("initialblockdownload", false)) {
|
|
884
|
+
setError("The node is still syncing");
|
|
885
|
+
m_ready = false;
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
m_last_answer = getTime();
|
|
889
|
+
setError("");
|
|
890
|
+
m_ready = true;
|
|
891
|
+
const int height = info["blocks"].get<int>();
|
|
892
|
+
m_tip_height = height;
|
|
893
|
+
if (m_ci->anchorHeight() < 0 && !anchorAt(m_ci->anchorHeightForTip(height))) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
896
|
+
const std::string best = info["bestblockhash"].get<std::string>();
|
|
897
|
+
if (best == m_tip_hash) {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
auto header = headerFor(best);
|
|
901
|
+
if (!header) {
|
|
902
|
+
setError("The node did not give its tip header");
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
m_tip_hash = best;
|
|
906
|
+
m_ci->setServerTipHeight(m_client_id, height);
|
|
907
|
+
m_ci->newBlockHeaderDBLock(height, header);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
std::shared_ptr<BlockHeader> NodeClient::headerFor(const std::string &hash)
|
|
911
|
+
{
|
|
912
|
+
json header_hex, error;
|
|
913
|
+
if (!call("getblockheader", json::array({hash, false}), header_hex, error) ||
|
|
914
|
+
!error.is_null() || !header_hex.is_string()) {
|
|
915
|
+
return nullptr;
|
|
916
|
+
}
|
|
917
|
+
std::vector<unsigned char> data;
|
|
918
|
+
auto header = m_ci->getBlockHeader();
|
|
919
|
+
if (0 != decode_hex(data, header_hex.get<std::string>()) ||
|
|
920
|
+
0 >= header->from_bytes(data.data(), data.size())) {
|
|
921
|
+
return nullptr;
|
|
922
|
+
}
|
|
923
|
+
return header;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
bool NodeClient::anchorAt(int height)
|
|
927
|
+
{
|
|
928
|
+
json hash, verbose, error;
|
|
929
|
+
if (!call("getblockhash", json::array({height}), hash, error) || !error.is_null() ||
|
|
930
|
+
!hash.is_string() || !call("getblockheader", json::array({hash, true}), verbose, error) ||
|
|
931
|
+
!error.is_null() || !verbose.is_object()) {
|
|
932
|
+
setError(strprintf("The node did not give block %d for the chain anchor", height));
|
|
933
|
+
return false;
|
|
934
|
+
}
|
|
935
|
+
auto header = headerFor(hash.get<std::string>());
|
|
936
|
+
auto parent = height > 0 ? headerFor(verbose.value("previousblockhash", "")) : nullptr;
|
|
937
|
+
if (!header || (height > 0 && !parent)) {
|
|
938
|
+
setError(strprintf("The node did not give block %d for the chain anchor", height));
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
if (!m_ci->newChainAnchorDBLock(height, uint256S(verbose.value("chainwork", "").c_str()),
|
|
942
|
+
header, parent)) {
|
|
943
|
+
setError(strprintf("Block %d from the node was refused as the chain anchor", height));
|
|
944
|
+
return false;
|
|
945
|
+
}
|
|
946
|
+
LOGI("%s chain anchor %d %s from the node", m_ci->coinTicker(), height,
|
|
947
|
+
hash.get<std::string>().c_str());
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
bool NodeClient::answer(const Request &request, json &reply)
|
|
952
|
+
{
|
|
953
|
+
json result, error;
|
|
954
|
+
switch (request.m_call) {
|
|
955
|
+
case Calls::FEE: {
|
|
956
|
+
if (!call("estimatesmartfee", json::array({request.m_number}), result, error)) {
|
|
957
|
+
return false;
|
|
958
|
+
}
|
|
959
|
+
if (!error.is_null()) {
|
|
960
|
+
reply = json{{"error", error}};
|
|
961
|
+
} else {
|
|
962
|
+
// Electrum's estimatefee answers -1 when there is no estimate
|
|
963
|
+
reply = json{{"result", result.is_object() && result.contains("feerate")
|
|
964
|
+
? result["feerate"]
|
|
965
|
+
: json(-1)}};
|
|
966
|
+
}
|
|
967
|
+
return true;
|
|
968
|
+
}
|
|
969
|
+
case Calls::RELAY_FEE: {
|
|
970
|
+
if (!call("getnetworkinfo", json::array(), result, error)) {
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
reply = !error.is_null() ? json{{"error", error}}
|
|
974
|
+
: result.is_object() && result.contains("relayfee")
|
|
975
|
+
? json{{"result", result["relayfee"]}}
|
|
976
|
+
: errorReply(-1, "getnetworkinfo has no relayfee");
|
|
977
|
+
return true;
|
|
978
|
+
}
|
|
979
|
+
case Calls::TRANSACTION:
|
|
980
|
+
case Calls::BROADCAST: {
|
|
981
|
+
const bool broadcast = request.m_call == Calls::BROADCAST;
|
|
982
|
+
json params = broadcast ? json::array({hex_str(request.m_data)})
|
|
983
|
+
: json::array({hex_str(request.m_data), false});
|
|
984
|
+
// Named by its block, so a node without -txindex can still serve it
|
|
985
|
+
const int found = broadcast ? -1 : foundHeight(hex_str(request.m_data));
|
|
986
|
+
if (found > 0) {
|
|
987
|
+
const auto block = m_block_hashes.find(found);
|
|
988
|
+
json hash, hash_error;
|
|
989
|
+
if (block != m_block_hashes.end()) {
|
|
990
|
+
params.push_back(block->second);
|
|
991
|
+
} else if (call("getblockhash", json::array({found}), hash, hash_error) &&
|
|
992
|
+
hash_error.is_null() && hash.is_string()) {
|
|
993
|
+
params.push_back(hash);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (!call(broadcast ? "sendrawtransaction" : "getrawtransaction", params, result,
|
|
997
|
+
error)) {
|
|
998
|
+
return false;
|
|
999
|
+
}
|
|
1000
|
+
if (broadcast && error.is_null() && result.is_string()) {
|
|
1001
|
+
// Others' txs show once mined, as in basicswap; the module's own from its send
|
|
1002
|
+
m_unmined.insert(hex_str(request.m_message.m_txid));
|
|
1003
|
+
indexTx(request.m_data, 0);
|
|
1004
|
+
}
|
|
1005
|
+
reply = !error.is_null() ? json{{"error", error}} : json{{"result", result}};
|
|
1006
|
+
return true;
|
|
1007
|
+
}
|
|
1008
|
+
case Calls::HISTORY:
|
|
1009
|
+
reply = json{{"result", historyOf(request.m_data)}};
|
|
1010
|
+
return true;
|
|
1011
|
+
case Calls::UNSPENT:
|
|
1012
|
+
reply = json{{"result", unspentOf(request.m_data)}};
|
|
1013
|
+
return true;
|
|
1014
|
+
case Calls::STATUS: {
|
|
1015
|
+
const json status = statusOf(request.m_data);
|
|
1016
|
+
{
|
|
1017
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
1018
|
+
const auto it = m_subscriptions.find(request.m_data);
|
|
1019
|
+
if (it != m_subscriptions.end()) {
|
|
1020
|
+
it->second.m_status = status.is_string() ? status.get<std::string>() : "";
|
|
1021
|
+
it->second.m_told = true;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
reply = json{{"result", status}};
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
case Calls::HEADER: {
|
|
1028
|
+
if (!call("getblockhash", json::array({request.m_number}), result, error)) {
|
|
1029
|
+
return false;
|
|
1030
|
+
}
|
|
1031
|
+
if (!error.is_null()) {
|
|
1032
|
+
reply = json{{"error", error}};
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
1035
|
+
const json hash = result;
|
|
1036
|
+
if (!call("getblockheader", json::array({hash, false}), result, error)) {
|
|
1037
|
+
return false;
|
|
1038
|
+
}
|
|
1039
|
+
reply = !error.is_null() ? json{{"error", error}} : json{{"result", result}};
|
|
1040
|
+
return true;
|
|
1041
|
+
}
|
|
1042
|
+
case Calls::HEADERS: {
|
|
1043
|
+
json hashes_call = json::array();
|
|
1044
|
+
for (int i = 0; i < request.m_count; ++i) {
|
|
1045
|
+
hashes_call.push_back(json{{"jsonrpc", "1.0"},
|
|
1046
|
+
{"id", i},
|
|
1047
|
+
{"method", "getblockhash"},
|
|
1048
|
+
{"params", json::array({request.m_number + i})}});
|
|
1049
|
+
}
|
|
1050
|
+
json hashes;
|
|
1051
|
+
if (!post(hashes_call, hashes) || !hashes.is_array()) {
|
|
1052
|
+
return false;
|
|
1053
|
+
}
|
|
1054
|
+
// Electrum's headers stop at the tip, so they stop at the first height the node refuses
|
|
1055
|
+
json headers_call = json::array();
|
|
1056
|
+
for (const auto &entry : hashes) {
|
|
1057
|
+
if (!entry.value("error", json()).is_null() ||
|
|
1058
|
+
!entry.value("result", json()).is_string()) {
|
|
1059
|
+
break;
|
|
1060
|
+
}
|
|
1061
|
+
headers_call.push_back(json{{"jsonrpc", "1.0"},
|
|
1062
|
+
{"id", headers_call.size()},
|
|
1063
|
+
{"method", "getblockheader"},
|
|
1064
|
+
{"params", json::array({entry["result"], false})}});
|
|
1065
|
+
}
|
|
1066
|
+
std::string hex;
|
|
1067
|
+
if (!headers_call.empty()) {
|
|
1068
|
+
json headers;
|
|
1069
|
+
if (!post(headers_call, headers) || !headers.is_array() ||
|
|
1070
|
+
headers.size() != headers_call.size()) {
|
|
1071
|
+
return false;
|
|
1072
|
+
}
|
|
1073
|
+
for (const auto &entry : headers) {
|
|
1074
|
+
if (!entry.value("error", json()).is_null() ||
|
|
1075
|
+
!entry.value("result", json()).is_string()) {
|
|
1076
|
+
return false;
|
|
1077
|
+
}
|
|
1078
|
+
hex += entry["result"].get<std::string>();
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
reply = json{
|
|
1082
|
+
{"result", {{"count", headers_call.size()}, {"hex", hex}, {"max", HEADERS_MAX}}}};
|
|
1083
|
+
return true;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
void NodeClient::respond(const Request &request, json reply)
|
|
1090
|
+
{
|
|
1091
|
+
auto response = std::make_shared<ElectrumResponse>();
|
|
1092
|
+
response->m_time = getTime();
|
|
1093
|
+
response->m_request_id = static_cast<int>(request.m_id);
|
|
1094
|
+
response->m_coin_type = m_ci->coinType();
|
|
1095
|
+
response->m_client_id = m_client_id;
|
|
1096
|
+
response->m_request = request.m_message;
|
|
1097
|
+
response->m_jdata = std::move(reply);
|
|
1098
|
+
{
|
|
1099
|
+
BSX_SCOPED_LOCK lock(m_mtx_response);
|
|
1100
|
+
m_responses.push_back(response);
|
|
1101
|
+
}
|
|
1102
|
+
if (m_notify_main_loop) {
|
|
1103
|
+
m_notify_main_loop();
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
void NodeClient::worker()
|
|
1108
|
+
{
|
|
1109
|
+
const auto byScript = [](Calls call) {
|
|
1110
|
+
return call == Calls::HISTORY || call == Calls::UNSPENT || call == Calls::STATUS;
|
|
1111
|
+
};
|
|
1112
|
+
while (running()) {
|
|
1113
|
+
if (getTime() >= m_next_poll) {
|
|
1114
|
+
m_next_poll = getTime() + m_poll_seconds;
|
|
1115
|
+
try {
|
|
1116
|
+
if (m_ready || connectToNode()) {
|
|
1117
|
+
pollTip();
|
|
1118
|
+
if (m_ready) {
|
|
1119
|
+
scanBlocks();
|
|
1120
|
+
dropUnmined();
|
|
1121
|
+
notifyStatuses();
|
|
1122
|
+
publishScan();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
} catch (const std::exception &e) {
|
|
1126
|
+
setError(std::string("The node's reply is malformed: ") + e.what());
|
|
1127
|
+
m_ready = false;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
Request request;
|
|
1131
|
+
const auto waited = std::find_if(m_waiting.begin(), m_waiting.end(),
|
|
1132
|
+
[&](const Request &r) { return scanned(r.m_data); });
|
|
1133
|
+
if (waited != m_waiting.end()) {
|
|
1134
|
+
request = std::move(*waited);
|
|
1135
|
+
m_waiting.erase(waited);
|
|
1136
|
+
} else {
|
|
1137
|
+
std::unique_lock<std::mutex> lock(m_mtx);
|
|
1138
|
+
const int wait = static_cast<int>(std::max<int64_t>(0, m_next_poll - getTime()) * 1000);
|
|
1139
|
+
coopWait(lock, m_cv, wait,
|
|
1140
|
+
[this] { return !m_running || !m_requests.empty() || m_login_changed; });
|
|
1141
|
+
if (m_login_changed) {
|
|
1142
|
+
m_login_changed = false;
|
|
1143
|
+
m_next_poll = 0;
|
|
1144
|
+
continue;
|
|
1145
|
+
}
|
|
1146
|
+
if (!m_running || m_requests.empty()) {
|
|
1147
|
+
continue;
|
|
1148
|
+
}
|
|
1149
|
+
request = std::move(m_requests.front());
|
|
1150
|
+
m_requests.pop_front();
|
|
1151
|
+
}
|
|
1152
|
+
if (byScript(request.m_call) && !scanned(request.m_data)) {
|
|
1153
|
+
// Answered once its blocks are scanned, which starts now
|
|
1154
|
+
m_waiting.push_back(std::move(request));
|
|
1155
|
+
m_next_poll = std::min(m_next_poll, getTime());
|
|
1156
|
+
continue;
|
|
1157
|
+
}
|
|
1158
|
+
json reply;
|
|
1159
|
+
bool answered = false;
|
|
1160
|
+
try {
|
|
1161
|
+
answered = answer(request, reply);
|
|
1162
|
+
} catch (const std::exception &e) {
|
|
1163
|
+
setError(std::string("The node's reply is malformed: ") + e.what());
|
|
1164
|
+
}
|
|
1165
|
+
bool current;
|
|
1166
|
+
{
|
|
1167
|
+
std::lock_guard<std::mutex> lock(m_mtx);
|
|
1168
|
+
current = request.m_generation == m_generation;
|
|
1169
|
+
if (current) {
|
|
1170
|
+
auto it = m_pending.find({request.m_message.m_watched_id,
|
|
1171
|
+
static_cast<int>(request.m_message.m_message_type)});
|
|
1172
|
+
if (it != m_pending.end()) {
|
|
1173
|
+
m_pending.erase(it);
|
|
1174
|
+
}
|
|
1175
|
+
if (!answered) {
|
|
1176
|
+
// As on a dropped Electrum connection, nothing asked so far is answered
|
|
1177
|
+
m_requests.clear();
|
|
1178
|
+
m_pending.clear();
|
|
1179
|
+
++m_generation;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (!answered) {
|
|
1184
|
+
m_waiting.clear();
|
|
1185
|
+
m_ready = false;
|
|
1186
|
+
m_next_poll = 0;
|
|
1187
|
+
continue;
|
|
1188
|
+
}
|
|
1189
|
+
m_last_answer = getTime();
|
|
1190
|
+
if (current) {
|
|
1191
|
+
respond(request, std::move(reply));
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
} // namespace bsx
|