From 114a8820456e73a7c63b14f9639df3a64fe05285 Mon Sep 17 00:00:00 2001
From: Dmitriy Gerasimov <dm@cifercom.com>
Date: Sun, 14 Jan 2018 21:07:16 +0700
Subject: [PATCH] [+] Wallet [+] Transactions and transaction items [*] Some
 renames mostly related to section

---
 CMakeLists.txt                              | 22 ++++---
 dap_chain.c                                 |  9 ++-
 dap_chain.h                                 |  6 +-
 dap_chain_block.c                           |  2 +-
 dap_chain_block.h                           | 11 ++--
 dap_chain_block_roots.c                     |  4 --
 dap_chain_block_roots.h                     | 27 --------
 dap_chain_block_section.c                   |  3 -
 dap_chain_block_section.h                   | 48 --------------
 dap_wallet.c => dap_chain_block_txs.c       |  0
 dap_wallet.h => dap_chain_block_txs.h       |  0
 dap_chain_common.h                          | 10 ++-
 dap_chain_internal.h                        | 52 +++++++++++++++
 dap_chain_tx.h => dap_chain_section.c       | 10 +--
 dap_chain_section.h                         | 70 +++++++++++++++++++++
 dap_chain_tx.c => dap_chain_section_roots.c | 22 +------
 dap_chain_section_roots.h                   | 43 +++++++++++++
 dap_chain_section_tx.c                      |  4 ++
 dap_chain_section_tx.h                      | 40 ++++++++++++
 dap_chain_section_tx_in.h                   | 22 +++++++
 dap_chain_section_tx_out.h                  | 20 ++++++
 dap_chain_wallet.c                          |  0
 dap_chain_wallet.h                          |  0
 dap_chain_wallet_internal.h                 |  0
 24 files changed, 292 insertions(+), 133 deletions(-)
 delete mode 100644 dap_chain_block_roots.c
 delete mode 100644 dap_chain_block_roots.h
 delete mode 100644 dap_chain_block_section.c
 delete mode 100644 dap_chain_block_section.h
 rename dap_wallet.c => dap_chain_block_txs.c (100%)
 rename dap_wallet.h => dap_chain_block_txs.h (100%)
 create mode 100644 dap_chain_internal.h
 rename dap_chain_tx.h => dap_chain_section.c (85%)
 create mode 100644 dap_chain_section.h
 rename dap_chain_tx.c => dap_chain_section_roots.c (72%)
 create mode 100644 dap_chain_section_roots.h
 create mode 100644 dap_chain_section_tx.c
 create mode 100644 dap_chain_section_tx.h
 create mode 100644 dap_chain_section_tx_in.h
 create mode 100644 dap_chain_section_tx_out.h
 create mode 100644 dap_chain_wallet.c
 create mode 100644 dap_chain_wallet.h
 create mode 100644 dap_chain_wallet_internal.h

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91d5204207..a01ff25cde 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,32 +4,38 @@ project (dap-chain)
 set(DAP_CHAIN_SRCS 
 	dap_chain_common.c
 	dap_chain_block.c 
-	dap_chain_block_section.c 
-	dap_chain_block_roots.c
+	dap_chain_block_txs.c 
+	dap_chain_section.c 
+	dap_chain_section_roots.c
 	dap_chain.c
 	dap_chain_coin.c  
 	dap_chain_srv.c  
-        dap_chain_tx.c
+        dap_chain_section_tx.c
         dap_hash.c
         dap_hash_fusion.c
         dap_hash_keccak.c
         dap_hash_slow.c
-
+        dap_chain_wallet.c
         )
 
 set(DAP_CHAIN_HEADERS
 	dap_chain_block.h
-	dap_chain_block_section.h
-	dap_chain_block_roots.h
 	dap_chain.h
-	dap_chain_common.h
+        dap_chain_internal.h
+        dap_chain_common.h
 	dap_chain_coin.h
 	dap_chain_srv.h
-	dap_chain_tx.h
+	dap_chain_section.h
+	dap_chain_section_roots.h
+	dap_chain_section_tx.h
+        dap_chain_section_tx_in.h
+        dap_chain_section_tx_out.h
         dap_hash.h
         dap_hash_fusion.h
         dap_hash_keccak.h
         dap_hash_slow.h
+        dap_chain_wallet.h
+        dap_chain_wallet_internal.h
     )
 
 add_subdirectory(monero_crypto)
