Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // YOBA BRAIN v0.1
- //
- package main
- import (
- "crypto/rand"
- "encoding/json"
- "fmt"
- "github.com/vsergeev/btckeygenie/btckey"
- "io/ioutil"
- "os"
- "net/http"
- )
- func Generate() (string, string, string, error) {
- private, err := btckey.GenerateKey(rand.Reader)
- if err != nil {
- return "", "", "", err
- }
- addressCompressed := private.ToAddress()
- addressUncompressed := private.ToAddressUncompressed()
- wif := private.ToWIF()
- return wif, addressUncompressed, addressCompressed, nil
- }
- func Check(address string) (float64, float64, int, error) {
- resp, err := http.Get("https://blockchain.info/balance?active=" + address)
- if err != nil {
- return 0, 0, 0, err
- }
- defer resp.Body.Close()
- body, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- return 0, 0, 0, err
- }
- var unmarshaled map[string]interface{}
- err = json.Unmarshal(body, &unmarshaled)
- if err != nil {
- return 0, 0, 0, err
- }
- unmarshaled = unmarshaled[address].(map[string]interface{})
- finalBalance := unmarshaled["final_balance"].(float64)
- totalReceived := unmarshaled["total_received"].(float64)
- nTx := int(unmarshaled["n_tx"].(float64))
- return finalBalance, totalReceived, nTx, nil
- }
- func Log(verbose bool, wif, addressUncompressed, addressCompressed string,
- finalBalance, totalReceived float64, nTx int) {
- if finalBalance != 0 || totalReceived != 0 || nTx != 0 {
- output := fmt.Sprintf("[%f/%f/%d] %s %s %s\n",
- finalBalance, totalReceived, nTx,
- wif, addressUncompressed, addressCompressed)
- fmt.Printf(output)
- ioutil.WriteFile("brain.txt", []byte(output), os.ModeAppend)
- return
- }
- if verbose {
- fmt.Printf("[%f/%f/%d] %s %s %s\n", finalBalance, totalReceived, nTx,
- wif, addressUncompressed, addressCompressed)
- }
- }
- func main() {
- if len(os.Args) > 1 && (os.Args[1] == "-h") {
- fmt.Printf("Usage: %s [-v|-h]\n\n", os.Args[0])
- fmt.Println("YOBA BRAIN v0.1");
- os.Exit(0)
- }
- verbose := false
- if len(os.Args) > 1 && (os.Args[1] == "-v") {
- verbose = true
- }
- fmt.Println("Ну че, народ, погнали, наxуй!");
- for true {
- wif, addressUncompressed, addressCompressed, err := Generate()
- if err != nil {
- fmt.Println("Произошла какая-то хуйня, но мне похуй!")
- if verbose == true {
- fmt.Println("Подробности: ", err)
- }
- continue
- }
- finalBalance, nTx, totalReceived, err := Check(addressUncompressed)
- if err != nil {
- fmt.Println("Произошла какая-то хуйня, но мне похуй!")
- if verbose == true {
- fmt.Println("Подробности: ", err)
- }
- continue
- }
- Log(verbose, wif, addressUncompressed, addressCompressed,
- finalBalance, nTx, totalReceived)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement