Skip to content

Commit

Permalink
Implements getting own balance without public key in console
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashy5000 committed Apr 1, 2024
1 parent 319d195 commit c8930de
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 11 deletions.
Binary file modified builds/node/node_darwin-amd64
Binary file not shown.
Binary file modified builds/node/node_darwin-arm64
Binary file not shown.
Binary file modified builds/node/node_linux-386
Binary file not shown.
Binary file modified builds/node/node_linux-amd64
Binary file not shown.
Binary file modified builds/node/node_linux-arm
Binary file not shown.
Binary file modified builds/node/node_linux-arm64
Binary file not shown.
Binary file modified builds/node/node_windows-386
Binary file not shown.
Binary file modified builds/node/node_windows-amd64
Binary file not shown.
Binary file modified builds/node/node_windows-arm
Binary file not shown.
Binary file modified builds/node/node_windows-arm64
Binary file not shown.
28 changes: 17 additions & 11 deletions cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func RunCmd(input string) {
fmt.Printf("Blockchain successfully synced!")
fmt.Printf("Length: %d", len(blockchain))
} else if action == "balance" {
if len(fields) == 1 {
publicKey := GetKey().PublicKey.Y
balance := GetBalance(*publicKey)
fmt.Println(fmt.Sprintf("Balance of %s: %f", publicKey.String(), balance))
return
}
keyStr := fields[1]
var key big.Int
key.SetString(keyStr, 10)
Expand Down Expand Up @@ -102,17 +108,6 @@ func RunCmd(input string) {
if err != nil {
panic(err)
}
} else if action == "exit" {
os.Exit(0)
} else if action == "help" {
fmt.Println("Commands:")
fmt.Println("sync - Sync the blockchain with peers")
fmt.Println("balance <public key> - Get the balance of a public key")
fmt.Println("send <public key> <amount> - Send an amount to a public key")
fmt.Println("keygen - Generate a new key")
fmt.Println("savestate - Save the blockchain to a file")
fmt.Println("loadstate - Load the blockchain from a file")
fmt.Println("exit - Exit the console")
} else if action == "addpeer" {
if *useLocalPeerList {
// Add the peer to the local peer list
Expand All @@ -135,6 +130,17 @@ func RunCmd(input string) {
} else if action == "bootstrap" {
Bootstrap()
fmt.Println("Bootstrap complete!")
} else if action == "exit" {
os.Exit(0)
} else if action == "help" {
fmt.Println("Commands:")
fmt.Println("sync - Sync the blockchain with peers")
fmt.Println("balance <public key> - Get the balance of a public key")
fmt.Println("send <public key> <amount> - Send an amount to a public key")
fmt.Println("keygen - Generate a new key")
fmt.Println("savestate - Save the blockchain to a file")
fmt.Println("loadstate - Load the blockchain from a file")
fmt.Println("exit - Exit the console")
} else if action == "license" {
license, err := os.ReadFile("COPYING")
if err != nil {
Expand Down

0 comments on commit c8930de

Please sign in to comment.