python-bitcoinlib icon indicating copy to clipboard operation
python-bitcoinlib copied to clipboard

bitcoin.params [bug]?

Open cluelessperson opened this issue 7 years ago • 12 comments

root@redwood:/etc/znc/modules# cat test.py

import bitcoin.rpc
txid = '55374e78c86bb739c0ef69f92e3f0cfa9b233e293426170c65a2fe381fd54593'
proxy = **bitcoin.rpc.Proxy(btc_conf_file='/etc/znc/bitcoin.conf')**

root@redwood:/etc/znc/modules# python3.5 test.py

Traceback (most recent call last): File "test.py", line 3, in proxy = bitcoin.rpc.Proxy(btc_conf_file='/etc/znc/bitcoin.conf') File "/usr/local/lib/python3.5/dist-packages/bitcoin/rpc.py", line 302, in init **kwargs) File "/usr/local/lib/python3.5/dist-packages/bitcoin/rpc.py", line 157, in init service_port = bitcoin.params.RPC_PORT AttributeError: module 'bitcoin' has no attribute 'params'


Params is defined here: https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/init.py#L62 but, bitcoin.rpc DOES contain "import bitcoin" https://github.com/petertodd/python-bitcoinlib/blob/master/bitcoin/rpc.py#L45

cluelessperson avatar Aug 18 '17 06:08 cluelessperson

This has been a strange issue for me, as well, affecting me only when doing some tinkering though an interpreter. Does this continue to be an issue for you too?

adventurist avatar Dec 23 '17 21:12 adventurist

Having the same problem on macOS, never had that problem on Ubuntu. Where you able to fix it?

lgdelgadom avatar Jun 07 '18 15:06 lgdelgadom

Hi Sir, Im having the same error in ubuntu version 18 from bitcoin.rpc import RawProxy

p= RawProxy() Traceback (most recent call last): File "", line 1, in File "/home/user/.local/lib/python3.6/site-packages/bitcoin/rpc.py", line 288, in init **kwargs) File "/home/user/.local/lib/python3.6/site-packages/bitcoin/rpc.py", line 164, in init service_port = bitcoin.params.RPC_PORT

i've tried to set a service_port but still encounter an issue p= RawProxy(service_port=8332) Traceback (most recent call last): File "", line 1, in File "/home/user/.local/lib/python3.6/site-packages/bitcoin/rpc.py", line 288, in init **kwargs) File "/home/user/.local/lib/python3.6/site-packages/bitcoin/rpc.py", line 172, in init if bitcoin.params.NAME != "mainnet": AttributeError: module 'bitcoin' has no attribute 'params'

Hope you can help me.

Gillian217 avatar Jun 13 '18 06:06 Gillian217

Hi Gillian,

I ended up not using this library, started working directly with bitcoin-qt RPC, it's actually simpler than I thought it would be. You can find the documentation here: https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

lgdelgadom avatar Jun 13 '18 16:06 lgdelgadom

Hi sir, Thank you for the quick response, may I ask if you have any idea how to integrate bitcoin-qt in python project?. Sorry I'm just a new in python and bitcoin. Hope you can help me.

Gillian217 avatar Jun 14 '18 00:06 Gillian217

Sure, I'm using the requests library for python. Basically this is the template for every rpc you'll do.

`import requests

url = "http://127.0.0.1:8332" auth = ("user","password") headers = {"Content-type":"text/plain"} data = '{"jsonrpc": "2.0", "method": "getblockcount", "id":"0", "params":[]}'

r = requests.post(url, auth=auth, headers=headers, data=data)`

The response is saved in r, you can get the content with r.text or r.content. This is assuming you are running bitcoind, just change the variables to match your node and the method and parameters for every call you want to make. Hope this helps!

lgdelgadom avatar Jun 14 '18 21:06 lgdelgadom

Hi Sir, Thank you for your help. I've tried the command and its working perfectly.

Gillian217 avatar Jun 15 '18 02:06 Gillian217

Hi sir, May I ask if you have been connected to testnet of bitcoin?. Because I want to try or test transaction of bitcoin or transfer of bitcoin from one account to another. Hope you could help me.

On Fri, Jun 15, 2018 at 5:22 AM, Luis Gerardo Delgado < [email protected]> wrote:

Sure, I'm using the requests library for python. Basically this is the template for every rpc you'll do.

`import requests

url = "http://127.0.0.1:8332" auth = ("user","password") headers = {"Content-type":"text/plain"} data = '{"jsonrpc": "2.0", "method": "getblockcount", "id":"0", "params":[]}'

r = requests.post(url, auth=auth, headers=headers, data=data)`

The response is saved in r, you can get the content with r.text or r.content. This is assuming you are running bitcoind, just change the variables to match your node and the method and parameters for every call you want to make. Hope this helps!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/petertodd/python-bitcoinlib/issues/142#issuecomment-397442429, or mute the thread https://github.com/notifications/unsubscribe-auth/Aj-CwEuJsuaI07YGPMSj9rcUk6x1M4jUks5t8tQNgaJpZM4O7K9w .

Gillian217 avatar Jun 18 '18 03:06 Gillian217

Same error

gigimushroom avatar Mar 21 '21 06:03 gigimushroom

Same. Any news on this?

juxeii avatar Apr 04 '22 08:04 juxeii

I got the same problem on ubuntu 20.04

JH6588 avatar May 26 '22 08:05 JH6588

I wonder if you guys have a different bitcoin module installed in your PYTHON_PATH?

petertodd avatar Jun 15 '22 02:06 petertodd