forked from jb55/nostril
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nip-0034
executable file
·153 lines (131 loc) · 5.78 KB
/
nip-0034
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
mkdir -p $HOME/.gnostr || true #TODO windows
GNOSTR_DIR=$HOME/.gnostr/
#echo $GNOSTR_DIR
type -P gnostr-blockheight >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-diff >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-post-event >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-sha256 >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-weeble >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-wobble >/dev/null || cargo binstall gnostr-bins --no-confirm || cargo install gnostr-bins
type -P gnostr-xor >/dev/null || install ./gnostr-xor /usr/local/bin/
type -P gnostr-xq >/dev/null || cargo binstall gnostr-xq --no-confirm || cargo install gnostr-xq
type -P mempool-space_blocks_tip_hash >/dev/null || cargo binstall mempool_space || cargo install mempool_space
EUC=$(git rev-list --reverse --topo-order --first-parent HEAD | sed 1q)
ROOT=$(git rev-list HEAD | tail -n 1)
ORIGIN=$(git remotes | grep origin | sed 's/origin//g' | sed 's/ //g' | sed 's/ (fetch)//g' | sed 's/ (push)//g' | head -n 1)
#echo $ORIGIN
TOPIC_BRANCH=$((git symbolic-ref HEAD 2>/dev/null || echo "(unnamed branch)")|cut -d/ -f3-) #&& echo $TOPIC_BRANCH
#echo $TOPIC_BRANCH
RELAYS_JSON=$(gnostr-get-relays -j)
#echo $RELAYS_JSON
RELAYS_STRIPPED=$(gnostr-get-relays -s)
#echo $RELAYS_STRIPPED
## NIP_05
BANNER="https://avatars.githubusercontent.com/u/135379339?s=400&u=e38855df24087feb9a6679c5e3974816e6aa3753&v=4"
#echo $BANNER
PICTURE="https://avatars.githubusercontent.com/u/135379339?s=400&u=e38855df24087feb9a6679c5e3974816e6aa3753&v=4"
WEBSITE=gnostr.org
#echo "$WEBSITE"
DAMUS_DONATION_V2=0
#echo "$DAMUS_DONATION_V2"
#REF: https://github.com/lnurl/luds/blob/luds/06.md
LUD06="randymcmillan@current.tips"
#echo "$LUD06"
#REF: https://github.com/lnurl/luds/blob/luds/16.md
LUD16="randymcmillan@current.tips"
DISPLAY_NAME=$(gnostr-weeble)
#echo "$DISPLAY_NAME"
ABOUT_ME="#gnostr/$(gnostr-weeble)"
#echo "$ABOUT"
NAME=$(gnostr-weeble)
#echo "$NAME"
NIP_05="gnostr@gnostr.org"
CREATED_AT=$(date +%s)
MESSAGE="{\"banner\":\"$BANNER\",\"website\":\"$WEBSITE\",\"lud06\":\"$LUD06\",\"lud16\":\"$LUD16\",\"nip05\":\"$NIP_05\",\"picture\":\"https://avatars.githubusercontent.com/u/135379339?s=400&u=e38855df24087feb9a6679c5e3974816e6aa3753&v=4\",\"display_name\":\"$DISPLAY_NAME\",\"about\":\"$ABOUT_ME\",\"name\":\"$NAME\"}"
echo $MESSAGE
for relay in $RELAYS_STRIPPED;do
WEEBLE=$(gnostr-weeble)
BLOCK_HEIGHT=$(gnostr-blockheight)
WOBBLE=$(gnostr-wobble)
#echo $relay/$WEEBLE/$BLOCK_HEIGHT/$WOBBLE
#GNOSTR DETERMINISTIC ALIASES
RELAY_PATH=$relay/$WEEBLE/$BLOCK_HEIGHT/$WOBBLE
echo $RELAY_PATH
PRIV_KEY_RELAY_PATH=$(gnostr-sha256 $RELAY_PATH)
echo $PRIV_KEY_RELAY_PATH
PRIV_KEY=$(gnostr-sha256) ##empty sha256 for testing
echo $PRIV_KEY
PUB_KEY=$(./nostril --sec $PRIV_KEY --content '' | gnostr-xq .pubkey | sed 's/\"//g')
echo $PUB_KEY
PRIV_KEY_RELAY=$(gnostr-sha256 $relay)
echo $PRIV_KEY_RELAY
PRIV_KEY_WEEBLE=$(gnostr-sha256 $WEEBLE)
echo $PRIV_KEY_WEEBLE
PRIV_KEY_BLOCKHEIGHT=$(gnostr-sha256 $BLOCK_HEIGHT)
echo $PRIV_KEY_BLOCKHEIGHT
PRIV_KEY_WOBBLE=$(gnostr-sha256 $WOBBLE)
echo $PRIV_KEY_WOBBLE
BLOCKS_TIP_HASH=$(mempool-space_blocks_tip_hash)
echo $BLOCKS_TIP_HASH
BLOCKS_TIP_HEIGHT=$(mempool-space_blocks_tip_height)
echo $BLOCKS_TIP_HEIGHT
ALIAS_PRIV_KEY=$(gnostr-xor $PRIV_KEY $BLOCKS_TIP_HASH)
echo ALIAS_PRIV_KEY=$ALIAS_PRIV_KEY
ALIAS_PUB_KEY=$(./nostril --sec $ALIAS_PRIV_KEY --content '' | gnostr-xq .pubkey | sed 's/\"//g')
echo ALIAS_PUB_KEY=$ALIAS_PUB_KEY
##{"time":1725576903,"USD":56078,"EUR":50492,"GBP":42557,"CAD":75777,"CHF":47395,"AUD":83337,"JPY":8061880}
TIME=$(mempool-space_prices | gnostr-xq .time)
USD=$(mempool-space_prices | gnostr-xq .USD)
EUR=$(mempool-space_prices | gnostr-xq .EUR)
GBP=$(mempool-space_prices | gnostr-xq .GBP)
CAD=$(mempool-space_prices | gnostr-xq .CAD)
CHF=$(mempool-space_prices | gnostr-xq .CHF)
AUD=$(mempool-space_prices | gnostr-xq .AUD)
#TODO fix
#./gnostr-nip --sec $PRIV_KEY | gnostr-post-event --relay $relay & sleep 1 || true
#./gnostr-nip --sec $ALIAS_PRIV_KEY | gnostr-post-event --relay $relay & sleep 1 || true
#./nostril --sec $(gnostr-sha256) --tag USD $USD --content "HEIGHT:$BLOCKS_TIP_HEIGHT:\$USD:$USD:\$EUR:$EUR:\$GBP:$GBP:\$CAD:$CAD:\$CHF:$CHF:\$AUD:$AUD" | gnostr-post-event --relay $relay & sleep 1 || true
#./nostril --sec $BLOCKS_TIP_HASH --tag USD $USD --content "HEIGHT:$BLOCKS_TIP_HEIGHT:\$USD:$USD:\$EUR:$EUR:\$GBP:$GBP:\$CAD:$CAD:\$CHF:$CHF:\$AUD:$AUD" | gnostr-post-event --relay $relay & sleep 1 || true
nostril --sec $PRIV_KEY \
--kind 30617 \
--pow 16 \
--tag d "$(gnostr-sha256 nostril)" \
--tag name "<human-readable project name>" \
--tag description "brief human-readable project description>" \
--tag web "${ORIGIN/.git}" \
--tag web "<url for browsing>" \
--tag clone "$ORIGIN" \
--tag clone "<url for git-cloning>" \
--tag branch "$TOPIC_BRANCH" \
--tag relays "$relay" \
--tag r "$EUC" \
--tag r "$ROOT" \
-t $(git rev-parse --short HEAD~0) \
-t $(git rev-parse HEAD~0) \
--tag topic $(git rev-parse HEAD~0) \
--tag maintainers "<other-recognized-maintainer>" \
--tag maintainers "<other-recognized-maintainer>" \
-t gnostr \
-t $relay \
-t $WEEBLE \
-t $BLOCK_HEIGHT \
-t $WOBBLE \
--content "$RELAY_PATH/$(git rev-parse HEAD~0):$(gnostr-diff)" | \
gnostr-post-event --relay $relay & sleep 4; \
(\
for head in $(ls .git/refs/heads/**);do \
nostril --sec $PRIV_KEY \
--kind 30618 \
--pow 16 \
--tag d "$(gnostr-sha256 nostril)" \
-t $head \
-t gnostr \
-t $relay \
-t $WEEBLE \
-t $BLOCK_HEIGHT \
-t $WOBBLE \
| gnostr-post-event --relay $relay & sleep 3; \
done
)
done