Skip to content

Commit

Permalink
[ADD] Bitcoind regtest network example
Browse files Browse the repository at this point in the history
  • Loading branch information
mccwdev committed Feb 21, 2022
1 parent 4c03a16 commit 75830f2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions examples/bitcoind_regtest.py
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
#
# BitcoinLib - Python Cryptocurrency Library
#
# EXAMPLES - Bitcoind regtest network example
#
# © 2022 Februari - 1200 Web Development <http://1200wd.com/>
#

from bitcoinlib.services.bitcoind import *
from pprint import pprint

bdc = BitcoindClient(base_url='http://rpcuser:pwd@localhost:18444')

print("Current blockheight is %d" % bdc.proxy.getblockcount())
address = bdc.proxy.getnewaddress()
print("Mine 50 blocks and generate regtest coins to address %s" % address)
bdc.proxy.generatetoaddress(50, address)
print("Current blockheight is %d" % bdc.proxy.getblockcount())

address2 = bdc.proxy.getnewaddress()
print("Send 10 rBTC to address %s" % address2)
bdc.proxy.settxfee(0.00002500)
txid = bdc.proxy.sendtoaddress(address2, 10)
print("Resulting txid: %s" % txid)
tx = bdc.proxy.gettransaction(txid)
pprint(tx)

0 comments on commit 75830f2

Please sign in to comment.