From b92bd958fd4a745aeb0195825ef5b2e842f4da05 Mon Sep 17 00:00:00 2001
From: "roman.khlopkov" <roman.khlopkov@demlabs.net>
Date: Tue, 26 Nov 2024 15:01:09 +0300
Subject: [PATCH] [+] Consensus based sign for transactions

---
 CMakeLists.txt           |  2 +-
 cellframe-sdk            |  2 +-
 dap-sdk                  |  2 +-
 python-cellframe         |  2 +-
 sources/cellframe-node.c |  4 ++++
 sources/main_node_tool.c | 30 ++++++++++++++++++++++++++----
 6 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98e95ca60..5b24903c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,7 +82,7 @@ if(LINUX)
 endif()
 
 set(CELLFRAME_MODULES "core chains mining network srv cs-dag-poa cs-esbocs cs-none
-                      srv-app srv-app-db srv-datum srv-stake srv-xchange srv-bridge srv-voting")
+                      srv-app srv-app-db srv-datum srv-stake srv-xchange srv-bridge srv-voting srv-emit-delegate")
 
 if(LINUX OR DARWIN)
     set(CELLFRAME_MODULES "${CELLFRAME_MODULES} srv-vpn")
diff --git a/cellframe-sdk b/cellframe-sdk
index b3f7e5436..eba135404 160000
--- a/cellframe-sdk
+++ b/cellframe-sdk
@@ -1 +1 @@
-Subproject commit b3f7e5436d113c5b7d46539d522e5bd5a295a4e2
+Subproject commit eba1354044f1b795ecde77643a8153ec072012fb
diff --git a/dap-sdk b/dap-sdk
index 675110f96..a97a5666c 160000
--- a/dap-sdk
+++ b/dap-sdk
@@ -1 +1 @@
-Subproject commit 675110f965164e650985545cd3f6006aac66f452
+Subproject commit a97a5666c839824df022291ccc6b847456ba6117
diff --git a/python-cellframe b/python-cellframe
index d560eca88..a34565330 160000
--- a/python-cellframe
+++ b/python-cellframe
@@ -1 +1 @@
-Subproject commit d560eca88c78ef003f1377af8b02eefda9ea8525
+Subproject commit a345653309b26f968f31c379f60eeee4375a200e
diff --git a/sources/cellframe-node.c b/sources/cellframe-node.c
index 253c3feae..e70268e4c 100755
--- a/sources/cellframe-node.c
+++ b/sources/cellframe-node.c
@@ -110,6 +110,7 @@
 #include "dap_chain_net_srv_bridge.h"
 #include "dap_chain_net_srv_stake_pos_delegate.h"
 #include "dap_chain_net_srv_stake_lock.h"
+#include "dap_chain_net_srv_emit_delegate.h"
 
 #include "dap_events_socket.h"
 #include "dap_client.h"
@@ -390,6 +391,9 @@ int main( int argc, const char **argv )
         log_it(L_ERROR, "Can't start stake lock service");
     }
 
+    if (dap_chain_net_srv_emit_delegate_init()) {
+        log_it(L_ERROR, "Can't start stake lock service");
+    }
 #ifndef _WIN32
 #   if !DAP_OS_ANDROID
     if( dap_chain_net_srv_vpn_pre_init() ){
diff --git a/sources/main_node_tool.c b/sources/main_node_tool.c
index 3caaced45..ffa392c33 100644
--- a/sources/main_node_tool.c
+++ b/sources/main_node_tool.c
@@ -57,6 +57,7 @@ static char s_system_wallet_dir[MAX_PATH];
 static int s_wallet_create(int argc, const char **argv);
 static int s_wallet_create_from(int argc, const char **argv);
 static int s_wallet_create_wp(int argc, const char **argv);
+static int s_wallet_pkey_show(int argc, const char **argv);
 static int s_wallet_sign_file(int argc, const char **argv);
 static int s_cert_create(int argc, const char **argv);
 static int s_cert_dump(int argc, const char **argv);
@@ -94,7 +95,7 @@ struct options {
 { "wallet", {"create"}, 1, s_wallet_create },
 { "wallet", {"create_from"}, 1, s_wallet_create_from },
 {"wallet", {"create_wp"}, 1, s_wallet_create_wp},
-//{ "wallet", {"sign_file"}, 1, s_wallet_sign_file },
+{ "wallet", {"pkey", "show"}, 2, s_wallet_pkey_show },
 { "cert", {"create"}, 1, s_cert_create },
 { "cert", {"dump"}, 1, s_cert_dump },
 { "cert", {"create_pkey"}, 1, s_cert_create_pkey },
@@ -597,6 +598,27 @@ static int s_cert_pkey_show(int argc, const char **argv)
     return 0;
 }
 
+static int s_wallet_pkey_show(int argc, const char **argv)
+{
+    if (argc != 5) {
+        log_it( L_ERROR, "Wrong 'wallet pkey show' command params\n");
+        exit(-800);
+    }
+    dap_chain_wallet_t *l_wallet = dap_chain_wallet_open(argv[4], s_system_wallet_dir, NULL);
+    if (!l_wallet) {
+        printf("Not found wallet %s\n", argv[4]);
+        exit(-134);
+    }
+
+    dap_hash_fast_t l_hash;
+    if (dap_chain_wallet_get_pkey_hash(l_wallet, &l_hash)) {
+        printf("Can't serialize wallet %s", argv[4]);
+        exit(-135);
+    }
+    printf("%s\n", dap_chain_hash_fast_to_str_static(&l_hash));
+    return 0;
+}
+
 static int s_cert_get_addr(int argc, const char **argv) {
     if (argc != 5) {
         log_it( L_ERROR, "Wrong 'cert pkey show' command params\n");
@@ -721,8 +743,8 @@ static void s_help()
     printf("\t%s wallet create_from <network name> <wallet name> <wallet ca1> [<wallet ca2> [...<wallet caN>]]\n\n", l_tool_appname);
 #endif
 
-    //printf(" * Sign file\n");
-    //printf("\t%s wallet sign_file <wallet name> <cert index> <data file>\n\n", l_tool_appname);
+    printf(" * Print hash of public key for wallet <wallet name>\n");
+    printf("\t%s wallet pkey show <wallet name>\n\n", l_tool_appname);
 
     printf(" * Create new key file with randomly produced key stored in\n");
     printf("\t%s cert create <cert name> <sign type> [<key length>]\n\n", l_tool_appname);
@@ -739,7 +761,7 @@ static void s_help()
     printf(" * Export only public key from <cert name> and stores it \n");
     printf("\t%s cert create_cert_pkey <cert name> <new cert name>\n\n", l_tool_appname);
 
-    printf(" * Print hash of cert <cert name>\n");
+    printf(" * Print hash of public key for cert <cert name>\n");
     printf("\t%s cert pkey show <cert name>\n\n", l_tool_appname);
 
     printf(" * Print addr of cert <cert name>\n");
-- 
GitLab