electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit f7859c041e68c545781cf3a5c6db5bf5e206d6a6
parent eebabdf20959945181dacb2c8cec9eb154ac57d6
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Tue, 19 Jan 2016 22:00:16 +0900

Support Casascius minikeys

Diffstat:
MRELEASE-NOTES | 2++
Mlib/bitcoin.py | 14++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/RELEASE-NOTES b/RELEASE-NOTES @@ -6,6 +6,8 @@ experimental feature. Enable it by setting the Coin Selection preference to Privacy. * the install wizard has been rewritten and improved + * support minikeys as used in Casascius coins for private key import + and sweeping # Release 2.5.4 * increase MIN_RELAY_TX_FEE to avoid dust transactions diff --git a/lib/bitcoin.py b/lib/bitcoin.py @@ -312,6 +312,8 @@ def ASecretToSecret(key, addrtype=0): vch = DecodeBase58Check(key) if vch and vch[0] == chr((addrtype+128)&255): return vch[1:] + elif is_minikey(key): + return minikey_to_private_key(key) else: return False @@ -378,6 +380,18 @@ def is_private_key(key): ########### end pywallet functions ####################### +def is_minikey(text): + # Minikeys are typically 22 or 30 characters, but this routine + # permits any length provided the minikey is valid. A valid + # minikey must begin with an 'S', be in base58, and when suffixed + # with '?' have its SHA256 hash begin with a zero byte. They are + # widely used in Casascius physical bitoins. + return (text and text[0] == 'S' and all(c in __b58chars for c in text) + and ord(sha256(text + '?')[0]) == 0) + +def minikey_to_private_key(text): + return sha256(text) + from ecdsa.ecdsa import curve_secp256k1, generator_secp256k1 from ecdsa.curves import SECP256k1 from ecdsa.ellipticcurve import Point