-
Notifications
You must be signed in to change notification settings - Fork 0
/
reclout.go
44 lines (39 loc) · 894 Bytes
/
reclout.go
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
package main
import (
"clout/keys"
"clout/models"
"clout/network"
"clout/session"
"encoding/json"
"fmt"
"os"
)
func HandleReclout() {
if len(os.Args) < 3 {
fmt.Println("missing username")
return
}
username := os.Args[2]
lastPost := username // hack to allow passing in specific msg
if len(username) < 64 {
js := network.GetPostsForPublicKey(username)
var ppk models.PostsPublicKey
json.Unmarshal([]byte(js), &ppk)
if len(ppk.Posts) == 0 {
return
}
lastPost = ppk.Posts[0].PostHashHex
}
mnemonic := session.ReadLoggedInWords()
if mnemonic == "" {
return
}
pub58, priv := keys.ComputeKeysFromSeed(session.SeedBytes(mnemonic))
bigString := network.SubmitReclout(pub58, lastPost)
var tx models.TxReady
json.Unmarshal([]byte(bigString), &tx)
jsonString := network.SubmitTx(tx.TransactionHex, priv)
if jsonString != "" {
fmt.Println("Success.")
}
}