Created
May 16, 2021 15:10
-
-
Save vindard/afbfcc403db4c76ea7cb51b734f6d84c to your computer and use it in GitHub Desktop.
Lightning Network chan_id format converter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: pass any number of chan_id values with 'x' character in them to be converted | |
# e.g. $ ./chan_id.sh 674831x113x1 | |
convert() { | |
export VAL=$1 | |
if [[ ! -z $VAL ]]; then | |
CONV=$(python3 -c "import os; arr = os.environ.get('VAL', '').rstrip().split('x'); print( (int(arr[0]) << 40) + (int(arr[1]) << 16) + int(arr[2]) )") | |
fi | |
echo "$VAL -> $CONV" | |
} | |
for i in "$@"; do | |
convert $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment