Bitcoin Forum
May 13, 2024, 03:33:22 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: offline bitcoin database connect on python  (Read 308 times)
mamuu (OP)
Member
**
Offline Offline

Activity: 71
Merit: 19


View Profile
June 21, 2020, 07:25:09 PM
 #1

rpc how to connect on python

i install bitcoin-core and downloaded all blocks

but i cant do connect rpc on python

my documants this > https://bitcoinlib.readthedocs.io/en/latest/_static/manuals.setup-bitcoind-connection.html#bitcoin-node-settings


is there any advice ?

1DWA3Sa8i6eHVWV4AG4UP2SBhYB2XrfiHW
1715571202
Hero Member
*
Offline Offline

Posts: 1715571202

View Profile Personal Message (Offline)

Ignore
1715571202
Reply with quote  #2

1715571202
Report to moderator
"The nature of Bitcoin is such that once version 0.1 was released, the core design was set in stone for the rest of its lifetime." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715571202
Hero Member
*
Offline Offline

Posts: 1715571202

View Profile Personal Message (Offline)

Ignore
1715571202
Reply with quote  #2

1715571202
Report to moderator
1715571202
Hero Member
*
Offline Offline

Posts: 1715571202

View Profile Personal Message (Offline)

Ignore
1715571202
Reply with quote  #2

1715571202
Report to moderator
1715571202
Hero Member
*
Offline Offline

Posts: 1715571202

View Profile Personal Message (Offline)

Ignore
1715571202
Reply with quote  #2

1715571202
Report to moderator
TheArchaeologist
Sr. Member
****
Offline Offline

Activity: 310
Merit: 727


---------> 1231006505


View Profile WWW
June 22, 2020, 07:09:21 AM
Last edit: June 26, 2020, 04:16:40 PM by TheArchaeologist
Merited by hugeblack (2), Heisenberg_Hunter (2)
 #2

Check a couple of things:

Did you fill the following settings in your config file of bitcoin core (bitcoin.conf, on linux in .bitcoin-folder):
Code:
server=1
rpcpassword=<password>
rpcuser=<user>
You should fill in the <password> and <user> values with your own.

If you want to be able to also get transaction info on addresses not in your wallet you also want to add txindex to your bitcoin.conf file:
Code:
txindex=1

Fire up bitcoind:
Code:
bitcoind -daemon

Check to see if you can use rpc calls from the commandline:
Code:
curl --user <user>:<password> --data-binary '{"jsonrpc":"1.0","id":"curltext","method":"getblockcount","params":[]}' -H 'content-type:text/plain;' http://127.0.0.1:8332
Where you use the same <user> and <password> as included in your bitcoin.conf file

If all works fine, you can setup things for Python, First install the bitcoin-rpc package (I assume you use python3):
Code:
sudo pip3 install bitcoinrpc

And finally connect from python:
Code:
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:8332"%("<user>", "<password>"),timeout = 120)
print('You are synced up to block %s) , % rpc_connection.getblockcount())
And once again, replace the <user> and <password> with your own settings.

Sooner or later you're going to realize, just as I did, that there's a difference between knowing the path and walking the path
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!