Transcript for #bitcoin-dev 2017/02/10

01:02 bsm117532 Another regtest monkey wrench...I need a segwit only wallet. But at block 0 on regtest segwit isn't enabled. Is there a way to get it enabled from block zero?
07:03 jimpo Can someone explain what the fClient flag means?
08:16 waxwing bsm117532: what's wrong with just mining N blocks (where N is a number i can't remember)
08:17 waxwing oh i guess maybe it's the mining part you're interested in?
13:39 RxMcDonald Anyone knows how to convert uint256S to int and back?
13:39 RxMcDonald I got this value 0x000000000000000000000000000000000000000000000005c13f99f6d0b1a908 and I want to make it a zero or 1 or just w/e I want ?
13:46 RxMcDonald well, nvm i guess it's not a big deal for now
14:51 RxMcDonald Anyone here?
14:51 RxMcDonald TZander: You there? 👋
14:54 RxMcDonald I don't understand why It can't find then LogPrintf in chainparams.cpp after adding #include "util.h" ... ?
15:33 RxMcDonald anyone here?
15:35 Chris_Stewart_5 RxMcDonald: will the uint256 fit inside of an 'int'?
15:38 RxMcDonald Chris_Stewart_5: I'm not sure, but i kind of have a different problem now
15:40 RxMcDonald it's still kind of the same problem though
15:41 RxMcDonald want to print some debug info and it's throwing expression ('std::ostream' (aka 'basic_ostream<char>') and 'const uint256') Chris_Stewart_5
15:42 RxMcDonald invalid operands to binary expression, so I guess i need to convert that to something for ostream or pass the right string placeholder, i.e. %s ?
15:42 Chris_Stewart_5 call .ToString() on uint256?
15:43 Chris_Stewart_5
15:43 RxMcDonald member reference base type uint32_t aka unsigned int is not a structure or union
15:44 RxMcDonald I guess I fixed it with %u instead of %s
15:45 RxMcDonald now I broke something, it says symbols not found for architecture x86_64, linker command failed
15:45 RxMcDonald so, i don't think I fixed anyhting, nice
15:46 RxMcDonald gonna build again from sracth and see if that fixes it
15:53 RxMcDonald Chris_Stewart_5: so, now I'm getting undefined symbols for x86_64 every time I try to compile it, fml
15:54 RxMcDonald do you know how to find the exact place and reason for this? xD
16:00 Chris_Stewart_5 I'm sure honestly, can you paste the line of code in here? Or in pastebin or something?
16:00 Chris_Stewart_5 I'm *not* sure*
16:02 RxMcDonald Chris_Stewart_5: I created a new issue on SO
16:02 RxMcDonald The problem could be related to trying to print a uint256 value I guess ?
16:04 Chris_Stewart_5 I would put that piece of code in your question as it is relevant
16:05 RxMcDonald I made too many changes already I'm, not sure where the error could be anymore fml
16:08 RxMcDonald I think i'm going to checkout the whole file, chainparams.cpp and see if that fixes it
16:09 RxMcDonald lmao still getting the same error
16:13 RxMcDonald 3k compile errors and growing, nice
16:14 RxMcDonald yep, same problem
16:16 RxMcDonald I think it could be related to qt ?
16:16 RxMcDonald gonna try building from the cli
16:19 RxMcDonald trying with the latest git commit before adding all these changes
16:27 Abstrct Hi all, I'm looking for some help understanding the decoded read-out of a segwit transaction. Specifically (xtn) afa25ec695f2a3ee662da65e3d8379f87ff6aacb4517c212a7d7b21c063a274b
16:28 Abstrct I'm hoping to trace it back to the previous input but I'm getting a tad lost in the data presentated and the docs
16:29 Chris_Stewart_5 RxMcDonald: I'm not familiar with qt at all unfortunately :-(
16:29 Abstrct previous output*
16:29 RxMcDonald Chris_Stewart_5: no it's not qt problem I think
16:29 Chris_Stewart_5 Abstrct: You should be able to paste it a block explorer and retrieve that tx
16:30 arubi Abstrct, there is no previous output. it's the generation tx
16:30 RxMcDonald I'm re compiling the version from the last git commit I made so if that works I fucked up somewhere along the way
16:30 Abstrct for the vin, I see it has "coinbase": "03d3971000fe8d039358fe20230a000963676d696e6572343208000000000000000000", "txinwitness": [ "0000000000000000000000000000000000000000000000000000000000000000" ], "sequence": 4294967295
16:30 arubi right, that's the coinbase
16:30 Abstrct from the core decoderawtransaction rpc call
16:32 RxMcDonald yea it looks like it's working
16:32 Abstrct so this one links back to block reward that went to a segwit addy?
16:33 arubi the block reward is sent to a normal p2pkh address
16:34 arubi Abstrct,
16:35 Abstrct ya, I've read that a number of times but it's just not clicking for me :/
16:35 arubi where are you stuck?
16:37 Abstrct I'm not quite sure where the disconnect is for me. I like to think I understand what segwit is doing at a high level but I'm looking at that VIN and the BIP and I just don't see how it works.
16:38 arubi again I ask, what specifically doesn't work for you? :) I mean, what do you expect to happen, and what happens instead?
16:38 Abstrct My goal is to identify the previous output that this vin spends
16:39 Abstrct but I'm not seeing the relatinoship between the two
16:39 arubi there is not previous output
16:39 arubi this is the transaction that pays the block reward. there's only coinbase where the input will usually be
16:39 waxwing it's a secret scam in bitcoin, don't tell anyone :)
16:40 arubi hehe yea, if you run enough miners, you can actually create bitcoins from thin air!
16:40 Abstrct ok, so this is the block reward. great
16:40 molz_ Abstrct, which block is this?
16:41 arubi 1087443 on testnet
16:41 Abstrct 000000000a39c29f2a52b92bdd3492ebe692e6b719b993f82f0792ba6329b337
16:41 molz_ oh
16:41 molz_ i kept looking on mainnet lol
16:41 molz_ thanks arubi
16:41 Abstrct heh no, xtn
16:41 arubi I wish we had segwit on mainnet :)
16:41 Abstrct not until I understand it pls D:
16:42 arubi :)
16:42 molz_ well arubi there's still a lot of misunderstanding on segwit out there... blew my mind
16:43 arubi yea tell me about it, it gets repeated so much that to some folks it looks like genuine information
16:43 Abstrct so why in this case would the txwitness = "0000000000000000000000000000000000000000000000000000000000000000"
16:43 Abstrct what is this representing?
16:44 arubi the witness reserved value
16:45 molz_ hm .. block 1087443 didn't mind segwit version though
16:45 molz_ mine*
16:45 arubi I guess you mean the bip9 version? it's because it's already activated on testnet
16:46 molz_ or blocktrail is wrong
16:47 arubi ftw
16:47 Abstrct does anybdoy have an example of a tx with a segwit output being spent?
16:47 Abstrct I mean, i could generate one.. but if you happen to have one handy
16:48 molz_ i have plenty
16:49 molz_
16:51 Abstrct ok, this makes a lot more sense
16:51 Abstrct thnx
16:52 molz_ decoderawtransaction for that tx:
16:53 Abstrct This is what I always expected to see, basically no changes aside from some additioinal crap
16:53 arubi \o/ soft fork
16:54 Abstrct I think it was actually that second vout in the transaction I posted that was my actual bug, and appears unrelated to segwit
16:55 arubi you mean the one in op_return? that's where the commitment for segwit data is
16:57 Abstrct ok, that makes sense too
16:57 Abstrct but I can also not care about it in what I'm working on (famous last words..)
17:03 Abstrct Thanks for all your help
17:06 arubi cheers
18:27 jimpo Can someone explain what the fClient flag means?
18:30 arubi jimpo, it would help if you provide context
18:32 jimpo I've been poking around parts of Bitcoin core and found this flag
18:32 jimpo It looks like some sort of light, reduced verification mode
18:32 jimpo that's been around since v0.1
18:33 jimpo I still feel like I don't have the full picture on this flag and was hoping someone could shed some light
18:34 arubi yea I see, looks like 'fClient = false; // set by version message' in net.cpp so maybe worth to look at "version message"
18:34 arubi really haven't messed with p2p stuff at all
19:15 molz_ arubi, how did he get this from that block: <Abstrct> so why in this case would the txwitness = "0000000000000000000000000000000000000000000000000000000000000000"
19:28 arubi it's called the witness reserved value, it's the witness for the coinbase "input|output", it says "0x20 0x0000000000000000000000000000000000000000000000000000000000000000" which is just a push operation that pushes 0x0000...
19:28 arubi it's in the witness part of the transaction
19:30 arubi (the generation transaction of that block)
22:49 RxMcDonald Is the genesis block hard-coded somewhere in the chainparams.cpp?
22:51 RxMcDonald trying to start a new blockchain
22:55 achow101 RxMcDonald: yes
22:56 RxMcDonald achow101: oh nice, so just changing that value will start a new blockchain? where is it exactly?
22:56 achow101
22:56 achow101 it actually builds the block and hashes it, then checks the hash, so you will need to change the assert
22:57 achow101 and the line after will need to be changed if you change the genesis block in CreateGenesisBlock
22:58 RxMcDonald so, what do I do if I want to start a new blockchain?
22:58 RxMcDonald just change the assert?
22:59 RxMcDonald or the genesis = ?
22:59 RxMcDonald change this ? genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
23:00 achow101 you have to change the assert to match whatever block you create.
23:00 RxMcDonald Yeah, I got that, but how do I make it create a new genesis block?
23:01 achow101 to change the block, you can change this:
23:01 achow101 anything in this function:
23:01 achow101 and anything in this function:
23:01 RxMcDonald so, just changing anything in there will automatically generate a new genesis block?
23:01 achow101 you'll probably want to change pszTimestamp and the output script
23:02 achow101 it will create a block according to the parameters, which you have to change in order to get a different block
23:03 achow101 then you need to get the hash of the block. easiest way is to just log the genesis hash to the debug.log file and then replace the hash in the assert with the hash of the block. you will need to do the same with the merkle root
23:04 RxMcDonald yes that's what I was trying to do earlier but my code didn't compile, can you show me how would you log it exactly?
23:05 RxMcDonald LogPrintf("new mainnet genesis hash: %s\n", genesis.GetHash().ToString()); // like this?
23:05 RxMcDonald just adding that?
23:06 achow101 that should work
23:06 achow101 you will need to do the same for genesis.hashMerkleRoot
23:08 RxMcDonald do I need to change this? consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000005c13f99f6d0b1a908");
23:09 achow101 yes. with a new blockchain you will need to remove that, consensus.assumeDefaultValid, and all of the checkpoints (just leave the list empty but the variable still there
23:14 RxMcDonald alright, just changing that it compiled
23:17 RxMcDonald Error: Incorrect or no genesis block found. Wrong datadir for network?
23:18 achow101 you need a blank datadir otherwise it will fail
23:20 RxMcDonald MBP:faratest mb$ ./src/faragecoind │2017-02-10 23:19:18 *** Failed to read block
23:20 RxMcDonald Error: Error: A fatal internal error occurred, see debug.log for details
23:20 RxMcDonald ERROR: ReadBlockFromDisk: Errors in block header at CBlockDiskPos(nFile=0, nPos=8)
23:22 RxMcDonald achow101: care to take a look?
23:22 achow101 this is altcoin stuff now, it is off topic for this channel. If you are trying to be an altcoin dev, then you should be able to figure it out and debug it yourself. That includes knowing how to just grep for things in code and follow logic. I will not help you anymore
23:22 RxMcDonald I called it like that it's my test dir for bitcoin
23:23 RxMcDonald i have several folders with different copies, just trying to start a new blockchain
23:25 achow101 I'm not going to hand-hold you through making an altcoin. just use grep or Github's search function and find out what line the error is being thrown at and just look to see what is causing that. the names are all fairly self explanatory and there are comments
23:26 RxMcDonald I'm not trying to make an altcoin, I'm trying to test and understand the whole bitcoin codebase and get into bitcoin development
23:27 achow101 in what way do you think that making a new genesis block is going to help you?
23:27 RxMcDonald The process for learning it includes creating a local coin? yes It's not going to be uploaded or used or anything, it's for testing
23:27 achow101 if you want a local coin just for testing, use regtest
23:27 RxMcDonald I want to have several different coins with different params and test stuff
23:28 RxMcDonald I need the whole coin for testing
23:28 RxMcDonald that is the only way to learn it imho, it's how I learn anything, just reproducing and playing with it
23:28 achow101 even so, if you are trying to get into any sort of software development, you should be able to read code, follow code paths, and search for errors that are being printed to logs or the console
23:28 achow101 (learn these things before actually doing)
23:28 RxMcDonald Yeah, alright, didn't meant to bother you
23:29 RxMcDonald just, pretty hard to get into this codebase
23:29 achow101 the issue here is that when you read this codebase, most things are named explicitly and are self explanatory. it should not take someone to explain to you that the function named CreateGenesisBlock is what makes the genesis block
23:30 RxMcDonald No, I already know that
23:32 achow101 anyways, your problem is the PoW of your genesis block is bad. if you just search part of the error in github, you will find that the first code result is and that you can infer the issue is because CheckProofOfWork returned false thus causing the error to be thrown
23:36 RxMcDonald yeah
23:40 RxMcDonald changed consensus.fPowAllowMinDifficultyBlocks = true; hope it fixes it
23:57 RxMcDonald achow101: well, it didn't fix it