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,860 @@
|
|
|
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 "wallet/xmr/scanner.h"
|
|
6
|
+
#include "wallet/xmr/reserve_proof.h"
|
|
7
|
+
|
|
8
|
+
#include "util/log.h"
|
|
9
|
+
#include "util/str.h"
|
|
10
|
+
|
|
11
|
+
#include <algorithm>
|
|
12
|
+
#include <cstring>
|
|
13
|
+
|
|
14
|
+
namespace bsx {
|
|
15
|
+
namespace xmr {
|
|
16
|
+
|
|
17
|
+
namespace {
|
|
18
|
+
|
|
19
|
+
std::array<unsigned char, 32> toArray(const std::vector<unsigned char> &v)
|
|
20
|
+
{
|
|
21
|
+
std::array<unsigned char, 32> out{};
|
|
22
|
+
memcpy(out.data(), v.data(), std::min(v.size(), out.size()));
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace
|
|
27
|
+
|
|
28
|
+
Scanner::Scanner(const Interface &ci, std::vector<std::shared_ptr<DaemonClient>> daemons)
|
|
29
|
+
: m_ci(ci), m_daemons(std::move(daemons))
|
|
30
|
+
{
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// monerod's mainnet forks: 15 brought view tags, 16 requires them, and tx.cpp's scan
|
|
34
|
+
// bound keys off the version a block states
|
|
35
|
+
static bool belowForkVersion(int chain_type, uint64_t height, uint8_t version)
|
|
36
|
+
{
|
|
37
|
+
if (ChainParams::MAINNET != chain_type) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return (height >= 2689608 && version < 16) || (height >= 2688888 && version < 15);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void Scanner::addWatch(const ScanWatch &watch)
|
|
44
|
+
{
|
|
45
|
+
m_watches[watch.m_id] = watch;
|
|
46
|
+
m_agreements.erase(watch.m_id);
|
|
47
|
+
m_invalid_seen.erase(watch.m_id);
|
|
48
|
+
std::erase_if(m_outputs, [&](const ScannedOutput &o) { return o.m_watch_id == watch.m_id; });
|
|
49
|
+
std::erase_if(m_spends, [&](const ScannedSpend &s) { return s.m_watch_id == watch.m_id; });
|
|
50
|
+
m_key_images.erase(watch.m_id);
|
|
51
|
+
m_watch_next[watch.m_id] = watch.m_start_height;
|
|
52
|
+
if (!m_next_height || watch.m_start_height < *m_next_height) {
|
|
53
|
+
scanBackTo(watch.m_start_height);
|
|
54
|
+
} else {
|
|
55
|
+
// Blocks fetched ahead were scanned without this watch
|
|
56
|
+
resetScan();
|
|
57
|
+
}
|
|
58
|
+
m_base_height =
|
|
59
|
+
m_base_height ? std::min(*m_base_height, watch.m_start_height) : watch.m_start_height;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
void Scanner::restoreOutputs(const std::vector<ScannedOutput> &outputs)
|
|
63
|
+
{
|
|
64
|
+
for (const auto &o : outputs) {
|
|
65
|
+
const auto it = m_watches.find(o.m_watch_id);
|
|
66
|
+
if (it != m_watches.end()) {
|
|
67
|
+
m_outputs.push_back(o);
|
|
68
|
+
keyImageOf(m_outputs.back(), it->second);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void Scanner::addWatchKeys(int64_t watch_id,
|
|
74
|
+
const std::vector<std::vector<unsigned char>> &spend_pubkeys,
|
|
75
|
+
const std::vector<secure_bytes> &spend_keys,
|
|
76
|
+
std::optional<uint64_t> from_height)
|
|
77
|
+
{
|
|
78
|
+
const auto it = m_watches.find(watch_id);
|
|
79
|
+
if (it == m_watches.end() || spend_pubkeys.size() != spend_keys.size() ||
|
|
80
|
+
it->second.m_spend_keys.size() != it->second.m_spend_pubkeys.size()) {
|
|
81
|
+
LOGE("Scanner: watch %lld takes no spend keys", (long long)watch_id);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
ScanWatch &watch = it->second;
|
|
85
|
+
watch.m_spend_pubkeys.insert(watch.m_spend_pubkeys.end(), spend_pubkeys.begin(),
|
|
86
|
+
spend_pubkeys.end());
|
|
87
|
+
watch.m_spend_keys.insert(watch.m_spend_keys.end(), spend_keys.begin(), spend_keys.end());
|
|
88
|
+
const uint64_t from = from_height ? std::max(*from_height, watch.m_start_height) : 0;
|
|
89
|
+
// The watch's own position: it can be ahead of the scan while another watch rescans
|
|
90
|
+
if (from_height && from < watchNext(watch_id)) {
|
|
91
|
+
m_watch_next[watch_id] = from;
|
|
92
|
+
scanBackTo(m_next_height ? std::min(from, *m_next_height) : from);
|
|
93
|
+
} else {
|
|
94
|
+
// Blocks fetched ahead were scanned without them
|
|
95
|
+
resetScan();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
std::vector<ScannedSpend> Scanner::spends(int64_t watch_id) const
|
|
100
|
+
{
|
|
101
|
+
std::vector<ScannedSpend> found;
|
|
102
|
+
for (const auto &s : m_spends) {
|
|
103
|
+
if (s.m_watch_id == watch_id) {
|
|
104
|
+
found.push_back(s);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return found;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
void Scanner::restoreSpends(const std::vector<ScannedSpend> &spends)
|
|
111
|
+
{
|
|
112
|
+
for (const auto &s : spends) {
|
|
113
|
+
if (m_watches.count(s.m_watch_id)) {
|
|
114
|
+
m_spends.push_back(s);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void Scanner::keyImageOf(ScannedOutput &output, const ScanWatch &watch)
|
|
120
|
+
{
|
|
121
|
+
const size_t address = output.m_output.spend_pubkey_index;
|
|
122
|
+
if (watch.m_spend_keys.empty()) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
std::vector<std::vector<unsigned char>> images;
|
|
126
|
+
if (address >= watch.m_spend_keys.size() ||
|
|
127
|
+
0 != keyImages(images, watch.m_spend_keys[address], {output}) || images.size() != 1) {
|
|
128
|
+
LOGE("Scanner: no key image for an output of watch %lld", (long long)watch.m_id);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
output.m_key_image.emplace();
|
|
132
|
+
memcpy(output.m_key_image->data(), images[0].data(), 32);
|
|
133
|
+
m_key_images[watch.m_id].insert(*output.m_key_image);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
void Scanner::indexKeyImages()
|
|
137
|
+
{
|
|
138
|
+
m_key_images.clear();
|
|
139
|
+
for (const auto &o : m_outputs) {
|
|
140
|
+
if (o.m_key_image) {
|
|
141
|
+
m_key_images[o.m_watch_id].insert(*o.m_key_image);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
void Scanner::removeWatch(int64_t watch_id)
|
|
147
|
+
{
|
|
148
|
+
m_watches.erase(watch_id);
|
|
149
|
+
m_watch_next.erase(watch_id);
|
|
150
|
+
m_agreements.erase(watch_id);
|
|
151
|
+
m_invalid_seen.erase(watch_id);
|
|
152
|
+
std::erase_if(m_outputs, [&](const ScannedOutput &o) { return o.m_watch_id == watch_id; });
|
|
153
|
+
std::erase_if(m_spends, [&](const ScannedSpend &s) { return s.m_watch_id == watch_id; });
|
|
154
|
+
m_key_images.erase(watch_id);
|
|
155
|
+
if (m_held && std::none_of(m_watches.begin(), m_watches.end(),
|
|
156
|
+
[](const auto &w) { return w.second.m_hold; })) {
|
|
157
|
+
releaseHold();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void Scanner::releaseHold()
|
|
162
|
+
{
|
|
163
|
+
if (m_held) {
|
|
164
|
+
m_held = false;
|
|
165
|
+
commitBlocks();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
bool Scanner::request(size_t daemon, Requests kind, uint64_t height, size_t request_id)
|
|
170
|
+
{
|
|
171
|
+
if (request_id == 0) {
|
|
172
|
+
LOGW("Scanner: daemon %d refused a request", m_daemons[daemon]->id());
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
m_pending[{m_daemons[daemon]->id(), request_id}] = {kind, daemon, height, m_scan_epoch};
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
void Scanner::update(int64_t now)
|
|
180
|
+
{
|
|
181
|
+
m_now = now;
|
|
182
|
+
requestAnchor(now);
|
|
183
|
+
if (m_watches.empty() || m_daemons.empty()) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
DaemonClient &primary = *m_daemons[m_primary];
|
|
187
|
+
if (!m_tip_pending && (!m_tip || now - m_tip_at >= m_tip_refresh_seconds)) {
|
|
188
|
+
m_tip_pending = request(m_primary, Requests::TIP, 0, primary.getInfo(0));
|
|
189
|
+
if (!m_tip_pending) {
|
|
190
|
+
failPrimary("refused a request");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (m_tip && m_next_height) {
|
|
195
|
+
// At 0 monerod reads block ids instead of the height, and the genesis block pays no watch
|
|
196
|
+
if (*m_next_height == 0) {
|
|
197
|
+
m_next_height = 1;
|
|
198
|
+
}
|
|
199
|
+
// A pruned tx can't be checked, so only blocks below every non-rescan watch come pruned
|
|
200
|
+
uint64_t checked_from = UINT64_MAX;
|
|
201
|
+
for (const auto &[id, watch] : m_watches) {
|
|
202
|
+
if (!watch.m_hold && !m_rescan_only) {
|
|
203
|
+
checked_from = std::min(checked_from, watch.m_start_height);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const uint64_t last = m_stop_height ? std::min(*m_tip, *m_stop_height) : *m_tip;
|
|
207
|
+
uint64_t height = *m_next_height;
|
|
208
|
+
while (m_batches.size() < BATCHES_IN_FLIGHT && height <= last &&
|
|
209
|
+
height < *m_next_height + BATCHES_IN_FLIGHT * BATCH_BLOCKS) {
|
|
210
|
+
const auto batch = std::find_if(m_batches.begin(), m_batches.end(), [&](const auto &b) {
|
|
211
|
+
return b.first <= height && height < b.second.m_end;
|
|
212
|
+
});
|
|
213
|
+
if (batch != m_batches.end()) {
|
|
214
|
+
height = batch->second.m_end;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (m_ahead.count(height)) {
|
|
218
|
+
++height;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
uint64_t count = std::min(BATCH_BLOCKS, last - height + 1);
|
|
222
|
+
const bool pruned = height < checked_from;
|
|
223
|
+
if (pruned) {
|
|
224
|
+
count = std::min(count, checked_from - height);
|
|
225
|
+
}
|
|
226
|
+
if (!request(m_primary, Requests::BLOCKS, height,
|
|
227
|
+
primary.getBlocksBin(0, height, count, pruned))) {
|
|
228
|
+
failPrimary("refused a request");
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
m_batches[height] = {height + count, pruned, std::chrono::steady_clock::now()};
|
|
232
|
+
LOGD("Scanner: asked daemon %d for blocks %llu to %llu, %s", primary.id(),
|
|
233
|
+
(unsigned long long)height, (unsigned long long)(height + count - 1),
|
|
234
|
+
pruned ? "pruned" : "full");
|
|
235
|
+
height += count;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
requestAgreements(now);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
bool Scanner::handleResponse(const DaemonResponse &response, int64_t now)
|
|
242
|
+
{
|
|
243
|
+
const auto it = m_pending.find({response.m_client_id, response.m_request_id});
|
|
244
|
+
if (it == m_pending.end()) {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
const Pending pending = it->second;
|
|
248
|
+
m_pending.erase(it);
|
|
249
|
+
const bool from_primary = pending.m_daemon == m_primary;
|
|
250
|
+
switch (pending.m_request) {
|
|
251
|
+
case Requests::TIP:
|
|
252
|
+
m_tip_pending = false;
|
|
253
|
+
if (from_primary) {
|
|
254
|
+
onTip(response, now);
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
case Requests::BLOCKS:
|
|
258
|
+
if (pending.m_scan_epoch == m_scan_epoch) {
|
|
259
|
+
const auto batch = m_batches.find(pending.m_height);
|
|
260
|
+
if (batch != m_batches.end()) {
|
|
261
|
+
const bool pruned = batch->second.m_pruned;
|
|
262
|
+
const auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
|
|
263
|
+
std::chrono::steady_clock::now() - batch->second.m_asked)
|
|
264
|
+
.count();
|
|
265
|
+
size_t blocks{0}, txs{0};
|
|
266
|
+
const auto served = response.m_result.find("blocks");
|
|
267
|
+
if (served != response.m_result.end() && served->is_array()) {
|
|
268
|
+
blocks = served->size();
|
|
269
|
+
for (const auto &b : *served) {
|
|
270
|
+
const auto t = b.find("txs");
|
|
271
|
+
txs += t != b.end() && t->is_array() ? t->size() : 0;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
LOGD(
|
|
275
|
+
"Scanner: daemon %d served %zu blocks from %llu, %zu txs, %s, in %lld ms%s%s",
|
|
276
|
+
m_daemons[pending.m_daemon]->id(), blocks,
|
|
277
|
+
(unsigned long long)pending.m_height, txs, pruned ? "pruned" : "full",
|
|
278
|
+
(long long)ms, response.m_error.empty() ? "" : ", ",
|
|
279
|
+
response.m_error.c_str());
|
|
280
|
+
m_batches.erase(batch);
|
|
281
|
+
if (from_primary) {
|
|
282
|
+
onBlocks(response, pending.m_height, pruned);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case Requests::AGREEMENT:
|
|
288
|
+
onAgreement(response, pending.m_daemon, pending.m_height, now);
|
|
289
|
+
break;
|
|
290
|
+
case Requests::ANCHOR:
|
|
291
|
+
onAnchor(response, pending.m_daemon, pending.m_height, now);
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
void Scanner::failPrimary(const char *reason)
|
|
298
|
+
{
|
|
299
|
+
LOGW("Scanner: daemon %d %s, moving to the next", m_daemons[m_primary]->id(), reason);
|
|
300
|
+
resetScan();
|
|
301
|
+
m_tip.reset();
|
|
302
|
+
m_primary = (m_primary + 1) % m_daemons.size();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
void Scanner::resetScan()
|
|
306
|
+
{
|
|
307
|
+
if (!m_ahead.empty() || !m_batches.empty()) {
|
|
308
|
+
LOGD("Scanner: dropping %zu blocks fetched ahead and %zu requests in flight",
|
|
309
|
+
m_ahead.size(), m_batches.size());
|
|
310
|
+
}
|
|
311
|
+
m_ahead.clear();
|
|
312
|
+
m_batches.clear();
|
|
313
|
+
m_scan_epoch++;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
void Scanner::rewind(uint64_t height)
|
|
317
|
+
{
|
|
318
|
+
m_block_ids.erase(m_block_ids.lower_bound(height), m_block_ids.end());
|
|
319
|
+
for (auto &[watch_id, next] : m_watch_next) {
|
|
320
|
+
next = std::min(next, height);
|
|
321
|
+
}
|
|
322
|
+
scanBackTo(height);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
void Scanner::scanBackTo(uint64_t height)
|
|
326
|
+
{
|
|
327
|
+
resetScan();
|
|
328
|
+
// Below its watch's start a row was restored, and the rescan would never find it again
|
|
329
|
+
auto rescanned = [&](int64_t watch_id, uint64_t at) {
|
|
330
|
+
const auto it = m_watches.find(watch_id);
|
|
331
|
+
return at >= watchNext(watch_id) &&
|
|
332
|
+
(it == m_watches.end() || at >= it->second.m_start_height);
|
|
333
|
+
};
|
|
334
|
+
std::erase_if(m_outputs,
|
|
335
|
+
[&](const ScannedOutput &o) { return rescanned(o.m_watch_id, o.m_height); });
|
|
336
|
+
std::erase_if(m_spends,
|
|
337
|
+
[&](const ScannedSpend &s) { return rescanned(s.m_watch_id, s.m_height); });
|
|
338
|
+
indexKeyImages();
|
|
339
|
+
m_next_height = height;
|
|
340
|
+
m_held = false;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
uint64_t Scanner::watchNext(int64_t watch_id) const
|
|
344
|
+
{
|
|
345
|
+
const auto it = m_watch_next.find(watch_id);
|
|
346
|
+
return it == m_watch_next.end() ? 0 : it->second;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
void Scanner::onTip(const DaemonResponse &response, int64_t now)
|
|
350
|
+
{
|
|
351
|
+
const auto height = response.m_result.find("height");
|
|
352
|
+
if (!response.m_error.empty() || height == response.m_result.end() ||
|
|
353
|
+
!height->is_number_unsigned() || height->get<uint64_t>() == 0) {
|
|
354
|
+
failPrimary("gave no height");
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const int64_t max_height = maxHeight();
|
|
358
|
+
if (max_height >= 0 && height->get<uint64_t>() - 1 > (uint64_t)max_height) {
|
|
359
|
+
failPrimary("claims a height beyond what the clock allows since the anchor");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
m_tip = height->get<uint64_t>() - 1;
|
|
363
|
+
m_tip_at = now;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
void Scanner::onBlocks(const DaemonResponse &response, uint64_t start, bool pruned)
|
|
367
|
+
{
|
|
368
|
+
if (!m_next_height) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
const nlohmann::json &result = response.m_result;
|
|
372
|
+
const auto blocks = result.find("blocks");
|
|
373
|
+
const auto indices = result.find("output_indices");
|
|
374
|
+
const auto start_height = result.find("start_height");
|
|
375
|
+
if (!response.m_error.empty() || blocks == result.end() || !blocks->is_array() ||
|
|
376
|
+
blocks->empty() || indices == result.end() || !indices->is_array() ||
|
|
377
|
+
indices->size() != blocks->size() || start_height == result.end() ||
|
|
378
|
+
!start_height->is_number_unsigned() || start_height->get<uint64_t>() != start) {
|
|
379
|
+
failPrimary(response.m_error.empty() ? "served blocks that don't verify"
|
|
380
|
+
: "failed a blocks request");
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
// epee leaves an empty array out
|
|
384
|
+
const nlohmann::json none = nlohmann::json::array();
|
|
385
|
+
for (size_t i = 0; i < blocks->size(); ++i) {
|
|
386
|
+
const uint64_t height = start + i;
|
|
387
|
+
if (height < *m_next_height || m_ahead.count(height)) {
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const nlohmann::json &entry = (*blocks)[i];
|
|
391
|
+
const auto blob = entry.find("block");
|
|
392
|
+
const auto txs_it = entry.find("txs");
|
|
393
|
+
const auto tx_indices_it = (*indices)[i].find("indices");
|
|
394
|
+
std::vector<unsigned char> block_id, miner_txid;
|
|
395
|
+
Block block;
|
|
396
|
+
if (!entry.is_object() || blob == entry.end() || !blob->is_binary() ||
|
|
397
|
+
0 != m_ci.parseBlock(block, blob->get_binary(), &block_id, &miner_txid) ||
|
|
398
|
+
block.miner_tx.inputs[0].height != height) {
|
|
399
|
+
failPrimary("served a block that doesn't verify");
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (belowForkVersion(m_ci.chainType(), height, block.major_version)) {
|
|
403
|
+
failPrimary("served a block below its fork's version");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const nlohmann::json &txs = txs_it == entry.end() ? none : *txs_it;
|
|
407
|
+
const nlohmann::json &tx_indices =
|
|
408
|
+
tx_indices_it == (*indices)[i].end() ? none : *tx_indices_it;
|
|
409
|
+
if (!txs.is_array() || txs.size() != block.tx_hashes.size() || !tx_indices.is_array() ||
|
|
410
|
+
tx_indices.size() != txs.size() + 1) {
|
|
411
|
+
failPrimary("served a block without its txs");
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
CurrentBlock current;
|
|
416
|
+
current.m_height = height;
|
|
417
|
+
current.m_block_version = block.major_version;
|
|
418
|
+
current.m_id = toArray(block_id);
|
|
419
|
+
memcpy(current.m_prev_id.data(), block.prev_id.data(), 32);
|
|
420
|
+
current.m_txids.push_back(toArray(miner_txid));
|
|
421
|
+
current.m_txids.insert(current.m_txids.end(), block.tx_hashes.begin(),
|
|
422
|
+
block.tx_hashes.end());
|
|
423
|
+
if (!scanTx(current, block.miner_tx, current.m_txids[0], tx_indices[0], {})) {
|
|
424
|
+
failPrimary("served a tx without its output indices");
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
for (size_t j = 0; j < txs.size(); ++j) {
|
|
428
|
+
const nlohmann::json &tx_entry = txs[j];
|
|
429
|
+
Tx tx;
|
|
430
|
+
std::vector<unsigned char> tx_data;
|
|
431
|
+
if (pruned) {
|
|
432
|
+
const auto tx_blob = tx_entry.is_object() ? tx_entry.find("blob") : tx_entry.end();
|
|
433
|
+
const std::vector<unsigned char> unknown(32, 0);
|
|
434
|
+
if (tx_blob == tx_entry.end() || !tx_blob->is_binary() ||
|
|
435
|
+
0 != m_ci.parsePrunedTx(tx, tx_blob->get_binary(), unknown, nullptr, false) ||
|
|
436
|
+
tx.inputs[0].coinbase) {
|
|
437
|
+
failPrimary("served a tx that doesn't parse");
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
} else {
|
|
441
|
+
std::vector<unsigned char> txid;
|
|
442
|
+
if (!tx_entry.is_binary() || 0 != m_ci.parseTx(tx, tx_entry.get_binary(), &txid) ||
|
|
443
|
+
0 != memcmp(txid.data(), block.tx_hashes[j].data(), 32) ||
|
|
444
|
+
tx.inputs[0].coinbase) {
|
|
445
|
+
failPrimary("served a tx that isn't the block's");
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const auto &full = tx_entry.get_binary();
|
|
449
|
+
std::vector<unsigned char> prunable_hash;
|
|
450
|
+
m_ci.prunableHash(prunable_hash, tx);
|
|
451
|
+
tx_data.assign(full.begin(), full.end() - tx.prunable.size());
|
|
452
|
+
tx_data.insert(tx_data.end(), prunable_hash.begin(), prunable_hash.end());
|
|
453
|
+
}
|
|
454
|
+
if (!scanTx(current, tx, block.tx_hashes[j], tx_indices[j + 1], tx_data)) {
|
|
455
|
+
failPrimary("served a tx without its output indices");
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
current.m_next_tx = current.m_txids.size();
|
|
460
|
+
m_ahead.emplace(height, std::move(current));
|
|
461
|
+
}
|
|
462
|
+
commitBlocks();
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
bool Scanner::scanTx(CurrentBlock &block, const Tx &tx, const std::array<unsigned char, 32> &txid,
|
|
466
|
+
const nlohmann::json &indices, const std::vector<unsigned char> &tx_data)
|
|
467
|
+
{
|
|
468
|
+
const auto list = indices.find("indices");
|
|
469
|
+
if (!indices.is_object() || list == indices.end() || !list->is_array() ||
|
|
470
|
+
list->size() != tx.outputs.size()) {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
for (const auto &[watch_id, watch] : m_watches) {
|
|
474
|
+
if (watch.m_start_height > block.m_height) {
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
std::vector<OwnedOutput> owned;
|
|
478
|
+
if (0 != m_ci.findOwnedOutputs(owned, tx, watch.m_view_key, watch.m_spend_pubkeys,
|
|
479
|
+
block.m_block_version)) {
|
|
480
|
+
continue;
|
|
481
|
+
}
|
|
482
|
+
for (const auto &o : owned) {
|
|
483
|
+
const auto &global_index = (*list)[o.index];
|
|
484
|
+
if (!global_index.is_number_unsigned()) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
ScannedOutput scanned;
|
|
488
|
+
scanned.m_watch_id = watch_id;
|
|
489
|
+
scanned.m_txid = txid;
|
|
490
|
+
scanned.m_height = block.m_height;
|
|
491
|
+
scanned.m_unlock_time = tx.unlock_time;
|
|
492
|
+
scanned.m_key = tx.outputs[o.index].key;
|
|
493
|
+
scanned.m_commitment = o.commitment;
|
|
494
|
+
scanned.m_global_index = global_index.get<uint64_t>();
|
|
495
|
+
scanned.m_output = o;
|
|
496
|
+
if (watch.m_lock_depth > 0) {
|
|
497
|
+
scanned.m_tx_data = tx_data;
|
|
498
|
+
}
|
|
499
|
+
keyImageOf(scanned, watch);
|
|
500
|
+
block.m_outputs.push_back(scanned);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (watchesSpends()) {
|
|
504
|
+
for (const auto &in : tx.inputs) {
|
|
505
|
+
if (!in.coinbase) {
|
|
506
|
+
block.m_inputs.emplace_back(in.key_image, txid);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
bool Scanner::watchesSpends() const
|
|
514
|
+
{
|
|
515
|
+
return std::any_of(m_watches.begin(), m_watches.end(),
|
|
516
|
+
[](const auto &w) { return !w.second.m_spend_keys.empty(); });
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
void Scanner::commitBlocks()
|
|
520
|
+
{
|
|
521
|
+
while (m_next_height && !m_held) {
|
|
522
|
+
const auto it = m_ahead.find(*m_next_height);
|
|
523
|
+
if (it == m_ahead.end() || it->second.m_next_tx < it->second.m_txids.size()) {
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
const CurrentBlock &block = it->second;
|
|
527
|
+
const auto below = m_block_ids.find(block.m_height - 1);
|
|
528
|
+
if (block.m_height > *m_base_height && below != m_block_ids.end() &&
|
|
529
|
+
0 != memcmp(below->second.data(), block.m_prev_id.data(), 32)) {
|
|
530
|
+
LOGI("Scanner: block %llu doesn't follow the one below, rewinding",
|
|
531
|
+
(unsigned long long)block.m_height);
|
|
532
|
+
rewind(block.m_height - 1);
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
const auto committed = m_block_ids.find(block.m_height);
|
|
536
|
+
if (committed != m_block_ids.end() && committed->second != block.m_id) {
|
|
537
|
+
LOGI("Scanner: block %llu was replaced since its last scan, rewinding",
|
|
538
|
+
(unsigned long long)block.m_height);
|
|
539
|
+
rewind(block.m_height);
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
commitBlock(block);
|
|
543
|
+
m_ahead.erase(it);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
void Scanner::commitBlock(const CurrentBlock &block)
|
|
548
|
+
{
|
|
549
|
+
m_block_ids[block.m_height] = block.m_id;
|
|
550
|
+
for (const auto &o : block.m_outputs) {
|
|
551
|
+
const auto it = m_watches.find(o.m_watch_id);
|
|
552
|
+
if (it == m_watches.end()) {
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
const ScanWatch &watch = it->second;
|
|
556
|
+
if (watchNext(o.m_watch_id) > block.m_height) {
|
|
557
|
+
m_held = m_held || watch.m_hold;
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
if (watch.m_lock_depth > 0 && o.m_unlock_time != 0) {
|
|
561
|
+
if (m_invalid_seen.insert(o.m_watch_id).second) {
|
|
562
|
+
LOGW("Scanner: watch %lld was paid with unlock time %llu", (long long)o.m_watch_id,
|
|
563
|
+
(unsigned long long)o.m_unlock_time);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
m_outputs.push_back(o);
|
|
567
|
+
m_held = m_held || watch.m_hold;
|
|
568
|
+
}
|
|
569
|
+
for (const auto &[watch_id, images] : m_key_images) {
|
|
570
|
+
if (!m_watches.count(watch_id) || watchNext(watch_id) > block.m_height) {
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
for (const auto &[key_image, txid] : block.m_inputs) {
|
|
574
|
+
if (images.count(key_image)) {
|
|
575
|
+
m_spends.push_back({watch_id, key_image, txid, block.m_height});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
for (auto &[watch_id, next] : m_watch_next) {
|
|
580
|
+
if (next == block.m_height) {
|
|
581
|
+
next = block.m_height + 1;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
m_next_height = block.m_height + 1;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const ScannedOutput *Scanner::lockOutput(const ScanWatch &watch) const
|
|
588
|
+
{
|
|
589
|
+
const ScannedOutput *found = nullptr;
|
|
590
|
+
for (const auto &o : m_outputs) {
|
|
591
|
+
if (o.m_watch_id == watch.m_id && o.m_output.amount == watch.m_lock_amount &&
|
|
592
|
+
o.m_unlock_time == 0 && (!found || o.m_height < found->m_height)) {
|
|
593
|
+
found = &o;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return found;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
size_t Scanner::agreementsNeeded() const { return std::min<size_t>(2, m_daemons.size()); }
|
|
600
|
+
|
|
601
|
+
void Scanner::requestAgreements(int64_t now)
|
|
602
|
+
{
|
|
603
|
+
for (const auto &[watch_id, watch] : m_watches) {
|
|
604
|
+
const int64_t scanned = scannedHeight(watch_id);
|
|
605
|
+
const ScannedOutput *lock = watch.m_lock_depth > 0 ? lockOutput(watch) : nullptr;
|
|
606
|
+
if (!lock || scanned < 0 || (uint64_t)scanned + 1 < lock->m_height + watch.m_lock_depth) {
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
const uint64_t height = lock->m_height + watch.m_lock_depth - 1;
|
|
610
|
+
const std::array<unsigned char, 32> &block_id = m_block_ids.at(height);
|
|
611
|
+
Agreement &agreement = m_agreements[watch_id];
|
|
612
|
+
if (agreement.m_height != height || agreement.m_block_id != block_id) {
|
|
613
|
+
agreement = Agreement();
|
|
614
|
+
agreement.m_height = height;
|
|
615
|
+
agreement.m_block_id = block_id;
|
|
616
|
+
}
|
|
617
|
+
for (size_t d = 0; d < m_daemons.size(); ++d) {
|
|
618
|
+
const auto answer = agreement.m_answers.find(d);
|
|
619
|
+
const bool asked = std::any_of(m_pending.begin(), m_pending.end(), [&](const auto &p) {
|
|
620
|
+
return p.second.m_request == Requests::AGREEMENT && p.second.m_daemon == d &&
|
|
621
|
+
p.second.m_height == height;
|
|
622
|
+
});
|
|
623
|
+
if (asked || (answer != agreement.m_answers.end() &&
|
|
624
|
+
now - answer->second.m_at < m_agreement_refresh_seconds)) {
|
|
625
|
+
continue;
|
|
626
|
+
}
|
|
627
|
+
request(d, Requests::AGREEMENT, height,
|
|
628
|
+
m_daemons[d]->getBlockHeadersRange(0, height, height));
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
void Scanner::onAgreement(const DaemonResponse &response, size_t daemon, uint64_t height,
|
|
634
|
+
int64_t now)
|
|
635
|
+
{
|
|
636
|
+
std::vector<unsigned char> hash;
|
|
637
|
+
const auto headers = response.m_result.find("headers");
|
|
638
|
+
const bool answered = response.m_error.empty() && headers != response.m_result.end() &&
|
|
639
|
+
headers->is_array() && headers->size() == 1 &&
|
|
640
|
+
(*headers)[0].is_object() && hexField(hash, (*headers)[0], "hash", 32);
|
|
641
|
+
for (auto &[watch_id, agreement] : m_agreements) {
|
|
642
|
+
if (agreement.m_height != height) {
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
if (!answered) {
|
|
646
|
+
if (response.m_rpc_error_code == RPC_ERROR_TOO_BIG_HEIGHT) {
|
|
647
|
+
const auto prior = agreement.m_answers.find(daemon);
|
|
648
|
+
const int64_t since = prior != agreement.m_answers.end() && prior->second.m_not_yet
|
|
649
|
+
? prior->second.m_not_yet_since
|
|
650
|
+
: now;
|
|
651
|
+
agreement.m_answers[daemon] = {false, now, true, since};
|
|
652
|
+
} else {
|
|
653
|
+
agreement.m_answers.erase(daemon);
|
|
654
|
+
}
|
|
655
|
+
continue;
|
|
656
|
+
}
|
|
657
|
+
const bool agrees = 0 == memcmp(hash.data(), agreement.m_block_id.data(), 32);
|
|
658
|
+
if (!agrees) {
|
|
659
|
+
LOGW("Scanner: daemon %d has another block at %llu", m_daemons[daemon]->id(),
|
|
660
|
+
(unsigned long long)height);
|
|
661
|
+
}
|
|
662
|
+
agreement.m_answers[daemon] = {agrees, now};
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
static bool keptBefore(const ScannedOutput &a, const ScannedOutput &b)
|
|
667
|
+
{
|
|
668
|
+
if ((a.m_unlock_time == 0) != (b.m_unlock_time == 0)) {
|
|
669
|
+
return a.m_unlock_time == 0;
|
|
670
|
+
}
|
|
671
|
+
return a.m_output.amount > b.m_output.amount;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
std::vector<ScannedOutput> Scanner::outputs(int64_t watch_id) const
|
|
675
|
+
{
|
|
676
|
+
// Outputs sharing a one-time key share a key image, so one is kept: unlocked first, then largest
|
|
677
|
+
std::vector<ScannedOutput> out;
|
|
678
|
+
for (const auto &o : m_outputs) {
|
|
679
|
+
if (o.m_watch_id != watch_id) {
|
|
680
|
+
continue;
|
|
681
|
+
}
|
|
682
|
+
const auto same = std::find_if(out.begin(), out.end(), [&](const ScannedOutput &kept) {
|
|
683
|
+
return kept.m_key == o.m_key;
|
|
684
|
+
});
|
|
685
|
+
if (same == out.end()) {
|
|
686
|
+
out.push_back(o);
|
|
687
|
+
} else if (keptBefore(o, *same)) {
|
|
688
|
+
*same = o;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
return out;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
LockBStatus Scanner::lockB(int64_t watch_id) const
|
|
695
|
+
{
|
|
696
|
+
LockBStatus status;
|
|
697
|
+
const auto watch = m_watches.find(watch_id);
|
|
698
|
+
if (watch == m_watches.end() || watch->second.m_lock_depth == 0) {
|
|
699
|
+
return status;
|
|
700
|
+
}
|
|
701
|
+
status.m_invalid_seen = m_invalid_seen.count(watch_id) > 0;
|
|
702
|
+
const ScannedOutput *lock = lockOutput(watch->second);
|
|
703
|
+
if (!lock) {
|
|
704
|
+
status.m_state = atTip(watch_id) ? LockBStates::MISSING : LockBStates::SCANNING;
|
|
705
|
+
return status;
|
|
706
|
+
}
|
|
707
|
+
status.m_lock = *lock;
|
|
708
|
+
status.m_depth = cappedDepth(lock->m_height, watch_id);
|
|
709
|
+
status.m_state = LockBStates::CONFIRMING;
|
|
710
|
+
if (status.m_depth < watch->second.m_lock_depth) {
|
|
711
|
+
return status;
|
|
712
|
+
}
|
|
713
|
+
const uint64_t height = lock->m_height + watch->second.m_lock_depth - 1;
|
|
714
|
+
const auto agreement = m_agreements.find(watch_id);
|
|
715
|
+
if (agreement == m_agreements.end() || agreement->second.m_height != height ||
|
|
716
|
+
agreement->second.m_block_id != m_block_ids.at(height)) {
|
|
717
|
+
return status;
|
|
718
|
+
}
|
|
719
|
+
size_t agree = 0;
|
|
720
|
+
bool waiting = false;
|
|
721
|
+
const int64_t hold = m_not_yet_hold_blocks * std::max<int64_t>(1, m_ci.targetSpacing());
|
|
722
|
+
for (const auto &[daemon, answer] : agreement->second.m_answers) {
|
|
723
|
+
if (answer.m_not_yet) {
|
|
724
|
+
waiting = waiting || m_now - answer.m_not_yet_since < hold;
|
|
725
|
+
} else if (answer.m_agrees) {
|
|
726
|
+
agree++;
|
|
727
|
+
} else {
|
|
728
|
+
status.m_disputed = true;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (!status.m_disputed && !waiting && agree >= agreementsNeeded()) {
|
|
732
|
+
status.m_state = LockBStates::CONFIRMED;
|
|
733
|
+
}
|
|
734
|
+
return status;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
uint64_t Scanner::cappedDepth(uint64_t height, int64_t watch_id) const
|
|
738
|
+
{
|
|
739
|
+
const AnchorStates anchor = anchorState();
|
|
740
|
+
if (anchor == AnchorStates::PENDING || anchor == AnchorStates::DISPUTED) {
|
|
741
|
+
return 0;
|
|
742
|
+
}
|
|
743
|
+
int64_t top = scannedHeight(watch_id);
|
|
744
|
+
const int64_t max_height = maxHeight();
|
|
745
|
+
if (max_height >= 0) {
|
|
746
|
+
top = std::min(top, max_height);
|
|
747
|
+
}
|
|
748
|
+
return top < (int64_t)height ? 0 : (uint64_t)top + 1 - height;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
void Scanner::setAnchor(uint64_t height, const std::array<unsigned char, 32> &hash, int64_t now)
|
|
752
|
+
{
|
|
753
|
+
if (m_anchor && m_anchor->m_height == height && m_anchor->m_hash == hash) {
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
m_anchor = Anchor();
|
|
757
|
+
m_anchor->m_height = height;
|
|
758
|
+
m_anchor->m_time = now;
|
|
759
|
+
m_anchor->m_hash = hash;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
AnchorStates Scanner::anchorState() const
|
|
763
|
+
{
|
|
764
|
+
if (!m_anchor) {
|
|
765
|
+
return AnchorStates::NONE;
|
|
766
|
+
}
|
|
767
|
+
std::map<std::array<unsigned char, 32>, size_t> counts;
|
|
768
|
+
for (const auto &[daemon, answer] : m_anchor->m_answers) {
|
|
769
|
+
if (answer.first) {
|
|
770
|
+
counts[*answer.first]++;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
for (const auto &[hash, count] : counts) {
|
|
774
|
+
if (hash != m_anchor->m_hash && count >= agreementsNeeded()) {
|
|
775
|
+
return AnchorStates::DISPUTED;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
const auto agreed = counts.find(m_anchor->m_hash);
|
|
779
|
+
return agreed != counts.end() && agreed->second >= agreementsNeeded() ? AnchorStates::VERIFIED
|
|
780
|
+
: AnchorStates::PENDING;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
uint64_t Scanner::anchorHeight() const { return m_anchor ? m_anchor->m_height : 0; }
|
|
784
|
+
|
|
785
|
+
int64_t Scanner::maxHeight() const
|
|
786
|
+
{
|
|
787
|
+
if (!m_anchor || m_ci.chainType() == ChainParams::REGTEST) {
|
|
788
|
+
return -1;
|
|
789
|
+
}
|
|
790
|
+
const int64_t spacing = std::max<int64_t>(1, m_ci.targetSpacing());
|
|
791
|
+
const int64_t elapsed = std::max<int64_t>(0, m_now - m_anchor->m_time);
|
|
792
|
+
// Block times vary, so the allowance grows by about one block for every 30
|
|
793
|
+
const int64_t drift = elapsed / (spacing * 30);
|
|
794
|
+
return (int64_t)m_anchor->m_height + elapsed / spacing + ANCHOR_HEIGHT_AHEAD_TOLERANCE + drift;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
void Scanner::requestAnchor(int64_t now)
|
|
798
|
+
{
|
|
799
|
+
if (!m_anchor || anchorState() == AnchorStates::VERIFIED) {
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
const uint64_t height = m_anchor->m_height;
|
|
803
|
+
for (size_t d = 0; d < m_daemons.size(); ++d) {
|
|
804
|
+
const auto answer = m_anchor->m_answers.find(d);
|
|
805
|
+
const bool asked = std::any_of(m_pending.begin(), m_pending.end(), [&](const auto &p) {
|
|
806
|
+
return p.second.m_request == Requests::ANCHOR && p.second.m_daemon == d &&
|
|
807
|
+
p.second.m_height == height;
|
|
808
|
+
});
|
|
809
|
+
if (asked || (answer != m_anchor->m_answers.end() &&
|
|
810
|
+
now - answer->second.second < m_anchor_recheck_seconds)) {
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
request(d, Requests::ANCHOR, height, m_daemons[d]->getBlockHeadersRange(0, height, height));
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
void Scanner::onAnchor(const DaemonResponse &response, size_t daemon, uint64_t height, int64_t now)
|
|
818
|
+
{
|
|
819
|
+
if (!m_anchor || m_anchor->m_height != height) {
|
|
820
|
+
return;
|
|
821
|
+
}
|
|
822
|
+
std::vector<unsigned char> hash;
|
|
823
|
+
const auto headers = response.m_result.find("headers");
|
|
824
|
+
const bool answered = response.m_error.empty() && headers != response.m_result.end() &&
|
|
825
|
+
headers->is_array() && headers->size() == 1 &&
|
|
826
|
+
(*headers)[0].is_object() && hexField(hash, (*headers)[0], "hash", 32);
|
|
827
|
+
m_anchor->m_answers[daemon] = {answered ? std::optional(toArray(hash)) : std::nullopt, now};
|
|
828
|
+
if (answered && toArray(hash) != m_anchor->m_hash) {
|
|
829
|
+
LOGW("Scanner: daemon %d has another block at %llu than the glue's anchor",
|
|
830
|
+
m_daemons[daemon]->id(), (unsigned long long)height);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
int64_t Scanner::scannedHeight() const { return m_next_height ? (int64_t)*m_next_height - 1 : -1; }
|
|
835
|
+
|
|
836
|
+
int64_t Scanner::scannedHeight(int64_t watch_id) const
|
|
837
|
+
{
|
|
838
|
+
return m_watch_next.count(watch_id) ? (int64_t)watchNext(watch_id) - 1 : -1;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
bool Scanner::atTip() const
|
|
842
|
+
{
|
|
843
|
+
return m_tip && m_next_height &&
|
|
844
|
+
*m_next_height > (m_stop_height ? std::min(*m_tip, *m_stop_height) : *m_tip);
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
bool Scanner::atTip(int64_t watch_id) const
|
|
848
|
+
{
|
|
849
|
+
return m_tip && m_watch_next.count(watch_id) &&
|
|
850
|
+
watchNext(watch_id) > (m_stop_height ? std::min(*m_tip, *m_stop_height) : *m_tip);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
std::optional<ScanWatch> Scanner::watch(int64_t watch_id) const
|
|
854
|
+
{
|
|
855
|
+
const auto it = m_watches.find(watch_id);
|
|
856
|
+
return it == m_watches.end() ? std::nullopt : std::optional<ScanWatch>(it->second);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
} // namespace xmr
|
|
860
|
+
} // namespace bsx
|