2

I'm writing a module that connects to multiple wallets at once and I would like to have a way I can simply query the coin daemon for its coins abbreviation (not the "microcoins" as asked in a comment below, just the 3 character currency identifier).

Since my module also reads the coins config file, my only solution thus far is to add a parameter in the coins config file:

abbr=BTC

But I was wondering if there was a cleaner way to do this. A simple rpc command that I can pull the abbr from?

  • Do you mean BTC as opposed to mBTC or uBTC? I don't think I understand what you mean. – Jannes Oct 28 '15 at 0:36
  • I don't think there's any way to do this that's better than what you've come up with. – Nick ODell Oct 30 '15 at 3:19
  • It just surprises me that the Bitcoin software does not output "BTC" anywhere. I know that it is defined in the code, but I don't think there is an rpc call that ouputs "BTC". Maybe a future feature... I could always modify the source code of each coin and compile it... but that is going the wrong direction on my part. – s4w3d0ff Oct 31 '15 at 17:48
3

I will post my solution, but I still think there should be a cleaner way of doing this.

You would first need to open up (or create) the conf file for the coin which you wish to connect with then add abbr=BTC (or replace 'BTC' with whatever coin abbr you want).

You would then need to open up and read that conf file with your script/module. Since I am working with Python, here a function that does that:

def readCfg(location):
    cfg ={}
    with open(location) as f:
        for line in f:
            line = line.strip()
            if line and not line.startswith("#") and '=' in line: cfg[line.split('=', 1)[0]] = line.split('=', 1)[1]
        return cfg

cfg = readCfg('/home/username/.bitcoin/bitcoin.conf')
print(cfg['abbr'])

I think maybe having a documentation of this method done in other languages would be beneficial to the Bitcoin community. Feel free to expand on my answer until Bitcoin devs decide to add 'BTC' to the output of an rpc call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.