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,1437 @@
|
|
|
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/chain.h"
|
|
6
|
+
|
|
7
|
+
#include "util/log.h"
|
|
8
|
+
#include "util/str.h"
|
|
9
|
+
#include "util/tinyformat.h"
|
|
10
|
+
#include "wallet/xmr/decoys.h"
|
|
11
|
+
|
|
12
|
+
#include <algorithm>
|
|
13
|
+
|
|
14
|
+
namespace bsx {
|
|
15
|
+
namespace xmr {
|
|
16
|
+
|
|
17
|
+
namespace {
|
|
18
|
+
|
|
19
|
+
constexpr uint64_t FEE_ESTIMATE_GRACE_BLOCKS = 10;
|
|
20
|
+
constexpr uint64_t RECENT_BLOCKS = 10;
|
|
21
|
+
|
|
22
|
+
void writeVarint(std::vector<unsigned char> &out, uint64_t v)
|
|
23
|
+
{
|
|
24
|
+
while (v >= 0x80) {
|
|
25
|
+
out.push_back((unsigned char)(v | 0x80));
|
|
26
|
+
v >>= 7;
|
|
27
|
+
}
|
|
28
|
+
out.push_back((unsigned char)v);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
bool sameLock(const ViewKeyLock &a, const ViewKeyLock &b)
|
|
32
|
+
{
|
|
33
|
+
return a.m_view_key == b.m_view_key && a.m_spend_pubkey == b.m_spend_pubkey &&
|
|
34
|
+
a.m_start_height == b.m_start_height && a.m_amount == b.m_amount &&
|
|
35
|
+
a.m_depth == b.m_depth && a.m_hold == b.m_hold;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // namespace
|
|
39
|
+
|
|
40
|
+
Chain::Chain(const Interface &ci, std::vector<std::shared_ptr<DaemonClient>> daemons)
|
|
41
|
+
: m_ci(ci), m_daemons(daemons), m_scanner(ci, std::move(daemons))
|
|
42
|
+
{
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
int Chain::start()
|
|
46
|
+
{
|
|
47
|
+
if (m_daemons.empty()) {
|
|
48
|
+
LOGE("Chain::start: no daemons");
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
for (auto &daemon : m_daemons) {
|
|
52
|
+
if (0 != daemon->start()) {
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void Chain::stop()
|
|
60
|
+
{
|
|
61
|
+
for (auto &daemon : m_daemons) {
|
|
62
|
+
daemon->stop();
|
|
63
|
+
}
|
|
64
|
+
m_pending.clear();
|
|
65
|
+
m_jobs.clear();
|
|
66
|
+
m_distribution_pending = false;
|
|
67
|
+
for (auto &[id, sent] : m_sent) {
|
|
68
|
+
sent.m_checks_pending = 0;
|
|
69
|
+
}
|
|
70
|
+
for (auto &[id, search] : m_searches) {
|
|
71
|
+
search.m_asked.clear();
|
|
72
|
+
}
|
|
73
|
+
for (auto &[id, check] : m_spent_checks) {
|
|
74
|
+
check.m_asked.clear();
|
|
75
|
+
check.m_answers.clear();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bool Chain::track(size_t daemon, size_t request_id, DaemonRequests request)
|
|
80
|
+
{
|
|
81
|
+
if (request_id == 0) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
m_pending[{m_daemons[daemon]->id(), request_id}] = request;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
bool Chain::askInfo()
|
|
89
|
+
{
|
|
90
|
+
DaemonClient &daemon = *m_daemons[m_daemon];
|
|
91
|
+
return track(m_daemon, daemon.getInfo(0), DaemonRequests::GET_INFO) &&
|
|
92
|
+
track(m_daemon, daemon.getTxpoolBacklog(0), DaemonRequests::GET_TXPOOL_BACKLOG);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
bool Chain::askFee()
|
|
96
|
+
{
|
|
97
|
+
while (m_fee_asked < m_daemons.size()) {
|
|
98
|
+
const size_t d = (m_fee_start + m_fee_asked++) % m_daemons.size();
|
|
99
|
+
if (track(d, m_daemons[d]->getFeeEstimate(0, FEE_ESTIMATE_GRACE_BLOCKS),
|
|
100
|
+
DaemonRequests::GET_FEE_ESTIMATE)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void Chain::refresh(int64_t now)
|
|
108
|
+
{
|
|
109
|
+
if (m_daemons.empty() || !m_pending.empty() || now < m_refresh_at) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
m_next = Snapshot();
|
|
113
|
+
m_info_tries = 1;
|
|
114
|
+
m_fee_start = m_daemon;
|
|
115
|
+
m_fee_asked = 0;
|
|
116
|
+
bool queued = askInfo();
|
|
117
|
+
for (size_t i = 0; queued && i < m_scanner.agreementsNeeded(); ++i) {
|
|
118
|
+
queued = askFee();
|
|
119
|
+
}
|
|
120
|
+
if (!queued) {
|
|
121
|
+
m_pending.clear();
|
|
122
|
+
m_refresh_at = now + m_info_retry_seconds;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
m_refresh_at = now + m_info_refresh_seconds;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
void Chain::fail(const DaemonResponse &response, DaemonRequests request)
|
|
129
|
+
{
|
|
130
|
+
LOGW("Chain: daemon %d failed: %s", response.m_client_id, response.m_error.c_str());
|
|
131
|
+
if (request == DaemonRequests::GET_FEE_ESTIMATE) {
|
|
132
|
+
askFee();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
size_t fees_lost = 0;
|
|
136
|
+
std::erase_if(m_pending, [&](const auto &entry) {
|
|
137
|
+
if (entry.first.first != response.m_client_id) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
fees_lost += entry.second == DaemonRequests::GET_FEE_ESTIMATE;
|
|
141
|
+
return true;
|
|
142
|
+
});
|
|
143
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
144
|
+
m_next.m_count.reset();
|
|
145
|
+
m_next.m_backlog.reset();
|
|
146
|
+
m_next.m_recent_weights.reset();
|
|
147
|
+
if (m_info_tries < m_daemons.size()) {
|
|
148
|
+
++m_info_tries;
|
|
149
|
+
askInfo();
|
|
150
|
+
}
|
|
151
|
+
for (size_t i = 0; i < fees_lost; ++i) {
|
|
152
|
+
askFee();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
void Chain::finishRound(int64_t now)
|
|
157
|
+
{
|
|
158
|
+
const bool complete = m_next.m_count && m_next.m_fee_answers >= m_scanner.agreementsNeeded();
|
|
159
|
+
if (!m_next.m_count) {
|
|
160
|
+
m_next.m_count = m_current.m_count;
|
|
161
|
+
m_next.m_block_weight_limit = m_current.m_block_weight_limit;
|
|
162
|
+
}
|
|
163
|
+
if (m_next.m_fee_answers < m_scanner.agreementsNeeded()) {
|
|
164
|
+
m_next.m_fee_estimate = m_current.m_fee_estimate;
|
|
165
|
+
m_next.m_fee_disputed = m_current.m_fee_disputed;
|
|
166
|
+
}
|
|
167
|
+
m_current = m_next;
|
|
168
|
+
if (!complete) {
|
|
169
|
+
m_refresh_at = now + m_info_retry_seconds;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
void Chain::handle(const DaemonResponse &response, int64_t now)
|
|
174
|
+
{
|
|
175
|
+
const auto pending = m_pending.find({response.m_client_id, response.m_request_id});
|
|
176
|
+
if (pending == m_pending.end()) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const DaemonRequests request = pending->second;
|
|
180
|
+
m_pending.erase(pending);
|
|
181
|
+
if (!response.m_error.empty() || !response.m_result.is_object() || !handleResult(response)) {
|
|
182
|
+
fail(response, request);
|
|
183
|
+
}
|
|
184
|
+
if (m_next.m_count) {
|
|
185
|
+
m_current.m_count = m_next.m_count;
|
|
186
|
+
m_current.m_block_weight_limit = m_next.m_block_weight_limit;
|
|
187
|
+
}
|
|
188
|
+
if (m_next.m_fee_answers >= m_scanner.agreementsNeeded()) {
|
|
189
|
+
if (m_next.m_fee_disputed && !m_current.m_fee_disputed) {
|
|
190
|
+
LOGE(
|
|
191
|
+
"Chain: the daemons' fee estimates differ by more than %llux, the higher is capped",
|
|
192
|
+
(unsigned long long)FEE_DISPUTE_RATIO);
|
|
193
|
+
}
|
|
194
|
+
m_current.m_fee_estimate = m_next.m_fee_estimate;
|
|
195
|
+
m_current.m_fee_disputed = m_next.m_fee_disputed;
|
|
196
|
+
}
|
|
197
|
+
if (m_pending.empty()) {
|
|
198
|
+
finishRound(now);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
bool Chain::handleResult(const DaemonResponse &response)
|
|
203
|
+
{
|
|
204
|
+
const nlohmann::json &result = response.m_result;
|
|
205
|
+
switch (response.m_request) {
|
|
206
|
+
case DaemonRequests::GET_INFO: {
|
|
207
|
+
const auto count = result.find("height");
|
|
208
|
+
const auto limit = result.find("block_weight_limit");
|
|
209
|
+
if (count == result.end() || !count->is_number_unsigned() || limit == result.end() ||
|
|
210
|
+
!limit->is_number_unsigned() || count->get<uint64_t>() < RECENT_BLOCKS) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
m_next.m_count = count->get<uint64_t>();
|
|
214
|
+
m_next.m_block_weight_limit = limit->get<uint64_t>();
|
|
215
|
+
return track(m_daemon,
|
|
216
|
+
m_daemons[m_daemon]->getBlockHeadersRange(
|
|
217
|
+
0, *m_next.m_count - RECENT_BLOCKS, *m_next.m_count - 1),
|
|
218
|
+
DaemonRequests::GET_BLOCK_HEADERS_RANGE);
|
|
219
|
+
}
|
|
220
|
+
case DaemonRequests::GET_BLOCK_HEADERS_RANGE: {
|
|
221
|
+
const auto headers = result.find("headers");
|
|
222
|
+
std::vector<uint64_t> weights;
|
|
223
|
+
if (headers != result.end() && headers->is_array()) {
|
|
224
|
+
for (const auto &header : *headers) {
|
|
225
|
+
if (header.is_object() && header.contains("block_weight") &&
|
|
226
|
+
header["block_weight"].is_number_unsigned()) {
|
|
227
|
+
weights.push_back(header["block_weight"].get<uint64_t>());
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (weights.size() != RECENT_BLOCKS) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
m_next.m_recent_weights = weights;
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
case DaemonRequests::GET_FEE_ESTIMATE: {
|
|
238
|
+
FeeEstimate estimate;
|
|
239
|
+
if (0 != parseFeeEstimate(estimate, result)) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
m_next.m_fee_estimates.push_back(estimate);
|
|
243
|
+
FeeEstimate merged;
|
|
244
|
+
m_next.m_fee_disputed = mergeFeeEstimates(merged, m_next.m_fee_estimates);
|
|
245
|
+
floorFees(merged);
|
|
246
|
+
m_next.m_fee_estimate = merged;
|
|
247
|
+
m_next.m_fee_answers++;
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
case DaemonRequests::GET_TXPOOL_BACKLOG: {
|
|
251
|
+
std::vector<BacklogEntry> backlog;
|
|
252
|
+
if (0 != parseTxpoolBacklog(backlog, result)) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
m_next.m_backlog = backlog;
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
default:
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
void Chain::update(int64_t now)
|
|
264
|
+
{
|
|
265
|
+
m_scanner.update(now);
|
|
266
|
+
if (m_catch_up) {
|
|
267
|
+
m_catch_up->update(now);
|
|
268
|
+
}
|
|
269
|
+
refresh(now);
|
|
270
|
+
for (auto &daemon : m_daemons) {
|
|
271
|
+
for (const auto &response : daemon->takeResponses()) {
|
|
272
|
+
if (!m_scanner.handleResponse(response, now) &&
|
|
273
|
+
!(m_catch_up && m_catch_up->handleResponse(response, now)) &&
|
|
274
|
+
!handleJob(response, now)) {
|
|
275
|
+
handle(response, now);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
updateJobs(now);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
int64_t Chain::scannedHeight() const { return m_scanner.scannedHeight(); }
|
|
283
|
+
|
|
284
|
+
int64_t Chain::scannedHeight(int64_t id) const { return m_scanner.scannedHeight(id); }
|
|
285
|
+
|
|
286
|
+
// About twice Monero's height in 2026, so no daemon's claim can size a distribution beyond it
|
|
287
|
+
static constexpr uint64_t MAX_DISTRIBUTION_ENTRIES = 8'000'000;
|
|
288
|
+
|
|
289
|
+
int64_t Chain::chainHeight() const
|
|
290
|
+
{
|
|
291
|
+
if (!m_current.m_count) {
|
|
292
|
+
return -1;
|
|
293
|
+
}
|
|
294
|
+
const int64_t max_height = m_scanner.maxHeight();
|
|
295
|
+
const int64_t height = (int64_t)*m_current.m_count - 1;
|
|
296
|
+
return max_height < 0 ? height : std::min(height, max_height);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
uint64_t Chain::trustedCount() const
|
|
300
|
+
{
|
|
301
|
+
const AnchorStates anchor = m_scanner.anchorState();
|
|
302
|
+
if (!m_current.m_count || anchor == AnchorStates::PENDING || anchor == AnchorStates::DISPUTED) {
|
|
303
|
+
return 0;
|
|
304
|
+
}
|
|
305
|
+
const int64_t max_height = m_scanner.maxHeight();
|
|
306
|
+
return max_height < 0 ? *m_current.m_count
|
|
307
|
+
: std::min<uint64_t>(*m_current.m_count, (uint64_t)max_height + 1);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
void Chain::setAnchor(uint64_t height, const std::array<unsigned char, 32> &hash, int64_t now)
|
|
311
|
+
{
|
|
312
|
+
m_scanner.setAnchor(height, hash, now);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
int Chain::anchorState() const
|
|
316
|
+
{
|
|
317
|
+
switch (m_scanner.anchorState()) {
|
|
318
|
+
case AnchorStates::NONE:
|
|
319
|
+
return ViewKeyAnchorStates::NONE;
|
|
320
|
+
case AnchorStates::PENDING:
|
|
321
|
+
return ViewKeyAnchorStates::PENDING;
|
|
322
|
+
case AnchorStates::VERIFIED:
|
|
323
|
+
return ViewKeyAnchorStates::VERIFIED;
|
|
324
|
+
case AnchorStates::DISPUTED:
|
|
325
|
+
return ViewKeyAnchorStates::DISPUTED;
|
|
326
|
+
}
|
|
327
|
+
return ViewKeyAnchorStates::NONE;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
uint64_t Chain::anchorHeight() const { return m_scanner.anchorHeight(); }
|
|
331
|
+
|
|
332
|
+
int Chain::feeRate(uint32_t &tier, uint64_t &base_fee, uint64_t &quantization_mask,
|
|
333
|
+
uint32_t priority) const
|
|
334
|
+
{
|
|
335
|
+
const Snapshot &s = m_current;
|
|
336
|
+
if (!s.m_fee_estimate) {
|
|
337
|
+
return 1;
|
|
338
|
+
}
|
|
339
|
+
tier = priority > 0 ? std::min<uint32_t>(priority, 4)
|
|
340
|
+
: s.m_backlog && s.m_recent_weights
|
|
341
|
+
? adjustPriority(0, *s.m_fee_estimate, *s.m_backlog, s.m_block_weight_limit,
|
|
342
|
+
*s.m_recent_weights)
|
|
343
|
+
: 1;
|
|
344
|
+
quantization_mask = s.m_fee_estimate->quantization_mask;
|
|
345
|
+
return baseFee(base_fee, *s.m_fee_estimate, tier);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
void Chain::getInfo(nlohmann::json &j) const
|
|
349
|
+
{
|
|
350
|
+
j["chain_height"] = chainHeight();
|
|
351
|
+
j["scanned_height"] = m_scanner.scannedHeight();
|
|
352
|
+
j["at_tip"] = m_scanner.atTip();
|
|
353
|
+
if (m_catch_up) {
|
|
354
|
+
j["catch_up_height"] = m_catch_up->scannedHeight();
|
|
355
|
+
}
|
|
356
|
+
j["daemons"] = m_daemons.size();
|
|
357
|
+
uint32_t tier = 0;
|
|
358
|
+
uint64_t base_fee = 0, mask = 0;
|
|
359
|
+
if (0 == feeRate(tier, base_fee, mask)) {
|
|
360
|
+
j["fee_tier"] = tier;
|
|
361
|
+
j["base_fee"] = base_fee;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
void Chain::watchLock(int64_t id, const ViewKeyLock &lock)
|
|
366
|
+
{
|
|
367
|
+
const auto it = m_locks.find(id);
|
|
368
|
+
if (it != m_locks.end() && sameLock(it->second, lock)) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
m_locks[id] = lock;
|
|
372
|
+
ScanWatch watch;
|
|
373
|
+
watch.m_id = id;
|
|
374
|
+
watch.m_view_key = lock.m_view_key;
|
|
375
|
+
watch.m_spend_pubkeys = {lock.m_spend_pubkey};
|
|
376
|
+
watch.m_start_height = lock.m_start_height;
|
|
377
|
+
watch.m_lock_amount = lock.m_amount;
|
|
378
|
+
watch.m_lock_depth = lock.m_depth;
|
|
379
|
+
watch.m_hold = lock.m_hold;
|
|
380
|
+
m_scanner.addWatch(watch);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
void Chain::watchWallet(int64_t id, const ViewKeyWallet &wallet)
|
|
384
|
+
{
|
|
385
|
+
if (wallet.m_spend_keys.size() != wallet.m_spend_pubkeys.size()) {
|
|
386
|
+
LOGE("Chain: wallet %lld needs a spend key for each address", (long long)id);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const auto it = m_wallets.find(id);
|
|
390
|
+
if (it != m_wallets.end() && it->second.m_view_key == wallet.m_view_key &&
|
|
391
|
+
it->second.m_start_height == wallet.m_start_height &&
|
|
392
|
+
it->second.m_spend_pubkeys.size() <= wallet.m_spend_pubkeys.size() &&
|
|
393
|
+
std::equal(it->second.m_spend_pubkeys.begin(), it->second.m_spend_pubkeys.end(),
|
|
394
|
+
wallet.m_spend_pubkeys.begin())) {
|
|
395
|
+
const size_t known = it->second.m_spend_pubkeys.size();
|
|
396
|
+
if (wallet.m_spend_pubkeys.size() > known) {
|
|
397
|
+
const std::vector<std::vector<unsigned char>> pubkeys(
|
|
398
|
+
wallet.m_spend_pubkeys.begin() + known, wallet.m_spend_pubkeys.end());
|
|
399
|
+
const std::vector<secure_bytes> keys(wallet.m_spend_keys.begin() + known,
|
|
400
|
+
wallet.m_spend_keys.end());
|
|
401
|
+
m_scanner.addWatchKeys(id, pubkeys, keys, wallet.m_keys_from_height);
|
|
402
|
+
if (m_catch_up && m_catch_up->watch(id)) {
|
|
403
|
+
m_catch_up->addWatchKeys(id, pubkeys, keys, wallet.m_keys_from_height);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
it->second = wallet;
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
m_wallets[id] = wallet;
|
|
410
|
+
ScanWatch watch;
|
|
411
|
+
watch.m_id = id;
|
|
412
|
+
watch.m_view_key = wallet.m_view_key;
|
|
413
|
+
watch.m_spend_pubkeys = wallet.m_spend_pubkeys;
|
|
414
|
+
watch.m_spend_keys = wallet.m_spend_keys;
|
|
415
|
+
watch.m_start_height = wallet.m_start_height;
|
|
416
|
+
m_scanner.addWatch(watch);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
std::vector<ViewKeySeenSpend> Chain::spends(int64_t id) const
|
|
420
|
+
{
|
|
421
|
+
std::vector<ViewKeySeenSpend> seen;
|
|
422
|
+
for (const auto &s : m_scanner.spends(id)) {
|
|
423
|
+
ViewKeySeenSpend spend;
|
|
424
|
+
spend.m_key_image.assign(s.m_key_image.begin(), s.m_key_image.end());
|
|
425
|
+
spend.m_txid.assign(s.m_txid.begin(), s.m_txid.end());
|
|
426
|
+
spend.m_height = s.m_height;
|
|
427
|
+
seen.push_back(std::move(spend));
|
|
428
|
+
}
|
|
429
|
+
return seen;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
void Chain::startCatchUp(uint64_t from_height, uint64_t to_height,
|
|
433
|
+
const std::map<int64_t, uint64_t> &below)
|
|
434
|
+
{
|
|
435
|
+
m_catch_up = std::make_unique<Scanner>(m_ci, m_daemons);
|
|
436
|
+
m_catch_up->m_tip_refresh_seconds = m_scanner.m_tip_refresh_seconds;
|
|
437
|
+
m_catch_up->m_agreement_refresh_seconds = m_scanner.m_agreement_refresh_seconds;
|
|
438
|
+
m_catch_up->m_anchor_recheck_seconds = m_scanner.m_anchor_recheck_seconds;
|
|
439
|
+
m_catch_up->m_rescan_only = true;
|
|
440
|
+
m_catch_up->m_stop_height = to_height;
|
|
441
|
+
m_catch_up_below.clear();
|
|
442
|
+
for (const auto &[id, height] : below) {
|
|
443
|
+
std::optional<ScanWatch> watch = m_scanner.watch(id);
|
|
444
|
+
if (!watch) {
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
watch->m_start_height = from_height;
|
|
448
|
+
watch->m_hold = false;
|
|
449
|
+
m_catch_up->addWatch(*watch);
|
|
450
|
+
m_catch_up_below[id] = height;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
int Chain::catchUpState() const
|
|
455
|
+
{
|
|
456
|
+
return !m_catch_up ? ViewKeyCatchUpStates::NONE
|
|
457
|
+
: m_catch_up->atTip() ? ViewKeyCatchUpStates::DONE
|
|
458
|
+
: ViewKeyCatchUpStates::RUNNING;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
void Chain::finishCatchUp()
|
|
462
|
+
{
|
|
463
|
+
if (!m_catch_up) {
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
for (const auto &[id, height] : m_catch_up_below) {
|
|
467
|
+
std::vector<ScannedOutput> earlier = m_catch_up->outputs(id);
|
|
468
|
+
std::erase_if(earlier, [&](const ScannedOutput &o) { return o.m_height >= height; });
|
|
469
|
+
m_scanner.restoreOutputs(earlier);
|
|
470
|
+
std::vector<ScannedSpend> spent = m_catch_up->spends(id);
|
|
471
|
+
std::erase_if(spent, [&](const ScannedSpend &s) { return s.m_height >= height; });
|
|
472
|
+
m_scanner.restoreSpends(spent);
|
|
473
|
+
}
|
|
474
|
+
m_catch_up.reset();
|
|
475
|
+
m_catch_up_below.clear();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
void Chain::forget(int64_t id)
|
|
479
|
+
{
|
|
480
|
+
m_scanner.removeWatch(id);
|
|
481
|
+
if (m_catch_up) {
|
|
482
|
+
m_catch_up->removeWatch(id);
|
|
483
|
+
m_catch_up_below.erase(id);
|
|
484
|
+
if (m_catch_up_below.empty()) {
|
|
485
|
+
m_catch_up.reset();
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
m_locks.erase(id);
|
|
489
|
+
m_wallets.erase(id);
|
|
490
|
+
m_sweeps.erase(id);
|
|
491
|
+
m_sent.erase(id);
|
|
492
|
+
m_searches.erase(id);
|
|
493
|
+
m_spent_checks.erase(id);
|
|
494
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
495
|
+
return j.second.first != Jobs::DISTRIBUTION && j.second.second == id;
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
ViewKeyLockStatus Chain::lockStatus(int64_t id) const
|
|
500
|
+
{
|
|
501
|
+
const LockBStatus lock = m_scanner.lockB(id);
|
|
502
|
+
ViewKeyLockStatus status;
|
|
503
|
+
switch (lock.m_state) {
|
|
504
|
+
case LockBStates::SCANNING:
|
|
505
|
+
status.m_state = ViewKeyLockStates::SCANNING;
|
|
506
|
+
break;
|
|
507
|
+
case LockBStates::MISSING:
|
|
508
|
+
status.m_state = ViewKeyLockStates::MISSING;
|
|
509
|
+
break;
|
|
510
|
+
case LockBStates::CONFIRMING:
|
|
511
|
+
status.m_state = ViewKeyLockStates::CONFIRMING;
|
|
512
|
+
break;
|
|
513
|
+
case LockBStates::CONFIRMED:
|
|
514
|
+
status.m_state = ViewKeyLockStates::CONFIRMED;
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
status.m_invalid_seen = lock.m_invalid_seen;
|
|
518
|
+
status.m_disputed = lock.m_disputed;
|
|
519
|
+
status.m_depth = lock.m_depth;
|
|
520
|
+
if (lock.m_lock) {
|
|
521
|
+
status.m_txid.assign(lock.m_lock->m_txid.begin(), lock.m_lock->m_txid.end());
|
|
522
|
+
status.m_height = lock.m_lock->m_height;
|
|
523
|
+
status.m_value = lock.m_lock->m_output.amount;
|
|
524
|
+
status.m_tx_data = lock.m_lock->m_tx_data;
|
|
525
|
+
}
|
|
526
|
+
return status;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
std::string Chain::savedOutputs(int64_t id, uint64_t below_height) const
|
|
530
|
+
{
|
|
531
|
+
nlohmann::json saved = nlohmann::json::array();
|
|
532
|
+
for (const auto &o : m_scanner.outputs(id)) {
|
|
533
|
+
if (o.m_height >= below_height) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
saved.push_back({{"txid", hex_str(o.m_txid.data(), 32)},
|
|
537
|
+
{"height", o.m_height},
|
|
538
|
+
{"unlock_time", o.m_unlock_time},
|
|
539
|
+
{"key", hex_str(o.m_key.data(), 32)},
|
|
540
|
+
{"global_index", o.m_global_index},
|
|
541
|
+
{"index", o.m_output.index},
|
|
542
|
+
{"spend_pubkey_index", o.m_output.spend_pubkey_index},
|
|
543
|
+
{"amount", o.m_output.amount},
|
|
544
|
+
{"mask", hex_str(o.m_output.mask.data(), 32)},
|
|
545
|
+
{"commitment", hex_str(o.m_output.commitment.data(), 32)},
|
|
546
|
+
{"derivation", hex_str(o.m_output.derivation.data(), 32)},
|
|
547
|
+
{"tx_pubkey", hex_str(o.m_output.tx_pubkey.data(), 32)}});
|
|
548
|
+
}
|
|
549
|
+
return saved.dump();
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
int Chain::restoreOutputs(int64_t id, const std::string &saved)
|
|
553
|
+
{
|
|
554
|
+
const nlohmann::json j = nlohmann::json::parse(saved, nullptr, false);
|
|
555
|
+
if (!j.is_array()) {
|
|
556
|
+
return 1;
|
|
557
|
+
}
|
|
558
|
+
const auto hex32 = [](std::array<unsigned char, 32> &out, const nlohmann::json &e,
|
|
559
|
+
const char *name) {
|
|
560
|
+
std::vector<unsigned char> bytes;
|
|
561
|
+
if (!hexField(bytes, e, name, 32)) {
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
memcpy(out.data(), bytes.data(), 32);
|
|
565
|
+
return true;
|
|
566
|
+
};
|
|
567
|
+
std::vector<ScannedOutput> outputs;
|
|
568
|
+
for (const auto &e : j) {
|
|
569
|
+
ScannedOutput o;
|
|
570
|
+
o.m_watch_id = id;
|
|
571
|
+
if (!e.is_object() || !hex32(o.m_txid, e, "txid") || !hex32(o.m_key, e, "key") ||
|
|
572
|
+
!hex32(o.m_output.mask, e, "mask") || !hex32(o.m_output.commitment, e, "commitment") ||
|
|
573
|
+
!hex32(o.m_output.derivation, e, "derivation") ||
|
|
574
|
+
!hex32(o.m_output.tx_pubkey, e, "tx_pubkey") ||
|
|
575
|
+
!e.value("height", nlohmann::json()).is_number_unsigned() ||
|
|
576
|
+
!e.value("global_index", nlohmann::json()).is_number_unsigned() ||
|
|
577
|
+
!e.value("index", nlohmann::json()).is_number_unsigned() ||
|
|
578
|
+
!e.value("spend_pubkey_index", nlohmann::json()).is_number_unsigned() ||
|
|
579
|
+
!e.value("amount", nlohmann::json()).is_number_unsigned() ||
|
|
580
|
+
!e.value("unlock_time", nlohmann::json()).is_number_unsigned()) {
|
|
581
|
+
return 1;
|
|
582
|
+
}
|
|
583
|
+
o.m_height = e["height"];
|
|
584
|
+
o.m_unlock_time = e["unlock_time"];
|
|
585
|
+
o.m_global_index = e["global_index"];
|
|
586
|
+
o.m_output.index = e["index"];
|
|
587
|
+
o.m_output.spend_pubkey_index = e["spend_pubkey_index"];
|
|
588
|
+
o.m_output.amount = e["amount"];
|
|
589
|
+
o.m_commitment = o.m_output.commitment;
|
|
590
|
+
outputs.push_back(std::move(o));
|
|
591
|
+
}
|
|
592
|
+
m_scanner.restoreOutputs(outputs);
|
|
593
|
+
return 0;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
std::vector<ViewKeyOutput> Chain::outputs(int64_t id) const
|
|
597
|
+
{
|
|
598
|
+
uint32_t tier = 0;
|
|
599
|
+
uint64_t base_fee = 0, quantization_mask = 0;
|
|
600
|
+
const bool rated = m_current.m_count && 0 == feeRate(tier, base_fee, quantization_mask);
|
|
601
|
+
std::vector<ViewKeyOutput> found;
|
|
602
|
+
for (const auto &output : m_scanner.outputs(id)) {
|
|
603
|
+
ViewKeyOutput o;
|
|
604
|
+
o.m_txid.assign(output.m_txid.begin(), output.m_txid.end());
|
|
605
|
+
o.m_index = (uint32_t)output.m_output.index;
|
|
606
|
+
o.m_height = output.m_height;
|
|
607
|
+
o.m_amount = output.m_output.amount;
|
|
608
|
+
o.m_unlock_time = output.m_unlock_time;
|
|
609
|
+
o.m_spendable = rated && canSpend(output, trustedCount(), base_fee);
|
|
610
|
+
o.m_address = (uint32_t)output.m_output.spend_pubkey_index;
|
|
611
|
+
if (output.m_key_image) {
|
|
612
|
+
o.m_key_image.assign(output.m_key_image->begin(), output.m_key_image->end());
|
|
613
|
+
}
|
|
614
|
+
found.push_back(std::move(o));
|
|
615
|
+
}
|
|
616
|
+
return found;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
int Chain::beginSpend(int64_t id, Sweep &sweep)
|
|
620
|
+
{
|
|
621
|
+
if (sweep.m_inputs.empty()) {
|
|
622
|
+
return 1;
|
|
623
|
+
}
|
|
624
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
625
|
+
return j.second.second == id &&
|
|
626
|
+
(j.second.first == Jobs::OUTS || j.second.first == Jobs::KEY_IMAGES);
|
|
627
|
+
});
|
|
628
|
+
sweep.m_result.m_state = ViewKeySweepStates::BUILDING;
|
|
629
|
+
m_sweeps[id] = std::move(sweep);
|
|
630
|
+
m_distribution_fresh_to.reset();
|
|
631
|
+
return 0;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
int Chain::startLockSweep(int64_t id, const secure_bytes &spend_key,
|
|
635
|
+
const std::vector<unsigned char> &dest)
|
|
636
|
+
{
|
|
637
|
+
const auto existing = m_sweeps.find(id);
|
|
638
|
+
if (existing != m_sweeps.end() &&
|
|
639
|
+
existing->second.m_result.m_state != ViewKeySweepStates::FAILED) {
|
|
640
|
+
return 0;
|
|
641
|
+
}
|
|
642
|
+
if (m_locks.count(id) == 0 || !m_current.m_count) {
|
|
643
|
+
return 1;
|
|
644
|
+
}
|
|
645
|
+
Sweep sweep;
|
|
646
|
+
uint32_t tier = 0;
|
|
647
|
+
if (0 != feeRate(tier, sweep.m_base_fee, sweep.m_quantization_mask)) {
|
|
648
|
+
return 1;
|
|
649
|
+
}
|
|
650
|
+
for (const auto &output : m_scanner.outputs(id)) {
|
|
651
|
+
if (canSpend(output, trustedCount(), sweep.m_base_fee)) {
|
|
652
|
+
sweep.m_inputs.push_back(output);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
// Anyone can pay the lock's address; more inputs could push get_outs past MAX_OUTS
|
|
656
|
+
std::stable_sort(sweep.m_inputs.begin(), sweep.m_inputs.end(),
|
|
657
|
+
[](const ScannedOutput &a, const ScannedOutput &b) {
|
|
658
|
+
return a.m_output.amount > b.m_output.amount;
|
|
659
|
+
});
|
|
660
|
+
if (sweep.m_inputs.size() > MAX_LOCK_SWEEP_INPUTS) {
|
|
661
|
+
sweep.m_inputs.resize(MAX_LOCK_SWEEP_INPUTS);
|
|
662
|
+
}
|
|
663
|
+
sweep.m_source = id;
|
|
664
|
+
sweep.m_spend_key = spend_key;
|
|
665
|
+
sweep.m_dest = dest;
|
|
666
|
+
return beginSpend(id, sweep);
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
int Chain::startSpend(int64_t id, const ViewKeySpend &spend)
|
|
670
|
+
{
|
|
671
|
+
const auto existing = m_sweeps.find(id);
|
|
672
|
+
if (existing != m_sweeps.end() &&
|
|
673
|
+
existing->second.m_result.m_state != ViewKeySweepStates::FAILED &&
|
|
674
|
+
existing->second.m_source == spend.m_source && existing->second.m_named == spend.m_inputs &&
|
|
675
|
+
existing->second.m_dest == spend.m_dest && existing->second.m_amount == spend.m_amount &&
|
|
676
|
+
existing->second.m_outputs == spend.m_outputs &&
|
|
677
|
+
existing->second.m_subtract_fee == spend.m_subtract_fee) {
|
|
678
|
+
return 0;
|
|
679
|
+
}
|
|
680
|
+
const auto wallet = m_wallets.find(spend.m_source);
|
|
681
|
+
if ((wallet == m_wallets.end() && m_locks.count(spend.m_source) == 0) || !m_current.m_count ||
|
|
682
|
+
spend.m_inputs.empty() || (spend.m_amount == 0 && !spend.m_outputs.empty()) ||
|
|
683
|
+
(spend.m_amount == 0 && spend.m_subtract_fee)) {
|
|
684
|
+
return 1;
|
|
685
|
+
}
|
|
686
|
+
Sweep sweep;
|
|
687
|
+
uint32_t tier = 0;
|
|
688
|
+
if (0 != feeRate(tier, sweep.m_base_fee, sweep.m_quantization_mask, spend.m_priority)) {
|
|
689
|
+
return 1;
|
|
690
|
+
}
|
|
691
|
+
const std::vector<ScannedOutput> found = m_scanner.outputs(spend.m_source);
|
|
692
|
+
for (const auto &[txid, index] : spend.m_inputs) {
|
|
693
|
+
const auto it = std::find_if(found.begin(), found.end(), [&](const ScannedOutput &o) {
|
|
694
|
+
return o.m_output.index == index && txid.size() == o.m_txid.size() &&
|
|
695
|
+
std::equal(txid.begin(), txid.end(), o.m_txid.begin());
|
|
696
|
+
});
|
|
697
|
+
if (it == found.end() || !canSpend(*it, trustedCount(), sweep.m_base_fee)) {
|
|
698
|
+
return 1;
|
|
699
|
+
}
|
|
700
|
+
sweep.m_inputs.push_back(*it);
|
|
701
|
+
if (wallet != m_wallets.end()) {
|
|
702
|
+
const size_t address = it->m_output.spend_pubkey_index;
|
|
703
|
+
if (address >= wallet->second.m_spend_keys.size()) {
|
|
704
|
+
return 1;
|
|
705
|
+
}
|
|
706
|
+
sweep.m_input_keys.push_back(wallet->second.m_spend_keys[address]);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
sweep.m_source = spend.m_source;
|
|
710
|
+
sweep.m_named = spend.m_inputs;
|
|
711
|
+
sweep.m_spend_key = spend.m_spend_key;
|
|
712
|
+
sweep.m_dest = spend.m_dest;
|
|
713
|
+
sweep.m_amount = spend.m_amount;
|
|
714
|
+
sweep.m_outputs = spend.m_outputs;
|
|
715
|
+
sweep.m_subtract_fee = spend.m_subtract_fee;
|
|
716
|
+
return beginSpend(id, sweep);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
int Chain::feePerKb(uint64_t &rate) const
|
|
720
|
+
{
|
|
721
|
+
uint32_t tier = 0;
|
|
722
|
+
uint64_t base_fee = 0, quantization_mask = 0;
|
|
723
|
+
if (0 != feeRate(tier, base_fee, quantization_mask)) {
|
|
724
|
+
return 1;
|
|
725
|
+
}
|
|
726
|
+
rate = base_fee * 1000;
|
|
727
|
+
return 0;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
int Chain::reserveProof(std::string &proof, int64_t id,
|
|
731
|
+
const std::vector<std::pair<std::vector<unsigned char>, uint32_t>> &outputs,
|
|
732
|
+
const secure_bytes &spend_key, const secure_bytes &view_key,
|
|
733
|
+
const std::string &message) const
|
|
734
|
+
{
|
|
735
|
+
const std::vector<ScannedOutput> found = m_scanner.outputs(id);
|
|
736
|
+
std::vector<ScannedOutput> proven;
|
|
737
|
+
for (const auto &[txid, index] : outputs) {
|
|
738
|
+
const auto it = std::find_if(found.begin(), found.end(), [&](const ScannedOutput &o) {
|
|
739
|
+
return o.m_output.index == index && txid.size() == o.m_txid.size() &&
|
|
740
|
+
std::equal(txid.begin(), txid.end(), o.m_txid.begin());
|
|
741
|
+
});
|
|
742
|
+
if (it == found.end()) {
|
|
743
|
+
return 1;
|
|
744
|
+
}
|
|
745
|
+
proven.push_back(*it);
|
|
746
|
+
}
|
|
747
|
+
return xmr::reserveProof(proof, spend_key, view_key, proven, message);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
uint64_t Chain::spendableDepth() const { return spendableAge(); }
|
|
751
|
+
|
|
752
|
+
int Chain::fractionalThreshold(uint64_t &threshold, uint32_t priority) const
|
|
753
|
+
{
|
|
754
|
+
uint32_t tier = 0;
|
|
755
|
+
uint64_t base_fee = 0, quantization_mask = 0;
|
|
756
|
+
if (0 != feeRate(tier, base_fee, quantization_mask, priority)) {
|
|
757
|
+
return 1;
|
|
758
|
+
}
|
|
759
|
+
threshold = bsx::xmr::fractionalThreshold(base_fee);
|
|
760
|
+
return 0;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
int Chain::estimateFee(uint64_t &fee, size_t n_inputs, size_t n_outputs, uint32_t priority) const
|
|
764
|
+
{
|
|
765
|
+
uint32_t tier = 0;
|
|
766
|
+
uint64_t base_fee = 0, quantization_mask = 0;
|
|
767
|
+
if (n_inputs == 0 || n_outputs < 2 ||
|
|
768
|
+
0 != feeRate(tier, base_fee, quantization_mask, priority)) {
|
|
769
|
+
return 1;
|
|
770
|
+
}
|
|
771
|
+
fee = feeFromWeight(base_fee, estimateTxWeight(n_inputs, n_outputs, 0), quantization_mask);
|
|
772
|
+
return 0;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
void Chain::dropSweep(int64_t id)
|
|
776
|
+
{
|
|
777
|
+
m_sweeps.erase(id);
|
|
778
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
779
|
+
return j.second.second == id &&
|
|
780
|
+
(j.second.first == Jobs::OUTS || j.second.first == Jobs::KEY_IMAGES);
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
ViewKeySweep Chain::sweep(int64_t id) const
|
|
785
|
+
{
|
|
786
|
+
const auto it = m_sweeps.find(id);
|
|
787
|
+
return it == m_sweeps.end() ? ViewKeySweep() : it->second.m_result;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
void Chain::sendTx(int64_t id, const std::vector<unsigned char> &txid,
|
|
791
|
+
const std::vector<unsigned char> &tx_data)
|
|
792
|
+
{
|
|
793
|
+
trackTx(id, txid);
|
|
794
|
+
for (size_t d = 0; d < m_daemons.size(); ++d) {
|
|
795
|
+
if (!job(Jobs::SEND, id, d, m_daemons[d]->sendRawTransaction(id, tx_data))) {
|
|
796
|
+
LOGW("Chain: daemon %d refused to queue a send", m_daemons[d]->id());
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
void Chain::trackTx(int64_t id, const std::vector<unsigned char> &txid)
|
|
802
|
+
{
|
|
803
|
+
Sent &sent = m_sent[id];
|
|
804
|
+
if (sent.m_txid != txid) {
|
|
805
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
806
|
+
return j.second.second == id &&
|
|
807
|
+
(j.second.first == Jobs::SEND || j.second.first == Jobs::TX);
|
|
808
|
+
});
|
|
809
|
+
sent = Sent();
|
|
810
|
+
sent.m_txid = txid;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
ViewKeyTxStatus Chain::txStatus(int64_t id) const
|
|
815
|
+
{
|
|
816
|
+
const auto it = m_sent.find(id);
|
|
817
|
+
if (it == m_sent.end()) {
|
|
818
|
+
return ViewKeyTxStatus();
|
|
819
|
+
}
|
|
820
|
+
ViewKeyTxStatus status = it->second.m_status;
|
|
821
|
+
if (trustedCount() == 0) {
|
|
822
|
+
status.m_depth = 0;
|
|
823
|
+
status.m_height = 0;
|
|
824
|
+
}
|
|
825
|
+
return status;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
void Chain::startHeightSearch(int64_t id, uint64_t timestamp)
|
|
829
|
+
{
|
|
830
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
831
|
+
return j.second.first == Jobs::SEARCH && j.second.second == id;
|
|
832
|
+
});
|
|
833
|
+
Search &search = m_searches[id];
|
|
834
|
+
search = Search();
|
|
835
|
+
search.m_search.m_result.m_state = ViewKeySearchStates::SEARCHING;
|
|
836
|
+
search.m_search.m_target = timestamp;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
ViewKeyHeightSearch Chain::heightSearch(int64_t id) const
|
|
840
|
+
{
|
|
841
|
+
const auto it = m_searches.find(id);
|
|
842
|
+
return it == m_searches.end() ? ViewKeyHeightSearch() : it->second.m_search.m_result;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
void Chain::startSpentCheck(int64_t id, const secure_bytes &spend_key)
|
|
846
|
+
{
|
|
847
|
+
std::erase_if(m_jobs, [&](const auto &j) {
|
|
848
|
+
return j.second.first == Jobs::SPENT && j.second.second == id;
|
|
849
|
+
});
|
|
850
|
+
SpentCheck &check = m_spent_checks[id];
|
|
851
|
+
check = SpentCheck();
|
|
852
|
+
const std::vector<ScannedOutput> found = m_scanner.outputs(id);
|
|
853
|
+
if (0 != keyImages(check.m_key_images, spend_key, found)) {
|
|
854
|
+
check.m_result.m_state = ViewKeySearchStates::FAILED;
|
|
855
|
+
check.m_result.m_error = "an output isn't the address's";
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
for (const auto &output : found) {
|
|
859
|
+
ViewKeyOutput o;
|
|
860
|
+
o.m_txid.assign(output.m_txid.begin(), output.m_txid.end());
|
|
861
|
+
o.m_index = (uint32_t)output.m_output.index;
|
|
862
|
+
o.m_height = output.m_height;
|
|
863
|
+
o.m_amount = output.m_output.amount;
|
|
864
|
+
check.m_outputs.push_back(std::move(o));
|
|
865
|
+
}
|
|
866
|
+
check.m_result.m_state =
|
|
867
|
+
found.empty() ? ViewKeySearchStates::FOUND : ViewKeySearchStates::SEARCHING;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
ViewKeySpentCheck Chain::spentCheck(int64_t id) const
|
|
871
|
+
{
|
|
872
|
+
const auto it = m_spent_checks.find(id);
|
|
873
|
+
return it == m_spent_checks.end() ? ViewKeySpentCheck() : it->second.m_result;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
void Chain::loadCache(const std::vector<unsigned char> &data)
|
|
877
|
+
{
|
|
878
|
+
m_rct_offsets.clear();
|
|
879
|
+
m_rct_start = 0;
|
|
880
|
+
m_cached = 0;
|
|
881
|
+
m_distribution_fresh_to.reset();
|
|
882
|
+
if (data.empty()) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
size_t o = 0;
|
|
886
|
+
uint64_t start = 0, count = 0;
|
|
887
|
+
if (!readVarint(start, data, o) || !readVarint(count, data, o) || count > data.size() - o) {
|
|
888
|
+
LOGW("Chain: unreadable output distribution cache");
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
std::vector<uint64_t> offsets;
|
|
892
|
+
offsets.reserve(count);
|
|
893
|
+
uint64_t total = 0;
|
|
894
|
+
for (uint64_t i = 0; i < count; ++i) {
|
|
895
|
+
uint64_t delta = 0;
|
|
896
|
+
if (!readVarint(delta, data, o) || delta > UINT64_MAX - total) {
|
|
897
|
+
LOGW("Chain: unreadable output distribution cache");
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
total += delta;
|
|
901
|
+
offsets.push_back(total);
|
|
902
|
+
}
|
|
903
|
+
if (o != data.size()) {
|
|
904
|
+
LOGW("Chain: unreadable output distribution cache");
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
m_rct_start = start;
|
|
908
|
+
m_rct_offsets = std::move(offsets);
|
|
909
|
+
m_cached = m_rct_offsets.size();
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
bool Chain::takeCache(std::vector<unsigned char> &data)
|
|
913
|
+
{
|
|
914
|
+
if (!m_cache_changed) {
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
917
|
+
m_cache_changed = false;
|
|
918
|
+
data.clear();
|
|
919
|
+
if (m_cached == 0) {
|
|
920
|
+
return true;
|
|
921
|
+
}
|
|
922
|
+
writeVarint(data, m_rct_start);
|
|
923
|
+
writeVarint(data, m_cached);
|
|
924
|
+
uint64_t previous = 0;
|
|
925
|
+
for (size_t i = 0; i < m_cached; ++i) {
|
|
926
|
+
writeVarint(data, m_rct_offsets[i] - previous);
|
|
927
|
+
previous = m_rct_offsets[i];
|
|
928
|
+
}
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
bool Chain::job(Jobs kind, int64_t id, size_t daemon, size_t request_id)
|
|
933
|
+
{
|
|
934
|
+
if (request_id == 0) {
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
m_jobs[{m_daemons[daemon]->id(), request_id}] = {kind, id};
|
|
938
|
+
return true;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
void Chain::failSweep(int64_t id, const std::string &error)
|
|
942
|
+
{
|
|
943
|
+
LOGW("Chain: sweep %lld failed: %s", (long long)id, error.c_str());
|
|
944
|
+
Sweep &sweep = m_sweeps[id];
|
|
945
|
+
sweep.m_result.m_state = ViewKeySweepStates::FAILED;
|
|
946
|
+
sweep.m_result.m_error = error;
|
|
947
|
+
sweep.m_spend_key.clear();
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
void Chain::updateJobs(int64_t now)
|
|
951
|
+
{
|
|
952
|
+
if (m_daemons.empty()) {
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
const auto waiting = [](const Sweep &sweep) {
|
|
956
|
+
return sweep.m_result.m_state == ViewKeySweepStates::BUILDING &&
|
|
957
|
+
sweep.m_stage == Sweep::Stages::DISTRIBUTION;
|
|
958
|
+
};
|
|
959
|
+
const bool any_waiting = std::any_of(m_sweeps.begin(), m_sweeps.end(),
|
|
960
|
+
[&](const auto &s) { return waiting(s.second); });
|
|
961
|
+
if (any_waiting && !m_distribution_fresh_to && !m_distribution_pending && chainHeight() >= 0) {
|
|
962
|
+
const uint64_t tip = (uint64_t)chainHeight();
|
|
963
|
+
if (m_cached > 0 && m_rct_start + m_cached > tip) {
|
|
964
|
+
LOGW("Chain: the output distribution cache is above the tip; dropping it");
|
|
965
|
+
m_cached = 0;
|
|
966
|
+
m_cache_changed = true;
|
|
967
|
+
}
|
|
968
|
+
m_rct_offsets.resize(m_cached);
|
|
969
|
+
const uint64_t from = m_cached > 0 ? m_rct_start + m_cached : 0;
|
|
970
|
+
m_distribution_from = from;
|
|
971
|
+
m_distribution_to = std::min(tip, from + MAX_DISTRIBUTION_ENTRIES - 1);
|
|
972
|
+
m_distribution_pending =
|
|
973
|
+
job(Jobs::DISTRIBUTION, 0, m_daemon,
|
|
974
|
+
m_daemons[m_daemon]->getOutputDistribution(0, from, m_distribution_to));
|
|
975
|
+
}
|
|
976
|
+
if (m_distribution_fresh_to) {
|
|
977
|
+
for (auto &[id, sweep] : m_sweeps) {
|
|
978
|
+
if (waiting(sweep)) {
|
|
979
|
+
requestOuts(id, sweep);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
for (auto &[id, sent] : m_sent) {
|
|
984
|
+
if (sent.m_checks_pending > 0 || now < sent.m_check_at) {
|
|
985
|
+
continue;
|
|
986
|
+
}
|
|
987
|
+
sent.m_check_at = now + m_tx_refresh_seconds;
|
|
988
|
+
for (size_t d = 0; d < m_daemons.size(); ++d) {
|
|
989
|
+
if (job(Jobs::TX, id, d, m_daemons[d]->getTransactions(id, {sent.m_txid}, true))) {
|
|
990
|
+
sent.m_checks_pending++;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
for (auto &[id, search] : m_searches) {
|
|
995
|
+
if (search.m_search.m_result.m_state == ViewKeySearchStates::SEARCHING) {
|
|
996
|
+
stepSearch(id, search);
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
const size_t needed = m_scanner.agreementsNeeded();
|
|
1000
|
+
for (auto &[id, check] : m_spent_checks) {
|
|
1001
|
+
if (check.m_result.m_state != ViewKeySearchStates::SEARCHING) {
|
|
1002
|
+
continue;
|
|
1003
|
+
}
|
|
1004
|
+
for (size_t i = 0; i < m_daemons.size() && check.m_asked.size() < needed; ++i) {
|
|
1005
|
+
const size_t d = (m_daemon + i) % m_daemons.size();
|
|
1006
|
+
if (!check.m_asked.count(d) &&
|
|
1007
|
+
job(Jobs::SPENT, id, d, m_daemons[d]->isKeyImageSpent(id, check.m_key_images))) {
|
|
1008
|
+
check.m_asked.insert(d);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
bool Chain::handleJob(const DaemonResponse &response, int64_t now)
|
|
1015
|
+
{
|
|
1016
|
+
const auto it = m_jobs.find({response.m_client_id, response.m_request_id});
|
|
1017
|
+
if (it == m_jobs.end()) {
|
|
1018
|
+
return false;
|
|
1019
|
+
}
|
|
1020
|
+
const auto [kind, id] = it->second;
|
|
1021
|
+
m_jobs.erase(it);
|
|
1022
|
+
if (kind == Jobs::DISTRIBUTION) {
|
|
1023
|
+
m_distribution_pending = false;
|
|
1024
|
+
onDistribution(response);
|
|
1025
|
+
return true;
|
|
1026
|
+
}
|
|
1027
|
+
if (kind == Jobs::SEND || kind == Jobs::TX) {
|
|
1028
|
+
const auto sent = m_sent.find(id);
|
|
1029
|
+
if (sent != m_sent.end()) {
|
|
1030
|
+
kind == Jobs::SEND ? onSend(sent->second, response) : onTx(sent->second, response);
|
|
1031
|
+
}
|
|
1032
|
+
return true;
|
|
1033
|
+
}
|
|
1034
|
+
if (kind == Jobs::SEARCH) {
|
|
1035
|
+
const auto search = m_searches.find(id);
|
|
1036
|
+
if (search != m_searches.end() &&
|
|
1037
|
+
search->second.m_search.m_result.m_state == ViewKeySearchStates::SEARCHING) {
|
|
1038
|
+
onSearchBlock(id, search->second, response);
|
|
1039
|
+
}
|
|
1040
|
+
return true;
|
|
1041
|
+
}
|
|
1042
|
+
if (kind == Jobs::SPENT) {
|
|
1043
|
+
const auto check = m_spent_checks.find(id);
|
|
1044
|
+
if (check != m_spent_checks.end() &&
|
|
1045
|
+
check->second.m_result.m_state == ViewKeySearchStates::SEARCHING) {
|
|
1046
|
+
onSpentCheck(check->second, response);
|
|
1047
|
+
}
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
const auto sweep = m_sweeps.find(id);
|
|
1051
|
+
if (sweep == m_sweeps.end() || sweep->second.m_result.m_state != ViewKeySweepStates::BUILDING) {
|
|
1052
|
+
return true;
|
|
1053
|
+
}
|
|
1054
|
+
if (!response.m_error.empty() || !response.m_result.is_object()) {
|
|
1055
|
+
failSweep(id, strprintf("daemon %d: %s", response.m_client_id, response.m_error.c_str()));
|
|
1056
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
1057
|
+
return true;
|
|
1058
|
+
}
|
|
1059
|
+
if (kind == Jobs::OUTS) {
|
|
1060
|
+
onOuts(id, sweep->second, response);
|
|
1061
|
+
} else {
|
|
1062
|
+
onKeyImages(id, sweep->second, response);
|
|
1063
|
+
}
|
|
1064
|
+
return true;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
void Chain::onDistribution(const DaemonResponse &response)
|
|
1068
|
+
{
|
|
1069
|
+
std::vector<uint64_t> offsets;
|
|
1070
|
+
uint64_t start = 0;
|
|
1071
|
+
const bool appends = !m_rct_offsets.empty();
|
|
1072
|
+
std::string error;
|
|
1073
|
+
if (!response.m_error.empty() || !response.m_result.is_object() ||
|
|
1074
|
+
0 != parseDistribution(offsets, response.m_result, &start,
|
|
1075
|
+
m_distribution_to - m_distribution_from + 1) ||
|
|
1076
|
+
offsets.empty() || !std::is_sorted(offsets.begin(), offsets.end())) {
|
|
1077
|
+
error = "unusable output distribution: " + response.m_error;
|
|
1078
|
+
} else if (start < m_distribution_from || start > m_distribution_to ||
|
|
1079
|
+
offsets.size() != m_distribution_to - start + 1) {
|
|
1080
|
+
error = "output distribution outside the heights asked for";
|
|
1081
|
+
} else if (appends && (start != m_rct_start + m_rct_offsets.size() ||
|
|
1082
|
+
offsets.front() < m_rct_offsets.back())) {
|
|
1083
|
+
LOGW("Chain: daemon %d's output distribution doesn't continue the cache; dropping it",
|
|
1084
|
+
response.m_client_id);
|
|
1085
|
+
m_rct_offsets.clear();
|
|
1086
|
+
m_cached = 0;
|
|
1087
|
+
m_cache_changed = true;
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
if (!error.empty()) {
|
|
1091
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
1092
|
+
for (auto &[id, sweep] : m_sweeps) {
|
|
1093
|
+
if (sweep.m_result.m_state == ViewKeySweepStates::BUILDING &&
|
|
1094
|
+
sweep.m_stage == Sweep::Stages::DISTRIBUTION) {
|
|
1095
|
+
failSweep(id, strprintf("daemon %d: %s", response.m_client_id, error.c_str()));
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
return;
|
|
1099
|
+
}
|
|
1100
|
+
if (!appends) {
|
|
1101
|
+
m_rct_start = start;
|
|
1102
|
+
}
|
|
1103
|
+
m_rct_offsets.insert(m_rct_offsets.end(), offsets.begin(), offsets.end());
|
|
1104
|
+
const uint64_t top = m_rct_start + m_rct_offsets.size() - 1;
|
|
1105
|
+
m_distribution_fresh_to = top;
|
|
1106
|
+
const size_t keep =
|
|
1107
|
+
top >= m_rct_start + m_cache_margin ? (size_t)(top - m_cache_margin - m_rct_start + 1) : 0;
|
|
1108
|
+
if (keep > m_cached) {
|
|
1109
|
+
m_cached = keep;
|
|
1110
|
+
m_cache_changed = true;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
void Chain::requestOuts(int64_t id, Sweep &sweep)
|
|
1115
|
+
{
|
|
1116
|
+
uint64_t max_index = 0;
|
|
1117
|
+
for (const auto &input : sweep.m_inputs) {
|
|
1118
|
+
max_index = std::max(max_index, input.m_global_index);
|
|
1119
|
+
}
|
|
1120
|
+
GammaPicker picker;
|
|
1121
|
+
if (0 != checkDistribution(m_rct_offsets, max_index) || 0 != picker.init(m_rct_offsets)) {
|
|
1122
|
+
failSweep(id, "the output distribution doesn't cover the inputs");
|
|
1123
|
+
return;
|
|
1124
|
+
}
|
|
1125
|
+
sweep.m_requests.clear();
|
|
1126
|
+
sweep.m_orders.clear();
|
|
1127
|
+
std::vector<uint64_t> all;
|
|
1128
|
+
for (const auto &input : sweep.m_inputs) {
|
|
1129
|
+
std::vector<uint64_t> request, order;
|
|
1130
|
+
if (0 != pickRingCandidates(request, order, picker, input.m_global_index)) {
|
|
1131
|
+
LOGW("Chain: no ring candidates from the output distribution; dropping it");
|
|
1132
|
+
m_rct_offsets.clear();
|
|
1133
|
+
m_cached = 0;
|
|
1134
|
+
m_cache_changed = true;
|
|
1135
|
+
m_distribution_fresh_to.reset();
|
|
1136
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
1137
|
+
failSweep(id, "no ring candidates");
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
all.insert(all.end(), request.begin(), request.end());
|
|
1141
|
+
sweep.m_requests.push_back(std::move(request));
|
|
1142
|
+
sweep.m_orders.push_back(std::move(order));
|
|
1143
|
+
}
|
|
1144
|
+
sweep.m_outs_chunks.clear();
|
|
1145
|
+
sweep.m_outs_sizes.clear();
|
|
1146
|
+
sweep.m_outs_parts.clear();
|
|
1147
|
+
for (size_t at = 0; at < all.size(); at += OUTS_CHUNK) {
|
|
1148
|
+
const std::vector<uint64_t> chunk(all.begin() + at,
|
|
1149
|
+
all.begin() + std::min(all.size(), at + OUTS_CHUNK));
|
|
1150
|
+
const size_t request_id = m_daemons[m_daemon]->getOuts(id, chunk);
|
|
1151
|
+
if (!job(Jobs::OUTS, id, m_daemon, request_id)) {
|
|
1152
|
+
failSweep(id, "get_outs not queued");
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
sweep.m_outs_chunks[request_id] = sweep.m_outs_sizes.size();
|
|
1156
|
+
sweep.m_outs_sizes.push_back(chunk.size());
|
|
1157
|
+
}
|
|
1158
|
+
sweep.m_outs_parts.resize(sweep.m_outs_sizes.size());
|
|
1159
|
+
sweep.m_stage = Sweep::Stages::OUTS;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
void Chain::onOuts(int64_t id, Sweep &sweep, const DaemonResponse &response)
|
|
1163
|
+
{
|
|
1164
|
+
const auto chunk = sweep.m_outs_chunks.find(response.m_request_id);
|
|
1165
|
+
std::vector<OutsEntry> answered;
|
|
1166
|
+
if (chunk == sweep.m_outs_chunks.end() || 0 != parseOuts(answered, response.m_result) ||
|
|
1167
|
+
answered.size() != sweep.m_outs_sizes[chunk->second]) {
|
|
1168
|
+
failSweep(id, "get_outs answered other outputs");
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
sweep.m_outs_parts[chunk->second] = std::move(answered);
|
|
1172
|
+
sweep.m_outs_chunks.erase(chunk);
|
|
1173
|
+
if (!sweep.m_outs_chunks.empty()) {
|
|
1174
|
+
return;
|
|
1175
|
+
}
|
|
1176
|
+
std::vector<OutsEntry> outs;
|
|
1177
|
+
for (auto &part : sweep.m_outs_parts) {
|
|
1178
|
+
outs.insert(outs.end(), part.begin(), part.end());
|
|
1179
|
+
}
|
|
1180
|
+
secure_bytes view_key;
|
|
1181
|
+
std::vector<unsigned char> main_spend_pubkey;
|
|
1182
|
+
if (const auto lock = m_locks.find(sweep.m_source); lock != m_locks.end()) {
|
|
1183
|
+
view_key = lock->second.m_view_key;
|
|
1184
|
+
main_spend_pubkey = lock->second.m_spend_pubkey;
|
|
1185
|
+
} else if (const auto wallet = m_wallets.find(sweep.m_source);
|
|
1186
|
+
wallet != m_wallets.end() && !wallet->second.m_spend_pubkeys.empty()) {
|
|
1187
|
+
view_key = wallet->second.m_view_key;
|
|
1188
|
+
main_spend_pubkey = wallet->second.m_spend_pubkeys[0];
|
|
1189
|
+
} else {
|
|
1190
|
+
failSweep(id, "the spent watch is gone");
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
std::vector<SpendSource> sources;
|
|
1194
|
+
size_t at = 0;
|
|
1195
|
+
for (size_t i = 0; i < sweep.m_inputs.size(); ++i) {
|
|
1196
|
+
const ScannedOutput &input = sweep.m_inputs[i];
|
|
1197
|
+
const std::vector<OutsEntry> slice(outs.begin() + at,
|
|
1198
|
+
outs.begin() + at + sweep.m_requests[i].size());
|
|
1199
|
+
at += sweep.m_requests[i].size();
|
|
1200
|
+
SpendSource source;
|
|
1201
|
+
const RingMember real{input.m_global_index, input.m_key, input.m_commitment};
|
|
1202
|
+
if (0 != buildRing(source.ring, source.real_position, sweep.m_requests[i], slice,
|
|
1203
|
+
sweep.m_orders[i], real)) {
|
|
1204
|
+
failSweep(id, "the daemon's ring members are unusable");
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
source.owned = input.m_output;
|
|
1208
|
+
source.spend_key = sweep.m_input_keys.empty() ? sweep.m_spend_key : sweep.m_input_keys[i];
|
|
1209
|
+
sources.push_back(std::move(source));
|
|
1210
|
+
}
|
|
1211
|
+
SpendAccount account;
|
|
1212
|
+
account.view_key = view_key;
|
|
1213
|
+
std::vector<unsigned char> view_pubkey;
|
|
1214
|
+
if (0 != m_ci.getPubkey(view_pubkey, view_key)) {
|
|
1215
|
+
failSweep(id, "invalid view key");
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
account.main_dest = {DestKinds::STANDARD};
|
|
1219
|
+
account.main_dest.insert(account.main_dest.end(), main_spend_pubkey.begin(),
|
|
1220
|
+
main_spend_pubkey.end());
|
|
1221
|
+
account.main_dest.insert(account.main_dest.end(), view_pubkey.begin(), view_pubkey.end());
|
|
1222
|
+
if (sweep.m_amount == 0 && 0 != buildSweep(sweep.m_built, m_ci, account, sources, sweep.m_dest,
|
|
1223
|
+
sweep.m_base_fee, sweep.m_quantization_mask)) {
|
|
1224
|
+
failSweep(id, "the sweep didn't build");
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
std::vector<Payment> payments{{sweep.m_dest, sweep.m_amount}};
|
|
1228
|
+
for (const auto &[dest, amount] : sweep.m_outputs) {
|
|
1229
|
+
payments.push_back({dest, amount});
|
|
1230
|
+
}
|
|
1231
|
+
if (sweep.m_amount > 0 &&
|
|
1232
|
+
0 != buildTransfer(sweep.m_built, m_ci, account, sources, payments, sweep.m_base_fee,
|
|
1233
|
+
sweep.m_quantization_mask, sweep.m_subtract_fee)) {
|
|
1234
|
+
failSweep(id, "the transfer didn't build");
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
sweep.m_result.m_fee = sweep.m_built.tx.fee;
|
|
1238
|
+
sweep.m_result.m_amount = sweep.m_built.amount;
|
|
1239
|
+
sweep.m_result.m_change = sweep.m_built.change;
|
|
1240
|
+
std::vector<std::vector<unsigned char>> key_images;
|
|
1241
|
+
for (const auto &key_image : sweep.m_built.key_images) {
|
|
1242
|
+
key_images.emplace_back(key_image.begin(), key_image.end());
|
|
1243
|
+
}
|
|
1244
|
+
if (!job(Jobs::KEY_IMAGES, id, m_daemon,
|
|
1245
|
+
m_daemons[m_daemon]->isKeyImageSpent(id, key_images))) {
|
|
1246
|
+
failSweep(id, "is_key_image_spent not queued");
|
|
1247
|
+
return;
|
|
1248
|
+
}
|
|
1249
|
+
sweep.m_stage = Sweep::Stages::KEY_IMAGES;
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
void Chain::onKeyImages(int64_t id, Sweep &sweep, const DaemonResponse &response)
|
|
1253
|
+
{
|
|
1254
|
+
const auto statuses = response.m_result.find("spent_status");
|
|
1255
|
+
if (statuses == response.m_result.end() || !statuses->is_array() ||
|
|
1256
|
+
statuses->size() != sweep.m_built.key_images.size()) {
|
|
1257
|
+
failSweep(id, "is_key_image_spent answered other key images");
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
for (const auto &status : *statuses) {
|
|
1261
|
+
if (!status.is_number_unsigned()) {
|
|
1262
|
+
failSweep(id, "is_key_image_spent answered other key images");
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
if (status.get<uint64_t>() != 0) {
|
|
1266
|
+
failSweep(id, "an input is already spent");
|
|
1267
|
+
return;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
sweep.m_result.m_state = ViewKeySweepStates::BUILT;
|
|
1271
|
+
sweep.m_result.m_txid = sweep.m_built.txid;
|
|
1272
|
+
sweep.m_result.m_tx_data = sweep.m_built.data;
|
|
1273
|
+
sweep.m_spend_key.clear();
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
void Chain::onSend(Sent &sent, const DaemonResponse &response)
|
|
1277
|
+
{
|
|
1278
|
+
if (response.m_error.empty()) {
|
|
1279
|
+
sent.m_status.m_accepted = true;
|
|
1280
|
+
sent.m_status.m_error.clear();
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
std::string error = response.m_error;
|
|
1284
|
+
if (response.m_result.is_object()) {
|
|
1285
|
+
const auto reason = response.m_result.find("reason");
|
|
1286
|
+
if (reason != response.m_result.end() && reason->is_string() &&
|
|
1287
|
+
!reason->get<std::string>().empty()) {
|
|
1288
|
+
error += ": " + reason->get<std::string>();
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
LOGW("Chain: daemon %d refused tx %s: %s", response.m_client_id, hex_str(sent.m_txid).c_str(),
|
|
1292
|
+
error.c_str());
|
|
1293
|
+
if (!sent.m_status.m_accepted) {
|
|
1294
|
+
sent.m_status.m_error = error;
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
void Chain::onTx(Sent &sent, const DaemonResponse &response)
|
|
1299
|
+
{
|
|
1300
|
+
if (sent.m_checks_pending > 0) {
|
|
1301
|
+
sent.m_checks_pending--;
|
|
1302
|
+
}
|
|
1303
|
+
if (!response.m_error.empty() || !response.m_result.is_object()) {
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
sent.m_heights.erase(response.m_client_id);
|
|
1307
|
+
bool seen{false};
|
|
1308
|
+
const auto txs = response.m_result.find("txs");
|
|
1309
|
+
if (txs != response.m_result.end() && txs->is_array()) {
|
|
1310
|
+
const std::string txid_hex = hex_str(sent.m_txid);
|
|
1311
|
+
for (const auto &entry : *txs) {
|
|
1312
|
+
if (!entry.is_object() || !entry.contains("tx_hash") || entry["tx_hash"] != txid_hex) {
|
|
1313
|
+
continue;
|
|
1314
|
+
}
|
|
1315
|
+
seen = true;
|
|
1316
|
+
const auto in_pool = entry.find("in_pool");
|
|
1317
|
+
const auto height = entry.find("block_height");
|
|
1318
|
+
if (in_pool != entry.end() && in_pool->is_boolean() && in_pool->get<bool>()) {
|
|
1319
|
+
sent.m_status.m_accepted = true;
|
|
1320
|
+
} else if (height != entry.end() && height->is_number_unsigned() && m_current.m_count &&
|
|
1321
|
+
height->get<uint64_t>() < *m_current.m_count) {
|
|
1322
|
+
sent.m_status.m_accepted = true;
|
|
1323
|
+
sent.m_heights[response.m_client_id] = height->get<uint64_t>();
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
sent.m_seen[response.m_client_id] = seen;
|
|
1328
|
+
// As lock B: k daemons put the tx in one block, and none in another
|
|
1329
|
+
sent.m_status.m_depth = 0;
|
|
1330
|
+
sent.m_status.m_height = 0;
|
|
1331
|
+
std::set<uint64_t> heights;
|
|
1332
|
+
for (const auto &[daemon, height] : sent.m_heights) {
|
|
1333
|
+
heights.insert(height);
|
|
1334
|
+
}
|
|
1335
|
+
if (heights.size() == 1 && sent.m_heights.size() >= m_scanner.agreementsNeeded()) {
|
|
1336
|
+
const uint64_t count = trustedCount();
|
|
1337
|
+
sent.m_status.m_depth = count > *heights.begin() ? count - *heights.begin() : 0;
|
|
1338
|
+
sent.m_status.m_height = *heights.begin();
|
|
1339
|
+
}
|
|
1340
|
+
size_t without{0};
|
|
1341
|
+
bool with{false};
|
|
1342
|
+
for (const auto &[daemon, had] : sent.m_seen) {
|
|
1343
|
+
if (had) {
|
|
1344
|
+
with = true;
|
|
1345
|
+
} else {
|
|
1346
|
+
++without;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
sent.m_status.m_missing = !with && without >= m_scanner.agreementsNeeded();
|
|
1350
|
+
sent.m_status.m_unseen = without >= m_scanner.agreementsNeeded();
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
void Chain::failSearch(Search &search, const std::string &error)
|
|
1354
|
+
{
|
|
1355
|
+
LOGW("Chain: height search failed: %s", error.c_str());
|
|
1356
|
+
search.m_search.m_result.m_state = ViewKeySearchStates::FAILED;
|
|
1357
|
+
search.m_search.m_result.m_error = error;
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
void Chain::stepSearch(int64_t id, Search &search)
|
|
1361
|
+
{
|
|
1362
|
+
if (!search.m_started) {
|
|
1363
|
+
if (!m_current.m_count) {
|
|
1364
|
+
return;
|
|
1365
|
+
}
|
|
1366
|
+
search.m_search.m_max = *m_current.m_count - 1;
|
|
1367
|
+
search.m_started = true;
|
|
1368
|
+
}
|
|
1369
|
+
for (const uint64_t height : stepHeightSearch(search.m_search)) {
|
|
1370
|
+
if (!search.m_asked.count(height) &&
|
|
1371
|
+
job(Jobs::SEARCH, id, m_daemon, m_daemons[m_daemon]->getBlock(id, height))) {
|
|
1372
|
+
search.m_asked.insert(height);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
if (search.m_search.m_result.m_state == ViewKeySearchStates::FAILED) {
|
|
1376
|
+
LOGW("Chain: height search failed: %s", search.m_search.m_result.m_error.c_str());
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
void Chain::onSearchBlock(int64_t id, Search &search, const DaemonResponse &response)
|
|
1381
|
+
{
|
|
1382
|
+
std::vector<unsigned char> blob;
|
|
1383
|
+
Block block;
|
|
1384
|
+
if (!response.m_error.empty() || !response.m_result.is_object() ||
|
|
1385
|
+
!hexField(blob, response.m_result, "blob") || 0 != m_ci.parseBlock(block, blob) ||
|
|
1386
|
+
0 == search.m_asked.erase(block.miner_tx.inputs[0].height)) {
|
|
1387
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
1388
|
+
failSearch(search, strprintf("daemon %d: %s", response.m_client_id,
|
|
1389
|
+
response.m_error.empty() ? "served a block that doesn't verify"
|
|
1390
|
+
: response.m_error));
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
search.m_search.m_timestamps[block.miner_tx.inputs[0].height] = block.timestamp;
|
|
1394
|
+
stepSearch(id, search);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
void Chain::onSpentCheck(SpentCheck &check, const DaemonResponse &response)
|
|
1398
|
+
{
|
|
1399
|
+
const auto statuses = response.m_result.is_object() ? response.m_result.find("spent_status")
|
|
1400
|
+
: response.m_result.end();
|
|
1401
|
+
bool usable = response.m_error.empty() && statuses != response.m_result.end() &&
|
|
1402
|
+
statuses->is_array() && statuses->size() == check.m_outputs.size();
|
|
1403
|
+
std::vector<uint64_t> answer;
|
|
1404
|
+
for (size_t i = 0; usable && i < check.m_outputs.size(); ++i) {
|
|
1405
|
+
const auto &status = (*statuses)[i];
|
|
1406
|
+
usable = status.is_number_unsigned();
|
|
1407
|
+
if (usable) {
|
|
1408
|
+
answer.push_back(status.get<uint64_t>());
|
|
1409
|
+
}
|
|
1410
|
+
}
|
|
1411
|
+
if (!usable) {
|
|
1412
|
+
m_daemon = (m_daemon + 1) % m_daemons.size();
|
|
1413
|
+
check.m_result.m_spent.clear();
|
|
1414
|
+
check.m_result.m_unspent.clear();
|
|
1415
|
+
check.m_result.m_state = ViewKeySearchStates::FAILED;
|
|
1416
|
+
check.m_result.m_error =
|
|
1417
|
+
strprintf("daemon %d: %s", response.m_client_id,
|
|
1418
|
+
response.m_error.empty() ? "is_key_image_spent answered other key images"
|
|
1419
|
+
: response.m_error);
|
|
1420
|
+
LOGW("Chain: spent check failed: %s", check.m_result.m_error.c_str());
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
check.m_answers[response.m_client_id] = std::move(answer);
|
|
1424
|
+
if (check.m_answers.size() < m_scanner.agreementsNeeded()) {
|
|
1425
|
+
return;
|
|
1426
|
+
}
|
|
1427
|
+
// Spent only when every daemon asked has it in a block: 2 is a pool spend, which can vanish
|
|
1428
|
+
for (size_t i = 0; i < check.m_outputs.size(); ++i) {
|
|
1429
|
+
const bool spent = std::all_of(check.m_answers.begin(), check.m_answers.end(),
|
|
1430
|
+
[&](const auto &a) { return a.second[i] == 1; });
|
|
1431
|
+
(spent ? check.m_result.m_spent : check.m_result.m_unspent).push_back(check.m_outputs[i]);
|
|
1432
|
+
}
|
|
1433
|
+
check.m_result.m_state = ViewKeySearchStates::FOUND;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
} // namespace xmr
|
|
1437
|
+
} // namespace bsx
|