Fix asset-aware subaddress balance bindings
This commit is contained in:
@@ -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_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user