mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
getinfo: add version information
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
e5b2cacd3f
commit
5b3bde715a
2
Makefile
2
Makefile
@ -305,7 +305,7 @@ doc/full-states.dot: test/test_state_coverage
|
||||
|
||||
gen_version.h: FORCE
|
||||
@(echo "#define VERSION \"`git describe --always --dirty`\"" && echo "#define VERSION_NAME \"$(NAME)\"" && echo "#define BUILD_FEATURES \"$(FEATURES)\"") > $@.new
|
||||
@if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; fi
|
||||
@if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; echo Version updated; fi
|
||||
|
||||
version.o: gen_version.h
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "lightningd.h"
|
||||
#include "log.h"
|
||||
#include "peer.h"
|
||||
#include "version.h"
|
||||
#include <ccan/array_size/array_size.h>
|
||||
#include <ccan/err/err.h>
|
||||
#include <ccan/io/io.h>
|
||||
@ -266,6 +267,7 @@ static void json_getinfo(struct command *cmd,
|
||||
if (cmd->dstate->portnum)
|
||||
json_add_num(response, "port", cmd->dstate->portnum);
|
||||
json_add_bool(response, "testnet", cmd->dstate->config.testnet);
|
||||
json_add_string(response, "version", version());
|
||||
json_object_end(response);
|
||||
command_success(cmd, response);
|
||||
}
|
||||
|
@ -439,6 +439,10 @@ if ! check "$LCLI3 getlog 2>/dev/null | $FGREP Hello"; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Version should be correct
|
||||
VERSION=`$LCLI1 getinfo | sed -n 's/.*"version" : "\([^"]*\)".*/\1/p'`
|
||||
[ $VERSION = `git describe --always --dirty` ] || (echo Wrong version $VERSION >&2; exit 1)
|
||||
|
||||
ID1=`$LCLI1 getlog | sed -n 's/.*"ID: \([0-9a-f]*\)".*/\1/p'`
|
||||
[ `$LCLI1 getinfo | sed -n 's/.*"id" : "\([0-9a-f]*\)".*/\1/p'` = $ID1 ]
|
||||
ID2=`$LCLI2 getlog | sed -n 's/.*"ID: \([0-9a-f]*\)".*/\1/p'`
|
||||
|
@ -2,6 +2,11 @@
|
||||
#include "version.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const char *version(void)
|
||||
{
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
char *version_and_exit(const void *unused)
|
||||
{
|
||||
printf("%s\n"
|
||||
|
Loading…
Reference in New Issue
Block a user