diff --git a/dap_chain.c b/dap_chain.c
index 8e797a7989..4bb2fb49fd 100644
--- a/dap_chain.c
+++ b/dap_chain.c
@@ -19,6 +19,7 @@
 */
 
 
+#include "dap_chain_internal.h"
 #include "dap_chain.h"
 
 #define LOG_TAG "dap_chain"
@@ -47,9 +48,15 @@ void dap_chain_deinit()
  * @param a_file_name
  * @return
  */
-dap_chain_t * dap_chain_open(const char * a_file_name)
+dap_chain_t * dap_chain_open(const char * a_file_cache,const char * a_file_storage )
 {
+    dap_chain_t * l_chain = DAP_NEW_Z(dap_chain_t);
+    DAP_CHAIN_INTERNAL_LOCAL_NEW(l_chain);
 
+    l_chain_internal->file_storage_type = 0x0000; // TODO compressed format
+    l_chain_internal->file_storage  blockhain_file = fopen(a_file_name,"a+");
+
+    return l_chain;
 }
 
 /**
diff --git a/dap_chain.h b/dap_chain.h
index 33c4e3efec..3260fd79ef 100644
--- a/dap_chain.h
+++ b/dap_chain.h
@@ -18,9 +18,7 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#ifndef _DAP_CHAIN_H_
-#define _DAP_CHAIN_H_
-
+#pragma once
 #include "dap_chain_block.h"
 
 typedef struct dap_chain{
@@ -42,5 +40,3 @@ void dap_chain_save(dap_chain_t * a_chain);
 void dap_chain_info_dump_log(dap_chain_t * a_chain);
 
 void dap_chain_close(dap_chain_t * a_chain);
-
-#endif
diff --git a/dap_chain_block.c b/dap_chain_block.c
index 9c3800732b..cd160264b0 100644
--- a/dap_chain_block.c
+++ b/dap_chain_block.c
@@ -19,7 +19,7 @@
 */
 
 #include "dap_common.h"
-#include "dap_chain_block_roots.h"
+#include "dap_chain_section_roots.h"
 
 #include "dap_chain_block.h"
 
diff --git a/dap_chain_block.h b/dap_chain_block.h
index 25ab478c19..f257726a8d 100644
--- a/dap_chain_block.h
+++ b/dap_chain_block.h
@@ -17,16 +17,15 @@
     You should have received a copy of the GNU General Public License
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
-#ifndef _DAP_CHAIN_BLOCK_H_
-#define _DAP_CHAIN_BLOCK_H_
+#pragma once
 #include <stdalign.h>
 #include <stdint.h>
 #include <stddef.h>
 #include "dap_common.h"
 #include "dap_math_ops.h"
 #include "dap_chain_common.h"
-#include "dap_chain_block_section.h"
-#include "dap_chain_block_roots.h"
+#include "dap_chain_section.h"
+#include "dap_chain_section_roots.h"
 
 #define DAP_CHAIN_BLOCK_SIGNATURE 0xDA05BF8E
 
@@ -39,11 +38,10 @@ typedef struct  dap_chain_block{
         uint32_t signature; /// @param signature @brief Magic number, always equels to DAP_CHAIN_BLOCK_SIGNATURE
         int32_t version; /// @param version @brief block version (be carefull, signed value, as Bitcoin has)
         dap_chain_hash_t prev_block; /// @param prev_block Hash of the previous block
-        dap_chain_hash_t root_main;/// @param root_main Main tree's root for all block's hashes
         uint64_t timestamp; /// @param timestamp @brief Block create time timestamp
         uint64_t difficulty; /// difficulty level
         uint64_t nonce; /// Nonce value to allow header variation for mining
-        uint32_t section_size; /// @param secion_size Size of section[] array
+        dap_chain_hash_t root_sections;/// @param root_main Main tree's root for all sections's hashes
     } header;
     dap_chain_block_section_t section[];
 } DAP_ALIGN_PACKED dap_chain_block_t;
