From 6890bd648499094f1af3b6b964cfbf1e5beebd28 Mon Sep 17 00:00:00 2001 From: cyan Date: Sun, 13 Oct 2024 12:54:43 +0000 Subject: [PATCH] Draft PHP implementation --- impls/monero.php/ffi.php | 35 +++++++++++++++++++ .../src/main/cpp/wallet2_api_c.h | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 impls/monero.php/ffi.php diff --git a/impls/monero.php/ffi.php b/impls/monero.php/ffi.php new file mode 100644 index 0000000..5ab35b3 --- /dev/null +++ b/impls/monero.php/ffi.php @@ -0,0 +1,35 @@ +MONERO_WalletManagerFactory_getWalletManager(); +$exists = $ffi->MONERO_WalletManager_walletExists($wmPtr, "test_wallet"); +if ($exists) { + $wPtr = $ffi->MONERO_WalletManager_openWallet($wmPtr, "test_wallet", "test_password", 0); +} else { + $wPtr = $ffi->MONERO_WalletManager_createWallet($wmPtr, "test_wallet", "test_password", "English", 0); +} +$status = $ffi->MONERO_Wallet_status($wPtr); +if ($status != 0) { + $error = $ffi->MONERO_Wallet_errorString($wPtr); + echo "Unable to create wallet: $error".PHP_EOL; + exit(1); +} +echo $ffi->MONERO_Wallet_address($wPtr, 0, 0).PHP_EOL; \ No newline at end of file diff --git a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h index 6e691c8..6cd4e3b 100644 --- a/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h +++ b/monero_libwallet2_api_c/src/main/cpp/wallet2_api_c.h @@ -948,7 +948,7 @@ extern ADDAPI bool MONERO_WalletManager_walletExists(void* wm_ptr, const char* p // virtual bool verifyWalletPassword(const std::string &keys_file_name, const std::string &password, bool no_spend_key, uint64_t kdf_rounds = 1) const = 0; extern ADDAPI bool MONERO_WalletManager_verifyWalletPassword(void* wm_ptr, const char* keys_file_name, const char* password, bool no_spend_key, uint64_t kdf_rounds); // virtual bool queryWalletDevice(Wallet::Device& device_type, const std::string &keys_file_name, const std::string &password, uint64_t kdf_rounds = 1) const = 0; -extern ADDAPI bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds); +// extern ADDAPI bool MONERO_WalletManager_queryWalletDevice(int device_type, const char* keys_file_name, const char* password, uint64_t kdf_rounds); // virtual std::vector findWallets(const std::string &path) = 0; extern ADDAPI const char* MONERO_WalletManager_findWallets(void* wm_ptr, const char* path, const char* separator); // virtual std::string errorString() const = 0;