Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bda5f949e | |||
| 52bb818185 | |||
| b5ba759c9f | |||
| 35cc401a30 | |||
| 473f81f81b | |||
| 7f703a05ff | |||
| c2ce9edbbe | |||
| cee6e90241 | |||
| 14748346e2 |
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cryptoforknote-util",
|
||||
"version": "1.0.1",
|
||||
"version": "4.0.2",
|
||||
"main": "cryptoforknote-util",
|
||||
"author": {
|
||||
"name": "LucasJones",
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
#define CURRENT_TRANSACTION_VERSION 1
|
||||
|
||||
enum BLOB_TYPE {
|
||||
BLOB_TYPE_CRYPTONOTE = 0,
|
||||
BLOB_TYPE_FORKNOTE1 = 1,
|
||||
BLOB_TYPE_FORKNOTE2 = 2,
|
||||
BLOB_TYPE_CRYPTONOTE2 = 3, // Masari
|
||||
BLOB_TYPE_CRYPTONOTE = 0,
|
||||
BLOB_TYPE_FORKNOTE1 = 1,
|
||||
BLOB_TYPE_FORKNOTE2 = 2,
|
||||
BLOB_TYPE_CRYPTONOTE2 = 3, // Masari
|
||||
BLOB_TYPE_CRYPTONOTE_RYO = 4, // Ryo
|
||||
BLOB_TYPE_CRYPTONOTE_LOKI = 5, // Loki
|
||||
BLOB_TYPE_CRYPTONOTE3 = 6, // Masari
|
||||
};
|
||||
@@ -141,6 +141,7 @@ namespace cryptonote
|
||||
{
|
||||
|
||||
public:
|
||||
enum BLOB_TYPE blob_type;
|
||||
// tx information
|
||||
size_t version;
|
||||
uint64_t unlock_time; //number of block (or time), used as a limitation like: spend this tx not early then block/time
|
||||
@@ -150,8 +151,16 @@ namespace cryptonote
|
||||
//extra
|
||||
std::vector<uint8_t> extra;
|
||||
|
||||
std::vector<uint64_t> output_unlock_times;
|
||||
bool is_deregister;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI)
|
||||
{
|
||||
FIELD(output_unlock_times)
|
||||
FIELD(is_deregister)
|
||||
}
|
||||
VARINT_FIELD(unlock_time)
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
@@ -160,13 +169,12 @@ namespace cryptonote
|
||||
|
||||
|
||||
protected:
|
||||
transaction_prefix(){}
|
||||
transaction_prefix() : blob_type(BLOB_TYPE_CRYPTONOTE) {}
|
||||
};
|
||||
|
||||
class transaction: public transaction_prefix
|
||||
{
|
||||
public:
|
||||
enum BLOB_TYPE blob_type;
|
||||
std::vector<std::vector<crypto::signature> > signatures; //count signatures always the same as inputs count
|
||||
rct::rctSig rct_signatures;
|
||||
|
||||
@@ -177,7 +185,7 @@ namespace cryptonote
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELDS(*static_cast<transaction_prefix *>(this))
|
||||
|
||||
if (version == 1 && blob_type != BLOB_TYPE_CRYPTONOTE2)
|
||||
if (version == 1 && blob_type != BLOB_TYPE_CRYPTONOTE2 && blob_type != BLOB_TYPE_CRYPTONOTE3)
|
||||
{
|
||||
ar.tag("signatures");
|
||||
ar.begin_array();
|
||||
@@ -235,7 +243,7 @@ namespace cryptonote
|
||||
};
|
||||
|
||||
inline
|
||||
transaction::transaction() : blob_type(BLOB_TYPE_CRYPTONOTE)
|
||||
transaction::transaction()
|
||||
{
|
||||
set_null();
|
||||
}
|
||||
@@ -390,6 +398,7 @@ namespace cryptonote
|
||||
|
||||
transaction miner_tx;
|
||||
std::vector<crypto::hash> tx_hashes;
|
||||
mutable crypto::hash uncle = cryptonote::null_hash;
|
||||
|
||||
void set_blob_type(enum BLOB_TYPE bt) { miner_tx.blob_type = blob_type = bt; }
|
||||
|
||||
@@ -402,6 +411,10 @@ namespace cryptonote
|
||||
}
|
||||
FIELD(miner_tx)
|
||||
FIELD(tx_hashes)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE3)
|
||||
{
|
||||
FIELD(uncle)
|
||||
}
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace cryptonote
|
||||
void get_transaction_prefix_hash(const transaction_prefix& tx, crypto::hash& h)
|
||||
{
|
||||
std::ostringstream s;
|
||||
if (tx.blob_type == BLOB_TYPE_CRYPTONOTE_RYO) s << "ryo-currency";
|
||||
binary_archive<true> a(s);
|
||||
::serialization::serialize(a, const_cast<transaction_prefix&>(tx));
|
||||
crypto::cn_fast_hash(s.str().data(), s.str().size(), h);
|
||||
@@ -369,7 +370,7 @@ namespace cryptonote
|
||||
bool get_transaction_hash(const transaction& t, crypto::hash& res, size_t* blob_size)
|
||||
{
|
||||
// v1 transactions hash the entire blob
|
||||
if (t.version == 1 && t.blob_type != BLOB_TYPE_CRYPTONOTE2)
|
||||
if (t.version == 1 && t.blob_type != BLOB_TYPE_CRYPTONOTE2 && t.blob_type != BLOB_TYPE_CRYPTONOTE3)
|
||||
{
|
||||
size_t ignored_blob_size, &blob_size_ref = blob_size ? *blob_size : ignored_blob_size;
|
||||
return get_object_hash(t, res, blob_size_ref);
|
||||
@@ -432,7 +433,9 @@ namespace cryptonote
|
||||
crypto::hash tree_root_hash = get_tx_tree_hash(b);
|
||||
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
|
||||
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
|
||||
|
||||
if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) {
|
||||
blob.append(reinterpret_cast<const char*>(&b.uncle), sizeof(b.uncle));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -45,6 +45,13 @@ inline bool do_serialize(Archive &ar, T &v)
|
||||
return ::serializer<Archive, T>::serialize(ar, v);
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
inline bool do_serialize(Archive &ar, bool &v)
|
||||
{
|
||||
ar.serialize_blob(&v, sizeof(v));
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef __GNUC__
|
||||
#ifndef constexpr
|
||||
#define constexpr
|
||||
|
||||
Reference in New Issue
Block a user