Comments (17)
I found the issue I had in my code:
I should have written:
buffer=Buffer.from(atob(Buffer.from(data, 'base64')), "hex")
instead of:
buffer=Buffer(atob(Buffer.from(data, 'base64')), "hex")
from node-webdollar.
Try to extract the first data from the Block raw bytes, then proceed to extract the 2nd data, and 3rd and so on. In case you can't extract the first data, then probably you don't have the block raw bytes or in the correct format.
from node-webdollar.
substr(buffer, 0, 32).toString("hex")
'3030303037653330313337313162633132366138373038613332343437326664'
The problem is that I cannot check if this is okay or not unless I ask someone who can actually confirm it.
from node-webdollar.
This is what I got from interrogating the this.blocks[0].serializeBlock().toString("hex")
00007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e330000e7240001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000004476c1d355b03205412204804e427f9a56de15f10f0c80fc530fecde9a48ae6aede861e9903e5422f7c111358032dfe6ca37aad8bdd5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000a1cfceb215aeac46c0b7eea0d5da9defd927e24504b757e6c3d3702853c9c9901000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4
from node-webdollar.
block[1] `
000125988a04e701c324eaa43798751e24422a8c65a3fc2fa78d5dd8d81d6cb600003c26000100007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e3300000472920ffd31f9752f90a0bd4c9fba25790b5340d7900b0438273a76b834b9f17856bd87b88551446a84650bdb7525ec27326e55ffd85df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c945600000000229cba7cd7926a980ddae11625db7a7a5e0f5a86267d44ab1689f140cd7a4b7303000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a400000200007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e33000000
from node-webdollar.
Perfect, it is the same thing if I do:
atob(Buffer.from(data, 'base64'))
Now, what is a valid hashPrev in hexa for the block[0] or the timestamp?
update: I saw the timestamp: is 1095
from node-webdollar.
The timestamp that I got following the code from:
is: deserializeNumber(substr(buffer, 0 + 32 + 4 +2+32, 4))
842281008
which is not the same.
This means that either I am doing something wrong (which I do not know), either the code from the repo is wrong.
from node-webdollar.
Your timestamp is for a date in the year of 1997.
I have uploaded you encoded block and decoded block. Try to obtain the values step by step, decoding hash, nonce, version, hashPrev and then the timestamp. Try to extract the current hash. Check the first image I have uploaded to see the data.
Be sure you have the same data as it was posted by me above.
from node-webdollar.
my timestamp is offseted by subtracting the Genesis timestamp. You can see the real value in the first screenshot i have uploaded. The timestamp of block[0] should be 1095
from node-webdollar.
Moreover, 1095 is the 0x447. So you can see that I have spotted 0x447 in my hex data
00007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e330000e7240001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000004476c1d355b03205412204804e427f9a56de15f10f0c80fc530fecde9a48ae6aede861e9903e5422f7c111358032dfe6ca37aad8bdd5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000a1cfceb215aeac46c0b7eea0d5da9defd927e24504b757e6c3d3702853c9c9901000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4
in my opinion, you are doing something wrong
from node-webdollar.
I told you already the encoded/decoded blocks are okay, I want to know how you extract the timestamp 1095 from that, as the code from the repo does not extract correctly.
from node-webdollar.
Basically, what is the math behind choosing for the timestamp an offset? And what are the steps using the primitives from the repo like substring or deserializeNumber and get you to the value: 1095?
from node-webdollar.
it is simple. I use byte operations.
...60e76423a4000004476c1d355b032...
I extract the bytes, you should get a buffer of 00 00 04 47, then I convert this buffer of 4 bytes into a Number and you will get the 1095 lucky number. Regarding your question, why I have substracted Genesis timestamp as an offset, with the only purpose that all timestamps must be higher than Genesis Timestamp by this way, I am partially solving the Javascript https://en.wikipedia.org/wiki/Year_2038_problem
from node-webdollar.
The genesis timestamp was set as an appropriate number to the Unix timestamp when I was preparing the new hard fork for main net.
from node-webdollar.
The question is from where do I know the offset? this is not documented and what is the math behind finding it?
from node-webdollar.
I am asking a simple thing, a piece of code that gets you from this "00007..a4" string to the timestamp.
from node-webdollar.
deserializeBlock(buffer,, offset){
if (!Buffer.isBuffer(buffer))
if (typeof buffer === "string")
buffer = new Buffer(buffer, "hex");
if (offset === undefined) offset = 0;
if ( (buffer.length - offset) > consts.SETTINGS.PARAMS.MAX_SIZE.BLOCKS_MAX_SIZE_BYTES )
throw {message: "Block Size is bigger than the MAX_SIZE.BLOCKS_MAX_SIZE_BYTES", bufferLength: buffer.length };
try {
this.hash = BufferExtended.substr(buffer, offset, consts.BLOCKCHAIN.BLOCKS_POW_LENGTH);
offset += consts.BLOCKCHAIN.BLOCKS_POW_LENGTH;
this.nonce = Serialization.deserializeNumber( BufferExtended.substr(buffer, offset, consts.BLOCKCHAIN.BLOCKS_NONCE) );
offset += consts.BLOCKCHAIN.BLOCKS_NONCE;
this.version = Serialization.deserializeNumber( BufferExtended.substr(buffer, offset, 2) );
offset += 2;
this.hashPrev = BufferExtended.substr(buffer, offset, consts.BLOCKCHAIN.BLOCKS_POW_LENGTH);
offset += consts.BLOCKCHAIN.BLOCKS_POW_LENGTH;
this.timeStamp = Serialization.deserializeNumber( BufferExtended.substr(buffer, offset, 4) );
offset += 4;
extracted from the code. If you call this function with the buffer 00007e3013711bc126a8708a324472fdfcf6855cef1f979b0df43475c9568e330000e7240001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4000004476c1d355b03205412204804e427f9a56de15f10f0c80fc530fecde9a48ae6aede861e9903e5422f7c111358032dfe6ca37aad8bdd5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456000000000a1cfceb215aeac46c0b7eea0d5da9defd927e24504b757e6c3d3702853c9c9901000001731d46c131eb6dd4667a96bdc27baf9223bec72c3468dfb6ba52c460e76423a4 you will get the timestamp.
from node-webdollar.
Related Issues (20)
- Cannot read property 'length' of undefined at MiniBlockchainTransactionFrom.calculateInputSum HOT 2
- findPendingIdenticalTransaction is not a function HOT 2
- Transactions are invalidated by TransactionsPendingQueue._removeOldTransactions shortly after they were created. HOT 2
- Impossible to create transaction with multiple inputs (from)
- block was incorrectly mined
- tx mining
- Wrong POS hash calculation HOT 2
- Bug 0
- How to create a mining pool? HOT 3
- Duplicate resolver information in the block structure
- Average block time is not 40s as advertised in the whitepaper HOT 1
- 2 time per day my pool is in fork. please solve the problem HOT 1
- Nonce is not right 2 HOT 2
- mine WebDollar in a Linux terminal. rgon2-bench2 process was lost after a few hours. pow is 0H/s HOT 8
- Transaction can't contain messages
- Auto export new created wallet and at first time visit
- Error on worker restart
- Could we have a guide to install terminal miner on mac os BigSur? HOT 1
- argon2-browser Unexpected Character in wasm HOT 2
- Creating a new mining pool uses an inactive domain HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-webdollar.