Use controller::User in TransactionTransfer

This commit is contained in:
Dario 2020-06-26 11:45:44 +02:00
parent ecae855fc0
commit 9e5bc624d9
2 changed files with 10 additions and 9 deletions

View File

@ -2,7 +2,7 @@
const std::string TransactionTransfer::mInvalidIndexMessage("invalid index");
TransactionTransfer::KontoTableEntry::KontoTableEntry(User* user, google::protobuf::int64 amount, bool negativeAmount/* = false*/)
TransactionTransfer::KontoTableEntry::KontoTableEntry(model::table::User* user, google::protobuf::int64 amount, bool negativeAmount/* = false*/)
{
if (!user) return;
@ -80,13 +80,14 @@ int TransactionTransfer::prepare()
unlock();
return -3;
}
User user((const unsigned char*)pubkey.data());
if (user.getUserState() == USER_EMPTY) {
//User user((const unsigned char*)pubkey.data());
auto user = controller::User::create();
if (!user->load((const unsigned char*)pubkey.data())) {
sodium_bin2hex(pubkeyHexTemp, 65, (const unsigned char*)pubkey.data(), pubkey.size());
mKontoTable.push_back(KontoTableEntry(pubkeyHexTemp, senderAmount.amount(), true));
}
else {
mKontoTable.push_back(KontoTableEntry(&user, senderAmount.amount(), true));
mKontoTable.push_back(KontoTableEntry(user->getModel(), senderAmount.amount(), true));
}
}
for (int i = 0; i < mProtoTransfer.receiveramounts_size(); i++) {
@ -98,13 +99,13 @@ int TransactionTransfer::prepare()
unlock();
return -4;
}
User user((const unsigned char*)pubkey.data());
if (user.getUserState() == USER_EMPTY) {
auto user = controller::User::create();
if (!user->load((const unsigned char*)pubkey.data())) {
sodium_bin2hex(pubkeyHexTemp, 65, (const unsigned char*)pubkey.data(), pubkey.size());
mKontoTable.push_back(KontoTableEntry(pubkeyHexTemp, receiverAmount.amount(), false));
}
else {
mKontoTable.push_back(KontoTableEntry(&user, receiverAmount.amount(), false));
mKontoTable.push_back(KontoTableEntry(user->getModel(), receiverAmount.amount(), false));
}
}
if (senderSum != receiverSum) {

View File

@ -14,7 +14,7 @@
#include "TransactionBase.h"
#include "../proto/gradido/Transfer.pb.h"
#include "User.h"
#include "../controller/User.h"
class TransactionTransfer : public TransactionBase
{
@ -34,7 +34,7 @@ protected:
struct KontoTableEntry
{
public:
KontoTableEntry(User* user, google::protobuf::int64 amount, bool negativeAmount = false);
KontoTableEntry(model::table::User* user, google::protobuf::int64 amount, bool negativeAmount = false);
KontoTableEntry(const std::string& pubkeyHex, google::protobuf::int64 amount, bool negativeAmount = false);
// first name, last name and email or pubkey hex if no user in db found
std::string kontoNameCell;