Skip to content

Commit

Permalink
complete serialisation by serialising output
Browse files Browse the repository at this point in the history
  • Loading branch information
110CodingP committed Apr 28, 2024
1 parent e0ee64c commit a67cee8
Show file tree
Hide file tree
Showing 4 changed files with 8,150 additions and 8,133 deletions.
Binary file modified mine
Binary file not shown.
19 changes: 18 additions & 1 deletion mine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ std::string serialise(Txn t) {
serialised+= big_to_little(ss.str(),8);
ss.str("");

//input
//inputs
int in_sz = t.vin.size();
int exp = compact_exp(in_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<in_sz;
Expand Down Expand Up @@ -126,6 +126,23 @@ std::string serialise(Txn t) {
ss.str("");
}

//outputs
int out_sz = t.vout.size();
exp = compact_exp(out_sz);
ss<<std::setfill('0')<<std::setw(2*exp)<<out_sz;
serialised+=ss.str();
ss.str("");

for (int i=0;i<out_sz;i++) {
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;
serialised+=ss.str();
ss.str("");

serialised += t.vout[i].scriptPubKey ;
}

return serialised;
}

Expand Down
Loading

0 comments on commit a67cee8

Please sign in to comment.