mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-01 09:40:19 +01:00
get-anchor-depth: simple helper to get min_confirms from OpenChannel packet
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
33bbd38691
commit
0742e5356f
2 changed files with 48 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
||||||
# Needs to have oneof support: Ubuntu vivid's is too old :(
|
# Needs to have oneof support: Ubuntu vivid's is too old :(
|
||||||
PROTOCC:=protoc-c
|
PROTOCC:=protoc-c
|
||||||
|
|
||||||
PROGRAMS := open-channel open-anchor-scriptsigs leak-anchor-sigs open-commit-sig check-commit-sig check-anchor-scriptsigs
|
PROGRAMS := open-channel open-anchor-scriptsigs leak-anchor-sigs open-commit-sig check-commit-sig check-anchor-scriptsigs get-anchor-depth
|
||||||
|
|
||||||
HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o
|
HELPER_OBJS := base58.o lightning.pb-c.o shadouble.o pkt.o bitcoin_script.o permute_tx.o signature.o bitcoin_tx.o bitcoin_address.o anchor.o commit_tx.o pubkey.o
|
||||||
|
|
||||||
|
|
47
get-anchor-depth.c
Normal file
47
get-anchor-depth.c
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/* My example:
|
||||||
|
* while [ 0$(bitcoin-cli -testnet getrawtransaction $(cat anchor.txid) 1 | sed -n 's/.*"confirmations" : \([0-9]*\),/\1/p') -lt $(./get-anchor-depth A-open.pb) ]; do sleep 60; done
|
||||||
|
* while [ 0$(bitcoin-cli -testnet getrawtransaction $(cat anchor.txid) 1 | sed -n 's/.*"confirmations" : \([0-9]*\),/\1/p') -lt $(./get-anchor-depth B-open.pb) ]; do sleep 60; done
|
||||||
|
*/
|
||||||
|
#include <ccan/crypto/shachain/shachain.h>
|
||||||
|
#include <ccan/short_types/short_types.h>
|
||||||
|
#include <ccan/tal/tal.h>
|
||||||
|
#include <ccan/opt/opt.h>
|
||||||
|
#include <ccan/str/hex/hex.h>
|
||||||
|
#include <ccan/err/err.h>
|
||||||
|
#include <ccan/read_write_all/read_write_all.h>
|
||||||
|
#include "lightning.pb-c.h"
|
||||||
|
#include "anchor.h"
|
||||||
|
#include "base58.h"
|
||||||
|
#include "pkt.h"
|
||||||
|
#include "bitcoin_script.h"
|
||||||
|
#include "permute_tx.h"
|
||||||
|
#include "signature.h"
|
||||||
|
#include "commit_tx.h"
|
||||||
|
#include "pubkey.h"
|
||||||
|
#include <openssl/ec.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
const tal_t *ctx = tal_arr(NULL, char, 0);
|
||||||
|
OpenChannel *o;
|
||||||
|
|
||||||
|
err_set_progname(argv[0]);
|
||||||
|
|
||||||
|
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
||||||
|
"<open-channel-file>\n"
|
||||||
|
"Prints anchor depth as contained in OpenChannel message",
|
||||||
|
"Print this message.");
|
||||||
|
|
||||||
|
opt_parse(&argc, argv, opt_log_stderr_exit);
|
||||||
|
|
||||||
|
if (argc != 2)
|
||||||
|
opt_usage_exit_fail("Expected one argument");
|
||||||
|
|
||||||
|
o = pkt_from_file(argv[1], PKT__PKT_OPEN)->open;
|
||||||
|
printf("%u\n", o->anchor->min_confirms);
|
||||||
|
|
||||||
|
tal_free(ctx);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue