@ -126,7 +126,8 @@ void Controller::setConnection(Connection* c)
ui - > listChat - > verticalScrollBar ( ) - > setValue (
ui - > listChat - > verticalScrollBar ( ) - > maximum ( ) ) ;
fetchAndProcessUnspentNotes ( ) ;
//fetch amounts of notes at startup
fetchAndProcessUnspentNotes ( ) ;
}
@ -160,14 +161,15 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx)
DataStore : : getSietchDataStore ( ) - > clear ( ) ; // clears the datastore
// Debugging, um die Daten aus NoteCountDataStore zu zeigen
int spendableNotesCount = NoteCountDataStore : : getInstance ( ) - > getSpendableNotesCount ( ) ;
QString addressWithMaxValue = NoteCountDataStore : : getInstance ( ) - > getAddressWithMaxValue ( ) ;
qDebug ( ) < < " Anzahl der spendablen Notizen über 10000: " < < spendableNotesCount ;
qDebug ( ) < < " Adresse mit dem höchsten Gesamtwert: " < < addressWithMaxValue ;
// Only for Debugging/Testing: How many free Notes are available?
int spendableNotesCount = NoteCountDataStore : : getInstance ( ) - > getSpendableNotesCount ( ) ;
QString addressWithMaxValue = NoteCountDataStore : : getInstance ( ) - > getAddressWithMaxValue ( ) ;
qDebug ( ) < < " Available notes over fee: " < < spendableNotesCount ;
// Clear NoteCountDataStore
DataStore : : getNoteCountDataStore ( ) - > clear ( ) ;
const QString possibleCharacters ( " 0123456789abcdef " ) ;
int sizerandomString = 512 ;
const int randomStringLength = sizerandomString ;
@ -186,10 +188,40 @@ qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
}
for ( auto & it : dust )
{
// Create more Notes if spendableNotesCount < 7
bool extraTransactionAdded = false ;
if ( spendableNotesCount < 7 ) {
// Create a random memo for that
QString randomMemo ;
for ( int i = 0 ; i < randomStringLength ; + + i ) {
int index = QRandomGenerator : : system ( ) - > bounded ( 0 , possibleCharacters . length ( ) ) ;
randomMemo . append ( possibleCharacters . at ( index ) ) ;
}
// create the transaction
json extraTransaction = json : : object ( ) ;
extraTransaction [ " address " ] = addressWithMaxValue . toStdString ( ) ;
extraTransaction [ " amount " ] = 12000 ;
extraTransaction [ " memo " ] = randomMemo . toStdString ( ) ;
// Replace one sietch transaction
if ( ! dust . empty ( ) ) {
dust . front ( ) = extraTransaction ;
extraTransactionAdded = true ;
} else {
dust . push_back ( extraTransaction ) ;
extraTransactionAdded = true ;
}
}
// Set amount = 0 to all sietch transactions
for ( auto & it : dust ) {
if ( ! extraTransactionAdded | | it [ " address " ] ! = addressWithMaxValue . toStdString ( ) ) {
it [ " amount " ] = 0 ;
}
}
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for ( int i = 0 ; i < tx . toAddrs . size ( ) ; i + + )
@ -249,7 +281,6 @@ qDebug() << "Adresse mit dem höchsten Gesamtwert:" << addressWithMaxValue;
}
}
}
void Controller : : noConnection ( )
@ -1545,8 +1576,11 @@ void Controller::executeStandardUITransaction(Tx tx)
// Execute a transaction!
void Controller : : executeTransaction ( Tx tx ,
const std : : function < void ( QString txid ) > submitted ,
const std : : function < void ( QString txid , QString errStr ) > error )
const std : : function < void ( QString txid , QString errStr ) > error )
{
// Refresh the available unspent notes
fetchAndProcessUnspentNotes ( ) ;
unlockIfEncrypted ( [ = ] ( ) {
// First, create the json params
json params = json : : array ( ) ;
@ -1572,7 +1606,6 @@ void Controller::executeTransaction(Tx tx,
} ) ;
}
void Controller : : checkForUpdate ( bool silent )
{
// qDebug()<< __func__;
@ -1666,7 +1699,7 @@ void Controller::checkForUpdate(bool silent)
// Get the hush->USD price from coinmarketcap using their API
void Controller : : refreshHUSHPrice ( )
{
qDebug ( ) < < __func__ ;
// qDebug()<< __func__;
if ( ! zrpc - > haveConnection ( ) )
return ;