<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://joaobordalo.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://joaobordalo.com/" rel="alternate" type="text/html" /><updated>2026-04-05T17:32:39+00:00</updated><id>https://joaobordalo.com/feed.xml</id><title type="html">João Bordalo</title><subtitle>Hello, I&apos;m João Bordalo, a full stack bitcoiner living in Portugal. Here you can see some of my work, know my history or get my CV. Feel free to reach out.</subtitle><entry><title type="html">Paywally</title><link href="https://joaobordalo.com/articles/2024/12/16/paywally.html" rel="alternate" type="text/html" title="Paywally" /><published>2024-12-16T04:20:00+00:00</published><updated>2024-12-16T04:20:00+00:00</updated><id>https://joaobordalo.com/articles/2024/12/16/paywally</id><content type="html" xml:base="https://joaobordalo.com/articles/2024/12/16/paywally.html"><![CDATA[<p>I decided to play with cashu so I made</p>

<p><a href="https://paywally.pages.dev">https://paywally.pages.dev</a></p>

<p>It’s a standalone web app, no KYC, that implements a lightning paywall: you need to pay 21 sats to unlock the hidden content.</p>

<p>How it works:</p>

<!--more-->

<ul>
  <li>The app fetches a 19 sats invoice from <code class="language-plaintext highlighter-rouge">bordalix@coinos.io</code></li>
  <li>Then it creates a melt quote with this invoice</li>
  <li>In return the app gets amount = 19 and fee_reserve = 2 sats</li>
  <li>It then creates a mint quote of 21 sats (19 + 2)</li>
  <li>In return the app gets a payment request (aka ln invoice)</li>
  <li>It shows this invoice to the user in qrcode and text</li>
  <li>It pools the mint every 5 seconds waiting for the invoice to be paid</li>
  <li>When paid, it mints the proofs</li>
  <li>Use these proofs to pay for the original invoice</li>
  <li>Receives a change of 2 sats and sends it to me via Nostr</li>
</ul>

<p>It’s not perfect, the reader can sheat by inspecting the code and:</p>

<ul>
  <li>Change the value to pay to 3 sats</li>
  <li>Change <code class="language-plaintext highlighter-rouge">bordalix@coinos.io</code> to his own lnurl</li>
  <li>Access the content in the code (is obfuscated, but is there)</li>
</ul>

