-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stub WIF functions and base conversion functions
- Loading branch information
Showing
6 changed files
with
83 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Base | ||
|
||
############################################################################## | ||
## | ||
## Dependencies | ||
## | ||
############################################################################## | ||
|
||
end # module Base |
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,11 @@ | ||
module Util | ||
|
||
############################################################################## | ||
## | ||
## Load files | ||
## | ||
############################################################################## | ||
|
||
include("Base.jl") | ||
|
||
end # module Util |
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,48 @@ | ||
module WIF | ||
|
||
############################################################################## | ||
## | ||
## Dependencies | ||
## | ||
############################################################################## | ||
|
||
using Coin | ||
|
||
############################################################################## | ||
## | ||
## Exported methods and types | ||
## | ||
############################################################################## | ||
|
||
export private2wif, wif2private, wif_checksum | ||
|
||
############################################################################## | ||
## | ||
## Wallet interchange format function definitions | ||
## | ||
############################################################################## | ||
|
||
# NOTE: As described in the document https://en.bitcoin.it/wiki/WIF | ||
|
||
# Convert private key to WIF. | ||
# TODO: turn keys into objects to hold metadata | ||
# - which_net: which network to use; 0x80 for mainnet, 0xef for testnet | ||
# - compression: 01 if private key corresponds to compressed public key | ||
function private2wif(pk::ASCIIString; which_net="80", compression="") | ||
pk = string(which_net, pk, compression) | ||
|
||
hashed = Coin.Crypto.SHA2.sha256(pk) | ||
hashed = Coin.Crypto.SHA2.sha256(hashed) | ||
|
||
checksum = hashed[1:8] | ||
|
||
pk = string(pk, checksum) | ||
end | ||
|
||
function wif2private(wif::ASCIIString) | ||
end | ||
|
||
function wif_checksum(wif::ASCIIString) | ||
end | ||
|
||
end # module WIF |
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,11 @@ | ||
module Wallet | ||
|
||
############################################################################## | ||
## | ||
## Load files | ||
## | ||
############################################################################## | ||
|
||
include("WIF.jl") | ||
|
||
end # module Wallet |