Skip to content

Commit

Permalink
Add instructions for a readonly bitcoinlib wallet from bitcoin core
Browse files Browse the repository at this point in the history
  • Loading branch information
Cryp Toon committed May 16, 2024
1 parent 7b3bf2a commit 46fe2d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions bitcoinlib/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def __init__(self, network=DEFAULT_NETWORK, min_providers=1, max_providers=1, pr
:type exclude_providers: list of str
:param strict: Strict checks of valid signatures, scripts and transactions. Normally use strict=True for wallets, transaction validations etcetera. For blockchain parsing strict=False should be used, but be sure to check warnings in the log file. Default is True.
:type strict: bool
:param wallet_name: Name of wallet if connecting to bitcoin node
:type wallet_name: str
"""

Expand Down
2 changes: 1 addition & 1 deletion examples/wallet_bitcoind_connected_wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# EXAMPLES - Using Bitcoin Core wallets with Bitcoinlib
#
# Method 1 - Create wallet in Bitcoin Core and use the same wallet in Bitcoinlib using the bitcoin node to
# receive and send bitcoin transactions.
# receive and send bitcoin transactions. Only works for legacy wallets.
#
# © 2024 April - 1200 Web Development <http://1200wd.com/>
#
Expand Down
19 changes: 10 additions & 9 deletions examples/wallet_bitcoind_connected_wallets2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# EXAMPLES - Using Bitcoin Core wallets with Bitcoinlib
#
# Method 2 - ...
# Method 2 - Create wallet in Bitcoin Core, export public keys to bitcoinlib and easily manage wallet from bitcoinlib.
#
# © 2024 April - 1200 Web Development <http://1200wd.com/>
# © 2024 May - 1200 Web Development <http://1200wd.com/>
#

from bitcoinlib.wallets import *
Expand All @@ -16,14 +16,15 @@
# Settings and Initialization
#

pkwif = 'cTAyLb37Sr4XQPzWCiwihJxdFpkLKeJBFeSnd5hwNiW8aqrbsZCd'
# Create wallet in Bitcoin Core and export descriptors
# $ bitcoin-cli createwallet wallet_bitcoincore2
# $ bitcoin-cli -rpcwallet=wallet_bitcoincore2 listdescriptors

w = wallet_create_or_open("wallet_bitcoincore2", keys=pkwif, network='testnet', witness_type='segwit',
key_path=KEY_PATH_BITCOINCORE)
# Now copy the descriptor of the public master key, which looks like: wpkh([.../84h/1h/0h]
pkwif = 'tpubDDuQM8y9z4VQW5FS13BXGMxUwkUKEXc8KG5xzzbe6UsssrJDKJEygqbgMATnn6ZDwLXQ5PQipH989qWRTzFhPPZMiHxYYrG14X34vc24pD6'

# You can create the wallet and manage it from bitcoinlib
w = wallet_create_or_open("wallet_bitcoincore2", keys=pkwif, witness_type='segwit')
w.providers=['bitcoind']
w.get_key()
w.scan(scan_gap_limit=1)
w.info()

# TODO
# FIXME

0 comments on commit 46fe2d8

Please sign in to comment.