From 2314a4aa5dd648b2d8ea314f41e76ce6ada13cc9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 17 Aug 2018 14:26:56 +0930 Subject: [PATCH] contrib/short_channel_id-to-txid.sh: simple mapping util. I use this to look up on smartbit.com.au to see if a channel is spent, for example. Signed-off-by: Rusty Russell --- contrib/short_channel_id-to-txid.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 contrib/short_channel_id-to-txid.sh diff --git a/contrib/short_channel_id-to-txid.sh b/contrib/short_channel_id-to-txid.sh new file mode 100755 index 000000000..1a4af3f4d --- /dev/null +++ b/contrib/short_channel_id-to-txid.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +set -e + +if [ "$#" != 1 ]; then + echo Usage: "$0" "short:channel:id" >&2 + echo Uses bitcoin-cli to extract the actual txid >&2 + exit 1 +fi + +BLOCK=$(echo "$1" | cut -d: -f1) +TXNUM=$(echo "$1" | cut -d: -f2) + +bitcoin-cli getblock "$(bitcoin-cli getblockhash "$BLOCK")" true | grep '^ "' | head -n "$((TXNUM + 1))" | tail -n 1 | tr -dc '0-9a-f\n' +