HackMD
  • Prime
    Prime  Full-text search on all paid plans
    Search anywhere and reach everything in a Workspace with Prime plan.
    Got it
    • Prime  Full-text search on all paid plans
      Prime  Full-text search on all paid plans
      Search anywhere and reach everything in a Workspace with Prime plan.
      Got it
      • Sharing Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • More (Comment, Invitee)
      • Publishing
        Everyone on the web can find and read all notes of this public team.
        After the note is published, everyone on the web can find and read this note.
        See all published notes on profile page.
      • Commenting Enable
        Disabled Forbidden Owners Signed-in users Everyone
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Invitee
      • No invitee
      • Options
      • Versions and GitHub Sync
      • Transfer ownership
      • Delete this note
      • Template
      • Insert from template
      • Export
      • Dropbox
      • Google Drive
      • Gist
      • Import
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
      • Download
      • Markdown
      • HTML
      • Raw HTML
    Menu Sharing Help
    Menu
    Options
    Versions and GitHub Sync Transfer ownership Delete this note
    Export
    Dropbox Google Drive Gist
    Import
    Dropbox Google Drive Gist Clipboard
    Download
    Markdown HTML Raw HTML
    Back
    Sharing
    Sharing Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    More (Comment, Invitee)
    Publishing
    Everyone on the web can find and read all notes of this public team.
    After the note is published, everyone on the web can find and read this note.
    See all published notes on profile page.
    More (Comment, Invitee)
    Commenting Enable
    Disabled Forbidden Owners Signed-in users Everyone
    Permission
    Owners
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Invitee
    No invitee
       owned this note    owned this note      
    Published Linked with GitHub
    Like BookmarkBookmarked
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: research --- # UTXOs Notes taken from Shinobi's interview with Peter McCormack from What Bitcoin Did (WBT) Ep 303... How does Bitcoin work at the technical level? - Consensus Rules - Mining & Nodes - Wallets & Transactions ## Why is Bitcoin important? - Predictable monetary supply - 21,000,000 / 42,000,000 / 100,000,000 ... doesn't matter how much, just important to have predictable and stubborn monetary supply to fight hyperinflation of fiat printing and expansion - Censorship resistance - Long term thinking, similar to how Founding Fathers thought - Long term consequences of decisions at base layer protocol - Long term consequences of centralised ownership - Anyone can become part of the network and broadcast TXs to the network ## What are UTXOs? > "...think of a UTXO as a programmable bank note, kind of like that blurring between a cash note and a bank account. Well, the interesting thing is there, you can add kind of locking conditions there. A UTXO isn't just handed to somebody; you have to unlock that. And, the most basic kind of lock is the signature that you make with a private key." ### Understanding how (most) people use bitcoin #### Use Case 1 - Most people use bitcoin with some sort of wallet application - I usually want to either send or receive bitcoin - When sending, I enter an amount and receiver address, and click "Send" - I don't look at anything to do with coins or UTXOs ### What is a UTXO and Why Should I Care? - A UTXO is what your actual bitcoin is - When you open a wallet and see a BTC "balance", that is a gross overgeneralisation of what is actually happening under the hood - In reality, there is no such thing as a balance. Your address is not like a "bank account" with $X in it... - It's actually a collection of individual UTXOs (coins), so when you see a balance, what your wallet is actually doing is looking at which UTXOs are owned by your wallet and then adding up the total sum of these coins - But it's important to recognise they are separate from each other and unique :::info **ANALOGY** Imagine a child's piggy bank. We know that there is a total sum of what is inside, let's say £10. But we also know that this $10 is made up of lots of different coins (1p, 2p, 5p, 10p, 20, 50, £1, etc). ::: Instead of having to break open the bank and count up all the coins to find your balance, with bitcoin your wallet does this for you by automatically scanning for UTXOs and presenting a sum total of these coins as your wallet "balance". ### Bank Accounts & Cash UTXOs are a strange mix of how cash and bank accounts work - If you go to a corner store and buy some eggs and milk, you might pay for this in cash... - How do you pay for this transaction? - Open your wallet - You see a bunch of descrete separate bills and coins that equate to some amount of money - You find some cash that *at least* equals the total amount you're buying (otherwise the clerk will reject your purchase) - You give an entire note (or coin) to the cashier, who then "breaks" this note and in return gives you your change from the transaction - You're not getting a piece of what you gave the cashier in return, you're actually getting an entirely different thing (coin) - What happens with a bank account? - Your bank account simply contains a number, or balance. There are no separate coins or notes, just one big total (the sources of these fractions differ, but once in the bank account become part of a bigger whole) - Imagine the same transaction but using a debit card - You swipe your card, the shop talks to your bank account and recognises how much money to subtract from your balance - There is no "change breaking" involved or exchange of unique separate things, it's simply a subtraction Try to think of a UTXO like a cash note that can equal any amount (i.e not limited to set numbers $5, $10, $20, $50, ...) So, let's say you walk into the store and you have your magic cash note that works like Bitcoin. Let's say there's $72.05 on it. Well, you're going to go hand that cash note to the guy at the counter and metaphorically, what's going to happen here is that cash note gets wiped clean. It's worth zero dollars now. That store clerk is going to take one cash note and make that worth whatever you're buying is and the cost of that, and he's going to make another cash note that is all the leftover money you're not spending, and hand that back to you. It's kind of like a blurring of cash and that bank account and how those things work into one thing. **Question**: Let's say I've got a $55 cash note and a $35 cash note and I need both of them, because I need to be over the total amount. I'm going to give you those two and then you're going to hand me back, because they add up to $90, the shoes are $75; you're going to give me one back for $15? **Answer**: But, the core point though is, instead of you just giving me those notes and I give you one back, I actually wipe those notes clean. They are worth zero dollars now; they are useless. And, I take two blank notes worth nothing and I make one of them worth $15 and give it back to you and I make another one worth $75 and I keep that. So, it's not just the change making like cash; I'm actually deleting the value on notes and then assigning the value to blank notes. ``` BTC TX looks like this: Inputs (UTXOs): 1. $55 2. $35 Outputs(UTXOs): 1. $75 2. $15 (change) ``` :::info **ANALOGY 2** Imagine gold coins instead. When making a transaction you take your gold coins (UTXOs) and throw them in the melting pot. The cashier then casts new gold coins worth whatever he needs to keep and gives the rest back to you. So with each bitcoin transaction, UTXOs are smelted down and remade. ::: **Question**: Can the cashier keep your gold and not give you a UTXO as change? **Answer**: No. Because the entire bitcoin transaction (handover, smelting and reforging, and then change returning) happens all at once. So the same confirmation signature used for confirming inputs also confirms outputs. There's no room for cheating. The only way you don't get change back is if the person you're paying never gets the money because that transaction didn't confirm. Then, you still have all your money. It's either the person gets paid and you get your change back; or, that person doesn't get paid. > "If you don't understand this is what's going on under the hood, can go wrong, can cost you money, can lead to you making decisions you don't understand the consequences of." #### How UTXOs, inputs and outputs affect fees > "Fees in Bitcoin have absolutely nothing to do with how much money you're moving. It's how many UTXOs you are using to input into a transaction and spend, and how many UTXOs that you're newly creating in that transaction. That could be $100 million worth; you could be playing with $10; but, the fee has nothing to do with that... It's just the number of inputs and the number of outputs." > "the reality is that a lot of the wallets out there that are kind of built and designed for the non-technical person, the newbies, they generally don't even show you what a UTXO is, or give you a way to control the UTXO, or pick which ones you're spending. They kind of just hide all of that for you and do it for you. > > none of those wallets have really any way to know you, Peter, don't want to spend these two UTXOs together because, let's say hypothetically, you pay bills with one and you buy weed off the dark net market with another. So, you don't want to tie those together." --- ## Considerations of UTXOs ### Fees As more UTXOs are added to a transaction as inputs, the data size of the transaction increases, causing the tx fee to also increase. `Fee = Size (bytes) x Fee Rate (sat/byte)` > "To go back to the hypothetical sat-stacker. He is just investing; he is planning on selling this all at a higher price; and he's bought $50 every week and withdrawn that and made a new UTXO. Well, let's say he did that for a year and he wants to sell everything now. Now he has 50 UTXOs that he has to put into a single transaction to send back to the exchange to sell it. Like we went over earlier, the fees have absolutely nothing to do with how much money he's moving; it's how many inputs there are; how many outputs. So, that person's fee is going to be way larger than if he only pulled it off every month and only had 12 UTXOs." :::info **ANALOGY** Fees increase with the complexity of a transaction. For example, using a $20 bill to pay for $X of groceries is less complex than using 100 different sized coins that have to be organised and counted, etc. This is similar to how data sizes of transactions increase as we use more UTXOs, the complexity of the transaction also increases. The cashier, or miner, has to put in more work by counting the separate bills and coins. ::: #### Does it make sense therefore to sometimes consolidate UTXOs, but be quite happy if it takes a week, two weeks to happen? > "Absolutely, but the thing you have to think about there is then the privacy, because you know, that really low fee and condensing UTXOs; that could wind up saving you money in the long term when fees go even higher, but you have to make sure you think here, "Do I care about tying these UTXOs together?" So, you kind of have to balance saving money versus maintaining your privacy." #### Legacy vs SegWit Addresses > "So, when you look at non-SegWit versus SegWit, there are differences in the fees that you pay for those signatures, because you have to remember inputs and outputs; that's the basic way to look at a transaction. But, those inputs also have to have the proof that you unlocked the transaction. So, you have to have that signature attached to that input. And because of that, inputs are actually bigger than the outputs in a transaction. With just the simple Legacy versus SegWit, there's actually a discount in the fee for the signature data with SegWit. So, just something as simple as using a SegWit address instead of a Legacy address, you're going to pay less in fees because you get that signature discount for the data size by using a SegWit signature instead of a normal one." ### Privacy Bitcoin is an openly verifiable payment ledger that allows people (via block-explorers) to see all sorts of transaction data, including addresses involved, UTXOs, inputs, outputs, change, and so on... > "...not only is that showing the entire world watching the blockchain what's going on with that transaction, you're showing the person you're sending money to all of that information as well; except in that case, it's a lot more likely they're actually going to know who you are." :::info You're walking down the street and have all your bitcoin in your phone's wallet, imagine it's one big UTXO. Some guy notices your bitcoin t-shirt and strikes up a convo. You tell him you'll give him $5 if he downloads an app and gives you his address. So you do it. But now when you send that transaction, because all your money is one big UTXO, say 50 BTC, he's going to see that amount in the transaction's inputs. And he suddenly thinks, "hey, this guy has $2.5M, I'm gonna follow him, see where he lives, and steal his money". So, from one transaction and also an act of kindness, you just gave away the fact that you're a millionaire to this random person on the street. ::: Furthermore, you can also trace UTXOs back in time until you reach their newly minted state (coinbase transaction). So I can also see the address that owned this UTXO before me, and its data including balance, etc. Whilst this information might be anonymous to someone looking at a random tx on the blockchain, each payment has context and is often made between two individuals that know at least some information about one another. Furthermore, custodial wallets know which addresses belong to which users, and so they have even more data... it goes on and on. But basically, it's really important to be aware of the fact that bitcoin is pseudononymous, because the data can be decrypted by payees, merchants, exchanges, or even the IRS or HMRC. >"this is kind of the sticky thing. Somebody might assume, just because they make that one hop, they're safe and that connection is broken right now, but that's not how this works." >"...you pay bills with one and you buy weed off the dark net market with another. So, you don't want to tie those together." >"I think if I was going to use this, what I would imagine is that I would want some kind of table that lists the UTXOs; when they were bought, because I'd obviously want to then know the price at which I bought them; and the value. And, I'd probably want to be able to arrange them in terms of date bought and the value, the size of each one." > "Privacy tools like CoinJoin, CoinSwap, even Lightning are very good tools, but you have to kind of start first by recognising what those tools are for, and that's managing the connections that get made between all the different UTXOs you have." > "...you kind of have to think about what you are buying with this UTXO and what are you going to buy in future with that same UTXO; and, do you want a record of a connection between those things to exist." When you make a Bitcoin transaction, not only is that showing the entire world watching the blockchain what's going on with that transaction, you're showing the person you're sending money to all of that information as well; except in that case, it's a lot more likely they're actually going to know who you are. #### Peeling Chains > "Well, if you spend Bitcoin a lot, that's going to create a big chain, and it will pretty much be that UTXO going into a transaction and then making a payment output, and the change output back to you. And then, that change output will go into another transaction and make a payment output, and another change output back to you. And, it will just kind of be a long chain of these transactions where there's always one output going back to you and another one peeling off and going to whoever you're paying. This is called a "peeling chain". ### UTXO Locks Every unspent transaction output (UTXO) has a lock on it. The simplest way to remove this lock (i.e spend your coins) is to attach your signature to the UTXO when building your transaction (inputs). > "there are a lot more complicated locks that you can put on a UTXO than just, give me a signature from one private key." ### Solutions for Privacy: #### CoinJoins Mixing your UTXOs with those of others and confusing historical tracking through multiple output options. #### Lightning Channels Base layer settling (transactions) happens when a channeled is opened/closed. The second layer transactions are done off chain and therefore it's hard to see how the settlements come to be... > "...in the long term, the only solution to this, I think, is just get payments for daily, regular things off chain; that needs to move to the Lightning Network. Because really, thinking about all of these things for every individual payment you make, it's not really tenable for most people." #### Labels Labelling your coins can held avoid UTXO mixing, and might mean your mom doesn't find out about your secret premium Pornhub account. ### Tax Implications When it comes to UTXOs, transactions, and trades, it's very important to understand the implications of coin selection, particularly with regards to capital gains tax. Capital gains is the financial gain (or loss) made between the time of buying an asset, and selling it. For example, if I buy a stock at $5 and then sell it at $50, I've made a capital gain of $45, which I can be taxed on (duristiction depending). #### How does this relate to UTXOs? Remember we talked about how a bitcoin wallet is a sum of all it's individual UTXOs? Well, if you sell bitcoin via an exchange, you are actuall selling a particular UTXO from your wallet. So each UTXO will have a completely different tax outcome. For example, I have wallet balance of 1 BTC, comprised of 3 UTXOs all purchased on different dates... 1. 0.5 BTC (1/1/20) 2. 0.25 BTC (2/2/20) 3. 0.25 BTC (3/3/20) Due to the fluctuation of Bitcoin's price, it's more than likely that these coins were purchased for different $ dollar amounts. So, if I sold the 0.25 BTC I purchased in January it will have a different capital gains tax value to the 0.25 BTC I bought in March. So, when we make larger trades, the date, time, and price of the coins we buy and sell can have wildly different outcomes in terms of taxation. A common example would be in the US. For example, if you earn less than ~$40,000/year, you do not have to pay capital gains tax on assets held for longer than one financial year. So, if I accumulate bitcoin as an investment over the course of a few years (including the current year), it's important when selling that I sell a UTXO which is older than one year (to avoid paying unnnecessary tax). If I select the most recent one (FIFO/LIFO), I might have to pay tax as I've owned it less than a year. So, that's how UTXOs can affect taxation. Simple enough? >"It's a lot of work coming in for the protection of privacy, and I'm not saying people shouldn't care about privacy; but for me, I've got a slight higher priority probably around right now, just thinking about taxes and if I ever do sell Bitcoin, I really want to know which ones I'm going to sell." --- ## Design Considerations #### On the issue of taxation >"I think if I was going to use this, what I would imagine is that I would want some kind of table that lists the UTXOs; when they were bought, because I'd obviously want to then know the price at which I bought them; and the value. And, I'd probably want to be able to arrange them in terms of date bought and the value, the size of each one." #### Labelling >"Electrum and Wasabi, I know for a fact, both have kind of a labelling system where you can kind of take notes of where this coin came from, where you're spending it. In Wasabi's case, they actually force you to use that; they will not let you kind of spend a coin or receive a coin without making a note of where did this come from; who knows about this UTXO?" #### Can you label "private" (weed, porn, bibles) and "not private"? > "Can you do that and group them together, or would you be better off consolidating them into different wallets or addresses?" #### Taxation vs Privacy >"It's a lot of work coming in for the protection of privacy, and I'm not saying people shouldn't care about privacy; but for me, I've got a slight higher priority probably around right now, just thinking about taxes and if I ever do sell Bitcoin, I really want to know which ones I'm going to sell." #### If you, say, lost your wallet and had to restore it from a private key, would you lose all your labels? Yes, if you didn't save the wallet file. The difference between, like, if you open up Electrum and just make an Electrum wallet and that's it, then yes, that wallet has your private keys and you need to keep that safe. But if you, say, made a wallet on a Coldcard and then imported that file off the Coldcard into Electrum, your private keys are not in that file. All it has is your addresses, so the worst that could happen is that somebody compromises that and then knows how many coins you have; which coins are yours. ---

    Import from clipboard

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lost their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template is not available.


    Upgrade

    All
    • All
    • Team
    No template found.

    Create custom template


    Upgrade

    Delete template

    Do you really want to delete this template?

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Tutorials

    Book Mode Tutorial

    Slide Mode Tutorial

    YAML Metadata

    Contacts

    Facebook

    Twitter

    Feedback

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions

    Versions and GitHub Sync

    Sign in to link this note to GitHub Learn more
    This note is not linked with GitHub Learn more
     
    Add badge Pull Push GitHub Link Settings
    Upgrade now

    Version named by    

    More Less
    • Edit
    • Delete

    Note content is identical to the latest version.
    Compare with
      Choose a version
      No search result
      Version not found

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub

        Please sign in to GitHub and install the HackMD app on your GitHub repo. Learn more

         Sign in to GitHub

        HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Available push count

        Upgrade

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Upgrade

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully