You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 15, 2025. It is now read-only.
.cli_command_detailed_desc=" * getdata - Sends 'getdata' to a idx-th node with given block hashes. Retrieves transaction data from returned 'blocks' message.",
160
160
.cli_command_usage="getdata [idx of node] [block hash 1] ..."
161
161
},
162
+
{
163
+
.cli_command=&cli_tx,
164
+
.cli_command_name="tx",
165
+
.cli_command_brief_desc="Sends a transaction to a specified node.",
166
+
.cli_command_detailed_desc=" * tx - Sends a 'tx' message to the specified node with the provided transaction data.",
167
+
.cli_command_usage="tx [idx of node] [transaction data in hex]"
168
+
},
162
169
}; // do not add NULLs at the end
163
170
164
171
voidprint_help()
@@ -1026,6 +1033,52 @@ int cli_inv(char** args)
1026
1033
return0;
1027
1034
}
1028
1035
1036
+
intcli_tx(char**args)
1037
+
{
1038
+
pthread_mutex_lock(&cli_mutex);
1039
+
if (args[0] ==NULL||args[1] ==NULL)
1040
+
{
1041
+
log_message(LOG_WARN, BITLAB_LOG, __FILE__,
1042
+
"No arguments provided for tx command");
1043
+
print_usage("tx");
1044
+
pthread_mutex_unlock(&cli_mutex);
1045
+
return1;
1046
+
}
1047
+
1048
+
intidx=atoi(args[0]);
1049
+
if (idx<0||idx >= MAX_NODES)
1050
+
{
1051
+
log_message(LOG_WARN, BITLAB_LOG, __FILE__,
1052
+
"Invalid node index for tx command");
1053
+
print_usage("tx");
1054
+
pthread_mutex_unlock(&cli_mutex);
1055
+
return1;
1056
+
}
1057
+
1058
+
// Parse the transaction data from the arguments
1059
+
size_ttx_size=strlen(args[1]) / 2;
1060
+
unsigned char*tx_data=malloc(tx_size);
1061
+
if (tx_data==NULL)
1062
+
{
1063
+
log_message(LOG_ERROR, BITLAB_LOG, __FILE__,
1064
+
"Failed to allocate memory for transaction data");
1065
+
pthread_mutex_unlock(&cli_mutex);
1066
+
return1;
1067
+
}
1068
+
1069
+
for (size_ti=0; i<tx_size; i++)
1070
+
{
1071
+
sscanf(&args[1][i*2], "%2hhx", &tx_data[i]);
1072
+
}
1073
+
1074
+
guarded_print_line("Sending transaction to %d with size %zu", idx, tx_size);
0 commit comments