Expose raw peya yield info in monero_c
build / peya x86_64 Linux (push) Failing after 13m2s
build / peya Win64 (push) Failing after 14m29s
consistency / checksum sync (push) Failing after 7s
consistency / Dart bindings sync (push) Successful in 1m2s

This commit is contained in:
Codex
2026-04-12 19:09:33 +02:00
parent 2a133d0102
commit 6ed8e1f7ab
8 changed files with 229 additions and 7 deletions
+1
View File
@@ -74,6 +74,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
set(MONERO_DIR ${CMAKE_SOURCE_DIR}/../${MONERO_FLAVOR})
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/../contrib/depends/${HOST_ABI})
include_directories(${MONERO_DIR}/src)
if (${HOST_ABI} STREQUAL "x86_64-apple-darwin11" OR ${HOST_ABI} STREQUAL "aarch64-apple-darwin11")
set(EXTRA_LIBS_APPLE "-framework IOKit" "-framework CoreFoundation" "-framework Cocoa" hidapi)
@@ -1,6 +1,6 @@
#ifndef MONEROC_CHECKSUMS
#define MONEROC_CHECKSUMS
const char * PEYA_wallet2_api_c_h_sha256 = "5ccccf76d6ce6a38985030ed89ff49c8d688b7920c38b85e6072bad415e5c28f";
const char * PEYA_wallet2_api_c_cpp_sha256 = "cfbc7bcfb8f8066660a2b19225249d6cc44958272c7816676a32c8ec37fedbda-fd1126fa7b476ab887502f63dd3ee565da4145a0";
const char * PEYA_wallet2_api_c_h_sha256 = "abfc67892fa12c69b7871ed5db0de819b7d6f1a270b2d9f3b0340d95e43bf8a7";
const char * PEYA_wallet2_api_c_cpp_sha256 = "5aeae36dc0d58a38d1ac61fc027c3c3f10f4331284f27833fdd3146e12d010b5-cf5969b5dd96d78d5bcc8a2fe97c9e6522c781a5";
const char * PEYA_wallet2_api_c_exp_sha256 = "31b4f92a01ff4812c46e5978c0195f725fe93c87bcd8036391a12fe9d5774621";
#endif
@@ -4,7 +4,9 @@
#include "helpers.hpp"
#include <cstring>
#include <thread>
#include <vector>
#include "../../../../peya/src/wallet/api/wallet2_api.h"
#include "wallet/api/wallet.h"
#include "peya_checksum.h"
#ifdef __cplusplus
@@ -2309,6 +2311,85 @@ const char* PEYA_Wallet_serializeCacheToJson(void* wallet_ptr) {
return strdup(result.c_str());
DEBUG_END()
}
void* PEYA_Wallet_getYieldInfoRaw(void* wallet_ptr) {
DEBUG_START()
auto *wallet = reinterpret_cast<Monero::WalletImpl*>(wallet_ptr);
auto *result = new std::vector<cryptonote::yield_block_info>();
if (!wallet->getYieldInfoRaw(*result)) {
delete result;
return nullptr;
}
return reinterpret_cast<void*>(result);
DEBUG_END()
}
int PEYA_YieldInfoRaw_count(void* yieldInfoRaw_ptr) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr) {
return 0;
}
return static_cast<int>(yieldInfoRaw->size());
DEBUG_END()
}
uint64_t PEYA_YieldInfoRaw_blockHeight(void* yieldInfoRaw_ptr, int index) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr || index < 0 || static_cast<size_t>(index) >= yieldInfoRaw->size()) {
return 0;
}
return (*yieldInfoRaw)[index].block_height;
DEBUG_END()
}
uint64_t PEYA_YieldInfoRaw_slippageTotalThisBlock(void* yieldInfoRaw_ptr, int index) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr || index < 0 || static_cast<size_t>(index) >= yieldInfoRaw->size()) {
return 0;
}
return (*yieldInfoRaw)[index].slippage_total_this_block;
DEBUG_END()
}
uint64_t PEYA_YieldInfoRaw_lockedCoinsThisBlock(void* yieldInfoRaw_ptr, int index) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr || index < 0 || static_cast<size_t>(index) >= yieldInfoRaw->size()) {
return 0;
}
return (*yieldInfoRaw)[index].locked_coins_this_block;
DEBUG_END()
}
uint64_t PEYA_YieldInfoRaw_lockedCoinsTally(void* yieldInfoRaw_ptr, int index) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr || index < 0 || static_cast<size_t>(index) >= yieldInfoRaw->size()) {
return 0;
}
return (*yieldInfoRaw)[index].locked_coins_tally;
DEBUG_END()
}
uint8_t PEYA_YieldInfoRaw_networkHealthPercentage(void* yieldInfoRaw_ptr, int index) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
if (yieldInfoRaw == nullptr || index < 0 || static_cast<size_t>(index) >= yieldInfoRaw->size()) {
return 0;
}
return (*yieldInfoRaw)[index].network_health_percentage;
DEBUG_END()
}
void PEYA_YieldInfoRaw_free(void* yieldInfoRaw_ptr) {
DEBUG_START()
auto *yieldInfoRaw = reinterpret_cast<std::vector<cryptonote::yield_block_info>*>(yieldInfoRaw_ptr);
delete yieldInfoRaw;
DEBUG_END()
}
void* PEYA_WalletManager_createWallet(void* wm_ptr, const char* path, const char* password, const char* language, int networkType) {
DEBUG_START()
@@ -876,6 +876,14 @@ extern ADDAPI void PEYA_Wallet_setDeviceReceivedData(void* wallet_ptr, unsigned
extern ADDAPI void PEYA_Wallet_setDeviceSendData(void* wallet_ptr, unsigned char* data, size_t len);
extern ADDAPI void PEYA_Wallet_setLedgerCallback(void (*sendToLedgerDevice)(unsigned char *command, unsigned int cmd_len));
extern ADDAPI const char* PEYA_Wallet_serializeCacheToJson(void* wallet_ptr);
extern ADDAPI void* PEYA_Wallet_getYieldInfoRaw(void* wallet_ptr);
extern ADDAPI int PEYA_YieldInfoRaw_count(void* yieldInfoRaw_ptr);
extern ADDAPI uint64_t PEYA_YieldInfoRaw_blockHeight(void* yieldInfoRaw_ptr, int index);
extern ADDAPI uint64_t PEYA_YieldInfoRaw_slippageTotalThisBlock(void* yieldInfoRaw_ptr, int index);
extern ADDAPI uint64_t PEYA_YieldInfoRaw_lockedCoinsThisBlock(void* yieldInfoRaw_ptr, int index);
extern ADDAPI uint64_t PEYA_YieldInfoRaw_lockedCoinsTally(void* yieldInfoRaw_ptr, int index);
extern ADDAPI uint8_t PEYA_YieldInfoRaw_networkHealthPercentage(void* yieldInfoRaw_ptr, int index);
extern ADDAPI void PEYA_YieldInfoRaw_free(void* yieldInfoRaw_ptr);
// };
// struct WalletManager