Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
110CodingP committed Jun 4, 2024
1 parent 641c5b6 commit 1273be3
Show file tree
Hide file tree
Showing 6 changed files with 8,141 additions and 8,137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"locktime": 0,
"vin": [
{
"txid": "a7ed2af034a3904fffeb9ea98f0fed90c683c323e066e6c8e3d0494bbbb5b18c",
"txid": "",
"vout": 0,
"prevout": {
"scriptpubkey": "76a91459769a1a9528da6cfd3893b9392290f1f600e67188ac",
Expand Down
Binary file modified mine
Binary file not shown.
14 changes: 9 additions & 5 deletions mine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ void from_json(const json& j, Output& p) {
j.at("scriptpubkey_address").get_to(p.scriptPubKeyAddress);
}
j.at("value").get_to(p.amount);
p.amount*=100000000;
}

void from_json(const json& j, Input& p) {
Expand Down Expand Up @@ -100,14 +101,14 @@ std::string serialise(Txn t) {
//inputs
int in_sz = t.vin.size();
int exp = compact_exp(in_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<in_sz;
ss<<std::setfill('0')<<std::setw(2*exp)<<std::hex<<in_sz;
serialised+=ss.str();
ss.str("");



for (int i=0;i<in_sz;i++) {
serialised+=t.vin[i].txId;
serialised+=big_to_little(t.vin[i].txId,64);
ss<<std::setfill('0')<<std::setw(8)<<std::hex<<t.vin[i].vOut;
serialised+= big_to_little(ss.str(),8);
ss.str("");
Expand All @@ -117,7 +118,7 @@ std::string serialise(Txn t) {
else {
int script_sz =(t.vin[i].scriptSig).size();
exp = compact_exp(script_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<script_sz;
ss<<std::setfill('0')<<std::setw(2*exp)<<std::hex<<script_sz;
serialised+=ss.str();
ss.str("");

Expand All @@ -131,14 +132,17 @@ std::string serialise(Txn t) {
//outputs
int out_sz = t.vout.size();
exp = compact_exp(out_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<out_sz;
ss<<std::setfill('0')<<std::setw(2*exp)<<std::hex<<out_sz;
serialised+=ss.str();
ss.str("");

for (int i=0;i<out_sz;i++) {
ss<<std::setfill('0')<<std::setw(8)<<std::hex<<t.vout[i].amount;
serialised += big_to_little(ss.str(),8);
ss.str("");
int script_pub_sz =(t.vout[i].scriptPubKey).size();
exp = compact_exp(script_pub_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<script_pub_sz;
ss<<std::setfill('0')<<std::setw(2*exp)<<std::hex<<script_pub_sz;
serialised+=ss.str();
ss.str("");

Expand Down
16,262 changes: 8,131 additions & 8,131 deletions output.txt

Large diffs are not rendered by default.

Binary file added reverse_string
Binary file not shown.
Binary file added trying_openssl_sha256
Binary file not shown.

0 comments on commit 1273be3

Please sign in to comment.