From 0dc07b6a36d6c2217901c80ffae3ffede4cae7fe Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Thu, 8 Apr 2021 11:20:53 +0000 Subject: [PATCH] update transaction models becaus gradido protocol has changed since stage1 --- .../Controller/StateBalancesController.php | 2 +- .../TransactionCreationsController.php | 4 +- .../src/Model/Transactions/SignatureMap.php | 8 +- .../src/Model/Transactions/Transaction.php | 16 +- .../Model/Transactions/TransactionBody.php | 6 +- .../Transactions/TransactionCreation.php | 85 ++------- .../Transactions/TransactionTransfer.php | 163 +++++++----------- 7 files changed, 93 insertions(+), 191 deletions(-) diff --git a/community_server/src/Controller/StateBalancesController.php b/community_server/src/Controller/StateBalancesController.php index 6e743a46c..c89dce8db 100644 --- a/community_server/src/Controller/StateBalancesController.php +++ b/community_server/src/Controller/StateBalancesController.php @@ -54,7 +54,7 @@ class StateBalancesController extends AppController ->order(['transaction_id ASC']) ->contain(false); - if(!$state_user_transactions) { + if(!$state_user_transactions || !$state_user_transactions->count()) { //debug($state_user_transactions); return true; } diff --git a/community_server/src/Controller/TransactionCreationsController.php b/community_server/src/Controller/TransactionCreationsController.php index f439bd893..d02320d25 100644 --- a/community_server/src/Controller/TransactionCreationsController.php +++ b/community_server/src/Controller/TransactionCreationsController.php @@ -130,8 +130,7 @@ class TransactionCreationsController extends AppController $builderResult = TransactionCreation::build( $amountCent, $requestData['memo'], - $pubKeyHex, - $identHash + $pubKeyHex ); if ($builderResult['state'] == 'success') { $user_balance = 0; @@ -568,7 +567,6 @@ class TransactionCreationsController extends AppController $amount, $memo, $receiverPubKeyHex, - $requestAnswear['data']['userData']['identHash'], new FrozenDate($jsonData['target_date']) ); $transaction_base64 = ''; diff --git a/community_server/src/Model/Transactions/SignatureMap.php b/community_server/src/Model/Transactions/SignatureMap.php index d8cf35929..438961e4a 100644 --- a/community_server/src/Model/Transactions/SignatureMap.php +++ b/community_server/src/Model/Transactions/SignatureMap.php @@ -29,12 +29,12 @@ class SignatureMap { static public function fromEntity($transactionSignatures) { - $protoSigMap = new \Model\Messages\Gradido\SignatureMap(); + $protoSigMap = new \Model\Messages\Proto\Gradido\SignatureMap(); $sigPairs = $protoSigMap->getSigPair(); //echo "sigPairs: "; var_dump($sigPairs); echo "
"; //return null; foreach($transactionSignatures as $signature) { - $sigPair = new \Model\Messages\Gradido\SignaturePair(); + $sigPair = new \Model\Messages\Proto\Gradido\SignaturePair(); $sigPair->setPubKey(stream_get_contents($signature->pubkey)); $sigPair->setEd25519(stream_get_contents($signature->signature)); @@ -46,14 +46,14 @@ class SignatureMap { static public function build($bodyBytes, array $keys) { - $protoSigMap = new \Model\Messages\Gradido\SignatureMap(); + $protoSigMap = new \Model\Messages\Proto\Gradido\SignatureMap(); $sigPairs = $protoSigMap->getSigPair(); //echo "sigPairs: "; var_dump($sigPairs); echo "
"; //return null; // sign with keys foreach($keys as $key) { - $sigPair = new \Model\Messages\Gradido\SignaturePair(); + $sigPair = new \Model\Messages\Proto\Gradido\SignaturePair(); $sigPair->setPubKey(hex2bin($key['pub'])); $sigPair->setEd25519(sodium_crypto_sign_detached($bodyBytes, hex2bin($key['priv']))); diff --git a/community_server/src/Model/Transactions/Transaction.php b/community_server/src/Model/Transactions/Transaction.php index 99bd5fae7..fef2cc12d 100644 --- a/community_server/src/Model/Transactions/Transaction.php +++ b/community_server/src/Model/Transactions/Transaction.php @@ -25,7 +25,7 @@ class Transaction extends TransactionBase { //$transactionBin = base64_decode($base64Data, true); //if($transactionBin == false) { //sodium_base64_VARIANT_URLSAFE_NO_PADDING - if(is_a($base64Data, '\Model\Messages\Gradido\Transaction')) { + if(is_a($base64Data, '\Model\Messages\Proto\Gradido\Transaction')) { $this->mProtoTransaction = $base64Data; $this->mTransactionBody = new TransactionBody($this->mProtoTransaction->getBodyBytes()); return; @@ -49,7 +49,7 @@ class Transaction extends TransactionBase { $this->addError('Transaction', 'base64 decode error: ' . $base64Data); } else { //var_dump($transactionBin); - $this->mProtoTransaction = new \Model\Messages\Gradido\Transaction(); + $this->mProtoTransaction = new \Model\Messages\Proto\Gradido\Transaction(); try { $this->mProtoTransaction->mergeFromString($transactionBin); //var_dump($this->mProtoTransaction); @@ -69,11 +69,11 @@ class Transaction extends TransactionBase { } } - static public function build(\Model\Messages\Gradido\TransactionBody $transactionBody, $senderKeyPair) + static public function build(\Model\Messages\Proto\Gradido\TransactionBody $transactionBody, $senderKeyPair) { - $protoTransaction = new \Model\Messages\Gradido\Transaction(); + $protoTransaction = new \Model\Messages\Proto\Gradido\Transaction(); - $recevied = new \Model\Messages\Gradido\TimestampSeconds(); + $recevied = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $recevied->setSeconds(time()); $protoTransaction->setReceived($recevied); @@ -197,14 +197,14 @@ class Transaction extends TransactionBase { 'TransactionSignatures']) ->first(); //var_dump($transactionEntry->toArray()); - $protoTransaction = new \Model\Messages\Gradido\Transaction(); + $protoTransaction = new \Model\Messages\Proto\Gradido\Transaction(); $protoTransaction->setId($transactionEntry->id); - $recevied = new \Model\Messages\Gradido\TimestampSeconds(); + $recevied = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $recevied->setSeconds($transactionEntry->received->getTimestamp()); $protoTransaction->setReceived($recevied); @@ -228,7 +228,7 @@ class Transaction extends TransactionBase { } //echo "verify bodybytes:
" . bin2hex($bodyBytes) . '
'; - $created = new \Model\Messages\Gradido\TimestampSeconds(); + $created = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $created->setSeconds($recevied->getSeconds()); $body->setCreated($created); $bodyBytes = $body->serializeToString(); diff --git a/community_server/src/Model/Transactions/TransactionBody.php b/community_server/src/Model/Transactions/TransactionBody.php index ef785705c..e7bf2a392 100644 --- a/community_server/src/Model/Transactions/TransactionBody.php +++ b/community_server/src/Model/Transactions/TransactionBody.php @@ -12,7 +12,7 @@ class TransactionBody extends TransactionBase { private $transactionTypeId = 0; public function __construct($bodyBytes) { - $this->mProtoTransactionBody = new \Model\Messages\Gradido\TransactionBody(); + $this->mProtoTransactionBody = new \Model\Messages\Proto\Gradido\TransactionBody(); try { $this->mProtoTransactionBody->mergeFromString($bodyBytes); // cannot catch Exception with cakePHP, I don't know why @@ -155,7 +155,7 @@ class TransactionBody extends TransactionBase { static public function fromEntity($memo, $transaction) { - $protoBody = new \Model\Messages\Gradido\TransactionBody(); + $protoBody = new \Model\Messages\Proto\Gradido\TransactionBody(); $protoBody->setMemo($memo); //$created->setSeconds($var); @@ -176,7 +176,7 @@ class TransactionBody extends TransactionBase { static public function build($memo, $specificTransaction) { - $protoBody = new \Model\Messages\Gradido\TransactionBody(); + $protoBody = new \Model\Messages\Proto\Gradido\TransactionBody(); $protoBody->setMemo($memo); if(is_a($specificTransaction, 'TransactionCreation')) { diff --git a/community_server/src/Model/Transactions/TransactionCreation.php b/community_server/src/Model/Transactions/TransactionCreation.php index aeac73ce8..872e04ed9 100644 --- a/community_server/src/Model/Transactions/TransactionCreation.php +++ b/community_server/src/Model/Transactions/TransactionCreation.php @@ -26,34 +26,33 @@ class TransactionCreation extends TransactionBase { return $this->protoTransactionCreation; } - static public function build($amount, $memo, $receiver_public_hex, $ident_hash, $targetDate = null) + static public function build($amount, $memo, $receiver_public_hex, $targetDate = null) { - $receiver = new \Model\Messages\Gradido\ReceiverAmount(); + $receiver = new \Model\Messages\Proto\Gradido\TransferAmount(); $receiver->setAmount($amount); //$this->receiver_pubkey_hex = $receiver_public_hex; if(strlen($receiver_public_hex) != 64) { return ['state' => 'error', 'msg' => 'invalid pubkey']; } $pubKeyBin = hex2bin($receiver_public_hex); - $receiver->setEd25519ReceiverPubkey($pubKeyBin); + $receiver->setPubkey($pubKeyBin); //var_dump($requestData); - $creationDate = new \Model\Messages\Gradido\TimestampSeconds(); + $creationDate = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $creationDate->setSeconds(time()); - $transactionBody = new \Model\Messages\Gradido\TransactionBody(); + $transactionBody = new \Model\Messages\Proto\Gradido\TransactionBody(); $transactionBody->setMemo($memo); $transactionBody->setCreated($creationDate); - $transaction = new \Model\Messages\Gradido\TransactionCreation(); - $transaction->setReceiverAmount($receiver); - $transaction->setIdentHash($ident_hash); + $transaction = new \Proto\Gradido\GradidoTransaction(); + $transaction->setReceiver($receiver); //echo "target date: "; //var_dump($targetDate); //die('die'); if($targetDate) { - $targetDateTimestamp = new \Model\Messages\Gradido\TimestampSeconds(); + $targetDateTimestamp = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $targetDateTimestamp->setSeconds($targetDate->getTimestamp()); //var_dump($targetDateTimestamp); die('target'); $transaction->setTargetDate($targetDateTimestamp); @@ -65,16 +64,13 @@ class TransactionCreation extends TransactionBase { public function getAmount() { - return $this->protoTransactionCreation->getReceiverAmount()->getAmount(); + return $this->protoTransactionCreation->getReceiver()->getAmount(); } public function getReceiverPublic() { - return $this->protoTransactionCreation->getReceiverAmount()->getEd25519ReceiverPubkey(); + return $this->protoTransactionCreation->getReceiver()->getPubkey(); } - public function getIdentHash() { - return $this->protoTransactionCreation->getIdentHash(); - } public function validate($sigPairs) { @@ -88,54 +84,6 @@ class TransactionCreation extends TransactionBase { } } - // check if creation threshold for this month isn't reached - - //$identHashBin = sprintf("%0d", $this->getIdentHash()); - // padding with zero in case hash is smaller than 32 bytes, static length binary field in db - // ident hash isn't collision ressistent, it is for speed up search - $identHashBin = pack('a32', $this->getIdentHash()); - - ////////// old validation not more than 3k GDD for 3 Month /////////////// - /*$existingCreations = $this->transactionCreationsTable - ->find('all') - ->select(['amount', 'state_user_id', 'target_date']) - ->contain(['StateUsers' => ['fields' => ['StateUsers.public_key']]]) - ->where(['target_date' => NULL]); - //$targetDate = $this->protoTransactionCreation->getTargetDate(); - //echo "choose existing transactions
"; - //$existingCreations->where([$q->func()->extract('YEAR_MONTH', 'target_date') . ' LIKE ' . $q->func()->extract('YEAR_MONTH', $targetDate)]); - // ->where(['EXTRACT(YEAR_MONTH FROM target_date) LIKE EXTRACT(YEAR_MONTH FROM']); - // uncomment because ident hash didn't work at the moment - //->where(['ident_hash' => $identHashBin]); - //$existingCreations->select(['amount_sum' => $existingCreations->func()->sum('amount')]); - - $existingCreations->matching('Transactions', function ($q) { - - return $q->where( - ['OR' => - ['EXTRACT(YEAR_MONTH FROM Transactions.received) LIKE EXTRACT(YEAR_MONTH FROM NOW())', - 'EXTRACT(YEAR_MONTH FROM DATE_ADD(Transactions.received, INTERVAL 2 MONTH)) LIKE EXTRACT(YEAR_MONTH FROM NOW())'] - ])->select('received'); - - - }); - //debug($existingCreations); - //echo "after choose existing transactions
"; - $newSum = $this->getAmount(); - //var_dump($existingCreations->toArray()); - foreach($existingCreations as $creation) { - $keyHex = bin2hex(stream_get_contents($creation->state_user->public_key)); - //echo "\ncompare \n$keyHex\nwith: \n". $this->receiver_pubkey_hex."\n"; - if($keyHex == $this->receiver_pubkey_hex) { - $newSum += $creation->amount; - } - } - - - if($newSum > 30000000) { - $this->addError('TransactionCreation::validate', 'Creation more than 1.000 GDD per Month (3 Month) not allowed'); - return false; - }//*/ /////////////// new validation, not more than 1K GDD per month via target_date /////////////////////////// $existingCreations2 = $this->transactionCreationsTable @@ -204,7 +152,6 @@ class TransactionCreation extends TransactionBase { } $transactionCreationEntity->state_user_id = $receiverUserId; $transactionCreationEntity->amount = $this->getAmount(); - $transactionCreationEntity->ident_hash = $this->getIdentHash(); $transactionCreationEntity->target_date = $this->protoTransactionCreation->getTargetDate()->getSeconds(); if(!$this->transactionCreationsTable->save($transactionCreationEntity)) { @@ -262,7 +209,7 @@ class TransactionCreation extends TransactionBase { static public function fromEntity($transactionCreationEntity) { - $protoCreation = new \Model\Messages\Gradido\TransactionCreation(); + $protoCreation = new \Model\Messages\Proto\Gradido\GradidoCreation(); //var_dump($transactionCreationEntity); $stateUsersTable = TableRegistry::getTableLocator()->get('state_users'); @@ -273,12 +220,14 @@ class TransactionCreation extends TransactionBase { $stateUser = $stateUsersTable->get($userId); - $receiverAmount = new \Model\Messages\Gradido\ReceiverAmount(); - $receiverAmount->setEd25519ReceiverPubkey(stream_get_contents($stateUser->public_key)); - + $receiverAmount = new \Model\Messages\Proto\Gradido\TransferAmount(); + $receiverAmount->setPubkey(stream_get_contents($stateUser->public_key)); $receiverAmount->setAmount($transactionCreationEntity->amount); - $protoCreation->setReceiverAmount($receiverAmount); + $protoCreation->setReceiver($receiverAmount); + + // TODO: add target_date + // function currently not used, maybe can even be deleted //echo "receiver amount: check
"; //$identHashBytes = stream_get_contents($transactionCreationEntity->ident_hash); diff --git a/community_server/src/Model/Transactions/TransactionTransfer.php b/community_server/src/Model/Transactions/TransactionTransfer.php index b9182c3ba..9f7ebd41f 100644 --- a/community_server/src/Model/Transactions/TransactionTransfer.php +++ b/community_server/src/Model/Transactions/TransactionTransfer.php @@ -22,9 +22,8 @@ class TransactionTransfer extends TransactionBase { { // repeated SenderAmount senderAmounts = 1; // repeated ReceiverAmount receiverAmounts = 2; - $receiver = new \Model\Messages\Gradido\ReceiverAmount(); - $sender = new \Model\Messages\Gradido\SenderAmount(); - $receiver->setAmount($amount); + + $sender = new \Model\Messages\Proto\Gradido\TransferAmount(); $sender->setAmount($amount); if(strlen($receiver_public_hex) != 64) { @@ -34,71 +33,56 @@ class TransactionTransfer extends TransactionBase { return ['state' => 'error', 'msg' => 'invalid sender pubkey']; } $receiverPubKeyBin = hex2bin($receiver_public_hex); - $receiver->setEd25519ReceiverPubkey($receiverPubKeyBin); $senderPubKeyBin = hex2bin($sender_public_hex); - $sender->setEd25519SenderPubkey($senderPubKeyBin); + $sender->setPubkey($senderPubKeyBin); //var_dump($requestData); - $creationDate = new \Model\Messages\Gradido\TimestampSeconds(); + $creationDate = new \Model\Messages\Proto\Gradido\TimestampSeconds(); $creationDate->setSeconds(time()); - $transactionBody = new \Model\Messages\Gradido\TransactionBody(); + $transactionBody = new \Model\Messages\Proto\Gradido\TransactionBody(); $transactionBody->setMemo($memo); $transactionBody->setCreated($creationDate); - $transaction = new \Model\Messages\Gradido\Transfer(); - $transaction->setReceiverAmounts([$receiver]); - $transaction->setSenderAmounts([$sender]); - $transactionBody->setTransfer($transaction); + $transfer = new \Model\Messages\Proto\Gradido\GradidoTransfer(); + $local_transfer = new \Model\Messages\Proto\Gradido\LocalTransfer(); + $local_transfer->setReceiver($receiverPubKeyBin); + $local_transfer->setSender($sender); + $transfer->setLocal($local_transfer); + $transactionBody->setTransfer($transfer); return ['state' => 'success', 'transactionBody' => $transactionBody]; } public function validate($sigPairs) { - //$this->addError('TransactionTransfer::validate', 'not implemented yet'); - //return false; - //$time = microtime(true); - static $functionName = 'TransactionCreation::validate'; - /* - * // check signature(s) - foreach($sigPairs as $sigPair) { - //echo 'sig Pair: '; var_dump($sigPair); echo "
"; - $pubkey = $sigPair->getPubKey(); - $signature = $sigPair->getEd25519(); - if (!\Sodium\crypto_sign_verify_detached($signature, $bodyBytes, $pubkey)) { - $this->addError('Transaction::validate', 'signature for key ' . bin2hex($pubkey) . ' isn\'t valid ' ); - return false; - } - } - */ - $sigPubHexs = []; - foreach($sigPairs as $sigPair) { - //echo 'sig Pair: '; var_dump($sigPair); echo "
"; - $pubkey = bin2hex($sigPair->getPubKey()); - //$hash = TransactionCreation::DRMakeStringHash($pubkey); - $hash = $pubkey; - if(!isset($sigPubHexs[$hash])) { - $sigPubHexs[$hash] = [$pubkey]; - } else { - array_push($sigPubHexs[$hash], $pubkey); - } - //array_push($sigPubHexs, $pubkey); - } - - $stateUsersTable = TableRegistry::getTableLocator()->get('state_users'); - $senderAmounts = $this->protoTransactionTransfer->getSenderAmounts(); - $senderSum = 0; - $receiverSum = 0; - - $senderPublics = []; - foreach($senderAmounts as $i => $senderAmount) { - $senderPublic = $senderAmount->getEd25519SenderPubkey(); - $senderPublicHex = bin2hex($senderPublic); - array_push($senderPublics, $senderPublic); + //$this->addError('TransactionTransfer::validate', 'not implemented yet'); + //return false; + //$time = microtime(true); + static $functionName = 'TransactionCreation::validate'; + $sigPubHexs = []; + foreach($sigPairs as $sigPair) + { + $pubkey = $sigPair->getPubKey(); + $pubkey_hex = bin2hex($pubkey); + //$hash = TransactionCreation::DRMakeStringHash($pubkey); + $hash = $pubkey_hex; + if(!isset($sigPubHexs[$hash])) { + $sigPubHexs[$hash] = [$pubkey_hex]; + } else { + array_push($sigPubHexs[$hash], $pubkey_hex); + } + //array_push($sigPubHexs, $pubkey); + } + + $stateUsersTable = TableRegistry::getTableLocator()->get('state_users'); + $local_transfer = $this->protoTransactionTransfer->getLocal(); + $sender = $local_transfer->getSender(); + $senderPublic = $sender->getPublic(); + $senderPublicHex = bin2hex($senderPublic); if(strlen($senderPublicHex) != 64) { - $this->addError($functionName, 'invalid sender public key'); - return false; + $this->addError($functionName, 'invalid sender public key'); + return false; } // check if signature exist for sender //$hash = TransactionCreation::DRMakeStringHash($senderPublicHex); @@ -108,7 +92,7 @@ class TransactionTransfer extends TransactionBase { return false; } // check if sender has enough Gradido - $amount = $senderAmount->getAmount(); + $amount = $sender->getAmount(); $user = $stateUsersTable ->find('all') ->select(['id']) @@ -123,66 +107,37 @@ class TransactionTransfer extends TransactionBase { $this->addError($functionName, 'sender ' . $i . ' hasn\t enough GDD'); return false; } - $senderSum += $amount; - } - $uniqueSenderPublics = array_unique($senderPublics); - if(count($senderPublics) !== count($uniqueSenderPublics)) { - $this->addError($functionName, 'duplicate sender public key'); - return false; - } - $receiverAmounts = $this->protoTransactionTransfer->getReceiverAmounts(); - $receiverPublics = []; - foreach($receiverAmounts as $reveiverAmount) { - if(strlen($reveiverAmount->getEd25519ReceiverPubkey()) != 32) { + $receiver_public_key = $local_transfer->getReceiver(); + if(strlen($receiver_public_key) != 32) { $this->addError($functionName, 'invalid receiver public key'); return false; } - array_push($receiverPublics, $reveiverAmount->getEd25519ReceiverPubkey()); - $receiverSum += $reveiverAmount->getAmount(); - } - $uniqueReceiverPublic = array_unique($receiverPublics); - if(count($uniqueReceiverPublic) !== count($receiverPublics)) { - $this->addError($functionName, 'duplicate receiver public key'); - return false; - } - $uniquePublics = array_unique(array_merge($receiverPublics, $senderPublics)); - if(count($uniquePublics) !== count($senderPublics) + count($receiverPublics)) { - // means at least one sender is the same as one receiver - $this->addError($functionName, 'duplicate public in sender and receiver'); - return false; - } - if($senderSum !== $receiverSum) { - $this->addError($functionName, 'sender amount doesn\'t match receiver amount'); - return false; - } - if($senderSum < 0) { - $this->addError($functionName, 'negative amount not supported'); - return false; - } - //die("\n"); - return true; + // check if receiver exist + $receiver_user = $stateUsersTable->find('all')->select(['id'])->where(['public_key' => $receiver_public_key])->first(); + if(!$receiver_user) { + $this->addError($functionName, 'couldn\'t find receiver ' . $i .' in db' ); + return false; + } + if($amount < 0) { + $this->addError($functionName, 'negative amount not supported'); + return false; + } + return true; } public function save($transaction_id, $firstPublic, $received) { static $functionName = 'TransactionCreation::save'; + $local_transfer = $this->protoTransactionTransfer->getLocal(); - if(count($this->protoTransactionTransfer->getSenderAmounts()) !== 1) { - $this->addError($functionName, 'not more than one sender currently supported'); - return false; - } - $senderAmount = $this->protoTransactionTransfer->getSenderAmounts()[0]; + $senderAmount = $local_transfer->getSender(); + $receiver = $local_transfer->getReceiver(); - if(count($this->protoTransactionTransfer->getReceiverAmounts()) !== 1) { - $this->addError($functionName, 'not more than one receiver currently supported'); - return false; - } - $receiverAmount = $this->protoTransactionTransfer->getReceiverAmounts()[0]; $transactionTransferTable = TableRegistry::getTableLocator()->get('TransactionSendCoins'); - $senderUserId = $this->getStateUserId($senderAmount->getEd25519SenderPubkey()); - $receiverUserId = $this->getStateUserId($receiverAmount->getEd25519ReceiverPubkey()); + $senderUserId = $this->getStateUserId($senderAmount->getPubkey()); + $receiverUserId = $this->getStateUserId($receiver); if($senderUserId === NULL || $receiverUserId === NULL) { return false; @@ -192,14 +147,14 @@ class TransactionTransfer extends TransactionBase { if(false === $finalSenderBalance) { return false; } - if(false === $this->updateStateBalance($receiverUserId, $receiverAmount->getAmount(), $received)) { + if(false === $this->updateStateBalance($receiverUserId, $senderAmount->getAmount(), $received)) { return false; } $transactionTransferEntity = $transactionTransferTable->newEntity(); $transactionTransferEntity->transaction_id = $transaction_id; $transactionTransferEntity->state_user_id = $senderUserId; - $transactionTransferEntity->receiver_public_key = $receiverAmount->getEd25519ReceiverPubkey(); + $transactionTransferEntity->receiver_public_key = $receiver; $transactionTransferEntity->receiver_user_id = $receiverUserId; $transactionTransferEntity->amount = $senderAmount->getAmount(); $transactionTransferEntity->sender_final_balance = $finalSenderBalance; @@ -263,7 +218,7 @@ class TransactionTransfer extends TransactionBase { static public function fromEntity($transactionTransferEntity) { - $protoTransfer = new \Model\Messages\Gradido\Transfer(); + $protoTransfer = new \Proto\Gradido\GradidoTransfer(); $stateUsersTable = TableRegistry::getTableLocator()->get('state_users');