Placeholder Image

Subtitles section Play video

  • The following content is provided under a Creative

  • Commons license.

  • Your support will help MIT OpenCourseWare

  • continue to offer high-quality educational resources for free.

  • To make a donation or to view additional materials

  • from hundreds of MIT courses, visit MIT OpenCourseWare

  • at ocw.mit.edu.

  • TADGE DRYJA: OK, so today I will talk about mostly fees, which

  • is an interesting and somewhat contentious

  • issue in Bitcoin and all these other systems.

  • So schedule for today, problem set 3 description,

  • we'll talk about fees, these unknowable acronyms--

  • Child Pays for Parent, Replaced By Fee--

  • and then talk a little bit about long-term incentives

  • in Bitcoin, and how that relates to fees.

  • OK, so the problem set 3 is to grab UTXOs.

  • Hopefully it's fun.

  • You're going to be making transactions

  • on the real Bitcoin test network.

  • So one of the parts of it that hopefully is not too hard

  • is downloading and install Bitcoin D. So I'll put a link.

  • The current, most up-to-date version is 0.16.0.

  • I believe the next version will just

  • be called 17, because a lot of the developers are like,

  • this is annoying, it's always starting with a zero,

  • it's like 0.1, 0.2, 0.3.

  • And they're like, well, at some point,

  • should we get to version 1?

  • And they're like, well, everyone's

  • going to think version 1 means it's better.

  • Let's just call the next version 17 instead of 0.17.

  • So download that, and then sync up to testnet.

  • If you just run it by default, it

  • will sync up to the main network, which will download

  • something like 170 gigabytes.

  • You don't want that.

  • And the homework assignment cannot be completed on the main

  • network.

  • There's no free money--

  • I haven't put any free money on the main network.

  • However, on the test network, it'll work.

  • And it's about 11 gigabytes of download.

  • So I think most people, on your laptop,

  • probably have 11 gigs free.

  • It's doable.

  • And it's kind of fun to see how it works.

  • So if you don't have access to 11 gigs,

  • you can probably get an Athena node to do it.

  • It's not too big.

  • You can run a tiny little node with not much RAM, not

  • much space, and it'll work.

  • You can also sync up on a Raspberry Pi.

  • It just takes a little longer.

  • So I don't think it'll be too hard to do.

  • You can probably get around--

  • sort of the goal of the assignment

  • is to check out the actual Bitcoin D and Bitcoin CLI.

  • You can use a block explorer if you want.

  • I'm not going to say that's cheating,

  • but it's also not as fun.

  • So the block explorers websites will

  • help you find a lot of things, because they

  • have different databases and different indexes

  • so you can sort of search through things.

  • It's more fun if you write it yourself.

  • But if you try this,

  • OK, that works too.

  • Yeah, so hopefully you get familiar with the Bitcoin CLI.

  • If you want to do your own scripting with Bitcoin,

  • you can use anything you want.

  • So Bitcoin CLI is a command-line utility

  • that will let you interact with the Bitcoin node.

  • So for example-- is this readable?

  • Kind of, right?

  • So if I want to get peer info.

  • I want to see-- this is a computer down

  • on the first floor, running Bitcoin Mainnet,

  • I want to see, OK, who's connected to me?

  • And then it'll tell me.

  • It returns JSON, and it tells me all about the people

  • I'm connected to.

  • If I want to say, get wallet info, it'll tell me

  • I don't have any money--

  • things like that.

  • And then there's, like, Help.

  • It's weird and it's not super well documented.

  • It's fairly well documented in this stuff.

  • There's also tons of undocumented hidden RPC calls

  • that are deprecated, or new, or programmers put in

  • and they don't want people to use them.

  • They only want to use them for themselves.

  • So it's kind of a mess, but it's fun

  • to see exactly how this software works.

  • So hopefully you can try that out.

  • And I will add more UTXOs to grab in the next few days.

  • So that might be fun.

  • You could, if you wanted to be a jerk, just steal all the money,

  • and then no one else could do it.

  • But please don't do that.

  • I mean, this is not as adversarial a setting

  • as actual Bitcoin.

  • If someone does it, I'll be like, OK, fine,

  • and I'll just like reseed the place.

  • So hopefully we don't have too many trolls

  • trying to prevent everyone from having fun

  • with this assignment.

  • That said, there is at-- aspect some of them are--

  • the one I put in the assignment last night,

  • there's five outputs that you can grab.

  • One of the sort of hints-- there's only five outputs.

  • So the first five people to grab it get the coins.

  • So there is a little bit of timing stuff there.

  • Any questions?

  • Cool?

  • Yeah, so if you have questions about it,

  • office hours tomorrow, also IRC, stuff like that.

  • OK, so today's main topic--

  • transaction fees.

  • So we described earlier that the transaction fee is just

  • the difference between the sum of the input amounts and output

  • amounts.

  • What's interesting is it's implicit.

  • So if you actually look at a transaction,

  • you can't tell what the fees are.

  • You have to look at its ancestors

  • to tell what the fees are.

  • So for example, if you want to go through here and-- oh,

  • how am I going to do this?

  • Jeez.

  • If I want to say, OK, what's the most current block?

  • getblockchaininfo.

  • OK, so the most current block is this.

  • And then I can say, OK, getblock--

  • can I just say getblock?

  • Yeah, I want to get that block.

  • OK, there's all the transactions in this block.

  • I can do getblock verbose true, and it'll give me

  • all the transaction data.

  • But instead, I can just pick one of these transactions

  • and say getrawtransaction, get that thing.

  • Oh, here's another weird thing.

  • So it'll just give you hex, which

  • is not very useful, unless you somehow can read hexadecimal.

  • And then in the actual thing, it says, like, examples.

  • Wait, true?

  • Did they change it?

  • You used to have to do 1 at the end.

  • Yeah.

  • But true works too?

  • It used to not work if you said true,

  • and you had to put the number 1 instead of true.

  • There is a lot of weird bugs in Bitcoin

  • that have been there for years, and I

  • guess they fixed that one.

  • The most egregious is probably the multisig bug,

  • where when you're spending from a multisig output,

  • you have to push a zero-byte onto the stack first,

  • or else it doesn't work.

  • It was just a bug Satoshi had.

  • And now it's consensus critical.

  • And people joke about it, like, oh, we also

  • have to put a zero-byte in whatever new

  • RPC we create, because there's just, like, bugs.

  • Anyway, so for example, this transaction that I just brought

  • up, this is how it'll look.

  • Here's the TXID, it's 370 bytes, it's

  • got this lock time, which-- ooh, I should mention that.

  • I'm guessing this transaction was created by Bitcoin Core

  • Wallet, not a different wallet.

  • That's a hint.

  • It's got one input--

  • no, two inputs.

  • OK, so inputs are specified-- this TXID input,

  • this TXID input--

  • two inputs and one output of value, 0004500.

  • We can't tell what the fee is from this.

  • No, sorry, two outputs.