Transcript for #bitcoin-dev 2017/05/19

11:40 karelb reposting question from #bitcoin - how exactly is fee/byte calculated for segwit transactions with respect to mining and which transaction will miner take into block
11:40 karelb if miner is running bitcoin-core
11:40 karelb I am writing a wallet software and I am not sure if fee is calculated from the whole tx, or only the "non-segwit" parts
11:49 conman effectively the block contribution size
11:51 instagibbs karelb, so for fee estimation you won't be relaying segwit tx if you're not a segwit node
11:51 instagibbs thus you wont be estimating them
11:52 instagibbs so you'll just be estimating non-segwit tx feerate
12:07 karelb instagibbs: but I will be segwit node?
12:08 karelb Also in source I see ModifiedSize and TransactionWeight (in primitives/transaction.cpp) and I am not sure what those are for
12:10 karelb it seems it gets used in txmempool for something :)
12:11 conman weight replaces size
12:12 conman when determining fee ratio; i.e. it will be fee/weight instead of fee/size
12:13 karelb oh, that seems important for fee estimation :D
12:16 karelb So the result of RPC calls estimatefee will return fee/weight, ok
12:16 karelb oh I see it in here
12:17 karelb "Uses virtual transaction size of transaction as defined in BIP 141 (witness data is discounted)."
12:17 conman traditional transactions are basically 4x size = weight
12:19 karelb oh. ok. ooooh BIP 141 defines all that
12:21 karelb hm. ok. I am maintaining right now bitcore/insight with segwit (since bitpay abandoned it), and I *think* it displays the size, and the fees, wrong (on segwit txs)
12:22 karelb I *think* it displays the total size on the segwit txs and counts fee/kb from that
12:35 instagibbs karelb, that's likely unless you replaced the equiv of GetTransactionSize
12:38 karelb nope, I didn't touch that since I didn't realize that
12:39 karelb Is there a way to get tx weight by RPC?
12:40 karelb Or at least by some online tool :D
12:41 karelb decoderawtransaction shows size
12:41 karelb oooh it shows vsize also
12:41 karelb great
12:55 instagibbs vsize is slightly different from weight, but you should be able to get weight as well
12:58 instagibbs "size" should be exactly what you need from that rpc call for a segwit-aware node
15:05 garit In bitcoin channel web of trust is used on a website.is there any similar service that i could use online? (To make my small web of trust with friends)
16:18 JuanDaugherty http://bitcoinstats.com/irc/bitcoin-dev/logs/2017/05 appears broken, or does it lag by some days?
16:22 cdecker JuanDaugherty, sometimes my logging bot is unable to auth and hence can't join
16:22 cdecker I try to fix it once I notice it
16:24 JuanDaugherty ah, #sidechains-dev seem to have similar issues but i think may be just low activity there. In any case it's central to context flow in publicly logged channels that people can see what they're entering
16:30 cdecker I'm not logging that
19:30 Iriez Can miners construct an O(n2) malicous block without it being valid? And would changing " if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)" require a HF? Curious if limiting transaction size at all is an effective solution to the problem?
20:34 Chris_Stewart_5 arubi: Let's move it over here since you are in this channel
20:34 arubi sure, better
20:34 Chris_Stewart_5 So I am calling funrawtransaction with a presigned input and the tx has two outputs *before* calling fundrawtx
20:35 arubi alright
20:35 Chris_Stewart_5 I want to use fundrawtransaction to add a input for a fee
20:35 Chris_Stewart_5 as the presigned input and two outputs are *exact* values -- i.e. there is no fee yet.
20:35 arubi okay, but the presigned one will becme invalid right
20:35 arubi s/become
20:35 Chris_Stewart_5 Well I was looking at the sighash types to try and figure out what to use -- i'm trying to use SIGHASH_SINGLE right now but I don't think that is right
20:35 Chris_Stewart_5 since I have two outputs
20:36 arubi it's possible, but not very safe
20:36 arubi anyone could replace the second output
20:36 arubi you'd want to sign the presigned input as ANYONECANPAY
20:37 Chris_Stewart_5 That doesn't protect *any* of the outputs though does it?
20:37 arubi it protects all outputs
20:37 arubi you wouldn't be able to add outputs at all
20:37 Chris_Stewart_5 well, isn't that problem because I would need to add a change output more than likely for a fee?
20:37 arubi it just asserts a single input, and allows to add more wil no outputs
20:38 Chris_Stewart_5 unless I just happen to have a good utxo for change
20:38 arubi right, then there's no simple way to do that without segwit
20:38 arubi well, maybe there is one way
20:39 arubi you could sign the presigned one as anyonecanpay|single with it being in index 1, and index 0 being blank
20:39 arubi then add the second input later at index 0
20:40 arubi that would assert that there should be another input (whichever), and that there should be at least one output that the anyonecanpay|single input pays for
20:40 arubi you'd have to make that single output at index 1 LESS than the input itself
20:40 arubi so it's not worth stealing it
20:41 arubi so output 3 pays to the recipient, output 2 pays a change from input 1 and input 0 pays fee and change to output 0
20:42 arubi off the top of my head, that should work :) output 3 will only be signed by input 0
20:43 Chris_Stewart_5 Does there have to be a predetermined fee in output index 0 though?
20:43 arubi nope
20:43 Chris_Stewart_5 or pre determined change for a fee in output index 0?
20:43 Chris_Stewart_5 also, doesn't that scheme with ANYONECANPAY|SINGLE not protect output at idnex 3?
20:44 arubi yes, but it doesn't have to as input 0 does
20:44 arubi input 0 can sign ALL
20:44 arubi and unless anyone wants to pay for you, input 1 and output 1 as a paid is useless :)
20:44 arubi a pair*
20:45 Chris_Stewart_5 ah, so I protect the change I am paying to myself with SIGHASHANYONECANPAY|SINGLE -- and the receipients output is protected by the SIGHASH_ALL
20:45 arubi right
20:47 Chris_Stewart_5 Ok, I think i follow and can't think of a way this would steal from some one off of the top of my head. How does segwit make that whole interaction easier?
20:48 arubi with segwit, anyonecanpay|single does not commit to an index in a transacation
20:48 arubi so the pair in itself can be presigned, stored, combined with other pairs, then signed finally with some ALL that pays for fees
20:49 Chris_Stewart_5 how is that different that NONE|ANYONECANPAY
20:49 Chris_Stewart_5 Oh, so it doesn't commit to an output, just not the index of that output
20:49 Chris_Stewart_5 it does* commit to an output
20:49 arubi it commits to input index and no outputs
20:50 Chris_Stewart_5 wait, so the pair you are talking about is (input,indexIndex)? Not (input,output)?
20:50 arubi no the pair is input,output
20:50 arubi in non segwit, any input also commits to its index
20:51 arubi in some way, even anyonecanpay because even though the input is the only one signed, the index is still committed to
20:51 arubi so you have to have "at least" that many inputs
20:53 Chris_Stewart_5 Now if only segwit would activate... :P. Just to be clear, you think the 'fundrawtx' call I was making was because i used SIGHASH_SINGLE instead of SIGHASH_SINGLE|ANYONECANPAY?
20:54 Chris_Stewart_5 since the input was presigned
20:54 arubi soon, if you run bip148 :) , I'm not sure, the error seems weird but from looking at traces this is the only thing I can think of
20:55 abpa August 1 is still a ways off
20:55 arubi and adding an input will invalidate the signature
20:55 Chris_Stewart_5 Yeah, i was looking at this issue from dooglus https://github.com/bitcoin/bitcoin/issues/7879
20:55 arubi it is, hopefully more will be running the client by then.
20:56 arubi ah interesting
20:56 Chris_Stewart_5 but I think we might have different problems -- although I am using a watchonly address too
20:58 arubi if you have anything exotic to sign, it's usually better to use `bitcoin-tx`, but you don't get wallet access with that and need to use raw keys
20:58 arubi (and prevtxs)
21:02 Chris_Stewart_5 Yeah I'm trying to use core for the boring things like adding change outputs/inputs. I'm gonna give implement your SIGHASH scheme latter. Thanks for the help
21:04 arubi cheers
21:07 Chris_Stewart_5 instagibbs: Not all outputs have to be solvable to call 'fundrawtx' right? I think arubi and I concluded that it was probably breaking because I was using the wrong SIGHASH scheme
21:12 Chris_Stewart_5 asssuming that input for that output is presigned