Post
Topic
Board Announcements (Altcoins)
Re: [ANN][CLAM] CLAMS, Proof-Of-Chain, Proof-Of-Pearl, @Poloniex.com
by
xploited
on 17/07/2014, 07:15:52 UTC
I was wondering whether it's possible to find out whether a particular Bitcoin address has any CLAMS associated with it without having to have access to the private key.

The helpful folks on the #clams IRC channel told me it is - you can convert from Bitcoin address to CLAMS address without needing the private key.

Here's one way of doing it, using the "python-bitcoinlib" library:

$ git clone https://github.com/jgarzik/python-bitcoinlib.git
Cloning into 'python-bitcoinlib'...
remote: Reusing existing pack: 913, done.       
remote: Total 913 (delta 0), reused 0 (delta 0)       
Receiving objects: 100% (913/913), 300.69 KiB | 145.00 KiB/s, done.
Resolving deltas: 100% (487/487), done.
Checking connectivity... done.

$ cd python-bitcoinlib/

$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bitcoin.base58
>>> def btc2clam(addr): return bitcoin.base58.CBase58Data(bitcoin.base58.decode(addr)[1:-4], 0x89).__str__()
...
>>> print btc2clam('14o7zMMUJkG6De24r3JkJ6USgChq7iWF86')
xC6ktEBwaTk8G27wCWwQjGmDuK14SZPvJa
>>>

Thats awesome! Not much of a python user but you got to love how simple it is.

Updating for any one wondering about DogeCoin or Litecoin which is also possible with 3 simple changes to the pubkey address in base58.py

For DogeCoin:
  Dec:  127
  Hex:   \x7f 

For LiteCoin:
  Dec:  48
  Hex:  \x30

The Decmial version of the pubkey address goes in the follow line: 

https://github.com/jgarzik/python-bitcoinlib/blob/master/bitcoin/base58.py#L106

The hex goes in the 2 following lines:

https://github.com/jgarzik/python-bitcoinlib/blob/master/bitcoin/base58.py#L40
https://github.com/jgarzik/python-bitcoinlib/blob/master/bitcoin/base58.py#L106

Once you make those changes the rest goes exactly like dooglus describes