Link

python-bitcoinlib

Generate Keys

#!/usr/bin/env python3

import bitcoin
from bitcoin.wallet import CBitcoinSecret, P2PKHBitcoinAddress  

bitcoin.SelectParams('testnet')

priv_key = 'cUHmPhwxCZN22yJP3orG1pgVSYrNcZtTB3KZMpPHXqyDnfFmzSF4' 

secret = CBitcoinSecret(priv_key)
public_key = secret.pub
p2pkh_address = P2PKHBitcoinAddress.from_pubkey(public_key)
scriptPubKey = p2pkh_address.to_scriptPubKey()
p2pkh_address2 = P2PKHBitcoinAddress.from_scriptPubKey(scriptPubKey)
print('P2PKH address based on public key: %s' % p2pkh_address)
print('P2PKH address based on scriptPubKey: %s' %  p2pkh_address2)

Get Block

#!/usr/bin/env python3

import bitcoin
import bitcoin.rpc

bitcoin.SelectParams('testnet')

proxy = bitcoin.rpc.Proxy()

block = proxy.getblock(proxy.getblockhash(10000))
print(block)

Send Coins

#!/usr/bin/env python3

import bitcoin
bitcoin.SelectParams('regtest')

from bitcoin.core import COIN, b2lx
import bitcoin.wallet
import bitcoin.rpc

rpc = bitcoin.rpc.Proxy()
addr = bitcoin.wallet.CBitcoinAddress('2NCbWGkCgntWxRJb3EKLiCBTZrGUm1LyBt9')

txid = rpc.sendtoaddress(addr, 10 * COIN)
print('Transaction created: %s' % b2lx(txid))