@@ -51,4 +49,3 @@ typedef struct  dap_chain_block{
 int dap_chain_block_init();
 void dap_chain_block_deinit();
 
-#endif
diff --git a/dap_chain_block_roots.c b/dap_chain_block_roots.c
deleted file mode 100644
index 1b2d6b05b4..0000000000
--- a/dap_chain_block_roots.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "dap_common.h"
-#include "dap_chain_block_roots.h"
-
-#define LOG_TAG "dap_chain_block_roots"
diff --git a/dap_chain_block_roots.h b/dap_chain_block_roots.h
deleted file mode 100644
index d1e8acfab9..0000000000
--- a/dap_chain_block_roots.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef _DAP_CHAIN_BLOCK_ROOTS_H_
-#define _DAP_CHAIN_BLOCK_ROOTS_H_
-
-#include "dap_common.h"
-#include "dap_chain_common.h"
-
-/**
-  * @struct dap_chain_block_roots_v1
-  * @brief Hash tree roots for block, version 1
-  */
-typedef struct dap_chain_block_roots_v1{
-    dap_chain_hash_t main;
-} DAP_ALIGN_PACKED dap_chain_block_roots_v1_t;
-
-/**
-  * @struct dap_chain_block_roots_v2
-  * @brief Hash tree roots for block, version 2
-  */
-typedef struct dap_chain_block_roots_v2{
-    dap_chain_hash_t main;
-    dap_chain_hash_t txs;
-} DAP_ALIGN_PACKED dap_chain_block_roots_v2_t;
-
-typedef dap_chain_block_roots_v2_t dap_chain_block_roots_t;
-
-#endif
-
diff --git a/dap_chain_block_section.c b/dap_chain_block_section.c
deleted file mode 100644
index 64604b2050..0000000000
--- a/dap_chain_block_section.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "dap_common.h"
-
-#define LOG_TAG "dap_chain_block_secion"
diff --git a/dap_chain_block_section.h b/dap_chain_block_section.h
deleted file mode 100644
index a76e44090c..0000000000
--- a/dap_chain_block_section.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
-  * @struct dap_chain_block_section
-  * @brief section inside the block
-  */
-#ifndef _DAP_CHAIN_BLOCK_SECTION_H_
-#define  _DAP_CHAIN_BLOCK_SECTION_H_
-#include <stdint.h>
-#include "dap_common.h"
-#include "dap_math_ops.h"
-#include "dap_chain_common.h"
-
-/// First section that must be in any block, with hash tree roots
-#define DAP_CHAIN_BLOCK_SECTION_ROOTS 0xffff
-
-/// End section, means all the rest of the block is empty
-#define DAP_CHAIN_BLOCK_SECTION_END 0x0000
-
-/// Transaction section
-#define DAP_CHAIN_BLOCK_SECTION_TX 0x0100
-
-/// Smart contract: EVM code section
-#define DAP_CHAIN_BLOCK_SECTION_EVM_CODE 0x0200
-
-/// Smart contract: EVM data section
-#define DAP_CHAIN_BLOCK_SECTION_EVM_DATA 0x0201
-
-/// Public key
-#define DAP_CHAIN_BLOCK_SECTION_PKEY 0x0300
-
-/// Coin: gold
-#define DAP_CHAIN_BLOCK_SECTION_COIN_GOLD 0xff00
-
-/// Coin: copper
-#define DAP_CHAIN_BLOCK_SECTION_COIN_COPPER 0xff01
-
-/// Coin: silver
-#define DAP_CHAIN_BLOCK_SECTION_COIN_SILVER 0xff02
-
-
-typedef struct dap_chain_block_section{
-    struct{
-        uint16_t type; // Section type
-        uint32_t size; // section size
-    } header;
-    uint8_t data[]; // data
-} DAP_ALIGN_PACKED dap_chain_block_section_t;
-
-#endif
diff --git a/dap_wallet.c b/dap_chain_block_txs.c
similarity index 100%
rename from dap_wallet.c
rename to dap_chain_block_txs.c
diff --git a/dap_wallet.h b/dap_chain_block_txs.h
similarity index 100%
rename from dap_wallet.h
rename to dap_chain_block_txs.h
diff --git a/dap_chain_common.h b/dap_chain_common.h
index 34a67094ba..df72b8e518 100644
--- a/dap_chain_common.h
+++ b/dap_chain_common.h
@@ -5,10 +5,18 @@
 #include "dap_common.h"
 #include "dap_math_ops.h"
 
-#define DAP_CHAIN_HASH_SIZE 32
+#define DAP_CHAIN_HASH_SIZE 64
 
 typedef union dap_chain_hash{
     uint8_t data[DAP_CHAIN_HASH_SIZE];
 } dap_chain_hash_t;
 
+typedef union dap_chain_sig_type{
+   uint16_t raw;
+   enum {
+     SIG_TYPE_NEWHOPE = 0x0000,
+     SIG_TYPE_MULTI = 0xffff ///  @brief Has inside subset of different signatures and sign composed with all of them
+   } type;
+} dap_chain_sig_type_t;
+
 #endif
diff --git a/dap_chain_internal.h b/dap_chain_internal.h
new file mode 100644
index 0000000000..720e15bb85
--- /dev/null
+++ b/dap_chain_internal.h
@@ -0,0 +1,52 @@
+/*
+ Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
+  All rights reserved.
+
+ This file is part of DAP (Deus Applications Prototypes) the open source project
+
+    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    DAP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#pragma once
+#include <stdio.h>
+#include <stdint.h>
+#include "dap_common.h"
+#include "dap_chain.h"
+
+#define DAP_CHAIN_FILE_SIGNATURE 0xfa340bef153eba48
+
+typedef struct dap_chain_file_header
+{
+    uint64_t signature;
+    uint32_t version;
+    uint8_t type;
+    uint32_t chain_id;
+} dap_chain_file_header_t;
+
+/**
+  * @struct dap_chain_internal
+  * @brief Internal blochain data, mostly aggregated
+typedef struct dap_chain_internal
+{
+    FILE * file_cache_idx_blocks; /// @param file_cache @brief Index for blocks
+    FILE * file_cache_idx_txs; /// @param file_cache @brief Index for cache
+    FILE * file_cache; /// @param file_cache @brief Cache for raw blocks
+    FILE * file_storage; /// @param file_cache @brief Cache for raw blocks
+    uint8_t file_storage_type; /// @param file_storage_type  @brief Is file_storage is raw, compressed or smth else
+} dap_chain_internal_t;
+
+#define DAP_CHAIN_INTERNAL(a) ((dap_chain_internal_t *) a->_inheritor  )
+
+#define DAP_CHAIN_INTERNAL_LOCAL(a) dap_chain_internal_t * l_chain_internal = DAP_CHAIN_INTERNAL(a)
+
+#define DAP_CHAIN_INTERNAL_LOCAL_NEW(a) dap_chain_internal_t * l_chain_internal = DAP_NEW_Z(dap_chain_internal_t); a->_inheritor = l_chain_internal
diff --git a/dap_chain_tx.h b/dap_chain_section.c
similarity index 85%
rename from dap_chain_tx.h
rename to dap_chain_section.c
index 74bd78ed3f..8264ee3210 100644
--- a/dap_chain_tx.h
+++ b/dap_chain_section.c
@@ -17,13 +17,7 @@
     You should have received a copy of the GNU General Public License
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
-#ifndef _DAP_CHAIN_TX_H_
-#define _DAP_CHAIN_TX_H_
 
-#include "dap_chain_common.h"
-
-int dap_chain_tx_init();
-void dap_chain_tx_deinit();
-
-#endif
+#include "dap_common.h"
 
+#define LOG_TAG "dap_chain_block_secion"
diff --git a/dap_chain_section.h b/dap_chain_section.h
new file mode 100644
index 0000000000..49e3fcff9a
--- /dev/null
+++ b/dap_chain_section.h
@@ -0,0 +1,70 @@
+/*
+ Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
+  All rights reserved.
+
+ This file is part of DAP (Deus Applications Prototypes) the open source project
+
+    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    DAP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+
+/**
+  * @struct dap_chain_block_section
+  * @brief section inside the block
+  */
+#pragma once
+#include <stdint.h>
+#include "dap_common.h"
+#include "dap_math_ops.h"
+#include "dap_chain_common.h"
+
+
+/// End section, means all the rest of the block is empty
+#define DAP_CHAIN_SECTION_END                 0x0000
+
+/// Transaction header section
+#define DAP_CHAIN_SECTION_TX                  0x0100
+
+/// Transaction request section
+#define DAP_CHAIN_SECTION_TX_REQUEST          0x0300
+
+/// Smart contract: DVM code section
+#define DAP_CHAIN_SECTION_DVM_CODE            0x0900
+/// Smart contract: DVM code section
+#define DAP_CHAIN_SECTION_DVM_DATA            0x0901
+
+/// Smart contract: EVM code section
+#define DAP_CHAIN_SECTION_EVM_CODE            0x0910
+
+/// Smart contract: EVM data section
+#define DAP_CHAIN_SECTION_EVM_CODE            0x0911
+
+/// Pub key section, with sign and address
+#define DAP_CHAIN_SECTION_PKEY                0x0c00
+
+/// Section with additional roots, for example transaction roots
+#define DAP_CHAIN_SECTION_ROOTS 0xf000
+
+/// Coin
+#define DAP_CHAIN_SECTION_COIN                0xffff
+
+
+
+
+typedef struct dap_chain_block_section{
+    uint16_t type; // Section type
+    uint8_t data[]; // data
+} DAP_ALIGN_PACKED dap_chain_block_section_t;
+
+inline uint32_t
diff --git a/dap_chain_tx.c b/dap_chain_section_roots.c
similarity index 72%
rename from dap_chain_tx.c
rename to dap_chain_section_roots.c
index a6c03c8818..56382e008f 100644
--- a/dap_chain_tx.c
+++ b/dap_chain_section_roots.c
@@ -19,24 +19,6 @@
 */
 
 #include "dap_common.h"
-#include "dap_chain_tx.h"
-
-#define LOG_TAG "dap_chain_tx"
-/**
- * @brief dap_chain_tx_init
- * @return
- */
-int dap_chain_tx_init()
-{
-    log_it(L_INFO,"DapChain Transactions module init");
-    return 0;
-}
-
-/**
- * @brief dap_chain_tx_deinit
- */
-void dap_chain_tx_deinit()
-{
-    log_it(L_INFO,"DapChain Transactions module deinit");
-}
+#include "dap_chain_section_roots.h"
 
+#define LOG_TAG "dap_chain_section_roots"
diff --git a/dap_chain_section_roots.h b/dap_chain_section_roots.h
new file mode 100644
index 0000000000..d0eb6320aa
--- /dev/null
+++ b/dap_chain_section_roots.h
@@ -0,0 +1,43 @@
+/*
+ Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
+  All rights reserved.
+
+ This file is part of DAP (Deus Applications Prototypes) the open source project
+
+    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    DAP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#pragma once
+
+#include "dap_common.h"
+#include "dap_chain_common.h"
+
+/**
+  * @struct dap_chain_section_roots_v1
+  * @brief Hash tree roots for block, version 1
+  */
+typedef struct dap_chain_section_roots_v1{
+    dap_chain_hash_t main;
+} DAP_ALIGN_PACKED dap_chain_block_roots_v1_t;
+
+/**
+  * @struct dap_chain_section_roots_v2
+  * @brief Hash tree roots for block, version 2
+  */
+typedef struct dap_chain_section_roots_v2{
+    dap_chain_hash_t main;
+    dap_chain_hash_t txs;
+} DAP_ALIGN_PACKED dap_chain_section_roots_v2_t;
+
+typedef dap_chain_section_roots_v2_t dap_chain_section_roots_t;
+
diff --git a/dap_chain_section_tx.c b/dap_chain_section_tx.c
new file mode 100644
index 0000000000..7410701458
--- /dev/null
+++ b/dap_chain_section_tx.c
@@ -0,0 +1,4 @@
+#include "dap_common.h"
+#include "dap_chain_section_tx.h"
+
+#define LOG_TAG "dap_chain_section_tx"
diff --git a/dap_chain_section_tx.h b/dap_chain_section_tx.h
new file mode 100644
index 0000000000..10bfc026f3
--- /dev/null
+++ b/dap_chain_section_tx.h
@@ -0,0 +1,40 @@
+/*
+ Copyright (c) 2017-2018 (c) Project "DeM Labs Inc" https://github.com/demlabsinc
+  All rights reserved.
+
+ This file is part of DAP (Deus Applications Prototypes) the open source project
+
+    DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    DAP is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#pragma once
+#include "dap_chain_common.h"
+#include "dap_chain_section.h"
+
+typedef enum dap_chain_tx_item_type{
+    TX_ITEM_TYPE_IN = 0x00,
+    TX_ITEM_TYPE_OUT = 0x10,
+} dap_chain_tx_item_type_t;
+
+/**
+  * @struct dap_chain_section_tx
+  * @brief Transaction section, consists from lot of tx_items
+  */
+typedef struct dap_chain_section_tx{
+    struct {
+        uint64_t lock_time;
+        uint32_t tx_items_size; // size of next sequencly lying tx_item sections would be decided to belong this transaction
+    } DAP_ALIGN_PACKED header;
+    uint8_t tx_items[];
+} DAP_ALIGN_PACKED dap_chain_section_tx_t;
+
diff --git a/dap_chain_section_tx_in.h b/dap_chain_section_tx_in.h
new file mode 100644
index 0000000000..c2484bacfe
--- /dev/null
+++ b/dap_chain_section_tx_in.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <stdint.h>
+#include "dap_common.h"
+#include "dap_chain_common.h"
+#include "dap_chain_section_tx.h"
+/**
+  * @struct dap_chain_tx_item
+  * @brief Sections belongs to heading tx section, with inputs, outputs and others tx relatated items
+  */
+
+typedef struct dap_chain_tx_in{
+    struct {
+        dap_chain_tx_item_type_t type:8; /// @param    type            @brief Transaction item type
+        dap_chain_hash_t tx_prev_hash; /// @param tx_prev_hash    @brief Hash of the previous transaction
+        uint32_t tx_out_prev_idx; ///      @param   tx_prev_idx     @brief Previous tx_out index
+        dap_chain_sig_type_t sig_type:16; /// Signature type
+        uint32_t sig_size; /// Signature size
+    } header; /// Only header's hash is used for verification
+    uint32_t seq_no; /// Sequence number, out of the header so could be changed during reorganization
+    uint8_t sig[]; /// @param sig @brief raw signatura dat
+} DAP_ALIGN_PACKED dap_chain_tx_in_t;
diff --git a/dap_chain_section_tx_out.h b/dap_chain_section_tx_out.h
new file mode 100644
index 0000000000..e014f19e4d
--- /dev/null
+++ b/dap_chain_section_tx_out.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <stdint.h>
+#include "dap_common.h"
+#include "dap_chain_common.h"
+#include "dap_chain_section_tx.h"
+
+/**
+  * @struct dap_chain_tx_out
+  * @brief Transaction item outout
+  */
+typedef struct dap_chain_tx_out{
+    struct {
+        dap_chain_tx_item_type_t type:8; ///           @param    type            @brief  Transaction item type
+        uint64_t value; ///                       @param    value           @brief  Number of Datoshis ( DAP/10^9 ) to be transfered
+        dap_chain_sig_type_t sig_type:16; ///     @param    sig_type        @brief  Signature type
+        uint32_t sig_size; ///                    @param    sig_size        @brief  Signature size
+    } header; /// Only header's hash is used for verification
+    uint8_t sig[]; /// @param sig @brief raw signatura dat
+} DAP_ALIGN_PACKED dap_chain_tx_out_t;
diff --git a/dap_chain_wallet.c b/dap_chain_wallet.c
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/dap_chain_wallet.h b/dap_chain_wallet.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/dap_chain_wallet_internal.h b/dap_chain_wallet_internal.h
new file mode 100644
index 0000000000..e69de29bb2
-- 
GitLab