<p><a href="https://paywally.pages.dev">Try it</a> to get access to the code repo.</p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="lightning" /><category term="cashu" /><summary type="html"><![CDATA[I decided to play with cashu so I made https://paywally.pages.dev It’s a standalone web app, no KYC, that implements a lightning paywall: you need to pay 21 sats to unlock the hidden content. How it works:]]></summary></entry><entry><title type="html">Ark payments</title><link href="https://joaobordalo.com/articles/2024/09/30/ark-payments.html" rel="alternate" type="text/html" title="Ark payments" /><published>2024-09-30T04:20:00+00:00</published><updated>2024-09-30T04:20:00+00:00</updated><id>https://joaobordalo.com/articles/2024/09/30/ark-payments</id><content type="html" xml:base="https://joaobordalo.com/articles/2024/09/30/ark-payments.html"><![CDATA[<p>Let me start with an analogy:</p>

<p>On mainnet, when Alice wants to send to Bob, she has 2 options:</p>

<ol>
  <li>Sign transaction and broadcast it (Bob will find it on mempool)</li>
  <li>Sign transaction and send it to Bob (Bob can broadcast it immediately or later)</li>
</ol>

<p>Let’s call it <u>Send</u> and <u>Send Async</u> respectively.</p>

<!--more-->

<p>In Ark there are also 2 options for Alice (assuming Alice already has a VTXO).</p>

<p><strong>Send:</strong></p>

<ul>
  <li>Alice asks the ASP to pay Bob</li>
  <li>ASP waits for other payment intentions</li>
  <li>ASP prepares a new <strong>round tx</strong> with a new VTXO belonging to Bob and shows it to Alice</li>
  <li>Alice signs a <strong>forfeit tx</strong> using a <strong>round tx</strong> output as input (making it atomic)</li>
  <li>Alice needs to be online during the round</li>
  <li>ASP liquidity is required immediately</li>
</ul>

<p><strong>Send Async (or Out-Of-Round):</strong></p>

<ul>
  <li>Alice prepares a <strong>redeem tx</strong> (spends Alice’s VTXO into a Bob’s VTXO)</li>
  <li>Alice ask the ASP to co-sign the <strong>redeem tx</strong></li>
  <li>Alice sends the <strong>redeem tx</strong> to Bob (it doesn’t matter how)</li>
  <li>Bob can use this <strong>redeem tx</strong> to join a round now or later (up until Alice’s VTXO validity)</li>
  <li>Alice doesn’t need to be online during the round</li>
  <li>ASP liquidity is required later (only when Bob joins the round)</li>
  <li>Up until joining the round, Bob is trusting Alice + ASP don’t collude to double spend him</li>
</ul>

<p>For a more detailed explanation, check <a href="https://arkdev.info/docs/learn/payments">Payments</a> and <a href="https://arkdev.info/docs/learn/payments-oor">Out-of-Round Payments</a> on <a href="https://arkdev.info">arkdev.info</a></p>

<p>Related: <a href="/labs/ark/">Ark explainer</a></p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="ark" /><summary type="html"><![CDATA[Let me start with an analogy: On mainnet, when Alice wants to send to Bob, she has 2 options: Sign transaction and broadcast it (Bob will find it on mempool) Sign transaction and send it to Bob (Bob can broadcast it immediately or later) Let’s call it Send and Send Async respectively.]]></summary></entry><entry><title type="html">Helm wallet</title><link href="https://joaobordalo.com/articles/2024/04/20/announcing-helm-wallet.html" rel="alternate" type="text/html" title="Helm wallet" /><published>2024-04-20T04:20:00+00:00</published><updated>2024-04-20T04:20:00+00:00</updated><id>https://joaobordalo.com/articles/2024/04/20/announcing-helm-wallet</id><content type="html" xml:base="https://joaobordalo.com/articles/2024/04/20/announcing-helm-wallet.html"><![CDATA[<p>Announcing my latest pet project, Helm Wallet.</p>

<p>I believe there’s a huge gap between the ease of use of Wallet of Satoshi and the self-custody of Phoenix. To minimize this gap, I created a new web app, a wallet that has the self-custody of Phoenix and is easy to use as WoS.</p>

<p>Helm is a Liquid wallet that uses Boltz submarine swaps to disguise itself as a Lightning wallet that even your grandma can use.</p>

<p>But it has a cost.</p>

<!--more-->

<p>All transactions must go on the Liquid chain and also Boltz must earn something for the service they provide, so there are fees to be paid:</p>

<ul>
  <li>The minimum cost for sending a payment is around 200 sats;</li>
  <li>The average cost for sending <strong>or receiving</strong> a payment is around 400 sats plus 0.1% of the amount;</li>
  <li>Transactions between Helm wallets don’t pay Boltz fees but can take up to 1 minute to complete;</li>
  <li>Amounts are limited between 1.000 and 25.000.000 sats.</li>
</ul>

<p>You can try it (testnet if you want) on <a href="https://helm-wallet.pages.dev/">https://helm-wallet.pages.dev/</a></p>

<p>Code is available at <a href="https://github.com/bordalix/helm-wallet/">https://github.com/bordalix/helm-wallet/</a></p>

<p>The web app is completely independent, no server required. You can clone it, build it and run it from your own computer. Everything runs on the browser.</p>

<p>Critics and suggestions are welcome.</p>

<p><a href="https://helm-wallet.com">Landing page</a></p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="liquid" /><category term="lightning" /><category term="wallet" /><summary type="html"><![CDATA[Announcing my latest pet project, Helm Wallet. I believe there’s a huge gap between the ease of use of Wallet of Satoshi and the self-custody of Phoenix. To minimize this gap, I created a new web app, a wallet that has the self-custody of Phoenix and is easy to use as WoS. Helm is a Liquid wallet that uses Boltz submarine swaps to disguise itself as a Lightning wallet that even your grandma can use. But it has a cost.]]></summary></entry><entry><title type="html">Buy gift cards with Liquid</title><link href="https://joaobordalo.com/articles/2023/11/30/buy-tbc-with-liquid.html" rel="alternate" type="text/html" title="Buy gift cards with Liquid" /><published>2023-11-30T12:34:56+00:00</published><updated>2023-11-30T12:34:56+00:00</updated><id>https://joaobordalo.com/articles/2023/11/30/buy-tbc-with-liquid</id><content type="html" xml:base="https://joaobordalo.com/articles/2023/11/30/buy-tbc-with-liquid.html"><![CDATA[<p>Buy gift cards from <a href="https://embed.thebitcoincompany.com">The Bitcoin Company</a> and pay with Liquid BTC:</p>

<ul>
  <li>Buy gift card (includes VISA)</li>
  <li>Capture Lightning (LN) invoice</li>
  <li>Call <a href="https://boltz.exchange">Boltz</a> and make LBTC =&gt; LN swap</li>
  <li>User pays LBTC with <a href="https://vulpem.com/marina.html">Marina</a> wallet</li>
</ul>

<!--more-->

<video class="has-border" width="100%" controls="">
  <source src="/images/static/blog/liquidTBC.mov" type="video/mp4" />
  Your browser does not support the video tag.
</video>

<p>Try it yourself: <a href="https://liquidtbc.pages.dev">Liquid TBC</a></p>

<p><strong>Motivation:</strong></p>

<ul>
  <li>Because I can 😉</li>
  <li>To show the possibilities of integrating Liquid with the Lightning Network</li>
  <li>Now there’s <a href="https://github.com/bordalix/liquidtbc">code</a> in plain javascript that anyone can read and adapt for their own needs</li>
</ul>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="liquid" /><category term="lightning" /><summary type="html"><![CDATA[Buy gift cards from The Bitcoin Company and pay with Liquid BTC: Buy gift card (includes VISA) Capture Lightning (LN) invoice Call Boltz and make LBTC =&gt; LN swap User pays LBTC with Marina wallet]]></summary></entry><entry><title type="html">What is Nostr</title><link href="https://joaobordalo.com/articles/2023/11/26/what_is_nostr.html" rel="alternate" type="text/html" title="What is Nostr" /><published>2023-11-26T11:27:38+00:00</published><updated>2023-11-26T11:27:38+00:00</updated><id>https://joaobordalo.com/articles/2023/11/26/what_is_nostr</id><content type="html" xml:base="https://joaobordalo.com/articles/2023/11/26/what_is_nostr.html"><![CDATA[<p>Nostr stands for “Notes and Other Stuff Transmitted by Relays”. It is a decentralized social network protocol that aims to create a censorship-resistant and user-empowered alternative to existing social media platforms.</p>

<!--more-->

<p>Key features of Nostr:</p>

<ul>
  <li><strong>Decentralized</strong>: Nostr does not have a central server or authority. Instead, it relies on a network of relays that store and distribute messages. This makes it difficult to censor or shut down the network.</li>
  <li><strong>User-empowered</strong>: Users have complete control over their own data and can choose which relays they trust. They can also self-host their own relays to ensure that their data is not subject to third-party control.</li>
  <li><strong>Censorship-resistant</strong>: Nostr’s decentralized nature makes it very difficult to censor messages. Even if some relays are censored, there will always be other relays that are available to store and distribute messages.</li>
  <li><strong>Open protocol</strong>: Nostr is an open protocol, which means that anyone can build applications on top of it. This has led to the development of a variety of Nostr clients, each with its own unique features.</li>
</ul>

<p>Besides social networking, Nostr has other potential use cases, including:</p>

<ul>
  <li><strong>News feeds and RSS feeds</strong>: Nostr could be used to create a decentralized and censorship-resistant alternative to traditional news feeds and RSS feeds.</li>
  <li><strong>Microblogging and status updates</strong>: Nostr could be used to create a decentralized and censorship-resistant alternative to microblogging platforms like Twitter.</li>
  <li><strong>File sharing and distributed file storage</strong>: Nostr could be used to create a decentralized and censorship-resistant alternative to file-sharing platforms like Dropbox and Google Drive.</li>
  <li><strong>Secure messaging and encrypted communication</strong>: Nostr could be used to create a decentralized and censorship-resistant alternative to secure messaging platforms like Signal and WhatsApp.</li>
  <li><strong>Identity management and self-sovereign identity</strong>: Nostr could be used to create a decentralized and censorship-resistant alternative to traditional identity management systems.</li>
  <li><strong>Decentralized applications (dApps)</strong>: Nostr could be used to build a wide variety of decentralized applications (dApps).</li>
</ul>

<p>A few examples of dApps built on top of Nostr:</p>

<ul>
  <li>Social Networking
    <ul>
      <li><a href="https://damus.io/">Damus</a>: A popular iOS Nostr client with a focus on privacy and security</li>
      <li><a href="https://primal.net/">Primal</a> - Lightning fast web client for Nostr</li>
      <li><a href="https://nostrchat.io/">NostrChat</a>: A simple and user-friendly Nostr chat client</li>
    </ul>
  </li>
  <li>File Sharing
    <ul>
      <li><a href="https://nostrfiles.dev/">Nostrfiles</a>: A decentralized file storage platform built on Nostr</li>
      <li><a href="https://github.com/cmdruid/nostr-storage">Nostr storage</a>: A decentralized cloud storage solution built on Nostr</li>
    </ul>
  </li>
  <li>Messaging
    <ul>
      <li><a href="https://blowater.deno.dev/">Blowlater</a>: A private messaging client built on Nostr</li>
      <li><a href="https://github.com/0xchat-app">0xChat</a>: A telegram-like Nostr client for iOS and Android</li>
    </ul>
  </li>
  <li>Other
    <ul>
      <li><a href="https://www.nostrnet.work/">NostrNet</a>: A decentralized event calendar built on Nostr</li>
      <li><a href="https://market.nostr.com/#/">Nostr Market</a>: Create your own decentralized market</li>
      <li><a href="https://gitlab.com/1440000bytes/joinstr">Joinstr</a>: Coinjoin implementation using Nostr</li>
      <li><a href="https://formstr.app/">Formstr</a>: A usable alternative to google forms</li>
      <li><a href="https://hostr.cc">Hostr</a>: Decentralized web hosting solution on Nostr</li>
      <li><a href="https://w3.do/">w3.do</a>: URL shortener</li>
      <li><a href="https://stemstr.app/">Stremr</a>: Sharing music</li>
    </ul>
  </li>
  <li>Made by me
    <ul>
      <li><a href="https://chesstr.pages.dev/">Chesstr</a>: A chessboard powered by Nostr</li>
      <li><a href="https://nostr-nip05-crawler.pages.dev/">NIP05 crawler</a>: Find all users on a nip05 provider</li>
      <li><a href="https://nostr-backup.pages.dev/">Nostr Backup</a>: Fetch and backup your events</li>
      <li><a href="https://nostr-restore.pages.dev/">Nostr Restore</a>: Restore your nostr backup</li>
      <li><a href="https://nostr-broadcast.pages.dev/">Nostr Broadcast</a>: Fetch and broadcast your events</li>
      <li><a href="https://nostr-markets.pages.dev/">Nostr Markets</a>: Find all Nostr markets</li>
    </ul>
  </li>
</ul>

<p>These are just a few examples of the many potential use cases for Nostr, you can read an exhaustive list on <a href="https://github.com/aljazceru/awesome-nostr">awesome-nostr</a></p>

<p>As the protocol matures and more creative minds get involved, we can expect to see even more innovative and groundbreaking ways to use Nostr in the future</p>]]></content><author><name></name></author><category term="articles" /><category term="nostr" /><summary type="html"><![CDATA[Nostr stands for “Notes and Other Stuff Transmitted by Relays”. It is a decentralized social network protocol that aims to create a censorship-resistant and user-empowered alternative to existing social media platforms.]]></summary></entry><entry><title type="html">Explaining SIGHASH</title><link href="https://joaobordalo.com/articles/2023/07/13/explaining_sighash.html" rel="alternate" type="text/html" title="Explaining SIGHASH" /><published>2023-07-13T11:27:38+00:00</published><updated>2023-07-13T11:27:38+00:00</updated><id>https://joaobordalo.com/articles/2023/07/13/explaining_sighash</id><content type="html" xml:base="https://joaobordalo.com/articles/2023/07/13/explaining_sighash.html"><![CDATA[<p>Sighash, short for Signature Hash, is a concept within the Bitcoin protocol that determines which parts of a transaction are signed. It plays a crucial role in ensuring the security and integrity of the Bitcoin network.</p>

