Bitcoin Dev Project's avatar
Bitcoin Dev Project
_@bitcoindevs.xyz
npub10p33...n2l2
The go-to resource for developers to learn bitcoin and related technologies. Get inspired to kickstart and grow your career in bitcoin open source software (₿OSS).
Bitcoin Dev Project's avatar
bitcoin_devs 9 hours ago
Enlightening! Testing! Inspiring! That is how 2025 alum Sangbida describes the ₿OSS Challenge. When she took it she was working on corporate side of #bitcoin. Now she is funded by @Blockstream to contribute to Core Lightning ⚡️ What’s stopping you? Start your career in bitcoin open source software (₿OSS) and change your life forever. Applications close in 10 days on Dec 31. Program kicks off the week of January 12.
Bitcoin Dev Project's avatar
bitcoin_devs 3 days ago
It can be tough to get into open source on your own. When Marco started the ₿OSS Challenge he was trading options. Now he is funded by Brink to work on fuzz testing. The program helped him navigate the large Bitcoin Core code base and decide where to focus his energy. It provided actionable steps to bring him closer to becoming a #bitcoin open source contributor. Don’t do it alone. Apply now for the ₿OSS Challenge. #opensource #boss #foss #softwaredeveloper #softwareengineering
Bitcoin Dev Project's avatar
bitcoin_devs 3 days ago
📢 ATTN: developers interested in bitcoin open-source 👀 We are looking for participants for voluntary usability testing. 🖥️ During the session you’ll be asked to share your thoughts while interacting with a website prototype. image If this sounds like something you'd be interested in, sign up here 👇 Selected participants will be contacted to schedule a remote session with the designer. Thank you in advance. We would love your participation! ✨ image
Bitcoin Dev Project's avatar
bitcoin_devs 5 days ago
Want a career in #bitcoin open source but feeling intimidated? Sangbida Chaudhuri and MacGyver talk about their experience on the Stephan Livera podcast transitioning from the corporate world to bitcoin open source development. Join us for the bosschallenge.xyz and change your career in 2026.
Bitcoin Dev Project's avatar
bitcoin_devs 2 weeks ago
The ₿OSS Challenge is back 🎉 Start your career in bitcoin open source software (₿OSS) and change your life forever. Serious about a career in bitcoin open source software? Do you dream of professional freedom? Do you want your work to have a profound impact? Are you looking for some of the most challenging engineering problems? Take the ₿OSS Challenge and start yourself on a new path image - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ❓ HOW DOES IT WORK? ❓ The challenge kicks off the week of January 12 🗓️ 30 days to complete a series of code-based technical challenges 🛣️ 2 additional months for anyone willing to continue the adventure If you are willing to do the work, we'll give you what you need to get to where you want to go. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 🧑‍🤝‍🧑 LEARNING IS BETTER WITH FRIENDS 🧑‍🤝‍🧑 That’s why we’re delighted to announce ₿OSS Challenge partnerships with: - @Btrust - @npub1m495...u22l - @La Librería de Satoshi - @BOBSpace_BKK - @Code Orange Dev School - zzmjxy in China - My Satoshis in Burundi 🌍 Live in one of these regions? Reach out to connect with others doing the ₿OSS Challenge! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Funding for bitcoin open source development is earned by demonstrating proof of work. There is no cheat code. 🧡 Come do the work and good things will happen. 🧡 The ₿OSS Challenge gives you structure while fostering the proactive, self-starter spirit that is required in open-source. Join the challenge. See how far you will go. Change your life in 2026. ⏰ Applications close: December 31 🎯 Program begins: January 12 🌎 Open to everyone. Totally free. Application: bosschallenge.xyz #bitcoin
Bitcoin Dev Project's avatar
bitcoin_devs 3 weeks ago
Well, we finally did it. We got a logo for the Bitcoin Dev Project got a logo and a new website to match it. image For the last few years you have trusted the Bitcoin Dev Project (BDP) to bring high quality, open-source tools and education to the developer community. Today, as a symbol of our ongoing commitment to this mission, we are proud to reveal a fresh look. 🌿 🌿 🌿 Let’s start with the pangolin in the room Yes, that is a pangolin. Is this unexpected? Yes. Is it intentional? Very much. Pangolins are solitary, curious creatures known for their armour-like scales and quiet determination. Like the best open-source contributors, they build, explore, and protect what matters. To us, they represent the kind of thoughtful, persistent energy we see in the bitcoin dev community every day. image 🌿 🌿 🌿 How it began In 2023, BDP was born from a desire to build for the developer ecosystem. We created efficiency boosting tools like Bitcoin Search and ChatBTC. From there, a suite of educational products and even games emerged with things like Decoding Bitcoin and Saving Satoshi. This past year we rounded our offerings out with the Common Application which helps contributors apply for funding. image BDP has been lovingly designed to serve the developer community in a way that is approachable and encouraging, yet without compromising the hard work and discipline required of bitcoin development. There is much more to bitcoin tech than what is seen at the surface. That is why we created BDP to be a place where you can grow your technical skills without the noise. Anyone in the world should be able to participate in bitcoin development. If you do the work, BDP is there to help you reach your goals. image 🌿 🌿 🌿 A reimagined website You’ve seen the logo but that’s not all. This makeover goes far beyond that. Instead, the BDP website has been completely reimagined to deliver more moments of delight, improved navigation, and easy access to our tools and resources. The new illustrations, icons, and vibrant color palette are all inspired by the pangolin’s natural habitat. With an earthy, nature-inspired theme, the website is warm and inviting, reflecting BDP’s goal of being a welcoming entry point into bitcoin development. image Despite all the changes, you’ll still find the things you have come to expect from BDP: learning material, developer tools, and funding guidance. BDP provides new opportunities for you to explore and take meaningful steps toward becoming a bitcoin developer. image 🌿 🌿 🌿 Design secrets For more on how the logo and website came to life, check out this blog post by our amazing designer Sanya. https://medium.com/@bitcoindevs/glow-up-95008146d653 🌿 🌿 🌿 From the bottom of our hearts, thank you. We’re deeply passionate about the work we do and grateful for your support. To those that don’t know us: While getting confused with BDK is arguably a good problem to have, we hope you’ll stick around and get to know us. We’re in this for the long haul and would love for you to join in the adventure.
Bitcoin Dev Project's avatar
bitcoin_devs 2 months ago
Reminder that there is still time to apply for the Bitcoin Scholarship! Contribute to bitcoin and get a full year of your college tuition covered in return. Open to applicants anywhere in the world. Sound too good to be true? Meet the 2025 winner, Ishaana Misra. image Ishaana taught herself C++ in high school and became the youngest contributor to Bitcoin Core in the process. She is now a freshman at MIT and president of the MIT Bitcoin Club. Congrats Ishaana! Her story shows that even as a student you can make meaningful contributions to bitcoin. Ready to apply for the scholarship? Click the link below!👇
Bitcoin Dev Project's avatar
bitcoin_devs 2 months ago
📣 ICYMI: Chaincode Labs is (again) awarding a scholarship to attract the brightest minds to work on bitcoin. 🎓 The scholarship covers 100% tuition for an undergraduate anywhere in the world. Last year's winner started at MIT last month. Applications close soon. Don't let this opportunity pass you by! More details can be found here 👇
Bitcoin Dev Project's avatar
bitcoin_devs 3 months ago
Did you know, the bitcoin-dev mailing list has over 20,000 posts going back to June 2011? If each post takes 30 min to read (on average), that’s over 400 days of nonstop reading! To be fair, 1️⃣ Posts aren't easily searchable 2️⃣ If a thread spans multiple months back it can be broken 3️⃣ Your inbox probably has enough emails competing for your attention Things can easily go ignored & unread. Few, if any, can say they have read it all. For the rest of us, we started working into a way to download the mailing list straight to your brain. While we haven’t quite figured that out (yet), we've built the next best thing… Meet 📚 Bitcoin TLDR v2 📚, a collection of summaries for the bitcoin-dev, lightning-dev, and Delving Bitcoin mailing lists. ➡️ tldr.bitcoinsearch.xyz The mailing lists are known for being some of the best places to get updates on bitcoin development. 🔨 It’s where the builders go to propose new ideas, gather feedback, and hash it out. Whether you are trying to stay on the cutting edge, or are catching up on bitcoin’s rich technical history, Bitcoin TLDR is made for you. TLDR summarizes every individual mailing list post while also creating summaries at the thread level. With daily updates, thread summaries remain fresh based on new replies so you never miss a beat. 👀 Visit the Active Discussions section to see what’s trending: image If you’re already subscribed to the mailing lists but feel overwhelmed, try out the Bitcoin TLDR newsletter. It’s got weekly summaries of all the latest activity, providing a manageable way for you to stay on top of it all. image How Does It Work? - The Scraper Repo This scrapes through Delving Bitcoin and the Bitcoin Dev Mailing List, fetches mailing list pages, and stores them locally. A parser processes those files to extract clean metadata and message content. Finally, an indexer pushes the structured documents into an index in Elasticsearch for search and analysis. - The Summarizer The summarizer repo has two main parts. First, it makes sure Elasticsearch always has the latest full thread data by syncing the combined XML files. Second, it adds short AI summaries to posts that don’t have one yet. This way, Elasticsearch stores both the complete thread summaries, and individual post. Third, it creates AI summaries for the full thread, creating a combined summary. - The TLDR Frontend This renders summaries for each thread and post, and displays them with a beautiful UI. - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bitcoin TLDR is completely free and open-source. It’s designed to help more people engage with high signal bitcoin and lightning tech discussions. Give it a try and let us know what you think! ➡️ tldr.bitcoinsearch.xyz
Bitcoin Dev Project's avatar
bitcoin_devs 4 months ago
🚀 ICYMI we recently launched a common application for bitcoin grants! Apply for funding once. Reach multiple bitcoin grant organizations. Are you a bitcoin open-source software (₿OSS) contributor? Are you tired of filling out multiple applications for funding? Now you don’t have to. The Common Grants App is one application that gets you in front of: - @OpenSats - @Spiral - @Btrust Builders - Brink - Maelstrom - - - - - - - - - - Here’s how it works: 1. Fill out one form 2. Pick the orgs 3. Submit 4. Each org receives your app 5. They contact you if they are interested - - - - - - - - - - Why this matters: ✅ Saves time ✅ Saves effort ✅ Reach 5 bitcoin funding orgs ✅ No duplicate work More time building. Less time on the paperwork. ❌ No chasing 5 different forms across 5 sites ❌ No unnecessary overhead ✅ One unified application flow - - - - - - - - - - Who’s it for? - ₿OSS contributors - App builders - Educators - Privacy researchers - Anyone building for Bitcoin - - - - - - - - - - Built with ♥️ by @Bitcoin Dev Project Big thanks to @BTCillustrated, @Theophilus , @satsie 🇹🇭 🇱🇹 - - - - - - - - - - Ready to apply? 👇
Bitcoin Dev Project's avatar
bitcoin_devs 5 months ago
🧰 Too much bitcoin tech knowledge is trapped in videos and podcasts If only there was an easy way to unearth those insights and gems… 🤔 We wondered that too, so we redesigned Bitcoin Transcripts! 🚀 image 🔍 Bitcoin Transcripts is a filterable library of transcripts from: • dev meetups • conferences • podcasts • panels Skim talks, quote insights, and search by keyword. All in one place. 👉 ⛏️ Missed a workshop or podcast episode? No worries. You can now quickly search by keyword or topic and read the conversation in minutes instead of watching hours of video, Accelerating your speed to insights. 🧑‍🏫 Bitcoin Transcripts is perfect for: - bitcoin devs digging into prior research - educators creating content - researchers analyzing protocol history or - enthusiasts who prefer reading over listening Taproot workshops, Lightning panels, it’s all in there. Open-source and built by the community 🧡 This project stands on the shoulders of contributors like Bryan Bishop (https://heybryan.org/) who manually transcribed hundreds of talks. Now, with modern tools, we can scale that effort for the whole community. image Many thanks to our contributors: - Dev: @0tuedon , Jamal (https://github.com/jrakibi), Emmanuel (https://github.com/Emmanuel-Develops), @Theophilus - Data & architecture: Andreas (https://www.kouloumos.com/), Urvish (https://github.com/urvishp80) - Vision: @Jonas - Design: Tobi (https://x.com/Adeoye_G), Khush (https://x.com/ikhushh7), @Stephen DeLorme - Product: @art assoiants - Inspiration: Bryan Bishop (https://heybryan.org/) What’s next? We’ll keep adding transcripts from upcoming events and backfill any important historic talks we missed. 🔍 Would love your help editing transcripts as well. Dive in, explore, and let us know what you think! 👇 btctranscripts.com
Bitcoin Dev Project's avatar
bitcoin_devs 8 months ago
Slots are filling up fast for our Warnet track at Friday's #MITBitcoinExpo Hackathon! We stand up a network of Bitcoin Core nodes. You use Bitcoin Core's functional test framework to write attacks in Python and take them down. This event is open to hackers around the globe. Participants can be in-person or remote. And did we mention the $3,000 prize from the MIT Bitcoin Club? 👉 Head over to to sign up today! image We'll also have we’ll have additional prizes for Warnet track winners that are able to join in person. These gorgeous coasters by A+ Engrave are just one example! 🤩
Bitcoin Dev Project's avatar
bitcoin_devs 9 months ago
𝐓𝐡𝐞 𝐁𝐢𝐭𝐜𝐨𝐢𝐧 𝐃𝐞𝐯 𝐏𝐫𝐨𝐣𝐞𝐜𝐭 𝐡𝐚𝐬 𝐚 𝐭𝐫𝐚𝐜𝐤 𝐚𝐭 𝐭𝐡𝐞 𝐌𝐈𝐓 𝐁𝐢𝐭𝐜𝐨𝐢𝐧 𝐄𝐱𝐩𝐨 𝐇𝐚𝐜𝐤𝐚𝐭𝐡𝐨𝐧, 𝐚𝐧𝐝 𝐢𝐭 𝐡𝐚𝐬 𝐚 $𝟑,𝟎𝟎𝟎 𝐩𝐫𝐢𝐳𝐞! Participants have 30 hours, starting April 4 and are welcome to hack from around the globe. 🌍 We repeat, you do not have to attend in person 🌎 𝐌𝐨𝐬𝐭 𝐡𝐚𝐜𝐤𝐚𝐭𝐡𝐨𝐧 𝐭𝐫𝐚𝐜𝐤𝐬 𝐚𝐫𝐞 𝐚𝐛𝐨𝐮𝐭 𝐛𝐮𝐢𝐥𝐝𝐢𝐧𝐠, 𝐛𝐮𝐭 𝐧𝐨𝐭 𝐭𝐡𝐢𝐬 𝐨𝐧𝐞. 𝐓𝐡𝐢𝐬 𝐢𝐬 𝐚𝐛𝐨𝐮𝐭 𝐛𝐫𝐞𝐚𝐤𝐢𝐧𝐠 🔨 For the Bitcoin Dev Project track, the goal is to take down the bitcoin network. We stand up a network of bitcoin core nodes. You and your team take down as many as possible. Whichever team brings down the most in the shortest amount of time wins. Monitor extreme and yet unknown network behaviors, discover vulnerabilities, and build a stronger, more resilient bitcoin. image This track is for hackers with some level of coding skill, & the ability to use the command line interface (CLI). Familiarity with Bitcoin Core, esp. the JSON-RPC interface is useful. A general understanding of how blockchains and distributed networks work will come in handy. Who's ready to win? Sign up below! 👇
Bitcoin Dev Project's avatar
bitcoin_devs 10 months ago
New tool in Decoding Bitcoin! REORG CALCULATOR ⚒️ Computes the probability that an attacker could reorganize z blocks with a given % of the total network hashrate Here’s the probability of an attacker reorganizing 6 blocks with 30% of the total hashrate image
Bitcoin Dev Project's avatar
bitcoin_devs 10 months ago
Buckle up for today's #DecodingBitcoin post. It's a long one but we promise it's worth your time. Today we're going to break down how to sign a #bitcoin segwit transaction using a real example from the BIP-143 test vectors (that’s one of the segwit BIPs!) image 𝑁𝑜𝑡𝑒: 𝑡ℎ𝑖𝑠 𝑒𝑥𝑎𝑚𝑝𝑙𝑒 𝑖𝑠 𝑓𝑜𝑟 𝑎 𝑠𝑒𝑔𝑤𝑖𝑡 𝑣0 𝑡𝑟𝑎𝑛𝑠𝑎𝑐𝑡𝑖𝑜𝑛 𝑠𝑜 𝑠𝑜𝑚𝑒 𝑜𝑓 𝑡ℎ𝑒 𝑠𝑝𝑒𝑐𝑖𝑓𝑖𝑐𝑠 𝑎𝑟𝑒 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑡 𝑓𝑜𝑟 𝑙𝑒𝑔𝑎𝑐𝑦 𝑎𝑛𝑑 𝑡𝑎𝑝𝑟𝑜𝑜𝑡 (𝑠𝑒𝑔𝑤𝑖𝑡 𝑣1) 𝑡𝑟𝑎𝑛𝑠𝑎𝑐𝑡𝑖𝑜𝑛𝑠. 𝐻𝑜𝑤𝑒𝑣𝑒𝑟, 𝑡ℎ𝑒 𝑔𝑒𝑛𝑒𝑟𝑎𝑙 𝑐𝑜𝑛𝑐𝑒𝑝𝑡𝑠 𝑎𝑟𝑒 𝑠𝑡𝑖𝑙𝑙 𝑡ℎ𝑒 𝑠𝑎𝑚𝑒! The transaction we'll be working with has two inputs. The first is a legacy P2PK input–we won’t be covering that today. Instead, we’re going to focus on the second input, the P2WPKH (native segwit) one. image Since this example came from one of the BIP-143 test vectors, we know what the final, signed transaction looks like. The goal is to recreate this: image First, we create the base transaction, the transaction without any signatures. We’ll start with the - version number - marker & flag fields (to indicate the tx is segwit) - locktime image 𝐴 𝑛𝑜𝑡𝑒 𝑜𝑛 𝑠𝑒𝑔𝑤𝑖𝑡 𝑣𝑠. 𝑙𝑒𝑔𝑎𝑐𝑦 𝑡𝑟𝑎𝑛𝑠𝑎𝑐𝑡𝑖𝑜𝑛𝑠: 𝐵𝑒𝑐𝑎𝑢𝑠𝑒 𝑎𝑡 𝑙𝑒𝑎𝑠𝑡 𝑜𝑛𝑒 𝑜𝑓 𝑡ℎ𝑒 𝑖𝑛𝑝𝑢𝑡𝑠 𝑖𝑠 𝑠𝑒𝑔𝑤𝑖𝑡 (𝑛𝑎𝑡𝑖𝑣𝑒 𝑜𝑟 𝑤𝑟𝑎𝑝𝑝𝑒𝑑), 𝑡ℎ𝑒 𝑡𝑟𝑎𝑛𝑠𝑎𝑐𝑡𝑖𝑜𝑛 𝑖𝑠 𝑎𝑙𝑠𝑜 𝑐𝑜𝑛𝑠𝑖𝑑𝑒𝑟𝑒𝑑 𝑠𝑒𝑔𝑤𝑖𝑡. image Here’s what we have so far: image Let’s add inputs! Recall that all inputs come from existing transactions. That means for each input, we need to find the transaction it came from and get: 1. that transaction’s ID 2. the output index 𝐖𝐡𝐚𝐭’𝐬 𝐚𝐧 𝐨𝐮𝐭𝐩𝐮𝐭 𝐢𝐧𝐝𝐞𝐱? Every transaction has a list of outputs. The “output index” is a way to reference a specific output from the list. We need to ask, "from a transaction’s list of outputs, which one corresponds to the input I care about?” For each input, two more things are needed: the 𝐬𝐜𝐫𝐢𝐩𝐭𝐒𝐢𝐠 (placeholder for data required to spend the input), and a 𝐬𝐞𝐪𝐮𝐞𝐧𝐜𝐞 𝐧𝐮𝐦𝐛𝐞𝐫 (usually 0xFFFFFFFF) image After adding all the inputs, the transaction looks like this: image Remember when we said the scriptSig would be a placeholder? Here’s why those fields are currently empty: image Time to add outputs! For each output, we include the - amount (in satoshis) - scriptPubKey: the locking script that defines the rules for how the output can be spent image Things are starting to come together! image A few more things are needed before we can get to signing. First is setting up the 𝐰𝐢𝐭𝐧𝐞𝐬𝐬 field. This is where the signature and corresponding public key go for segwit transactions. The witness field starts off empty. This is different from legacy transactions where signatures are placed directly in the scriptSig field. image The next thing that’s needed is the 𝐬𝐜𝐫𝐢𝐩𝐭𝐂𝐨𝐝𝐞. The scriptCode for a P2WPKH (pay-to-witness-public-key-hash) input is: image 𝑊ℎ𝑎𝑡’𝑠 𝑡ℎ𝑎𝑡 20 𝑏𝑦𝑡𝑒 𝑝𝑢𝑏𝑘𝑒𝑦 ℎ𝑎𝑠ℎ? 𝐸𝑎𝑟𝑙𝑖𝑒𝑟 𝑤𝑒 𝑠𝑎𝑤 𝑒𝑎𝑐ℎ 𝑜𝑢𝑡𝑝𝑢𝑡 ℎ𝑎𝑠 𝑎 𝑠𝑐𝑟𝑖𝑝𝑡𝑃𝑢𝑏𝐾𝑒𝑦 (𝑟𝑢𝑙𝑒𝑠 𝑓𝑜𝑟 ℎ𝑜𝑤 𝑡𝑜 𝑠𝑝𝑒𝑛𝑑 𝑡ℎ𝑒 𝑜𝑢𝑡𝑝𝑢𝑡). 𝐴𝑙𝑠𝑜, 𝑟𝑒𝑐𝑎𝑙𝑙 𝑡ℎ𝑎𝑡 𝑡ℎ𝑒 𝑖𝑛𝑝𝑢𝑡 𝑡𝑜 𝑜𝑛𝑒 𝑡𝑟𝑎𝑛𝑠𝑎𝑐𝑡𝑖𝑜𝑛 𝑖𝑠 𝑡ℎ𝑒 𝑜𝑢𝑡𝑝𝑢𝑡 𝑓𝑟𝑜𝑚 𝑎𝑛𝑜𝑡ℎ𝑒𝑟. 𝑇ℎ𝑒 20 𝑏𝑦𝑡𝑒 𝑝𝑢𝑏𝑘𝑒𝑦 ℎ𝑎𝑠ℎ 𝑖𝑠 𝑒𝑥𝑡𝑟𝑎𝑐𝑡𝑒𝑑 𝑓𝑟𝑜𝑚 𝑡ℎ𝑒 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑𝑖𝑛𝑔 𝑜𝑢𝑡𝑝𝑢𝑡'𝑠 𝑠𝑐𝑟𝑖𝑝𝑡𝑃𝑢𝑏𝐾𝑒𝑦. Here’s the 𝐬𝐜𝐫𝐢𝐩𝐭𝐂𝐨𝐝𝐞 for the example we’re working on: image Lastly, three important hashes are required. The first is 𝐡𝐚𝐬𝐡𝐏𝐫𝐞𝐯𝐨𝐮𝐭𝐬. It’s the double SHA256 hash of all input outpoints (outpoint = the transaction id + output index) The second is 𝐡𝐚𝐬𝐡𝐒𝐞𝐪𝐮𝐞𝐧𝐜𝐞, the double SHA256 hash of all input sequence numbers. The third is 𝐡𝐚𝐬𝐡𝐎𝐮𝐭𝐩𝐮𝐭𝐬, the double SHA256 hash of all outputs. That’s everything (finally!). Let’s put it all together into something that can be signed! When signing a transaction, the spender actually signs a hash of the transaction data, not the entire transaction itself. This hash is called the 𝐬𝐢𝐠𝐡𝐚𝐬𝐡. The data used to create the sighash is called the 𝐩𝐫𝐞𝐢𝐦𝐚𝐠𝐞. For a transaction input, the preimage is made of these items: image The sighash_type indicates which parts of the transaction the signature is committing to. image After hashing the preimage twice with SHA-256, we’re left with the sighash. At last! It’s time to do some signing! image There are a few steps for signing a segwit (v0) transaction. First, the signer’s private key is used to create an ECDSA signature for the sighash. The resulting signature has two parts, 𝑟 and 𝑠. In ECDSA, there are actually two valid s values for every signature: a "high" value and a "low" value. Both are mathematically valid, but bitcoin requires using the low s value to prevent transaction malleability (that means altering a transaction's ID!) After selecting the low s value, the signature must be encoded into DER format. This is how it’s structured: image And here’s what the DER encoded signature looks like for our example: image The last step is to add a byte at the end for the sighash type. If we look back at the preimage made earlier we see this example is using SIGHASH_ALL (0x01). The full code for the signing step looks like this: image Remember the transaction witness field we set space aside for? It’s now time to put the signature in it 🚀 image This is how the witness field is structured: image Which works out to be this for our example: image With the completion of the witness field, the transaction is now signed! image This is what the final signed transaction hex looks like broken down: image Bonus: You can use the Bitcoin Core CLI decoderawtransaction command to examine all the parts of the raw transaction hex image * ~ * ~ * ~ * ~ * ~ * ~ If you made it to the end, give yourself a pat on the back. If you enjoyed it, be sure to like this post so we know to make more like it! * ~ * ~ * ~ * ~ * ~ * ~ This material is from Decoding Bitcoin, your go-to resource for understanding bitcoin, #privacy, and #decentralization. You can visit for the full lesson with all the code examples, as well as more free, interactive content. For more of a challenge, play chapters 4, 5, and 6 of @Saving Satoshi (https://savingsatoshi.com) to learn about public-private key cryptography, digital signatures, and transaction building 😺 image Hope you learned something new about transaction signing. If you enjoyed this, share it with a friend and don’t forget to follow us, @Bitcoin Dev Project for more content like this. Thanks for reading!
Bitcoin Dev Project's avatar
bitcoin_devs 10 months ago
We’ve got a good #DecodingBitcoin post for you today. The topic? 𝐄𝐧𝐝𝐢𝐚𝐧𝐧𝐞𝐬𝐬, AKA the order of bytes in a computer’s memory. When we put it like that it sounds a little boring, but there’s something interesting, and dare we say 𝑎𝑛𝑛𝑜𝑦𝑖𝑛𝑔, about how bitcoin handles endianness… Before we get to that, let’s better understand what endianness is. Imagine reading directions in different languages: while English is written and read from left to right, Arabic text flows from right to left. image Similarly, computers have two ways to store data: 1. 𝐁𝐢𝐠-𝐞𝐧𝐝𝐢𝐚𝐧 (BE): Most significant byte first 2. 𝐋𝐢𝐭𝐭𝐥𝐞-𝐞𝐧𝐝𝐢𝐚𝐧 (LE): Least significant byte first image When computers with different byte orders try to communicate, they can misread each other. It’s like two people reading numbers from opposite directions. image 𝐁𝐢𝐠-𝐞𝐧𝐝𝐢𝐚𝐧 𝐬𝐭𝐨𝐫𝐞𝐬 𝐭𝐡𝐞 𝐦𝐨𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 𝐟𝐢𝐫𝐬𝐭. This is similar to how humans read numbers and Hex in most cases: starting with the most important information. Suppose we want to store the number 12345678 (hexadecimal: 0x00BC614E) in memory. In big-endian, the bytes are stored in this order: 00 BC 61 4E image Observe that: - The 𝐦𝐨𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 (00) is stored at the 𝐥𝐨𝐰𝐞𝐬𝐭 𝐦𝐞𝐦𝐨𝐫𝐲 𝐚𝐝𝐝𝐫𝐞𝐬𝐬 (00). - The 𝐥𝐞𝐚𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 (4E) is stored at the 𝐡𝐢𝐠𝐡𝐞𝐬𝐭 𝐚𝐝𝐝𝐫𝐞𝐬𝐬 (03). Big-endian is considered more "human-readable" because the data is stored in the order we naturally read it. 𝐋𝐢𝐭𝐭𝐥𝐞-𝐞𝐧𝐝𝐢𝐚𝐧 𝐬𝐭𝐨𝐫𝐞𝐬 𝐭𝐡𝐞 𝐥𝐞𝐚𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 𝐟𝐢𝐫𝐬𝐭. This might feel counter intuitive to humans but is more efficient for modern processors. Using the same number 12345678 (0x00BC614E), here's how it looks in little-endian: 4E 61 BC 00 image This time, the 𝐥𝐞𝐚𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 (4E) is stored at the 𝐥𝐨𝐰𝐞𝐬𝐭 𝐦𝐞𝐦𝐨𝐫𝐲 𝐚𝐝𝐝𝐫𝐞𝐬𝐬 (00). The 𝐦𝐨𝐬𝐭 𝐬𝐢𝐠𝐧𝐢𝐟𝐢𝐜𝐚𝐧𝐭 𝐛𝐲𝐭𝐞 (00) is stored at the 𝐡𝐢𝐠𝐡𝐞𝐬𝐭 𝐚𝐝𝐝𝐫𝐞𝐬𝐬 (03). This "reversal" of bytes is common in the Bitcoin Core codebase. In bitcoin, most data like transaction IDs, block headers, and amounts are all in little-endian format or with the bytes reversed. image 𝑁𝑜𝑡𝑒: 𝐸𝑛𝑑𝑖𝑎𝑛𝑛𝑒𝑠𝑠 𝑜𝑛𝑙𝑦 𝑎𝑝𝑝𝑙𝑖𝑒𝑠 𝑡𝑜 𝑖𝑛𝑡𝑒𝑔𝑒𝑟𝑠. 𝐼𝑡 𝑖𝑠 𝑛𝑜𝑡 𝑐𝑜𝑟𝑟𝑒𝑐𝑡 𝑡𝑜 𝑠𝑎𝑦 𝑎 ℎ𝑎𝑠ℎ 𝑖𝑠 𝑙𝑖𝑡𝑡𝑙𝑒-𝑒𝑛𝑑𝑖𝑎𝑛. 𝑆𝑖𝑛𝑐𝑒 𝑡ℎ𝑒𝑟𝑒’𝑠 𝑛𝑜 𝑜𝑓𝑓𝑖𝑐𝑖𝑎𝑙 𝑡𝑒𝑟𝑚 𝑓𝑜𝑟 𝑡ℎ𝑖𝑠 𝑤𝑒 𝑠𝑎𝑦 “𝑏𝑦𝑡𝑒 𝑠𝑤𝑎𝑝𝑝𝑒𝑑” 𝑜𝑟 “𝑟𝑒𝑣𝑒𝑟𝑠𝑒 𝑏𝑦𝑡𝑒𝑠”. For readability, the bytes are swapped back to the style of big-endian when this data is displayed to humans. A block explorer is one example of where you can see this. Bitcoin Core’s JSON-RPC interface was the first time block hashes were printed for human consumption. That was when someone decided to reverse the ordering of hash so that it looked like a human readable integer. image It turns out the real block hash, the actual sha256 value you get if you compute the hash yourself, is: e4b1d56439d46d9070e58c4368cccc97596fa908daf101000000000000000000 The zeros are actually on the right! At first glance it looks like this is a very large number, but we know the integer value of a block hash actually gets smaller as the difficulty increases. It's clear that the bytes are reversed and in the style of little-endian. But why? We can thank Satoshi for that. Satoshi decided to interpret the block hash as a little-endian integer. The more zeroes there are on the right side, the smaller the (little-endian) integer. Since most modern CPUs are little-endian, bitcoin uses it to optimize performance. However, network protocols typically use big-endian, creating a mismatch 🙀 Big-endian is used for network communication (network byte order). Little-endian is used for bitcoin’s internal storage. This duality requires developers to frequently, and sometimes frustratingly, convert between the two formats when working with bitcoin data. Have you been the victim of an endianness oversight when writing bitcoin code? It's a common source of pain for developers new to bitcoin (and even the seasoned ones!) As covered by the transaction ID example earlier, byte order confusion can be common. image Another gotcha is length specification. When converting to little-endian, always specify the correct byte length: image Hope you learned something new about endianness today. If you enjoyed this, share it with a friend and don’t forget to follow us, @Bitcoin Dev Project ! This material is from Decoding Bitcoin, your go-to resource for understanding #bitcoin, privacy, and decentralization. Visit for the full lesson, and more free, interactive content. Thanks for reading!