-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Charlie Revett
authored
Sep 18, 2017
1 parent
4f24886
commit 01f9cae
Showing
5 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ | |
|
||
# Added by Authors | ||
vendor/ | ||
go-tcw.* | ||
go-tcw.* | ||
neo-go-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.2.0 | ||
1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/CityOfZion/neo-go-sdk/neo" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 3 || os.Args[1] != "--wif" { | ||
outputUsage() | ||
} | ||
|
||
wif := os.Args[2] | ||
|
||
if len(wif) != 52 { | ||
outputError("WIF entered is not 52 characters long.") | ||
} | ||
|
||
privateKey, err := neo.NewPrivateKeyFromWIF(wif) | ||
if err != nil { | ||
outputError("Unable to convert WIF to private key.") | ||
} | ||
|
||
publicAddress, err := privateKey.PublicAddress() | ||
if err != nil { | ||
outputError("Error when deriving public address from private key.") | ||
} | ||
|
||
fmt.Println("Details:") | ||
fmt.Printf(" - Private key: \t\t%s\n", privateKey.Output()) | ||
fmt.Printf(" - Private key (base64): \t%s\n", privateKey.OutputBase64()) | ||
fmt.Printf(" - Public address (compressed): %s\n", publicAddress) | ||
fmt.Printf(" - WIF (compressed): \t\t%s\n", wif) | ||
} | ||
|
||
func outputError(message string) { | ||
fmt.Printf("[ERROR] %s\n", message) | ||
fmt.Println("Try: neo-go-sdk --help") | ||
os.Exit(1) | ||
} | ||
|
||
func outputUsage() { | ||
fmt.Println("Tool to help debug a NEO public and private key pair.") | ||
fmt.Println("") | ||
fmt.Println("Usage:") | ||
fmt.Println("\tneo-go-sdk --wif <WIF>") | ||
fmt.Println("") | ||
fmt.Println("Options:") | ||
fmt.Println("\t--wif\tWIF (wallet import format) for NEO private key.") | ||
fmt.Println("\t--help\tPrint usage.") | ||
os.Exit(1) | ||
} |