Fix asset-aware subaddress balance bindings
build / peya x86_64 Linux (push) Successful in 13m21s
build / peya Win64 (push) Has been cancelled
consistency / checksum sync (push) Has been cancelled
consistency / Dart bindings sync (push) Has been cancelled

This commit is contained in:
Codex
2026-04-09 15:11:44 +02:00
parent 4b03e7aefa
commit c74e024f98
4 changed files with 24 additions and 8 deletions
+8 -2
View File
@@ -1523,9 +1523,10 @@ String SubaddressAccountRow_getBalance(
SubaddressAccountRow addressBookRow_ptr) {
debugStart?.call('PEYA_SubaddressAccountRow_getBalance');
lib ??= PeyaC(DynamicLibrary.open(libPath));
final asset_ = 'PEY'.toNativeUtf8().cast<Char>();
try {
final strPtr = lib!
.PEYA_SubaddressAccountRow_getBalance(addressBookRow_ptr)
.PEYA_SubaddressAccountRow_getBalance(addressBookRow_ptr, asset_)
.cast<Utf8>();
final str = strPtr.toDartString();
PEYA_free(strPtr.cast());
@@ -1535,6 +1536,8 @@ String SubaddressAccountRow_getBalance(
errorHandler?.call('PEYA_SubaddressAccountRow_getBalance', e);
debugEnd?.call('PEYA_SubaddressAccountRow_getBalance');
return "";
} finally {
calloc.free(asset_);
}
}
@@ -1542,9 +1545,10 @@ String SubaddressAccountRow_getUnlockedBalance(
SubaddressAccountRow addressBookRow_ptr) {
debugStart?.call('PEYA_SubaddressAccountRow_getUnlockedBalance');
lib ??= PeyaC(DynamicLibrary.open(libPath));
final asset_ = 'PEY'.toNativeUtf8().cast<Char>();
try {
final strPtr = lib!
.PEYA_SubaddressAccountRow_getUnlockedBalance(addressBookRow_ptr)
.PEYA_SubaddressAccountRow_getUnlockedBalance(addressBookRow_ptr, asset_)
.cast<Utf8>();
final str = strPtr.toDartString();
PEYA_free(strPtr.cast());
@@ -1554,6 +1558,8 @@ String SubaddressAccountRow_getUnlockedBalance(
errorHandler?.call('PEYA_SubaddressAccountRow_getUnlockedBalance', e);
debugEnd?.call('PEYA_SubaddressAccountRow_getUnlockedBalance');
return "";
} finally {
calloc.free(asset_);
}
}
+8 -2
View File
@@ -1523,9 +1523,10 @@ String SubaddressAccountRow_getBalance(
SubaddressAccountRow addressBookRow_ptr) {
debugStart?.call('SALVIUM_SubaddressAccountRow_getBalance');
lib ??= SalviumC(DynamicLibrary.open(libPath));
final asset_ = 'SAL'.toNativeUtf8().cast<Char>();
try {
final strPtr = lib!
.SALVIUM_SubaddressAccountRow_getBalance(addressBookRow_ptr)
.SALVIUM_SubaddressAccountRow_getBalance(addressBookRow_ptr, asset_)
.cast<Utf8>();
final str = strPtr.toDartString();
SALVIUM_free(strPtr.cast());
@@ -1535,6 +1536,8 @@ String SubaddressAccountRow_getBalance(
errorHandler?.call('SALVIUM_SubaddressAccountRow_getBalance', e);
debugEnd?.call('SALVIUM_SubaddressAccountRow_getBalance');
return "";
} finally {
calloc.free(asset_);
}
}
@@ -1542,9 +1545,10 @@ String SubaddressAccountRow_getUnlockedBalance(
SubaddressAccountRow addressBookRow_ptr) {
debugStart?.call('SALVIUM_SubaddressAccountRow_getUnlockedBalance');
lib ??= SalviumC(DynamicLibrary.open(libPath));
final asset_ = 'SAL'.toNativeUtf8().cast<Char>();
try {
final strPtr = lib!
.SALVIUM_SubaddressAccountRow_getUnlockedBalance(addressBookRow_ptr)
.SALVIUM_SubaddressAccountRow_getUnlockedBalance(addressBookRow_ptr, asset_)
.cast<Utf8>();
final str = strPtr.toDartString();
SALVIUM_free(strPtr.cast());
@@ -1554,6 +1558,8 @@ String SubaddressAccountRow_getUnlockedBalance(
errorHandler?.call('SALVIUM_SubaddressAccountRow_getUnlockedBalance', e);
debugEnd?.call('SALVIUM_SubaddressAccountRow_getUnlockedBalance');
return "";
} finally {
calloc.free(asset_);
}
}
@@ -994,7 +994,8 @@ const char* PEYA_SubaddressAccountRow_getLabel(void* subaddressAccountRow_ptr) {
const char* PEYA_SubaddressAccountRow_getBalance(void* subaddressAccountRow_ptr, const char* asset) {
DEBUG_START()
Monero::SubaddressAccountRow *subaddressAccountRow = reinterpret_cast<Monero::SubaddressAccountRow*>(subaddressAccountRow_ptr);
std::string str = subaddressAccountRow->getBalance("SAL1");
const std::string requested_asset = asset ? asset : "PEY";
std::string str = subaddressAccountRow->getBalance(requested_asset);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
@@ -1005,7 +1006,8 @@ const char* PEYA_SubaddressAccountRow_getBalance(void* subaddressAccountRow_ptr,
const char* PEYA_SubaddressAccountRow_getUnlockedBalance(void* subaddressAccountRow_ptr, const char* asset) {
DEBUG_START()
Monero::SubaddressAccountRow *subaddressAccountRow = reinterpret_cast<Monero::SubaddressAccountRow*>(subaddressAccountRow_ptr);
std::string str = subaddressAccountRow->getUnlockedBalance("SAL1");
const std::string requested_asset = asset ? asset : "PEY";
std::string str = subaddressAccountRow->getUnlockedBalance(requested_asset);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
@@ -994,7 +994,8 @@ const char* SALVIUM_SubaddressAccountRow_getLabel(void* subaddressAccountRow_ptr
const char* SALVIUM_SubaddressAccountRow_getBalance(void* subaddressAccountRow_ptr, const char* asset) {
DEBUG_START()
Monero::SubaddressAccountRow *subaddressAccountRow = reinterpret_cast<Monero::SubaddressAccountRow*>(subaddressAccountRow_ptr);
std::string str = subaddressAccountRow->getBalance("SAL1");
const std::string requested_asset = asset ? asset : "SAL";
std::string str = subaddressAccountRow->getBalance(requested_asset);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);
@@ -1005,7 +1006,8 @@ const char* SALVIUM_SubaddressAccountRow_getBalance(void* subaddressAccountRow_p
const char* SALVIUM_SubaddressAccountRow_getUnlockedBalance(void* subaddressAccountRow_ptr, const char* asset) {
DEBUG_START()
Monero::SubaddressAccountRow *subaddressAccountRow = reinterpret_cast<Monero::SubaddressAccountRow*>(subaddressAccountRow_ptr);
std::string str = subaddressAccountRow->getUnlockedBalance("SAL1");
const std::string requested_asset = asset ? asset : "SAL";
std::string str = subaddressAccountRow->getUnlockedBalance(requested_asset);
const std::string::size_type size = str.size();
char *buffer = new char[size + 1]; //we need extra char for NUL
memcpy(buffer, str.c_str(), size + 1);