<!--more-->

<p>By using different Sighash types, users have control over which parts of a transaction are mutable and which are immutable when they sign it. This flexibility allows for various use cases, such as creating conditional transactions or enabling partial signatures for multi-signature transactions.</p>

<p>Sighash types, such as SIGHASH_ALL, SIGHASH_NONE, SIGHASH_SINGLE, and others, define different signing schemes. These schemes specify which parts of a transaction are committed to, preventing tampering while still allowing different transaction formats.</p>

<p>Each signature has two flags appended at the end:</p>

<p>SIGHASH, which <strong>outputs</strong> were committed to this signature:</p>

<ul>
  <li>ALL (0x01) = all outputs</li>
  <li>NONE (0x02) = none output</li>
  <li>SINGLE (0x03) = only the output with same index as this input.</li>
</ul>

<p>ANYONECANPAY, which <strong>inputs</strong> were committed to this signature:</p>

<ul>
  <li>False (0x00) = all inputs</li>
  <li>True (0x80) = only this input</li>
</ul>

<p>Using both flags in conjunction we get 6 possibilities:</p>

<p><a href="/images/static/blog/sighash.jpeg">
  <img class="has-border" src="/images/static/blog/sighash.jpeg" aria-label="sighash diagram" />
</a></p>

<p><strong>SIGHASH_DEFAULT:</strong></p>

