Fixes for Linux build scripts. Fixes for load cw_monero on Linux. Catch exception for get PackageInfo in SettingsStore. Add excludeFlutterSecureStorage to app_config.sh for Linux. Add FUNCTION_VISABILITY_ATTRIBUTE for monero_api.cpp.

This commit is contained in:
M 2023-04-18 16:45:32 -04:00
parent 9cd02b7541
commit 2e19e9d2b6
10 changed files with 82 additions and 23 deletions

View file

@ -18,6 +18,10 @@ void __clear_cache(void* start, void* end) { }
#include "../External/android/include/wallet2_api.h"
#endif
#if defined(__GNUC__)
#define FUNCTION_VISABILITY_ATTRIBUTE __attribute__((visibility("default"))) __attribute__((used))
#endif
using namespace std::chrono_literals;
#ifdef __cplusplus
extern "C"
@ -152,7 +156,8 @@ extern "C"
fee = transaction->fee();
blockHeight = transaction->blockHeight();
subaddrAccount = transaction->subaddrAccount();
std::set<uint32_t>::iterator it = transaction->subaddrIndex().begin();
std::set<uint32_t> subIndex = transaction->subaddrIndex();
std::set<uint32_t>::iterator it = subIndex.begin();
subaddrIndex = *it;
confirmations = transaction->confirmations();
datetime = static_cast<int64_t>(transaction->timestamp());
@ -194,6 +199,7 @@ extern "C"
std::mutex store_lock;
bool is_storing = false;
FUNCTION_VISABILITY_ATTRIBUTE
void change_current_wallet(Monero::Wallet *wallet)
{
m_wallet = wallet;
@ -233,6 +239,7 @@ extern "C"
return m_wallet;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool create_wallet(char *path, char *password, char *language, int32_t networkType, char *error)
{
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
@ -255,6 +262,7 @@ extern "C"
return true;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool restore_wallet_from_seed(char *path, char *password, char *seed, int32_t networkType, uint64_t restoreHeight, char *error)
{
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
@ -280,6 +288,7 @@ extern "C"
return true;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool restore_wallet_from_keys(char *path, char *password, char *language, char *address, char *viewKey, char *spendKey, int32_t networkType, uint64_t restoreHeight, char *error)
{
Monero::NetworkType _networkType = static_cast<Monero::NetworkType>(networkType);
@ -308,6 +317,7 @@ extern "C"
return true;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool load_wallet(char *path, char *password, int32_t nettype)
{
nice(19);
@ -323,78 +333,91 @@ extern "C"
return !(status != Monero::Wallet::Status_Ok || !errorString.empty());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *error_string() {
return strdup(get_current_wallet()->errorString().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
bool is_wallet_exist(char *path)
{
return Monero::WalletManagerFactory::getWalletManager()->walletExists(std::string(path));
}
FUNCTION_VISABILITY_ATTRIBUTE
void close_current_wallet()
{
Monero::WalletManagerFactory::getWalletManager()->closeWallet(get_current_wallet());
change_current_wallet(nullptr);
}
FUNCTION_VISABILITY_ATTRIBUTE
char *get_filename()
{
return strdup(get_current_wallet()->filename().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *secret_view_key()
{
return strdup(get_current_wallet()->secretViewKey().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *public_view_key()
{
return strdup(get_current_wallet()->publicViewKey().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *secret_spend_key()
{
return strdup(get_current_wallet()->secretSpendKey().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *public_spend_key()
{
return strdup(get_current_wallet()->publicSpendKey().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *get_address(uint32_t account_index, uint32_t address_index)
{
return strdup(get_current_wallet()->address(account_index, address_index).c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
const char *seed()
{
return strdup(get_current_wallet()->seed().c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_full_balance(uint32_t account_index)
{
return get_current_wallet()->balance(account_index);
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_unlocked_balance(uint32_t account_index)
{
return get_current_wallet()->unlockedBalance(account_index);
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_current_height()
{
return get_current_wallet()->blockChainHeight();
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_node_height()
{
return get_current_wallet()->daemonBlockChainHeight();
}
FUNCTION_VISABILITY_ATTRIBUTE
bool connect_to_node(char *error)
{
nice(19);
@ -408,6 +431,7 @@ extern "C"
return is_connected;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool setup_node(char *address, char *login, char *password, bool use_ssl, bool is_light_wallet, char *error)
{
nice(19);
@ -438,27 +462,32 @@ extern "C"
return inited;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool is_connected()
{
return get_current_wallet()->connected();
}
FUNCTION_VISABILITY_ATTRIBUTE
void start_refresh()
{
get_current_wallet()->refreshAsync();
get_current_wallet()->startRefresh();
}
FUNCTION_VISABILITY_ATTRIBUTE
void set_refresh_from_block_height(uint64_t height)
{
get_current_wallet()->setRefreshFromBlockHeight(height);
}
FUNCTION_VISABILITY_ATTRIBUTE
void set_recovering_from_seed(bool is_recovery)
{
get_current_wallet()->setRecoveringFromSeed(is_recovery);
}
FUNCTION_VISABILITY_ATTRIBUTE
void store(char *path)
{
store_lock.lock();
@ -472,6 +501,7 @@ extern "C"
store_lock.unlock();
}
FUNCTION_VISABILITY_ATTRIBUTE
bool set_password(char *password, Utf8Box &error) {
bool is_changed = get_current_wallet()->setPassword(std::string(password));
@ -482,6 +512,7 @@ extern "C"
return is_changed;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool transaction_create(char *address, char *payment_id, char *amount,
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
{
@ -522,6 +553,7 @@ extern "C"
return true;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool transaction_create_mult_dest(char **addresses, char *payment_id, char **amounts, uint32_t size,
uint8_t priority_raw, uint32_t subaddr_account, Utf8Box &error, PendingTransactionRaw &pendingTransaction)
{
@ -564,6 +596,7 @@ extern "C"
return true;
}
FUNCTION_VISABILITY_ATTRIBUTE
bool transaction_commit(PendingTransactionRaw *transaction, Utf8Box &error)
{
bool committed = transaction->transaction->commit();
@ -578,6 +611,7 @@ extern "C"
return committed;
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_node_height_or_update(uint64_t base_eight)
{
if (m_cached_syncing_blockchain_height < base_eight) {
@ -587,6 +621,7 @@ extern "C"
return m_cached_syncing_blockchain_height;
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t get_syncing_height()
{
if (m_listener == nullptr) {
@ -607,6 +642,7 @@ extern "C"
return height;
}
FUNCTION_VISABILITY_ATTRIBUTE
uint64_t is_needed_to_refresh()
{
if (m_listener == nullptr) {
@ -622,6 +658,7 @@ extern "C"
return should_refresh;
}
FUNCTION_VISABILITY_ATTRIBUTE
uint8_t is_new_transaction_exist()
{
if (m_listener == nullptr) {
@ -638,6 +675,7 @@ extern "C"
return is_new_transaction_exist;
}
FUNCTION_VISABILITY_ATTRIBUTE
void set_listener()
{
m_last_known_wallet_height = 0;
@ -651,6 +689,7 @@ extern "C"
get_current_wallet()->setListener(m_listener);
}
FUNCTION_VISABILITY_ATTRIBUTE
int64_t *subaddrress_get_all()
{
std::vector<Monero::SubaddressRow *> _subaddresses = m_subaddress->getAll();
@ -667,33 +706,39 @@ extern "C"
return subaddresses;
}
FUNCTION_VISABILITY_ATTRIBUTE
int32_t subaddrress_size()
{
std::vector<Monero::SubaddressRow *> _subaddresses = m_subaddress->getAll();
return _subaddresses.size();
}
FUNCTION_VISABILITY_ATTRIBUTE
void subaddress_add_row(uint32_t accountIndex, char *label)
{
m_subaddress->addRow(accountIndex, std::string(label));
}
FUNCTION_VISABILITY_ATTRIBUTE
void subaddress_set_label(uint32_t accountIndex, uint32_t addressIndex, char *label)
{
m_subaddress->setLabel(accountIndex, addressIndex, std::string(label));
}
FUNCTION_VISABILITY_ATTRIBUTE
void subaddress_refresh(uint32_t accountIndex)
{
m_subaddress->refresh(accountIndex);
}
FUNCTION_VISABILITY_ATTRIBUTE
int32_t account_size()
{
std::vector<Monero::SubaddressAccountRow *> _accocunts = m_account->getAll();
return _accocunts.size();
}
FUNCTION_VISABILITY_ATTRIBUTE
int64_t *account_get_all()
{
std::vector<Monero::SubaddressAccountRow *> _accocunts = m_account->getAll();
@ -710,21 +755,25 @@ extern "C"
return accocunts;
}
FUNCTION_VISABILITY_ATTRIBUTE
void account_add_row(char *label)
{
m_account->addRow(std::string(label));
}
FUNCTION_VISABILITY_ATTRIBUTE
void account_set_label_row(uint32_t account_index, char *label)
{
m_account->setLabel(account_index, label);
}
FUNCTION_VISABILITY_ATTRIBUTE
void account_refresh()
{
m_account->refresh();
}
FUNCTION_VISABILITY_ATTRIBUTE
int64_t *transactions_get_all()
{
std::vector<Monero::TransactionInfo *> transactions = m_transaction_history->getAll();
@ -741,16 +790,19 @@ extern "C"
return transactionAddresses;
}
FUNCTION_VISABILITY_ATTRIBUTE
void transactions_refresh()
{
m_transaction_history->refresh();
}
FUNCTION_VISABILITY_ATTRIBUTE
int64_t transactions_count()
{
return m_transaction_history->count();
}
FUNCTION_VISABILITY_ATTRIBUTE
int LedgerExchange(
unsigned char *command,
unsigned int cmd_len,
@ -760,37 +812,44 @@ extern "C"
return -1;
}
FUNCTION_VISABILITY_ATTRIBUTE
int LedgerFind(char *buffer, size_t len)
{
return -1;
}
FUNCTION_VISABILITY_ATTRIBUTE
void on_startup()
{
Monero::Utils::onStartup();
Monero::WalletManagerFactory::setLogLevel(0);
}
FUNCTION_VISABILITY_ATTRIBUTE
void rescan_blockchain()
{
m_wallet->rescanBlockchainAsync();
}
FUNCTION_VISABILITY_ATTRIBUTE
char * get_tx_key(char * txId)
{
return strdup(m_wallet->getTxKey(std::string(txId)).c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
char *get_subaddress_label(uint32_t accountIndex, uint32_t addressIndex)
{
return strdup(get_current_wallet()->getSubaddressLabel(accountIndex, addressIndex).c_str());
}
FUNCTION_VISABILITY_ATTRIBUTE
void set_trusted_daemon(bool arg)
{
m_wallet->setTrustedDaemon(arg);
}
FUNCTION_VISABILITY_ATTRIBUTE
bool trusted_daemon()
{
return m_wallet->trustedDaemon();

View file

@ -3,4 +3,4 @@ import 'dart:io';
final DynamicLibrary moneroApi = Platform.isAndroid
? DynamicLibrary.open("libcw_monero.so")
: DynamicLibrary.open("cw_monero.framework/cw_monero");
: DynamicLibrary.process();

View file

@ -17,6 +17,7 @@ set(PLUGIN_NAME "cw_monero_plugin")
# Any new source files that you add to the plugin should be added here.
add_library(${PLUGIN_NAME} SHARED
"cw_monero_plugin.cc"
"../ios/Classes/monero_api.cpp"
)
# Apply a standard set of build settings that are configured in the
@ -37,7 +38,7 @@ target_include_directories(${PLUGIN_NAME} INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter)
target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK)
target_link_libraries(${PLUGIN_NAME} PUBLIC cw_monero)
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
@ -50,8 +51,6 @@ add_library( cw_monero
STATIC
../ios/Classes/monero_api.cpp)
#find_library( log-lib log )
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../cw_shared_external/ios/External/linux)
############
@ -268,6 +267,4 @@ target_link_libraries( cw_monero
crypto
sodium
#${log-lib}
)
)

View file

@ -324,7 +324,13 @@ abstract class SettingsStoreBase with Store {
final bitcoinElectrumServer = nodeSource.get(bitcoinElectrumServerId);
final litecoinElectrumServer = nodeSource.get(litecoinElectrumServerId);
final havenNode = nodeSource.get(havenNodeId);
final packageInfo = await PackageInfo.fromPlatform();
var appVersion = '';
try {
final packageInfo = await PackageInfo.fromPlatform();
appVersion = packageInfo.version;
} catch(_) {}
final shouldShowYatPopup =
sharedPreferences.getBool(PreferencesKey.shouldShowYatPopup) ?? true;
@ -349,7 +355,7 @@ abstract class SettingsStoreBase with Store {
return SettingsStore(
sharedPreferences: sharedPreferences,
nodes: nodes,
appVersion: packageInfo.version,
appVersion: appVersion,
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
initialFiatCurrency: currentFiatCurrency,
initialBalanceDisplayMode: currentBalanceDisplayMode,

View file

@ -8,7 +8,6 @@
#include <cw_monero/cw_monero_plugin.h>
#include <devicelocale/devicelocale_plugin.h>
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <platform_device_id_linux/platform_device_id_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
@ -19,9 +18,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) devicelocale_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "DevicelocalePlugin");
devicelocale_plugin_register_with_registrar(devicelocale_registrar);
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) platform_device_id_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "PlatformDeviceIdLinuxPlugin");
platform_device_id_linux_plugin_register_with_registrar(platform_device_id_linux_registrar);

View file

@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST
cw_monero
devicelocale
flutter_secure_storage_linux
platform_device_id_linux
url_launcher_linux
)

View file

@ -13,7 +13,7 @@ CONFIG_ARGS=""
case $APP_LINUX_TYPE in
$CAKEWALLET)
CONFIG_ARGS="--monero --bitcoin";; #--haven
CONFIG_ARGS="--monero --bitcoin --excludeFlutterSecureStorage";; #--haven
esac
cp -rf pubspec_description.yaml pubspec.yaml

View file

@ -21,7 +21,8 @@ rm -rf $BOOST_SRC_DIR
tar -xvf $BOOST_FILE_PATH -C $EXTERNAL_LINUX_SOURCE_DIR
cd $BOOST_SRC_DIR
./bootstrap.sh --prefix=${EXTERNAL_LINUX_DIR}
./b2 --with-chrono \
./b2 cxxflags=-fPIC cflags=-fPIC \
--with-chrono \
--with-date_time \
--with-filesystem \
--with-program_options \

View file

@ -14,6 +14,6 @@ curl https://www.openssl.org/source/${OPENSSL_FILENAME} -o ${OPENSSL_FILE_PATH}
rm -rf $OPENSSL_SRC_DIR
tar -xzf $OPENSSL_FILE_PATH -C $EXTERNAL_LINUX_SOURCE_DIR
cd $OPENSSL_SRC_DIR
./config -static --prefix=${EXTERNAL_LINUX_DIR}
export CFLAGS=-fPIC
./config -fPIC shared --prefix=${EXTERNAL_LINUX_DIR}
make install

View file

@ -14,11 +14,12 @@ git clone https://github.com/NLnetLabs/unbound.git -b ${UNBOUND_VERSION} ${UNBOU
cd $UNBOUND_DIR_PATH
test `git rev-parse HEAD` = ${UNBOUND_HASH} || exit 1
./configure --prefix="${EXTERNAL_LINUX_DIR}" \
export CFLAGS=-fPIC
./configure cxxflags=-fPIC cflags=-fPIC \
--prefix="${EXTERNAL_LINUX_DIR}" \
--with-ssl="${EXTERNAL_LINUX_DIR}" \
--with-libexpat="${EXTERNAL_LINUX_DIR}" \
--enable-static \
--disable-shared \
--disable-flto
make
make install