Bitcoin API Python

This will allow us to run bitcoin in test mode.

Now start the bitcoind daemon using:

To check that it's working, do:

If you see a JSON output, you should be good to go.

Using JSON RPC:

Bitcoin includes a JSON RPC server as a part of the daemon.

> import bitcoinrpc >> bitcoin = bitcoinrpc.connect_to_local >> bitcoin.getinfo

Payment Flow:

In a standard payment flow, the steps involved would be:

  • User checks out a shopping cart. Transaction starts.
  • Generate a new bitcoin addres and ask the user to pay.
  • Verify that payment is made, wait for confirmations if required.
  • Generate invoice. Transaction ends.

Let's see how to do each of this step using the python client:

Generate a new bitcoin address:

> add = bitcoin.getnewaddress

Verify payment is made:

> bitcoin.getreceivedbyaddress(add)

Get transcation info:

> bitcoin.listtransactions(address=add)

Note: By default the RPC client waits for 1 confirmation, you can increase this using the minconf argument to most API calls.

You can use a testnet faucet for testing:

When you're ready, you can switch the testnet mode in your bitcoinf.conf.

Security:

Bitcoin API PHP

Bitcoin Aktien

Bitcoin addnode

Bitcoin API example

Bitcoin API net