<p><a href="https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki">BIP-341</a> (Taproot) introduces a new flag, SIGHASH_DEFAULT (0x00), that works like SIGHASH_ALL but spares one byte on the signature (64 instead of 65 bytes).</p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="difficulty" /><category term="pow" /><summary type="html"><![CDATA[Sighash, short for Signature Hash, is a concept within the Bitcoin protocol that determines which parts of a transaction are signed. It plays a crucial role in ensuring the security and integrity of the Bitcoin network.]]></summary></entry><entry><title type="html">Maximum target hash</title><link href="https://joaobordalo.com/articles/2023/07/10/maximum-target-hash.html" rel="alternate" type="text/html" title="Maximum target hash" /><published>2023-07-10T11:27:38+00:00</published><updated>2023-07-10T11:27:38+00:00</updated><id>https://joaobordalo.com/articles/2023/07/10/maximum-target-hash</id><content type="html" xml:base="https://joaobordalo.com/articles/2023/07/10/maximum-target-hash.html"><![CDATA[<p>Do you know which Bitcoin constant is this?</p>

<p>26,959,535,291,011,309,493,156,476,344,723,991,336,010,898,738,574,164,086,137,773,096,960</p>

<p>Maybe in its hexadecimal format?</p>

<p>0x00000000FFFF0000000000000000000000000000000000000000000000000000</p>

<!--more-->

<p>Yes, it’s the maximum target hash.</p>

<p>But what thus it means, and why this “weird” value?</p>

<p>Bitcoin’s protocol wants blocks mined every 10 minutes (on average), but the number of miners doing it varies along the time. The protocol adjusts to this hash power variation by increasing or decreasing the difficulty to mine a block.</p>

<p>This adjustment is made every 2016 blocks (~2 weeks), by multiplying the current difficulty with the ratio of expected time / actual time it took to mine the previous 2016 blocks.</p>

<p>For example, if the last 2016 took 18144 minutes (instead of 20160), the ratio would be 1.1 and the new difficulty would be 1.1 times the previous difficulty:</p>

<p>new difficulty = difficulty * ( 20160 / 18144)</p>

<p>To reflect difficulty in the process of mining, a new value is calculated from the difficulty value (the target hash) and block headers must be equal or below this target hash. Since block headers are found by trial and error, the lower the target hash, the harder it is to find a valid block header.</p>

<p>The target hash is calculated and written to the block header:</p>

<p>target hash = maximum target hash / difficulty</p>

<p>So, we now reached the maximum target, a Bitcoin constant with the value of 0x00000000FFFF0000000000000000000000000000000000000000000000000000</p>

<p>Now, why 0x00000000FFFF00…00? Why not 0xFF…FF?</p>

<p>If you are Satoshi, and you are about to launch the genesis block, you have two things to consider:</p>

<ol>
  <li>
    <p>What will be the difficulty of block 0? Well, logic says it should be the easiest block of all, so it should have the minimum value possible, 1.</p>
  </li>
  <li>
    <p>How to make sure that my computer will take about 10 minutes to mine the next blocks? After all, you are pretty sure you will be alone doing this for a while.</p>
  </li>
</ol>

<p>If you put a maximum target of 0xFF..FF, and difficulty at 1, using the above formula, you’ll have a target hash of 0xFF..FF, which means that EVERY block will be a valid block, which means that your computer will generate thousands of blocks in a few seconds.</p>

<p>The difficulty adjustment would kick in every 2016 blocks, but since the difficulty adjustment it’s limited to a variation by a factor of 4 (4 &gt; ratio &gt; 0.25), it would take some time adjusting and we would end up with thousands of empty blocks.</p>

<p>To prevent this, you’ll need to calculate the hash power of your computer and then define the maximum target in order to have it mining blocks every 10 minutes on average.</p>

<p>And it seems 0x00000000FFFF00…00 was the number.</p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="difficulty" /><category term="pow" /><summary type="html"><![CDATA[Do you know which Bitcoin constant is this? 26,959,535,291,011,309,493,156,476,344,723,991,336,010,898,738,574,164,086,137,773,096,960 Maybe in its hexadecimal format? 0x00000000FFFF0000000000000000000000000000000000000000000000000000]]></summary></entry><entry><title type="html">Explain Bitcoin like I’m 10</title><link href="https://joaobordalo.com/articles/2020/03/02/explain-bitcoin-like-I-am-10.html" rel="alternate" type="text/html" title="Explain Bitcoin like I’m 10" /><published>2020-03-02T11:09:38+00:00</published><updated>2020-03-02T11:09:38+00:00</updated><id>https://joaobordalo.com/articles/2020/03/02/explain-bitcoin-like-I-am-10</id><content type="html" xml:base="https://joaobordalo.com/articles/2020/03/02/explain-bitcoin-like-I-am-10.html"><![CDATA[<p>
  <strong>How can I buy Bitcoin?</strong><br />
  Generate a password, and then pay someone to send bitcoins to that password.
</p>
<p>
  <strong>A password?! That's it?</strong><br />
  Yep, that's it.
</p>

<!--more-->
<p>
  <strong>What do you mean with "send to a password"?</strong><br />
  It means those bitcoins now belong to the owner of that password.
</p>
<p>
  <strong>What if someone finds my password?</strong><br />
  Then he will be able to spend your bitcoins.
</p>
<p>
  <strong>How hard will it be to try all possible passwords to check if they have bitcoins?</strong><br />
  Really hard, it would take hundreds of thousands of years to do it. There are a lot of different possible passwords available. If you choose your password at random - and don’t use your birthday - you're safe.
</p>
<p>
  <strong>How many different possible passwords are there?</strong><br />
  Almost 2^256, or in numbers you understand, 115,792,089,237,316,195,423,570,985,008,687,907,852,837,564,279,074,904,382,605,163,141,518,161,494,336. That's higher than the number of atoms in the perceived universe.
</p>
<p>
  <strong>But wait, you told me that to get some bitcoins, I had to pay someone for him to send his bitcoins to my password. So, he must know my password, right?</strong><br />
  No, absolutely not. Bitcoin uses mathematics to transform your password (also known as a private key) into a public key. These two keys are related, but totally different. It's really easy to get a public key from a private key. But it's impossible to guess a private key from his public key. So what you do is ask that guy to send his bitcoin to your public key, instead of your private key, thus keeping it secret.
</p>
<p>
  <strong>Send to the public key?! But if it's public, everyone will know about it! How are my bitcoins secured then?</strong><br />
  Because you asked that guy to send the bitcoins not to the public key itself, but to a script.
</p>
<p>
  <strong>A script? What is that?</strong><br />
  Imagine your public key as a word. One can say "These bitcoins now belong to these public key X". But with Bitcoin script, we can build sentences. So, instead, we can say "These bitcoins now belong to <strong>who proofs to own the private key where its public key is the same as this public key X</strong>". That sentence in bold is what we call the <i>unlocking script</i>.
</p>
<p>
  <strong>Sentences instead of words? That sounds interesting.</strong><br />
  Yes, it is. There are different sentences in use nowadays in Bitcoin, but I will explain this to you when you're 11. For the meantime, let's stay with the basics: a) you need a password, or as you now know, a pair of keys (public and private), b) you pay someone to send his bitcoins to your public key, and c) you don't need to show him the private key. Only the script and your public key are recorded, in what is called a <i>transaction</i>.
</p>
<p>
  <strong>So a transaction happens when some bitcoins change ownership?</strong><br />
  Exactly. A transaction has two parts: inputs and outputs. Input are all the bitcoins entering the transaction. These bitcoins will change ownership. Remember, the owner has to prove he owns these bitcoins, by satisfying the unlocking script. The output defines the new ownership of the bitcoins referenced in the input.
</p>
<p>
  <strong>We can have more than one input and more than one output? Why?</strong><br />
  Imagine you have 2 private keys, each "owning" 5 bitcoins. You want to buy something that costs 7 bitcoins. You create a transaction with those 2 private keys on the input, which gives you 10 bitcoins in total. On the output, you define that 7 will belong to the public key of the seller, and 3 to your public key again (it's your change).
</p>
<p>
  <strong>But now everyone can see that my bitcoins belong to this public key. Is that ok?</strong><br />
  If you use the same public key for every bitcoin you receive, people will know that they belong to the same person. So you should generate a new pair of keys for every bitcoin you receive. Even the public key for your change should be different.
</p>
<p>
  <strong>A new password for every bitcoin I receive? That's a nightmare!</strong><br />
  No it isn't, if you use a Bitcoin wallet to manage all your passwords.
</p>
<p>
  <strong>A wallet? What's that?</strong><br />
  You know what a browser is, right?
</p>
<p>
  <strong>Yeah, it allows me to access the World Wide Web.</strong><br />
  Exactly, and a Bitcoin wallet it's just like a browser, but to access the Bitcoin network.
</p>
<p>
  <strong>So, my bitcoins are stored in that wallet?</strong><br />
  Not your bitcoins, your passwords. Your bitcoins are registered on the network as belonging to your passwords, so you just need to take care of your passwords.
</p>
<p>
  <strong>So, if I lose my wallet, and so my passwords, I lose my bitcoins?</strong><br />
  Yeah. That's why it is so important to backup your passwords.
</p>
<p>
  <strong>But with a new password for every time someone sends me bitcoins, there are always new passwords being generated. How can I backup something that's always changing?</strong><br />
  Because in Bitcoin there's a concept of a super master password. If you backup that, you'll be able to access all your used (and future) passwords. This super master password is called a <i>seed phrase</i>.
</p>
<p>
  <strong>Future passwords? Really?</strong><br />
  That's the beauty of Elliptic Curve Cryptography. But I will explain that to you when you're 12.
</p>
<p>
  <strong>What if my wallet app disappears? Like if the company which made the app go bankrupt?</strong><br />
  You just install another wallet and add the seed phrase to it. The new wallet will then be able to know all your passwords, and will be able to scan the network and find your bitcoins there.
</p>
<p>
  <strong>But where do wallets see this? Where is that information recorded?</strong><br />
  In a database, or how we call it, a <i>ledger</i>.
</p>
<p>
  <strong>A database? What's that?</strong><br />
  It's a place where information is stored. You know that Google spreadsheet where I keep your school grades? The one I share with you and your mother? That's a database. Imagine that there's a Google spreadsheet where every transaction is recorded. Imagine that anyone in the world could read that Google spreadsheet. Anyone, with no restrictions. But no one could edit it.
</p>
<p>
  <strong>Yeah, like tweeting the public link of the spreadsheet.</strong><br />
  Exactly, everyone could read all the sheets from the spreadsheet and verify all transactions.
</p>
<p>
  <strong>Verify all transactions?</strong><br />
  Yeah, all transactions must be registered in this spreadsheet and can be validated. And you should validate all transactions, to be sure you don't have a fake spreadsheet. You want to be sure the transaction changing ownership of the bitcoins to you is there. Before sending the money. For this to work the spreadsheet must be non editable.
</p>
<p>
  <strong>That's ok, no one can edit the spreadsheet, they only have read access.</strong><br />
  Except of course, for the owner of the spreadsheet. The one who sent the link initially. He can do whatever he wants with it.
</p>
<p>
  <strong>The owner? I forgot about him. But, in that case, we have to trust him to be honest?</strong><br />
  No, we don't. Bitcoin solved the problem by not having an owner, and by distributing the ledger. There is not one, but more than 100.000 copies of the ledger distributed around the world. These copies run in computers we call <i>nodes</i>.
</p>
<p>
  <strong>So nodes maintain copies of the ledger around the world?</strong><br />
  Yes, and they validate transactions.
</p>
<p>
  <strong>How do they know they have the correct spreadsheet?</strong><br />
  Because all transactions are valid, and no one can change what's written there.
</p>
<p>
  <strong>No one can write to it? How come?</strong><br />
  I didn't say no one can write to it, I said no one can change what's written there. Pay attention please.
</p>
<p>
  <strong>Hu? What's the difference?</strong><br />
  Well, you cannot change what's written there, but you can add information there. Like with your school grades spreadsheet. Do you know how your school grade spreadsheet has several sheets?
</p>
<p>
  <strong>Yes, one for each school period.</strong><br />
  Exactly. After I enter your grades, I don't need to change them. They will not change. And in the next period, I just add a new sheet to the spreadsheet with the new grades. Without touching the previous sheets.
</p>
<p>
  <strong>So, you can never change anything, but you can always add information on top?</strong><br />
  Clever boy.
</p>
<p>
  <strong>Why is that important?</strong><br />
  Because after a transaction is stored in a new sheet, it cannot be changed. Imagine the guy you pay for your bitcoins afterwards changes the transaction to another public key. You no longer control/own those bitcoins, and you lost your money. It's of paramount importance the immutability of the spreadsheet.
</p>
<p>
  <strong>So, will my transaction appear in a new sheet in this spreadsheet?</strong><br />
  Yes, sooner or later.
</p>
<p>
  <strong>Sooner or later? How come?</strong><br />
  Well, someone needs to write the new sheet, right? But who? To solve this, Bitcoin runs a lottery every 10 minutes. Whoever wins it gains the right to add a new sheet to the spreadsheet. So, your transaction will only appear after this lottery finishes. And even then, it may not see it in the new sheet. If there are a lot of transactions waiting to be included in a sheet, you will have to wait.
</p>
<p>
  <strong>Why aren't all new transactions in the new sheet?</strong><br />
  Because sheets have a limit in size. If there are too many transactions to be included, a selection must be made. The winner of the lottery is free to choose which transactions he wants to include in the new sheet. You know, we should start calling these sheets <i>blocks</i>, that's their real names.
</p>
<p>
  <strong>Can't we bribe the lottery winner?</strong><br />
  Bribery? What do they teach you in school nowadays?
</p>
<p>
  <strong>...</strong><br />
  Actually, we can, and it's quite easy. When you define a transaction, you can define your output inferior to your input. This way, you are telling the lottery winner he can keep the difference. Of course, lottery winners will choose those transactions with a higher difference.
</p>
<p>
  <strong>How are new bitcoins generated?</strong><br />
  In this 10 minute lottery. The winner also gains some bitcoins as a prize, and this it's the only way new bitcoins are born.
</p>
<p>
  <strong>So, every 10 minutes some bitcoins are born?</strong><br />
  Yes. It’s called the <i>block subsidy</i>, and these new bitcoins belong to the lottery winner. When Bitcoin started, the block subsidy was 50 bitcoins. Every 210.000 blocks (more or less 4 years) this block subsidy is cut in half. Nowadays the block subsidy is 6.25 bitcoins, and in 2024 it will be cut to 3.125 bitcoins.
</p>
<p>
  <strong>So, how many bitcoins will ever be generated?</strong><br />
  Almost 21 millions.
</p>
<p>
  <strong>That’s it? 21 millions?</strong><br />
  Yes, 21 millions in round numbers, no more no less.
</p>
<p>
  <strong>And why 21 million?</strong><br />
  Nobody knows. Satoshi Nakamoto, the guy who invented this, decided it. It was easy to get any other number. If for instance he wanted to be 42 millions, all was needed was to start with a block subsidy of 100 bitcoins instead of 50. Or if he wanted it to be 16 millions, just halved the block subsidy every 160.000 blocks instead of 210.000. The truth is, nobody really knows.
</p>
<p>
  <strong>Can’t we ask him?</strong><br />
  Nopes. He disappeared shortly after announcing Bitcoin.
</p>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><category term="eli5" /><summary type="html"><![CDATA[How can I buy Bitcoin? Generate a password, and then pay someone to send bitcoins to that password. A password?! That's it? Yep, that's it.]]></summary></entry><entry><title type="html">Analysis of Bitcoin Cash double spends</title><link href="https://joaobordalo.com/articles/2018/08/23/analysis-of-bitcoin-cash-double-spends.html" rel="alternate" type="text/html" title="Analysis of Bitcoin Cash double spends" /><published>2018-08-23T10:42:53+00:00</published><updated>2018-08-23T10:42:53+00:00</updated><id>https://joaobordalo.com/articles/2018/08/23/analysis-of-bitcoin-cash-double-spends</id><content type="html" xml:base="https://joaobordalo.com/articles/2018/08/23/analysis-of-bitcoin-cash-double-spends.html"><![CDATA[<p>
  <strong>Bitcoin Cash double spends</strong>
</p>
<p>
  Double spend is when a set of coins is spent in more than one transaction.
  This can happen for various reasons, but one of the reasons is fraud attempts.
</p>
<p>
  Bitcoin Cash accepts 0-conf payments, which I consider insecure by default.
  But I would like to have some data to support this, so I went looking.
</p>

<!--more-->
<p>Since someone developed a website for detecting double spends on the Bitcoin Cash network,
I decided to scrape it and get some numbers from it. The site in question is:</p>

<p><a href="https://doublespend.cash/">https://doublespend.cash/</a></p>

<p><strong>Numbers</strong></p>

<ul>
  <li>Date of first transaction, 2018-02-13 11:34:44 +0000</li>
  <li>Date of last transaction, 2018-08-22 06:31:53 +0100</li>
  <li>Period, 189 days </li>
  <li>Number of attempts, 387</li>
  <li>Successful double spends, 109 (28%)</li>
</ul>

<p><strong>Files</strong></p>

<p>Feel free to clone the <a href="https://github.com/bordalix/scrape_doublespend_cash">GitHub repo</a> and use it at your own will.</p>

<ul>
  <li>
    <a href="https://github.com/bordalix/scrape_doublespend_cash/blob/master/scrape.rb">scrape.rb</a>,
    a ruby script, scrapes the website and writes to a json file
  </li>
  <li>
    <a href="https://github.com/bordalix/scrape_doublespend_cash/blob/master/output.json">output.json,</a>
    file with all transactions in JSON format
  </li>
  <li>
    <a href="https://github.com/bordalix/scrape_doublespend_cash/blob/master/stats.rb">stats.rb</a>,
    parses the output.json file and delivers some stats
  </li>
</ul>]]></content><author><name></name></author><category term="articles" /><category term="bitcoin" /><summary type="html"><![CDATA[Bitcoin Cash double spends Double spend is when a set of coins is spent in more than one transaction. This can happen for various reasons, but one of the reasons is fraud attempts. Bitcoin Cash accepts 0-conf payments, which I consider insecure by default. But I would like to have some data to support this, so I went looking.]]></summary></entry><entry><title type="html">Nintendo Switch, meet cardboard</title><link href="https://joaobordalo.com/articles/2018/01/19/nintendo_switch_meet_cardboard.html" rel="alternate" type="text/html" title="Nintendo Switch, meet cardboard" /><published>2018-01-19T10:55:04+00:00</published><updated>2018-01-19T10:55:04+00:00</updated><id>https://joaobordalo.com/articles/2018/01/19/nintendo_switch_meet_cardboard</id><content type="html" xml:base="https://joaobordalo.com/articles/2018/01/19/nintendo_switch_meet_cardboard.html"><![CDATA[<p>
  What a <a href="https://labo.nintendo.com/">clever idea</a>. The possibilites are endless. Well played Nintendo.
</p>
<div class="placeholder">
  <iframe title="Nintendo Switch, meet cardboard" width="480" height="300" data-src="https://www.youtube.com/embed/P3Bd3HUMkyU" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe>
<div>
</div></div>]]></content><author><name></name></author><category term="articles" /><category term="nintendo" /><category term="switch" /><summary type="html"><![CDATA[What a clever idea. The possibilites are endless. Well played Nintendo.]]></summary></entry></feed>