Hey there!
Is it possible to grab all the signatures from the blockchain and pull out the R values? I'm looking for a way to do this.
I found some files here: https://gz.blockchair.com/bitcoin/inputs/
I tried doing it with Python, but it's pretty slow.
Anyone got a code snippet in C for this?
Appreciate any help!
If you're looking for double r-values, forget about it!
You are definitely not the first to search the blockchain for it.
I wrote a blockchain explorer that you can use to search for anything in the blockchain. But it's not finished yet and needs a lot of memory and RAM.
There are billions of signatures on the bitcoin blockchain, why do you need to export "all" of them?
Things aren't "very slow" because of the programming language, they are usually slow because of bad code or simply slow process.
As for other code, there are general blockchain parsers but there is no point in extracting signatures alone so there isn't any "good" code for it.
Thank you
I will not be looking at repeating R values. I will use it in some tests and at the same time I am trying to learn and develop the parse operation in the blockchain.
Thank you for the explanation pooya87.
I had such an idea after reviewing the video here.
https://www.youtube.com/watch?v=C6zrPMnyWSw
Download the whole blockchain (bitcoin-core).
Use https://github.com/gcarq/rusty-blockparser to parse blockchain. As you are developer you will manage to export only sigscript from each transaction input. (hint: change file https://github.com/gcarq/rusty-blockparser/blob/master/src/callbacks/csvdump.rs)
Then you may write your program to extract R from each sigscript.
That's a pretty bad example.
First of all that is not the correct way of benchmarking a code, as you can see the repeated execution of the same command reports different times (totals) that have a spread with a difference as big as 68% to my calculation.
The correct way would be a warm-up, then execution of the same method (aka a function) in a loop with an accurate timer attached that measures the time it takes to run that chunk of code then reports the mean with deviance discarding any value that is way off the mark. This also eliminates the time it takes for the first execution of the program.
I don't know much about python but I can write a C# program that takes a longer time to open for the first time (eg. self-contained without ReadyToRun) but then runs just as fast C.
Secondly the speed of an application as a whole depends on the quality of the code and the amount of optimization that has gone into it. A bad C application runs just as slowly as A bad python application. It comes down to how familiar that developer is with the language and how correctly they can benchmark it and how effectively they can improve their code. For example there are certain cases where the following runs faster:
Finally C is faster than most other languages in certain cases and only if you have squeezed every ounce of performance from codes written in each language.
Take a look at these two posts, different people write the same code in different languages some even rewrite the same code in python and get faster results than the starter:
https://codegolf.stackexchange.com/questions/26323/how-slow-is-python-really-or-how-fast-is-your-language
https://codegolf.stackexchange.com/questions/26371/how-slow-is-python-really-part-ii
Bear in mind that any program that extracts R values will need to use different procedures for segwit and non-segwit transactions, because segwit transactions have the signatures in the witness data while normal transactions (including "wrapped" segwit transactions) have them in the scriptSig.
C# is actually much faster than Python because the files are compiled down to byte code that .NET runtime understands. Same with Java and other languages with a runtime. Python has an not well documented feature where it can compile the python files down into its own bytecode separately, and you can get similar performance as C# from that since the burden of parsing statements is removed.
C is just compiling all its statements down to assembly code for x86 processors which is just a tiny bit faster than C# for all code that isn't doing some scientific for math work because nearly all programs for the most part spend most of their time making system calls or altering data structures for which native assembly code cannot optimize (there are SSE registers, AVX registers, the L1 and L2 cache but they are all too small to store complex data structures and are useless for shortening the overhead programs transition between user land and OS land).
And of course all performance advantages of C (and C++ which for speed purposes is just C with classes) are lost the moment you use a big general-purpose library inside your program.
There are bitcoin-related programs written in C and the reason they are so fast is because they use their own hand-written functions, and this works because they know their application requirements so they only write the functionality that will actually be used, unlike a general-purpose library (such as Boost) which cannot make this assumption.
If it helps, I made [~500 GB work in progress] Bitcoin block data: inputs, outputs and transactions:
It's not complete yet, and unfortunately I only now noticed my download got stuck 7 days ago. Currently, I have 220-ish GB of data from "inputs" available at much better download speed than Blockchair.com itself offers.
Hi
My question went like this
I understand asserts in python. but I didn't understand the first '48' part.
my aim is to separate the "signature" and separate it as in the link below, of course together with the PubKey
Can you give me information about conditions (assert) that will help me?
Thanks.
information that helps me
https://bitcoin.stackexchange.com/questions/58853/how-do-you-figure-out-the-r-and-s-out-of-a-signature-using-python
type :
pubkeyhash
spending_signature_hex :
483045022100cbee7b355c737bccdaaaf566b52e07c6e560fa33861b3035d37feffad94f66e6022 053114a529ab13eba906f9e08288bcf02dd5142ae0ecb117f10d54f56868443af014104d720973d f5c090aa1dd17adefd9f575baa2f0547dd2913fb4982bf423f1cf82623b700e0d1b7f2b7b5dcfa9 301f8c197dd0b601204d00e02b544251c5d9ac45a
information I want to parse
r = 00cbee7b355c737bccdaaaf566b52e07c6e560fa33861b3035d37feffad94f66e6
s = 53114a529ab13eba906f9e08288bcf02dd5142ae0ecb117f10d54f56868443af
PubKey= 04d720973df5c090aa1dd17adefd9f575baa2f0547dd2913fb4982bf423f1cf82623b700e0d1b7f 2b7b5dcfa9301f8c197dd0b601204d00e02b544251c5d9ac45a
Good day
What files from this:
blockdata.loyce.club/inputs/ (159 GB - currently incomplete, growing 8 GB per day)
blockdata.loyce.club/outputs/ (117 GB)
blockdata.loyce.club/transactions/ (43 GB)
contain r,s,z transaction data ?
Thank you
Thank you