Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] Bitcoind regtest network example
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |