1 2017-05-19 11:40:00 <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
  2 2017-05-19 11:40:07 <karelb> if miner is running bitcoin-core
  3 2017-05-19 11:40:36 <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
  4 2017-05-19 11:49:52 <conman> effectively the block contribution size
  5 2017-05-19 11:51:52 <instagibbs> karelb, so for fee estimation you won't be relaying segwit tx if you're not a segwit node
  6 2017-05-19 11:51:57 <instagibbs> thus you wont be estimating them
  7 2017-05-19 11:52:08 <instagibbs> so you'll just be estimating non-segwit tx feerate
  8 2017-05-19 12:07:22 <karelb> instagibbs: but I will be segwit node?
  9 2017-05-19 12:08:03 <karelb> Also in source I see ModifiedSize and TransactionWeight (in primitives/transaction.cpp) and I am not sure what those are for
 10 2017-05-19 12:10:51 <karelb> it seems it gets used in txmempool for something :)
 11 2017-05-19 12:11:26 <conman> weight replaces size
 12 2017-05-19 12:12:27 <conman> when determining fee ratio; i.e. it will be fee/weight instead of fee/size
 13 2017-05-19 12:13:19 <karelb> oh, that seems important for fee estimation :D
 14 2017-05-19 12:16:38 <karelb> So the result of RPC calls estimatefee will return fee/weight, ok
 15 2017-05-19 12:16:55 <karelb> oh I see it in here
 16 2017-05-19 12:17:01 <karelb> "Uses virtual transaction size of transaction as defined in BIP 141 (witness data is discounted)."
 17 2017-05-19 12:17:10 <conman> traditional transactions are basically 4x size = weight
 18 2017-05-19 12:19:34 <karelb> oh. ok. ooooh BIP 141 defines all that
 19 2017-05-19 12:21:45 <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)
 20 2017-05-19 12:22:10 <karelb> I *think* it displays the total size on the segwit txs and counts fee/kb from that
 21 2017-05-19 12:35:52 <instagibbs> karelb, that's likely unless you replaced the equiv of GetTransactionSize
 22 2017-05-19 12:38:37 <karelb> nope, I didn't touch that since I didn't realize that
 23 2017-05-19 12:39:55 <karelb> Is there a way to get tx weight by RPC?
 24 2017-05-19 12:40:01 <karelb> Or at least by some online tool :D
 25 2017-05-19 12:41:01 <karelb> decoderawtransaction shows size
 26 2017-05-19 12:41:15 <karelb> oooh it shows vsize also
 27 2017-05-19 12:41:17 <karelb> great
 28 2017-05-19 12:55:08 <instagibbs> vsize is slightly different from weight, but you should be able to get weight as well
 29 2017-05-19 12:58:07 <instagibbs> "size" should be exactly what you need from that rpc call for a segwit-aware node
 30 2017-05-19 15:05:19 <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)
 31 2017-05-19 16:18:25 <JuanDaugherty> http://bitcoinstats.com/irc/bitcoin-dev/logs/2017/05 appears broken, or does it lag by some days?
 32 2017-05-19 16:22:42 <cdecker> JuanDaugherty, sometimes my logging bot is unable to auth and hence can't join
 33 2017-05-19 16:22:50 <cdecker> I try to fix it once I notice it
 34 2017-05-19 16:24:51 <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
 35 2017-05-19 16:30:08 <cdecker> I'm not logging that
 36 2017-05-19 19:30:08 <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?
 37 2017-05-19 20:34:16 <Chris_Stewart_5> arubi: Let's move it over here since you are in this channel
 38 2017-05-19 20:34:48 <arubi> sure, better
 39 2017-05-19 20:34:52 <Chris_Stewart_5> So I am calling funrawtransaction with a presigned input and the tx has two outputs *before* calling fundrawtx
 40 2017-05-19 20:35:03 <arubi> alright
 41 2017-05-19 20:35:07 <Chris_Stewart_5> I want to use fundrawtransaction to add a input for a fee
 42 2017-05-19 20:35:25 <Chris_Stewart_5> as the presigned input and two outputs are *exact* values -- i.e. there is no fee yet.
 43 2017-05-19 20:35:30 <arubi> okay, but the presigned one will becme invalid right
 44 2017-05-19 20:35:38 <arubi> s/become
 45 2017-05-19 20:35:52 <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
 46 2017-05-19 20:35:55 <Chris_Stewart_5> since I have two outputs
 47 2017-05-19 20:36:07 <arubi> it's possible, but not very safe
 48 2017-05-19 20:36:33 <arubi> anyone could replace the second output
 49 2017-05-19 20:36:55 <arubi> you'd want to sign the presigned input as ANYONECANPAY
 50 2017-05-19 20:37:21 <Chris_Stewart_5> That doesn't protect *any* of the outputs though does it?
 51 2017-05-19 20:37:30 <arubi> it protects all outputs
 52 2017-05-19 20:37:37 <arubi> you wouldn't be able to add outputs at all
 53 2017-05-19 20:37:56 <Chris_Stewart_5> well, isn't that problem because I would need to add a change output more than likely for a fee?
 54 2017-05-19 20:37:59 <arubi> it just asserts a single input, and allows to add more wil no outputs
 55 2017-05-19 20:38:08 <Chris_Stewart_5> unless I just happen to have a good utxo for change
 56 2017-05-19 20:38:11 <arubi> right, then there's no simple way to do that without segwit
 57 2017-05-19 20:38:41 <arubi> well, maybe there is one way
 58 2017-05-19 20:39:21 <arubi> you could sign the presigned one as anyonecanpay|single with it being in index 1, and index 0 being blank
 59 2017-05-19 20:39:33 <arubi> then add the second input later at index 0
 60 2017-05-19 20:40:14 <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
 61 2017-05-19 20:40:32 <arubi> you'd have to make that single output at index 1 LESS than the input itself
 62 2017-05-19 20:40:44 <arubi> so it's not worth stealing it
 63 2017-05-19 20:41:40 <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
 64 2017-05-19 20:42:27 <arubi> off the top of my head, that should work :)  output 3 will only be signed by input 0
 65 2017-05-19 20:43:21 <Chris_Stewart_5> Does there have to be a predetermined fee in output index 0 though?
 66 2017-05-19 20:43:35 <arubi> nope
 67 2017-05-19 20:43:36 <Chris_Stewart_5> or pre determined change for a fee in output index 0?
 68 2017-05-19 20:43:54 <Chris_Stewart_5> also, doesn't that scheme with ANYONECANPAY|SINGLE not protect output at idnex 3?
 69 2017-05-19 20:44:09 <arubi> yes, but it doesn't have to as input 0 does
 70 2017-05-19 20:44:18 <arubi> input 0 can sign ALL
 71 2017-05-19 20:44:38 <arubi> and unless anyone wants to pay for you, input 1 and output 1 as a paid is useless :)
 72 2017-05-19 20:44:53 <arubi> a pair*
 73 2017-05-19 20:45:35 <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
 74 2017-05-19 20:45:50 <arubi> right
 75 2017-05-19 20:47:44 <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?
 76 2017-05-19 20:48:05 <arubi> with segwit, anyonecanpay|single does not commit to an index in a transacation
 77 2017-05-19 20:48:43 <arubi> so the pair in itself can be presigned, stored, combined with other pairs, then signed finally with some ALL that pays for fees
 78 2017-05-19 20:49:00 <Chris_Stewart_5> how is that different that NONE|ANYONECANPAY
 79 2017-05-19 20:49:08 <Chris_Stewart_5> Oh, so it doesn't commit to an output, just not the index of that output
 80 2017-05-19 20:49:17 <Chris_Stewart_5> it does* commit to an output
 81 2017-05-19 20:49:34 <arubi> it commits to input index and no outputs
 82 2017-05-19 20:50:13 <Chris_Stewart_5> wait, so the pair you are talking about is (input,indexIndex)? Not (input,output)?
 83 2017-05-19 20:50:35 <arubi> no the pair is input,output
 84 2017-05-19 20:50:58 <arubi> in non segwit, any input also commits to its index
 85 2017-05-19 20:51:37 <arubi> in some way, even anyonecanpay because even though the input is the only one signed, the index is still committed to
 86 2017-05-19 20:51:50 <arubi> so you have to have "at least" that many inputs
 87 2017-05-19 20:53:39 <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?
 88 2017-05-19 20:54:46 <Chris_Stewart_5> since the input was presigned
 89 2017-05-19 20:54:57 <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
 90 2017-05-19 20:55:14 <abpa> August 1 is still a ways off
 91 2017-05-19 20:55:17 <arubi> and adding an input will invalidate the signature
 92 2017-05-19 20:55:35 <Chris_Stewart_5> Yeah, i was looking at this issue from dooglus https://github.com/bitcoin/bitcoin/issues/7879
 93 2017-05-19 20:55:38 <arubi> it is, hopefully more will be running the client by then.
 94 2017-05-19 20:56:03 <arubi> ah interesting
 95 2017-05-19 20:56:10 <Chris_Stewart_5> but I think we might have different problems -- although I am using a watchonly address too
 96 2017-05-19 20:58:39 <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
 97 2017-05-19 20:58:47 <arubi> (and prevtxs)
 98 2017-05-19 21:02:04 <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
 99 2017-05-19 21:04:43 <arubi> cheers
100 2017-05-19 21:07:25 <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
101 2017-05-19 21:12:48 <Chris_Stewart_5> asssuming that input for that output is presigned