Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
base58=({1..9} {A..H} {J..N} {P..Z} {a..k} {m..z})
|
||||
bitcoinregex="^[$(printf "%s" "${base58[@]}")]{34}$"
|
||||
|
||||
decodeBase58() {
|
||||
local s=$1
|
||||
for i in {0..57}
|
||||
do s="${s//${base58[i]}/ $i}"
|
||||
done
|
||||
dc <<< "16o0d${s// /+58*}+f"
|
||||
}
|
||||
|
||||
checksum() {
|
||||
xxd -p -r <<<"$1" |
|
||||
openssl dgst -sha256 -binary |
|
||||
openssl dgst -sha256 -binary |
|
||||
xxd -p -c 80 |
|
||||
head -c 8
|
||||
}
|
||||
|
||||
checkBitcoinAddress() {
|
||||
if [[ "$1" =~ $bitcoinregex ]]
|
||||
then
|
||||
h=$(decodeBase58 "$1")
|
||||
checksum "00${h::${#h}-8}" |
|
||||
grep -qi "^${h: -8}$"
|
||||
else return 2
|
||||
fi
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue