@@ -59,6 +59,16 @@ namespace cryptonote
5959 crypto::public_key key;
6060 };
6161
62+ #pragma pack(push, 1)
63+ struct bb_txout_to_key
64+ {
65+ bb_txout_to_key () { }
66+ bb_txout_to_key (const crypto::public_key &_key) : key(_key) { }
67+ crypto::public_key key;
68+ uint8_t mix_attr;
69+ };
70+ #pragma pack(pop)
71+
6272
6373 /* inputs */
6474
@@ -116,6 +126,7 @@ namespace cryptonote
116126 typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_to_key> txin_v;
117127
118128 typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key> txout_target_v;
129+ typedef boost::variant<txout_to_script, txout_to_scripthash, bb_txout_to_key> bb_txout_target_v;
119130
120131 // typedef std::pair<uint64_t, txout> out_t;
121132 struct tx_out
@@ -127,8 +138,16 @@ namespace cryptonote
127138 VARINT_FIELD (amount)
128139 FIELD (target)
129140 END_SERIALIZE ()
141+ };
142+ struct bb_tx_out
143+ {
144+ uint64_t amount;
145+ bb_txout_target_v target;
130146
131-
147+ BEGIN_SERIALIZE_OBJECT ()
148+ VARINT_FIELD (amount)
149+ FIELD (target)
150+ END_SERIALIZE ()
132151 };
133152
134153 class transaction_prefix
@@ -204,6 +223,49 @@ namespace cryptonote
204223 static size_t get_signature_size (const txin_v& tx_in);
205224 };
206225
226+ class bb_transaction_prefix
227+ {
228+
229+ public:
230+ // tx information
231+ size_t version;
232+ uint64_t unlock_time; // number of block (or time), used as a limitation like: spend this tx not early then block/time
233+
234+ std::vector<txin_v> vin;
235+ std::vector<bb_tx_out> vout;
236+ // extra
237+ std::vector<uint8_t > extra;
238+
239+ BEGIN_SERIALIZE ()
240+ VARINT_FIELD (version)
241+ VARINT_FIELD (unlock_time)
242+ FIELD (vin)
243+ FIELD (vout)
244+ FIELD (extra)
245+ END_SERIALIZE ()
246+
247+
248+ protected:
249+ bb_transaction_prefix (){}
250+ };
251+
252+ class bb_transaction : public bb_transaction_prefix
253+ {
254+ public:
255+ std::vector<std::vector<crypto::signature> > signatures; // count signatures always the same as inputs count
256+
257+ bb_transaction ();
258+ virtual ~bb_transaction ();
259+ void set_null ();
260+
261+ BEGIN_SERIALIZE_OBJECT ()
262+ FIELDS (*static_cast <bb_transaction_prefix *>(this ))
263+ FIELD (signatures)
264+ END_SERIALIZE ()
265+
266+ static size_t get_signature_size (const txin_v& tx_in);
267+ };
268+
207269
208270 inline
209271 transaction::transaction ()
@@ -242,6 +304,43 @@ namespace cryptonote
242304 return boost::apply_visitor (txin_signature_size_visitor (), tx_in);
243305 }
244306
307+ inline
308+ bb_transaction::bb_transaction ()
309+ {
310+ set_null ();
311+ }
312+
313+ inline
314+ bb_transaction::~bb_transaction ()
315+ {
316+ // set_null();
317+ }
318+
319+ inline
320+ void bb_transaction::set_null ()
321+ {
322+ version = 0 ;
323+ unlock_time = 0 ;
324+ vin.clear ();
325+ vout.clear ();
326+ extra.clear ();
327+ signatures.clear ();
328+ }
329+
330+ inline
331+ size_t bb_transaction::get_signature_size (const txin_v& tx_in)
332+ {
333+ struct txin_signature_size_visitor : public boost ::static_visitor<size_t >
334+ {
335+ size_t operator ()(const txin_gen& txin) const {return 0 ;}
336+ size_t operator ()(const txin_to_script& txin) const {return 0 ;}
337+ size_t operator ()(const txin_to_scripthash& txin) const {return 0 ;}
338+ size_t operator ()(const txin_to_key& txin) const {return txin.key_offsets .size ();}
339+ };
340+
341+ return boost::apply_visitor (txin_signature_size_visitor (), tx_in);
342+ }
343+
245344
246345
247346 /* ***********************************************************************/
@@ -257,7 +356,6 @@ namespace cryptonote
257356
258357 BEGIN_SERIALIZE ()
259358 VARINT_FIELD (major_version)
260- if (major_version > CURRENT_BLOCK_MAJOR_VERSION) return false ;
261359 VARINT_FIELD (minor_version)
262360 VARINT_FIELD (timestamp)
263361 FIELD (prev_id)
@@ -277,6 +375,37 @@ namespace cryptonote
277375 END_SERIALIZE ()
278376 };
279377
378+ struct bb_block_header
379+ {
380+ uint8_t major_version;
381+ uint8_t minor_version;
382+ uint64_t timestamp;
383+ crypto::hash prev_id;
384+ uint64_t nonce;
385+ uint8_t flags;
386+
387+ BEGIN_SERIALIZE ()
388+ FIELD (major_version)
389+ FIELD (nonce)
390+ FIELD (prev_id)
391+ VARINT_FIELD (minor_version)
392+ VARINT_FIELD (timestamp)
393+ FIELD (flags)
394+ END_SERIALIZE ()
395+ };
396+
397+ struct bb_block : public bb_block_header
398+ {
399+ bb_transaction miner_tx;
400+ std::vector<crypto::hash> tx_hashes;
401+
402+ BEGIN_SERIALIZE ()
403+ FIELDS (*static_cast <bb_block_header *>(this ))
404+ FIELD (miner_tx)
405+ FIELD (tx_hashes)
406+ END_SERIALIZE ()
407+ };
408+
280409
281410 /* ***********************************************************************/
282411 /* */
@@ -314,6 +443,7 @@ namespace cryptonote
314443}
315444
316445BLOB_SERIALIZER (cryptonote::txout_to_key);
446+ BLOB_SERIALIZER (cryptonote::bb_txout_to_key);
317447BLOB_SERIALIZER (cryptonote::txout_to_scripthash);
318448
319449VARIANT_TAG (binary_archive, cryptonote::txin_gen, 0xff );
@@ -323,6 +453,7 @@ VARIANT_TAG(binary_archive, cryptonote::txin_to_key, 0x2);
323453VARIANT_TAG (binary_archive, cryptonote::txout_to_script, 0x0 );
324454VARIANT_TAG (binary_archive, cryptonote::txout_to_scripthash, 0x1 );
325455VARIANT_TAG (binary_archive, cryptonote::txout_to_key, 0x2 );
456+ VARIANT_TAG (binary_archive, cryptonote::bb_txout_to_key, 0x2 );
326457VARIANT_TAG (binary_archive, cryptonote::transaction, 0xcc );
327458VARIANT_TAG (binary_archive, cryptonote::block, 0xbb );
328459
@@ -333,6 +464,7 @@ VARIANT_TAG(json_archive, cryptonote::txin_to_key, "key");
333464VARIANT_TAG (json_archive, cryptonote::txout_to_script, " script" );
334465VARIANT_TAG (json_archive, cryptonote::txout_to_scripthash, " scripthash" );
335466VARIANT_TAG (json_archive, cryptonote::txout_to_key, " key" );
467+ VARIANT_TAG (json_archive, cryptonote::bb_txout_to_key, " key" );
336468VARIANT_TAG (json_archive, cryptonote::transaction, " tx" );
337469VARIANT_TAG (json_archive, cryptonote::block, " block" );
338470
@@ -343,5 +475,6 @@ VARIANT_TAG(debug_archive, cryptonote::txin_to_key, "key");
343475VARIANT_TAG (debug_archive, cryptonote::txout_to_script, " script" );
344476VARIANT_TAG (debug_archive, cryptonote::txout_to_scripthash, " scripthash" );
345477VARIANT_TAG (debug_archive, cryptonote::txout_to_key, " key" );
478+ VARIANT_TAG (debug_archive, cryptonote::bb_txout_to_key, " key" );
346479VARIANT_TAG (debug_archive, cryptonote::transaction, " tx" );
347480VARIANT_TAG (debug_archive, cryptonote::block, " block" );
0 commit comments