If I include some extra data at the end of a tx (i.e. after nLockTime), raw transaction api will just ignore them, instead of reporting an error. Why?
raw transaction api ignores bogus data at the end of a tx, instead of reporting an error #8202
issue jl2012 opened this issue on June 14, 2016-
jl2012 commented at 3:54 PM on June 14, 2016: contributor
-
dcousens commented at 12:11 AM on June 15, 2016: contributor
Probably because the parser treats the data range as a stream, aka, something to consume, rather than as a fixed size of useful data. Therefore, as it finishes "consuming" a transaction from the stream, it stops parsing. Leaving your junk data behind.
This can be seen here.
This could be changed by simply enforcing that the number of bytes read is equal to the length of the hex string / 2.
- jonasschnelli added the label Feature on Jun 15, 2016
- jonasschnelli added the label Easy to implement on Jun 15, 2016
-
jonasschnelli commented at 11:57 AM on June 15, 2016: contributor
I think it would be useful to reject or at least warn if there is data left in the stream after parsing the entire transaction.
-
laanwj commented at 9:39 AM on June 16, 2016: member
This definitely needs to be an error.
-
drbsci commented at 1:01 AM on July 10, 2016: none
I have written some code to address this issue. How would I test it? Presume I should test before sending a pull request. Complete noob on bitcoin, as you must have guessed.
-
drbsci commented at 1:25 AM on July 10, 2016: none
Ok. Will do in a day or two.
-
drbsci commented at 11:54 PM on July 11, 2016: none
Found something strange here. Ran make on the whole repository, terminating normally, but when I ran gcc or g++ on the original core_read.cpp, got a fatal error because primitives/block.h had at line 9: #include "primitives/transaction.h" "No such file" presumably because relative to src/ folder, that means include a file named primitives/primitives/transaction.h. Is the src/core_read.cpp file even being used during make?
-
Tyler-Hardin commented at 3:55 AM on July 17, 2016: contributor
@drbsci maybe I misunderstood your problem, but normally you never have to run g++ yourself. When make is done, it has all the files it needed, including your modified file.
-
TheBlueMatt commented at 9:37 PM on August 16, 2016: member
IIRC this is a hidden feature that allows you to inclue multiple transactions in a signrawtransaction call and it will merge the signatures from each. It is undocumented but useful, so maybe we should actually replace it with something not broken :).
- fanquake closed this on Mar 6, 2018
- MarcoFalke locked this on Sep 8, 2021