stacks-network / pybitcoin

A Bitcoin python library for private + public keys, addresses, transactions, & RPC
MIT License
277 stars 117 forks source link

What is pubkeyhash_version_byte, How to find its value? #22

Open cqtenq opened 9 years ago

cqtenq commented 9 years ago

_pubkeyhash_version_byte = 52 in NamecoinPrivateKey _pubkeyhash_version_byte = 48 in LitecoinPrivateKey

I hope to add Feathercoin, How to find its value? _pubkeyhash_version_byte = ?? in FeathercoinPrivateKey

shea256 commented 9 years ago
class FeathercoinKeypair(BitcoinKeypair):
    _pubkeyhash_version_byte = 14
cqtenq commented 9 years ago

If PUBKEY_ADDRESS = 14 in base58.h, _pubkeyhash_version_byte =14 ?

shea256 commented 9 years ago

Yes, that is correct.

And actually, since you're looking for a private key class, here's what you should use:

class FeathercoinPrivateKey(BitcoinPrivateKey):
    _pubkeyhash_version_byte = 14
cqtenq commented 9 years ago

Thank you ,When I register a key-value pair with FTC's PrivateKey, first preorder the name, I get a error information.

blockstore-cli preorder swiftonsecurity N876Ywf8bL5JWMPbHvjHP2AaSF1Ap8Wg4qAn9AAiQbmYFWPh2vqe { "error": "UnboundLocalError: local variable 'secret_exponent' referenced before assignment", "traceback": [ "Traceback (most recent call last):", " File \"/usr/local/lib/python2.7/dist-packages/blockstore/blockstored.py\", line 253, in jsonrpc_preorder", " blockchain_client=blockchain_client, testset=True)", " File \"/usr/local/lib/python2.7/dist-packages/blockstore/lib/operations/preorder.py\", line 28, in broadcast", " hash160 = BitcoinPrivateKey(private_key).public_key().hash160()", " File \"/usr/local/lib/python2.7/dist-packages/coinkit/privatekey.py\", line 61, in init", " if not is_secret_exponent(secret_exponent, self._curve.order):", "UnboundLocalError: local variable 'secret_exponent' referenced before assignment" ] }

What I miss ?

cqtenq commented 9 years ago

OK, may error. I test coinkit right. Private Keys

from coinkit import FeathercoinPrivateKey priv = FeathercoinPrivateKey() priv.to_hex() '598cabac1a4aaff109bb2374cdc66e415a8993dfb37f681df64809072f3cf8be'

Public Keys

pub = priv.public_key() pub.to_hex() '04f733b299a8cce90e5dd7fab86756cb035a0806f368d46a16644d6dfb90ea5fa08be84ffb1011dc8721f7f6fb74c8b1aeadefc1d08fd86438eedf4482a3449e32' from coinkit import FeatherPublicKey pub2 = FeatherPublicKey(pub.to_hex()) print pub.to_hex() == pub2.to_hex() True

Addresses

pub.address() '6vGM9mgCN5vfyJMvw7CEZAkzqmPPjQmz8A' pub.hash160() 'b55a3463bce670f3040bdb87f58be48a62fdab07'

cqtenq commented 9 years ago

Wait , A new problem . How to change SCRIPT_ADDRESS, FTC's SCRIPT_ADDRESS is 96, not 5. SCRIPT_ADDRESS=96 not 5.

shea256 commented 9 years ago

I think the problem you have is your private key is not valid. Can you try using a fresh private key in hex format and make sure there's money in it?

cqtenq commented 9 years ago

If I create private key in FTC's Qt wallet, All private keys are prefix 'N'. I don't know why are they different.

cqtenq commented 9 years ago

I can not import private key to Qt-wallet, coinkit's private key is not standard operating procedure ? importprivkey c3b2287c0d2970d53dc7c7f3ef26a0e6575f2f3af3c8c35b46e3ed6116143501 Invalid private key (code -5)