update transaction for compose transaction from db entry

This commit is contained in:
Dario Rekowski on RockPI 2020-01-31 16:30:19 +00:00
parent 06e37c101a
commit b4e7ad02aa
7 changed files with 369 additions and 69 deletions

View File

@ -9,9 +9,11 @@
"cakephp/cakephp": "3.8.*",
"cakephp/migrations": "^2.0.0",
"cakephp/plugin-installer": "^1.0",
"datto/json-rpc": "^6.0",
"google/protobuf": "v3.10.*",
"mobiledetect/mobiledetectlib": "2.*",
"paragonie/sodium_compat": "^1.11",
"google/protobuf": "v3.10.*"
"tuupola/base58": "^2.0"
},
"require-dev": {
"cakephp/bake": "^1.9.0",

228
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "de9b091bfb2ef9e30a63a154a97b5d9f",
"content-hash": "7f922dda80856a46c7b637afb52338ab",
"packages": [
{
"name": "aura/intl",
@ -54,16 +54,16 @@
},
{
"name": "cakephp/cakephp",
"version": "3.8.8",
"version": "3.8.9",
"source": {
"type": "git",
"url": "https://github.com/cakephp/cakephp.git",
"reference": "d01515c90646590183e34bc40cf8d9911f88ef5c"
"reference": "1e5da0893ecf89baa2fd3cce2862c24d9fb9b9b3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/cakephp/zipball/d01515c90646590183e34bc40cf8d9911f88ef5c",
"reference": "d01515c90646590183e34bc40cf8d9911f88ef5c",
"url": "https://api.github.com/repos/cakephp/cakephp/zipball/1e5da0893ecf89baa2fd3cce2862c24d9fb9b9b3",
"reference": "1e5da0893ecf89baa2fd3cce2862c24d9fb9b9b3",
"shasum": ""
},
"require": {
@ -139,7 +139,7 @@
"rapid-development",
"validation"
],
"time": "2019-12-29T02:09:22+00:00"
"time": "2020-01-25T01:41:07+00:00"
},
{
"name": "cakephp/chronos",
@ -291,6 +291,56 @@
"description": "A composer installer for CakePHP 3.0+ plugins.",
"time": "2019-11-12T10:21:19+00:00"
},
{
"name": "datto/json-rpc",
"version": "6.0.0",
"source": {
"type": "git",
"url": "https://github.com/datto/php-json-rpc.git",
"reference": "77edbb6fde5424665c12f8b3a91b778b2b4c9ea7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/datto/php-json-rpc/zipball/77edbb6fde5424665c12f8b3a91b778b2b4c9ea7",
"reference": "77edbb6fde5424665c12f8b3a91b778b2b4c9ea7",
"shasum": ""
},
"require": {
"php": ">=7.0.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Datto\\JsonRpc\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0+"
],
"authors": [
{
"name": "Spencer Mortensen",
"email": "smortensen@datto.com",
"homepage": "http://spencermortensen.com",
"role": "Developer"
}
],
"description": "Fully unit-tested JSON-RPC 2.0 for PHP",
"homepage": "http://datto.com",
"keywords": [
"json",
"json-rpc",
"jsonrpc",
"php",
"php-json-rpc",
"rpc"
],
"time": "2019-07-26T20:20:13+00:00"
},
{
"name": "google/protobuf",
"version": "v3.10.0",
@ -782,16 +832,16 @@
},
{
"name": "symfony/config",
"version": "v5.0.2",
"version": "v5.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "7f930484966350906185ba0a604728f7898b7ba0"
"reference": "7640c6704f56bf64045066bc5d93fd9d664baa63"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/7f930484966350906185ba0a604728f7898b7ba0",
"reference": "7f930484966350906185ba0a604728f7898b7ba0",
"url": "https://api.github.com/repos/symfony/config/zipball/7640c6704f56bf64045066bc5d93fd9d664baa63",
"reference": "7640c6704f56bf64045066bc5d93fd9d664baa63",
"shasum": ""
},
"require": {
@ -842,20 +892,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2019-12-18T13:50:31+00:00"
"time": "2020-01-04T14:08:26+00:00"
},
{
"name": "symfony/console",
"version": "v4.4.2",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "82437719dab1e6bdd28726af14cb345c2ec816d0"
"reference": "f512001679f37e6a042b51897ed24a2f05eba656"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/82437719dab1e6bdd28726af14cb345c2ec816d0",
"reference": "82437719dab1e6bdd28726af14cb345c2ec816d0",
"url": "https://api.github.com/repos/symfony/console/zipball/f512001679f37e6a042b51897ed24a2f05eba656",
"reference": "f512001679f37e6a042b51897ed24a2f05eba656",
"shasum": ""
},
"require": {
@ -918,20 +968,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2019-12-17T10:32:23+00:00"
"time": "2020-01-25T12:44:29+00:00"
},
{
"name": "symfony/filesystem",
"version": "v4.4.2",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "40c2606131d56eff6f193b6e2ceb92414653b591"
"reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/40c2606131d56eff6f193b6e2ceb92414653b591",
"reference": "40c2606131d56eff6f193b6e2ceb92414653b591",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/266c9540b475f26122b61ef8b23dd9198f5d1cfd",
"reference": "266c9540b475f26122b61ef8b23dd9198f5d1cfd",
"shasum": ""
},
"require": {
@ -968,7 +1018,7 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2019-11-26T23:16:41+00:00"
"time": "2020-01-21T08:20:44+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1205,16 +1255,16 @@
},
{
"name": "symfony/yaml",
"version": "v5.0.2",
"version": "v5.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "847661e77afa48d99ecfa508e8b60f0b029a19c0"
"reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/847661e77afa48d99ecfa508e8b60f0b029a19c0",
"reference": "847661e77afa48d99ecfa508e8b60f0b029a19c0",
"url": "https://api.github.com/repos/symfony/yaml/zipball/69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a",
"reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a",
"shasum": ""
},
"require": {
@ -1260,7 +1310,59 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2019-12-10T11:06:55+00:00"
"time": "2020-01-21T11:12:28+00:00"
},
{
"name": "tuupola/base58",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/tuupola/base58.git",
"reference": "9e9cb3b1a8e1b6a540de4a1b1a6d61193756d09a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/tuupola/base58/zipball/9e9cb3b1a8e1b6a540de4a1b1a6d61193756d09a",
"reference": "9e9cb3b1a8e1b6a540de4a1b1a6d61193756d09a",
"shasum": ""
},
"require": {
"php": "^7.1"
},
"require-dev": {
"overtrue/phplint": "^1.0.0",
"phpbench/phpbench": "^0.13.0",
"phpstan/phpstan": "^0.11.1",
"phpunit/phpunit": "^5.0|^6.0|^7.0",
"squizlabs/php_codesniffer": "^3.0"
},
"suggest": {
"ext-gmp": "GMP extension provides the fastest encoding and decoding."
},
"type": "library",
"autoload": {
"psr-4": {
"Tuupola\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mika Tuupola",
"email": "tuupola@appelsiini.net",
"homepage": "https://appelsiini.net/",
"role": "Developer"
}
],
"description": "Base58 encoder and decoder for arbitrary data",
"homepage": "https://github.com/tuupola/base58",
"keywords": [
"base58"
],
"time": "2019-03-31T07:33:09+00:00"
},
{
"name": "zendframework/zend-diactoros",
@ -1594,16 +1696,16 @@
},
{
"name": "cakephp/debug_kit",
"version": "3.21.0",
"version": "3.21.1",
"source": {
"type": "git",
"url": "https://github.com/cakephp/debug_kit.git",
"reference": "74c289cbd9ee07a531ce813dec744c9f2f472e14"
"reference": "beb1f551e6cf4282a9236d72d78aad94fb334d11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cakephp/debug_kit/zipball/74c289cbd9ee07a531ce813dec744c9f2f472e14",
"reference": "74c289cbd9ee07a531ce813dec744c9f2f472e14",
"url": "https://api.github.com/repos/cakephp/debug_kit/zipball/beb1f551e6cf4282a9236d72d78aad94fb334d11",
"reference": "beb1f551e6cf4282a9236d72d78aad94fb334d11",
"shasum": ""
},
"require": {
@ -1650,7 +1752,7 @@
"debug",
"kit"
],
"time": "2019-11-10T02:41:02+00:00"
"time": "2020-01-27T16:15:08+00:00"
},
{
"name": "composer/ca-bundle",
@ -2419,16 +2521,16 @@
},
{
"name": "myclabs/deep-copy",
"version": "1.9.4",
"version": "1.9.5",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7"
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/579bb7356d91f9456ccd505f24ca8b667966a0a7",
"reference": "579bb7356d91f9456ccd505f24ca8b667966a0a7",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef",
"reference": "b2c28789e80a97badd14145fda39b545d83ca3ef",
"shasum": ""
},
"require": {
@ -2463,7 +2565,7 @@
"object",
"object graph"
],
"time": "2019-12-15T19:12:40+00:00"
"time": "2020-01-17T21:11:47+00:00"
},
{
"name": "nikic/php-parser",
@ -2772,24 +2874,24 @@
},
{
"name": "phpspec/prophecy",
"version": "1.10.1",
"version": "v1.10.2",
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc"
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/cbe1df668b3fe136bcc909126a0f529a78d4cbbc",
"reference": "cbe1df668b3fe136bcc909126a0f529a78d4cbbc",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"reference": "b4400efc9d206e83138e2bb97ed7f5b14b831cd9",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0",
"sebastian/comparator": "^1.2.3|^2.0|^3.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
"sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0"
},
"require-dev": {
"phpspec/phpspec": "^2.5 || ^3.2",
@ -2831,7 +2933,7 @@
"spy",
"stub"
],
"time": "2019-12-22T21:05:45+00:00"
"time": "2020-01-20T15:57:02+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -3954,16 +4056,16 @@
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.3",
"version": "3.5.4",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb"
"reference": "dceec07328401de6211037abbb18bda423677e26"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/557a1fc7ac702c66b0bbfe16ab3d55839ef724cb",
"reference": "557a1fc7ac702c66b0bbfe16ab3d55839ef724cb",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dceec07328401de6211037abbb18bda423677e26",
"reference": "dceec07328401de6211037abbb18bda423677e26",
"shasum": ""
},
"require": {
@ -4001,20 +4103,20 @@
"phpcs",
"standards"
],
"time": "2019-12-04T04:46:47+00:00"
"time": "2020-01-30T22:20:29+00:00"
},
{
"name": "symfony/finder",
"version": "v4.4.2",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e"
"reference": "3a50be43515590faf812fbd7708200aabc327ec3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/ce8743441da64c41e2a667b8eb66070444ed911e",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e",
"url": "https://api.github.com/repos/symfony/finder/zipball/3a50be43515590faf812fbd7708200aabc327ec3",
"reference": "3a50be43515590faf812fbd7708200aabc327ec3",
"shasum": ""
},
"require": {
@ -4050,20 +4152,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-11-17T21:56:56+00:00"
"time": "2020-01-04T13:00:46+00:00"
},
{
"name": "symfony/process",
"version": "v4.4.2",
"version": "v4.4.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "b84501ad50adb72a94fb460a5b5c91f693e99c9b"
"reference": "f5697ab4cb14a5deed7473819e63141bf5352c36"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/b84501ad50adb72a94fb460a5b5c91f693e99c9b",
"reference": "b84501ad50adb72a94fb460a5b5c91f693e99c9b",
"url": "https://api.github.com/repos/symfony/process/zipball/f5697ab4cb14a5deed7473819e63141bf5352c36",
"reference": "f5697ab4cb14a5deed7473819e63141bf5352c36",
"shasum": ""
},
"require": {
@ -4099,20 +4201,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2019-12-06T10:06:46+00:00"
"time": "2020-01-09T09:50:08+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v5.0.2",
"version": "v5.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a"
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a",
"reference": "d7bc61d5d335fa9b1b91e14bb16861e8ca50f53a",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/923591cfb78a935f0c98968fedfad05bfda9d01f",
"reference": "923591cfb78a935f0c98968fedfad05bfda9d01f",
"shasum": ""
},
"require": {
@ -4174,7 +4276,7 @@
"debug",
"dump"
],
"time": "2019-12-18T13:50:31+00:00"
"time": "2020-01-25T15:56:29+00:00"
},
{
"name": "theseer/tokenizer",

View File

@ -6,6 +6,8 @@ use App\Controller\AppController;
use Model\Transactions\Transaction;
use Model\Transactions\TransactionBody;
use Cake\Core\Configure;
/**
* Transactions Controller
*
@ -20,6 +22,7 @@ class TransactionsController extends AppController
{
parent::initialize();
$this->loadComponent('GradidoNumber');
$this->loadComponent('JsonRpcRequestClient');
$this->Auth->allow(['decode']);
}
@ -86,6 +89,99 @@ class TransactionsController extends AppController
}
}
public function sendToNode() {
$this->viewBuilder()->setLayout('frontend');
$startTime = microtime(true);
//$loginServer = Configure::read('LoginServer');
$jsonRpcResult = $this->JsonRpcRequestClient->request('getlasttransaction', []);
$result = $jsonRpcResult['result'];
//var_dump($result);
if($result['state'] != 'success') {
$this->Flash->error(__('error retriving last saved transaction from gradido node.'));
$timeUsed = microtime(true) - $startTime;
$this->set('timeUsed', $timeUsed);
return;
}
$firstId = 1;
if($result['transaction'] != '') {
$lastKnowTransaction = new Transaction($result['transaction']);
$firstId = $lastKnowTransaction->getId()+1;
}
$transactionIDEntities = $this->Transactions
->find('all')
->select(['id'])
->where(['id >=' => $firstId])
;
$transactionIDs = [];
foreach($transactionIDEntities as $entity) {
array_push($transactionIDs, $entity->id);
}
$csfr_token = $this->request->getParam('_csrfToken');
$this->set('csfr_token', $csfr_token);
$this->set('transactionIds', $transactionIDs);
$timeUsed = microtime(true) - $startTime;
$this->set('timeUsed', $timeUsed);
if ($this->request->is('post')) {
$host = $this->request->getData('host');
$port = $this->request->getData('port');
//$gradidod = new JsonRpcClient($host . ':' . $port);
//var_dump($transactionIDs);
//$result = $this->JsonRpcRequestClient->request('puttransaction', ['group' => 'Hallo', 'transaction' => 'Hallo2' ]);
//$result = $gradidod->putTransaction(['group' => 'Hallo', 'transaction' => 'Hallo2' ]);
//var_dump($result);
$timeUsed = microtime(true) - $startTime;
$this->set('timeUsed', $timeUsed);
}
}
public function ajaxPutTransactionToGradidoNode()
{
$startTime = microtime(true);
if($this->request->is('post')) {
//$jsonData = $this->request->input('json_decode', true);
$data = $this->request->getData();
//$user = $jsonData['user'];
//var_dump($data);
$transactionId = $data['transaction_id'];
if($transactionId == null || $transactionId < 1) {
$timeUsed = microtime(true) - $startTime;
return $this->returnJson(['state' => 'error', 'msg' => 'invalid transaction id', 'timeUsed' => $timeUsed]);
}
try {
$transaction = Transaction::fromTable($transactionId);
} catch(Exception $e) {
echo "exception: ";
var_dump($e);
}
$transactionBase64 = base64_encode($transaction->serializeToString());
//echo "base64: <br>$transactionBase64<br>";
$result = $this->JsonRpcRequestClient->request('puttransaction', [
'group' => 'd502c4254defe1842d71c484dc35f56983ce938e3c22058795c7520b62ab9123',
'transaction' => $transactionBase64
]);
$timeUsed = microtime(true) - $startTime;
$result['timeUsed'] = $timeUsed;
return $this->returnJson($result);
//return $this->returnJson(['state' => 'success', 'timeUsed' => $timeUsed]);
}
$timeUsed = microtime(true) - $startTime;
return $this->returnJson(['state' => 'error', 'msg' => 'no post request', 'timeUsed' => $timeUsed]);
}
/**
* Add method

View File

@ -17,6 +17,8 @@ class Transaction extends TransactionBase {
private $mProtoTransaction = null;
private $mTransactionBody = null;
public function __construct($base64Data) {
//$transactionBin = base64_decode($base64Data, true);
@ -69,6 +71,10 @@ class Transaction extends TransactionBase {
return $sigPairs[0]->getPubKey();
}
public function getId() {
return $this->mProtoTransaction->getId();
}
public function validate() {
$sigMap = $this->mProtoTransaction->getSigMap();
if(!$sigMap) {
@ -151,9 +157,42 @@ class Transaction extends TransactionBase {
return true;
}
static public function fromTable($id)
{
$transactionsTable = TableRegistry::getTableLocator()->get('transactions');
$transactionEntry = $transactionsTable
->find('all')
->where(['id' => $id])
->contain([
'TransactionCreations',
'TransactionSendCoins',
'TransactionSignatures'])
->first();
//var_dump($transactionEntry->toArray());
$protoTransaction = new \Model\Messages\Gradido\Transaction();
$protoTransaction->setId($transactionEntry->id);
$recevied = new \Model\Messages\Gradido\TimestampSeconds();
$recevied->setSeconds($transactionEntry->received->getTimestamp());
$protoTransaction->setReceived($recevied);
$sigMap = SignatureMap::fromEntity($transactionEntry->transaction_signatures);
$protoTransaction->setSigMap($sigMap->getProto());
//echo "sig map: check<br>";
$protoTransaction->setTxHash(stream_get_contents($transactionEntry->tx_hash));
$body = TransactionBody::fromEntity($transactionEntry->memo, $transactionEntry);
if(is_array($body)) {
return ['state' => 'error', 'msg' => 'error creating body transaction', 'details' => $body];
}
//$protoTransaction->setBodyBytes($body->serializeToString());
return $protoTransaction;
}
}

View File

@ -136,4 +136,22 @@ class TransactionBody extends TransactionBase {
return $this->transactionTypeId;
}
static public function fromEntity($memo, $transaction)
{
$protoBody = new \Model\Messages\Gradido\TransactionBody();
$protoBody->setMemo($memo);
if(count($transaction->transaction_creations) == 1) {
//echo "is creation<br>";
$protoBody->setCreation(TransactionCreation::fromEntity($transaction->transaction_creations[0])->getProto());
}
else if(count($transaction->transaction_send_coins) == 1) {
echo "is transfer";
$protoBody->setTransfer(TransactionTransfer::fromEntity($transaction->transaction_send_coins)->getProto());
} else {
return ['invalid transaction type or count'];
}
return $protoBody;
}
}

View File

@ -18,6 +18,10 @@ class TransactionCreation extends TransactionBase {
$this->receiver_pubkey_hex = bin2hex($this->getReceiverPublic());
}
public function getProto() {
return $this->protoTransactionCreation;
}
static public function build($amount, $memo, $receiver_public_hex, $ident_hash)
{
$receiver = new \Model\Messages\Gradido\ReceiverAmount();
@ -152,5 +156,30 @@ class TransactionCreation extends TransactionBase {
return true;
}
static public function fromEntity($transactionCreationEntity)
{
$protoCreation = new \Model\Messages\Gradido\TransactionCreation();
//var_dump($transactionCreationEntity);
$stateUsersTable = TableRegistry::getTableLocator()->get('state_users');
//return new TransactionCreation($protoCreation);
$userId = $transactionCreationEntity->state_user_id;
$stateUser = $stateUsersTable->get($userId);
$receiverAmount = new \Model\Messages\Gradido\ReceiverAmount();
$receiverAmount->setEd25519ReceiverPubkey(stream_get_contents($stateUser->public_key));
$receiverAmount->setAmount($transactionCreationEntity->amount);
$protoCreation->setReceiverAmount($receiverAmount);
//echo "receiver amount: check<br>";
$identHashBytes = stream_get_contents($transactionCreationEntity->ident_hash);
$protoCreation->setIdentHash(intval($identHashBytes));
return new TransactionCreation($protoCreation);
}
}

View File

@ -12,6 +12,10 @@ class TransactionTransfer extends TransactionBase {
$this->protoTransactionTransfer = $protoTransactionTransfer;
}
public function getProto() {
return $this->protoTransactionTransfer;
}
static public function build($amount, $memo, $receiver_public_hex, $sender_public_hex)
{
// repeated SenderAmount senderAmounts = 1;
@ -201,5 +205,15 @@ class TransactionTransfer extends TransactionBase {
//return false;
return true;
}
static public function fromEntity($transactionTransferEntity)
{
$protoTransfer = new \Model\Messages\Gradido\Transfer();
$stateUsersTable = TableRegistry::getTableLocator()->get('state_users');
return new TransactionTransfer($protoTransfer);
}
}