Bitcoin Forum
March 08, 2021, 07:18:00 PM *
News: Latest Bitcoin Core release: 0.21.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: offline bitcoin database connect on python  (Read 271 times)
mamuu
Jr. Member
*
Online Online

Activity: 38
Merit: 16


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 ?
1615231080
Hero Member
*
Offline Offline

Posts: 1615231080

View Profile Personal Message (Offline)

Ignore
1615231080
Reply with quote  #2

1615231080
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1615231080
Hero Member
*
Offline Offline

Posts: 1615231080

View Profile Personal Message (Offline)

Ignore
1615231080
Reply with quote  #2

1615231080
Report to moderator
1615231080
Hero Member
*
Offline Offline

Posts: 1615231080

View Profile Personal Message (Offline)

Ignore
1615231080
Reply with quote  #2

1615231080
Report to moderator
TheArchaeologist
Full Member
***
Offline Offline

Activity: 168
Merit: 458


---------> 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
ETFbitcoin
Legendary
*
Offline Offline

Activity: 1792
Merit: 2683


NotYourKeys.org - Not Your Keys, Not Your Bitcoin


View Profile
June 23, 2020, 12:17:24 PM
 #3

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.

Don't forget to makesure rpcport properties on bitcoin.conf file and your software have same value, i saw few members missconfigure their ports, especially when they use testnet or regnet.

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!