Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: dbasch/dogecoin-paper-wallet
base: 841b11bae6
...
head fork: dbasch/dogecoin-paper-wallet
compare: 21499f37c5
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
18 README.md
@@ -20,9 +20,25 @@ The wallet will look like this:
* run `lein uberjar` on a trusted computer, copy the jar file to a pen drive and then to the Ubuntu box.
* run `java -jar dogecoin-[version]-SNAPSHOT-standalone.jar` on the Ubuntu box.
+## Password-protected wallets
+
+If you run
+
+`lein run "correct horse battery staple"`
+
+You will get a wallet with an encrypted key. It will look like:
+
+![wallet](https://raw.github.com/dbasch/dogecoin-paper-wallet/master/encryptedwallet.png)
+
+You will need your passphrase when you want to convert it into the Wallet Import Format. You can decrypt it by running:
+
+`lein run -m dogecoin.bip38 "correct horse battery staple" 6P......`
+
+If you do this, you should either memorize your passphase or keep it in a safe place separate from the wallet. Otherwise, you might as well generate it unencrypted.
+
## WARNING WARNING WARNING
-Be very careful when using this program. It uses the [dogecoinj](https://github.com/langerhans/dogecoinj-new) library for key generation
+Be very careful when using this program. It uses the bitcoinj library for key generation
so I'm not responsible for any bugs that might generate insecure wallets. Use at your own risk.
Find this useful? send me a tip at **DHpZsQCDKq9WbqyqfetMcGq87pFZfkwLBh** :)
View
BIN  encryptedwallet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  project.clj
@@ -3,7 +3,7 @@
:url "http://diegobasch.com"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
- :dependencies [[org.clojars.dbasch/dogecoinj "0.11"]
+ :dependencies [[org.clojars.dbasch/bip38 "0.1.1"]
[com.madgag/scprov-jdk15on "1.47.0.3"]
[com.google.guava/guava "15.0"]
[org.slf4j/slf4j-api "1.7.5"]
View
8 src/dogecoin/bip38.clj
@@ -0,0 +1,8 @@
+(ns dogecoin.bip38
+ (:require dogecoin.wallet)
+ (:import com.fruitcat.bitcoin.BIP38))
+
+(defn -main [& args]
+ (com.fruitcat.bitcoin.BIP38/setNetParams (dogecoin.wallet/np))
+ (println (first args))
+ (println (com.fruitcat.bitcoin.BIP38/decrypt (first args) (second args))))
View
49 src/dogecoin/wallet.clj
@@ -6,7 +6,8 @@
com.google.zxing.common.BitMatrix
com.google.zxing.BarcodeFormat
com.google.zxing.client.j2se.MatrixToImageWriter
- [com.google.dogecoin.core Address DumpedPrivateKey ECKey NetworkParameters]))
+ com.fruitcat.bitcoin.BIP38
+ [com.google.bitcoin.core Address DumpedPrivateKey ECKey NetworkParameters]))
;; generate qr code as an image
(defn qr [s]
@@ -14,10 +15,16 @@
matrix (.encode writer s BarcodeFormat/QR_CODE 300 300)]
(MatrixToImageWriter/toBufferedImage matrix)))
+(defn np []
+ (proxy [com.google.bitcoin.params.MainNetParams] []
+ (get [] (np))
+ (getDumpedPrivateKeyHeader [] 158)
+ (getAddressHeader [] 30)))
+
(defn address [k]
- (.toAddress k (NetworkParameters/prodNet)))
+ (.toAddress k (np)))
-(defn gen-image [qr-key qr-add key-str add-str]
+(defn gen-image [qr-key qr-add key-str add-str passphrase]
;; I'm no artist, I just draw everything with absolute coordinates
;; in a way that looks ok for me.
(let [img (BufferedImage. 800 350 BufferedImage/TYPE_INT_RGB)
@@ -29,32 +36,42 @@
(.setPaint g (Color/BLACK))
(.setFont g (Font. "Courier" Font/PLAIN 14))
(.drawString g "Dogecoin Address" 35 30)
- (.drawString g "Private Key (Wallet Import Format)" 400 30)
- (.drawString g key-str 360 320)
+ (if passphrase
+ (do
+ (.drawString g "Private Key (Encrypted Format)" 420 30)
+ (.drawString g key-str 320 320))
+ (do
+ (.drawString g "Private Key (Wallet Import Format)" 400 30)
+ (.drawString g key-str 360 320)))
(.drawString g add-str 35 320)
(.setPaint g (Color/GREEN))
(.setFont g (Font. "Courier" Font/BOLD 20))
(.drawString g "SHARE" 210 30)
(.setPaint g (Color/RED))
(.drawString g "SECRET" 695 30)
- (javax.imageio.ImageIO/write img "png" (java.io.File. "wallet.png"))))
+ (javax.imageio.ImageIO/write img "png" (java.io.File. "dogewallet.png"))))
(defn gen-key []
- (.getPrivateKeyEncoded (ECKey.) (NetworkParameters/prodNet)))
-
-(defn gen-wallet []
- (let [k (gen-key)
- key-str (.toString k)
- p (NetworkParameters/prodNet)
- dk (DumpedPrivateKey. p key-str)
- add-str (.toString (.toAddress (.getKey dk) p))
+ (.getPrivateKeyEncoded (ECKey.) (np)))
+
+(defn gen-wallet [passphrase]
+ (let [key-str (if passphrase
+ (com.fruitcat.bitcoin.BIP38/generateEncryptedKey passphrase)
+ (.toString (gen-key)))
+ plain-key (if passphrase
+ (com.fruitcat.bitcoin.BIP38/decrypt passphrase key-str)
+ key-str)
+ k (.getKey (DumpedPrivateKey. (np) plain-key))
+ add-str (.toString (address k))
qr-key (qr key-str)
qr-add (qr add-str)]
(println "Address:" add-str "\nKey:" key-str)
- (gen-image qr-key qr-add key-str add-str)))
+ (gen-image qr-key qr-add key-str add-str passphrase)))
(defn -main [& args]
- (when (gen-wallet) (println "Print wallet.png and delete or encrypt the file. Don't share the above key with anyone, ever.")))
+ (com.fruitcat.bitcoin.BIP38/setNetParams (np))
+ (when (gen-wallet (first args)) (println "Print wallet.png and delete or encrypt the file. Don't share the above key with anyone, ever."))
+ (when (first args) (println "Also, memorize your passphrase or store it SEPARATE from your wallet:" (first args))))

No commit comments for this range

Something went wrong with that request. Please try again.