GithubHelp home page GithubHelp logo

bitcoin-requests's People

Contributors

fiatjaf avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

bitcoin-requests's Issues

Cookie file etc

Hi, if you are interested, I am using the library with an interface like this that automatically finds credentials:

    def __init__(self, datadir='~/.bitcoin', rpcurl='127.0.0.1', rpcuser=None, rpcpassword=None, rpcport=None):
        if '://' in rpcurl:
            dummy, rpcurl = rpcurl.split('://', 1)
        if '/' in rpcurl:
            rpcurl, dummy = rpcurl.split('/', 1)
        if '@' in rpcurl:
            if rpcuser is not None:
                raise Exception('user specified in rpcurl and parameter list')
            rpcuser, rpcurl = rpcurl.split('@', 1)
            if ':' in rpcuser:
                if rpcpassword is not None:
                    raise Exception('password specified in rpcurl and parameter list')
                rpcuser, rpcpassword = rpcuser.split(':', 1)
        if ':' in rpcurl:
            if rpcport is not None:
                raise DatacoinException('port specified in rpcurl and parameter list')
            rpcurl, rpcport = rpcurl.split(':', 1)
        rpcurl = 'http://{}'.format(rpcurl)
        if rpcport is not None:
            rpcurl += ':{}'.format(rpcport)
        if rpcpassword is None and rpcuser is None:
            datadir = os.path.expanduser(datadir)
            cookiefn = os.path.join(datadir, '.cookie')
            if os.path.exists(cookiefn):
                with open(cookiefn) as cookiefile:
                    rpcuser, rpcpassword = cookiefile.read().split(':', 1)

empty responses

Empty responses (e.g. rpc.gethelp('nonexistent') or rpc.nonexistent()) presently raise a json decoding error. it would be nice to raise a non-json error or simply return None.

Json Decoding Issue

Having some trouble getting calls to work properly. Any idea what I'm doing wrong? Bitcoin Core is running in background.

>>> username = '<my_username>'
>>> password = '<password>'
>>> rpc = BitcoinRPC('http://127.0.0.1:8332', username, password)
>>> rpc
<bitcoin_requests.bitcoin.BitcoinRPC object at 0x0000029F23B13B20>
>>> blockhash='000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254'
>>> block = rpc.getblock(blockhash)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\bitcoin_requests\bitcoin.py", line 30, in call
    resp = json.loads(v, parse_float=decimal.Decimal)
  File "C:\Python39\lib\json\__init__.py", line 359, in loads
    return cls(**kw).decode(s)
  File "C:\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python39\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.