{"id":610,"date":"2024-05-22T09:59:56","date_gmt":"2024-05-22T09:59:56","guid":{"rendered":"https:\/\/nownodes.io\/blog\/?p=610"},"modified":"2024-05-22T10:07:21","modified_gmt":"2024-05-22T10:07:21","slug":"bitcoin-hierarchical-deterministic-wallet-python","status":"publish","type":"post","link":"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/","title":{"rendered":"Bitcoin Hierarchical Deterministic wallet Python"},"content":{"rendered":"\n<p>Here we start a series of articles that entirely cover topics on how to start working with a blockchain network; from local creation of keys and addresses to transaction creation, signing, and broadcasting to the network. We take Bitcoin as the best example of the UTXO model, though then we\u2019ll trace the same for Account-based blockchain networks.<br><br>In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language. To learn how HD wallet works, you can check&nbsp;<a href=\"https:\/\/medium.com\/@harshagoli\/hd-wallets-explained-from-high-level-to-nuts-and-bolts-9a41545f5b0\" target=\"_blank\" rel=\"noreferrer noopener\">this<\/a>&nbsp;article.<\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisite\"><strong>Prerequisite<\/strong><\/h2>\n\n\n<ul class=\"wp-block-list\">\n<li>Python<\/li>\n\n\n\n<li>Basic understanding of programming<\/li>\n<\/ul>\n\n\n\n<p>Download and install python\u2019s latest version from its&nbsp;<a href=\"https:\/\/www.python.org\/downloads\/\" target=\"_blank\" rel=\"noreferrer noopener\">official website<\/a>.<\/p>\n\n\n\n<p>We need to install a python library called&nbsp;<a href=\"https:\/\/pypi.org\/project\/bitcoinlib\/#description\" target=\"_blank\" rel=\"noreferrer noopener\">bitcoinlib<\/a>&nbsp;to create and manage bitcoin wallets. To install the library run following command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install bitcoinlib<\/code><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"bitcoin-hd-wallet-with-python\"><strong>Bitcoin HD Wallet with Python<\/strong><\/h2>\n\n\n<p>Using HD wallets, we can generate a complete suite of crypto wallets for different cryptocurrency networks using just one seed. However, in today\u2019s article, we will only focus on Bitcoin and how to create a simple HD wallet.<\/p>\n\n\n\n<p>So let\u2019s create our first Bitcoin HD wallet.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from bitcoinlib.wallets import HDWallet\n\nwallet = HDWallet.create('Wallet1')\n\nkey1 = wallet.new_key()\n\nprint(key1.address)<\/code><\/pre>\n\n\n\n<p>In the above script, we are performing the following steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Importing bitcoinlib library<\/li>\n\n\n\n<li>create a new wallet<\/li>\n\n\n\n<li>Generating a new HD Key.<\/li>\n\n\n\n<li>Create a new address<\/li>\n<\/ul>\n\n\n\n<p>To run the above program, save it in a file with .py extension. (Ex- hd_wallet1.py). Then run that file using the command below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python hd_wallet1.py<\/code><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"bitcoin-hd-wallet-with-mnemonics\"><strong>Bitcoin HD Wallet with Mnemonics<\/strong><\/h2>\n\n\n<p>Mnemonics are very popular because they are easy to remember. Let\u2019s see how to create a Bitcoin wallet using mnemonics.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from bitcoinlib.wallets import HDWallet, wallet_delete\n\nfrom bitcoinlib.mnemonic import Mnemonic\n\npassphrase = Mnemonic().generate()\n\nprint(passphrase)\n\nwallet = HDWallet.create(\"mWallet1\", keys=passphrase, network='bitcoin')\n\nkey1 = wallet.new_key()\n\nprint(key1.address)<\/code><\/pre>\n\n\n\n<p>In the above script, we are performing the following steps.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Importing relevant classes from bitcoinlib<\/li>\n\n\n\n<li>Generating a random mnemonic, you can pass your own<\/li>\n\n\n\n<li>Creating a new wallet named mWallet1<\/li>\n\n\n\n<li>Generating keys<\/li>\n\n\n\n<li>Getting bitcoin public address<\/li>\n<\/ul>\n\n\n\n<p>To run this program, save it in a file with .py extension. (Ex- hd_wallet2.py). Then run that file using the command below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python hd_wallet2.py<\/code><\/pre>\n\n\n\n<p>To learn more about the bitcoinlib library check out the&nbsp;<a href=\"https:\/\/bitcoinlib.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">official documentation<\/a>.<\/p>\n\n\n\n<p>In the next article, we will talk about the Bitcoin Multi-sig wallet and how to create one.<\/p>\n\n\n\n<p><strong>Note<\/strong>: Never post your keys or mnemonic publically.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link has-palette-color-7-color has-vivid-purple-background-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/nownodes.io\/pricing\" target=\"_blank\" rel=\"noreferrer noopener\">Get access to Bitcoin<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here we start a series of articles that entirely cover topics on how to start working with a blockchain network; from local creation of keys and addresses to transaction creation, signing, and broadcasting to the network. We take Bitcoin as the best example of the UTXO model, though then we\u2019ll trace the same for Account-based [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":611,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","_lmt_disableupdate":"","_lmt_disable":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[95,7],"tags":[96,199,76,39],"class_list":["post-610","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bitcoin","category-node-guides","tag-bitcoin","tag-python","tag-testnet","tag-tutorial"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bitcoin Hierarchical Deterministic wallet Python<\/title>\n<meta name=\"description\" content=\"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nownodes.io\/blog\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bitcoin Hierarchical Deterministic wallet Python\" \/>\n<meta property=\"og:description\" content=\"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nownodes.io\/blog\/\" \/>\n<meta property=\"og:site_name\" content=\"NOWNodes Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-05-22T09:59:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-22T10:07:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/05\/NN_TON-2-min-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1440\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"NOWNodes Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@nownodes\" \/>\n<meta name=\"twitter:site\" content=\"@nownodes\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"NOWNodes Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/nownodes.io\/blog#article\",\"isPartOf\":{\"@id\":\"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/\"},\"author\":{\"name\":\"NOWNodes Team\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c\"},\"headline\":\"Bitcoin Hierarchical Deterministic wallet Python\",\"datePublished\":\"2024-05-22T09:59:56+00:00\",\"dateModified\":\"2024-05-22T10:07:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/\"},\"wordCount\":365,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\"},\"keywords\":[\"BItcoin\",\"Python\",\"Testnet\",\"Tutorial\"],\"articleSection\":[\"Bitcoin\",\"Node Guides\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/nownodes.io\/blog#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/\",\"url\":\"https:\/\/nownodes.io\/blog\",\"name\":\"Bitcoin Hierarchical Deterministic wallet Python\",\"isPartOf\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#website\"},\"datePublished\":\"2024-05-22T09:59:56+00:00\",\"dateModified\":\"2024-05-22T10:07:21+00:00\",\"description\":\"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language\",\"breadcrumb\":{\"@id\":\"https:\/\/nownodes.io\/blog#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/nownodes.io\/blog\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/nownodes.io\/blog#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/nownodes.io\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Node Guides\",\"item\":\"https:\/\/nownodes.io\/blog\/category\/node-guides\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Bitcoin\",\"item\":\"https:\/\/nownodes.io\/blog\/category\/node-guides\/bitcoin\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Bitcoin Hierarchical Deterministic wallet Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/nownodes.io\/blog\/#website\",\"url\":\"https:\/\/nownodes.io\/blog\/\",\"name\":\"NOWNodes Blog\",\"description\":\"Your first-to-go source of development guides, web3 analytics and most recent news about NOWNodes\",\"publisher\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/nownodes.io\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/nownodes.io\/blog\/#organization\",\"name\":\"NOWNodes Blog\",\"url\":\"https:\/\/nownodes.io\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png\",\"contentUrl\":\"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png\",\"width\":1164,\"height\":1164,\"caption\":\"NOWNodes Blog\"},\"image\":{\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/nownodes\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c\",\"name\":\"NOWNodes Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nownodes.io\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g\",\"caption\":\"NOWNodes Team\"},\"sameAs\":[\"http:\/\/65.108.139.113\"],\"url\":\"https:\/\/nownodes.io\/blog\/author\/nownodes\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Bitcoin Hierarchical Deterministic wallet Python","description":"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nownodes.io\/blog\/","og_locale":"en_US","og_type":"article","og_title":"Bitcoin Hierarchical Deterministic wallet Python","og_description":"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language","og_url":"https:\/\/nownodes.io\/blog\/","og_site_name":"NOWNodes Blog","article_published_time":"2024-05-22T09:59:56+00:00","article_modified_time":"2024-05-22T10:07:21+00:00","og_image":[{"width":2560,"height":1440,"url":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/05\/NN_TON-2-min-scaled.jpg","type":"image\/jpeg"}],"author":"NOWNodes Team","twitter_card":"summary_large_image","twitter_creator":"@nownodes","twitter_site":"@nownodes","twitter_misc":{"Written by":"NOWNodes Team","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nownodes.io\/blog#article","isPartOf":{"@id":"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/"},"author":{"name":"NOWNodes Team","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c"},"headline":"Bitcoin Hierarchical Deterministic wallet Python","datePublished":"2024-05-22T09:59:56+00:00","dateModified":"2024-05-22T10:07:21+00:00","mainEntityOfPage":{"@id":"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/"},"wordCount":365,"commentCount":0,"publisher":{"@id":"https:\/\/nownodes.io\/blog\/#organization"},"keywords":["BItcoin","Python","Testnet","Tutorial"],"articleSection":["Bitcoin","Node Guides"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nownodes.io\/blog#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nownodes.io\/blog\/bitcoin-hierarchical-deterministic-wallet-python\/","url":"https:\/\/nownodes.io\/blog","name":"Bitcoin Hierarchical Deterministic wallet Python","isPartOf":{"@id":"https:\/\/nownodes.io\/blog\/#website"},"datePublished":"2024-05-22T09:59:56+00:00","dateModified":"2024-05-22T10:07:21+00:00","description":"In this article, we will create a bitcoin HD (Hierarchical Deterministic) wallet using Python language","breadcrumb":{"@id":"https:\/\/nownodes.io\/blog#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nownodes.io\/blog"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nownodes.io\/blog#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/nownodes.io\/blog"},{"@type":"ListItem","position":2,"name":"Node Guides","item":"https:\/\/nownodes.io\/blog\/category\/node-guides"},{"@type":"ListItem","position":3,"name":"Bitcoin","item":"https:\/\/nownodes.io\/blog\/category\/node-guides\/bitcoin"},{"@type":"ListItem","position":4,"name":"Bitcoin Hierarchical Deterministic wallet Python"}]},{"@type":"WebSite","@id":"https:\/\/nownodes.io\/blog\/#website","url":"https:\/\/nownodes.io\/blog\/","name":"NOWNodes Blog","description":"Your first-to-go source of development guides, web3 analytics and most recent news about NOWNodes","publisher":{"@id":"https:\/\/nownodes.io\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nownodes.io\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/nownodes.io\/blog\/#organization","name":"NOWNodes Blog","url":"https:\/\/nownodes.io\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png","contentUrl":"https:\/\/nownodes.io\/blog\/wp-content\/uploads\/2024\/02\/cropped-New-Logo-NN.png","width":1164,"height":1164,"caption":"NOWNodes Blog"},"image":{"@id":"https:\/\/nownodes.io\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/twitter.com\/nownodes"]},{"@type":"Person","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/c041891469390738b68a2aafe063f93c","name":"NOWNodes Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nownodes.io\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084e45aa2f2bfa61b9ce9f41af97a74f38e87c065b0d49f23a1bb84727320c2e?s=96&d=mm&r=g","caption":"NOWNodes Team"},"sameAs":["http:\/\/65.108.139.113"],"url":"https:\/\/nownodes.io\/blog\/author\/nownodes"}]}},"modified_by":"NOWNodes Team","_links":{"self":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/comments?post=610"}],"version-history":[{"count":2,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/610\/revisions"}],"predecessor-version":[{"id":615,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/posts\/610\/revisions\/615"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/media\/611"}],"wp:attachment":[{"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/media?parent=610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/categories?post=610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nownodes.io\/blog\/wp-json\/wp\/v2\/tags?post=610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}