Skip to content

Commit

Permalink
parse transactions with no witness and scriptpubkey_address fields
Browse files Browse the repository at this point in the history
  • Loading branch information
110CodingP committed Apr 27, 2024
1 parent 43123be commit 687633e
Show file tree
Hide file tree
Showing 4 changed files with 8,113 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Doc.md → Solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ Fourth, we need to find the nonce which passes difficulty and hence the hash
We need to output the coinbase txn also


// since cpp doesn't have a function for iterating over files in a directory had to make "txns.txt".
// since cpp doesn't have a function for iterating over files in a directory had to make "txns.txt".

//not all have witness
//not all have scriptpubkey_address
Binary file modified mine
Binary file not shown.
8 changes: 6 additions & 2 deletions mine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ void from_json(const json& j, Output& p) {
j.at("scriptpubkey").get_to(p.scriptPubKey);
j.at("scriptpubkey_asm").get_to(p.scriptPubKeyAsm);
j.at("scriptpubkey_type").get_to(p.scriptPubKeyType);
j.at("scriptpubkey_address").get_to(p.scriptPubKeyAddress);
if (j.contains("scriptpubkey_address")) {
j.at("scriptpubkey_address").get_to(p.scriptPubKeyAddress);
}
j.at("value").get_to(p.amount);
}

Expand All @@ -47,7 +49,9 @@ void from_json(const json& j, Input& p) {
j.at("prevout").get_to(p.prevout);
j.at("scriptsig").get_to(p.scriptSig);
j.at("scriptsig_asm").get_to(p.scriptSigAsm);
j.at("witness").get_to(p.witness);
if (j.contains("witness")) {
j.at("witness").get_to(p.witness);
}
j.at("is_coinbase").get_to(p.isCoinbase);
j.at("sequence").get_to(p.sequence);
}
Expand Down
Loading

0 comments on commit 687633e

Please sign in to comment.