Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
da133cd
updates for Nan 2.x
clintar Nov 12, 2015
0ac11dc
use copybuffer
clintar Nov 12, 2015
54f5563
make compatible with standard node-cryptonote-pool
clintar Nov 18, 2015
81f2e15
since BLOCK_MAJOR_VERSION_2 is the same after xmr hardfork, create a
clintar Mar 23, 2016
0a25962
another fix since xmr hardfork version increased
clintar Mar 24, 2016
15d682b
more fixes since xmr hardfork version increased
clintar Mar 24, 2016
3e9fd69
more fixes
clintar Mar 24, 2016
8d74079
accidentally removed nonce. need nonce
clintar Mar 24, 2016
06862b9
fix for monero fork
clintar Sep 22, 2016
bd693d4
get rid of old fantomcoin cruft
clintar Sep 22, 2016
9025719
implement block differences after ringct, attempt 1
clintar Oct 4, 2016
54d041c
Digitalnote 4.0.0-beta update
clintar Nov 21, 2016
31c531b
Revert "Digitalnote 4.0.0-beta update"
clintar Nov 21, 2016
7fefaae
deletel line 411 minor major return false
Gingeropolous Dec 12, 2016
7e9bb84
delete all major lines
Gingeropolous Dec 12, 2016
9d9f185
removed another major comparison
Gingeropolous Dec 12, 2016
48551c3
swapped in new rctTypes.h
Gingeropolous Dec 13, 2016
55a1dde
Merge pull request #2 from Gingeropolous/xmr-Nan-2.0
clintar Dec 13, 2016
37f50f9
Add files via upload
Dec 19, 2016
bceb602
Migrating changes because I'm an idiot who can't target the right bra…
Snipa22 Jan 29, 2017
f1e3597
Retargeting.
Snipa22 Jan 29, 2017
7aa89bd
Make package compilable on OSX
Kukunin Mar 3, 2017
49d6ec7
Merge pull request #1 from Kukunin/xmr-Nan-2.0
Snipa22 Mar 3, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"-fexceptions",
"-frtti",
],
"xcode_settings": {
"OTHER_CFLAGS": ["-fexceptions", "-frtti"]
}
}
]
}
38 changes: 19 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "cryptonote-util",
"version": "0.0.1",
"main": "cryptonote",
"author": {
"name": "LucasJones",
"email": "lucasjonesdev@hotmail.co.uk"
},
"repository": {
"type": "git",
"url": "https://github.com/LucasJones/node-cryptonote-util.git"
},
"dependencies" : {
"bindings" : "*",
"nan" : "1"
},
"keywords": [
"cryptonight",
"cryptonote"
]
"name": "cryptonote-util",
"version": "0.0.3",
"main": "cryptonote",
"author": {
"name": "LucasJones",
"email": "lucasjonesdev@hotmail.co.uk"
},
"repository": {
"type": "git",
"url": "https://github.com/clintar/node-cryptonote-util.git"
},
"dependencies": {
"bindings": "*",
"nan": "^2.0.0"
},
"keywords": [
"cryptonight",
"cryptonote"
]
}
69 changes: 38 additions & 31 deletions src/crypto/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,50 +11,57 @@

namespace crypto {

extern "C" {
extern "C" {
#include "hash-ops.h"
}
}

#pragma pack(push, 1)
POD_CLASS hash {
char data[HASH_SIZE];
};
POD_CLASS hash{
char data[HASH_SIZE];
};
POD_CLASS hash8{
char data[8];
};

#pragma pack(pop)

static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
static_assert(sizeof(hash) == HASH_SIZE, "Invalid structure size");
static_assert(sizeof(hash8) == 8, "Invalid structure size");

/*
Cryptonight hash functions
*/
/*
Cryptonight hash functions
*/

inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
}
inline void cn_fast_hash(const void *data, std::size_t length, hash &hash) {
cn_fast_hash(data, length, reinterpret_cast<char *>(&hash));
}

inline hash cn_fast_hash(const void *data, std::size_t length) {
hash h;
cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
return h;
}
inline hash cn_fast_hash(const void *data, std::size_t length) {
hash h;
cn_fast_hash(data, length, reinterpret_cast<char *>(&h));
return h;
}

inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) {
cn_slow_hash(data, length, reinterpret_cast<char *>(&hash));
}
inline void cn_slow_hash(const void *data, std::size_t length, hash &hash) {
cn_slow_hash(data, length, reinterpret_cast<char *>(&hash));
}

inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
}
inline void tree_hash(const hash *hashes, std::size_t count, hash &root_hash) {
tree_hash(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char *>(&root_hash));
}

inline void tree_branch(const hash* hashes, std::size_t count, hash* branch)
{
tree_branch(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count, reinterpret_cast<char (*)[HASH_SIZE]>(branch));
}
inline void tree_branch(const hash *hashes, std::size_t count, hash *branch) {
tree_branch(reinterpret_cast<const char (*)[HASH_SIZE]>(hashes), count,
reinterpret_cast<char (*)[HASH_SIZE]>(branch));
}

inline void tree_hash_from_branch(const hash* branch, std::size_t depth, const hash& leaf, const void* path, hash& root_hash)
{
tree_hash_from_branch(reinterpret_cast<const char (*)[HASH_SIZE]>(branch), depth, reinterpret_cast<const char*>(&leaf), path, reinterpret_cast<char*>(&root_hash));
}
inline void
tree_hash_from_branch(const hash *branch, std::size_t depth, const hash &leaf, const void *path, hash &root_hash) {
tree_hash_from_branch(reinterpret_cast<const char (*)[HASH_SIZE]>(branch), depth,
reinterpret_cast<const char *>(&leaf), path, reinterpret_cast<char *>(&root_hash));
}

}

CRYPTO_MAKE_HASHABLE(hash)
CRYPTO_MAKE_COMPARABLE(hash8)
4 changes: 2 additions & 2 deletions src/cryptonote_config.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
#define CURRENT_TRANSACTION_VERSION 1
#define CURRENT_TRANSACTION_VERSION 2
#define CURRENT_BLOCK_MAJOR_VERSION 1
#define CURRENT_BLOCK_MINOR_VERSION 0

#define BLOCK_MAJOR_VERSION_1 1
#define BLOCK_MAJOR_VERSION_2 2
#define BLOCK_MAJOR_VERSION_2 3

#define COIN ((uint64_t)100000000) // pow(10, 8)
#define DEFAULT_FEE ((uint64_t)1000000) // pow(10, 6)
Expand Down
104 changes: 66 additions & 38 deletions src/cryptonote_core/cryptonote_basic.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "crypto/hash.h"
#include "misc_language.h"
#include "tx_extra.h"
#include "ringct/rctTypes.h"


namespace cryptonote
Expand Down Expand Up @@ -189,6 +190,7 @@ namespace cryptonote
{
public:
std::vector<std::vector<crypto::signature> > signatures; //count signatures always the same as inputs count
rct::rctSig rct_signatures;

transaction();
virtual ~transaction();
Expand All @@ -197,34 +199,57 @@ namespace cryptonote
BEGIN_SERIALIZE_OBJECT()
FIELDS(*static_cast<transaction_prefix *>(this))

ar.tag("signatures");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures);
bool signatures_not_expected = signatures.empty();
if (!signatures_not_expected && vin.size() != signatures.size())
return false;

for (size_t i = 0; i < vin.size(); ++i)
if (version == 1)
{
size_t signature_size = get_signature_size(vin[i]);
if (signatures_not_expected)
ar.tag("signatures");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(vin.size(), signatures);
bool signatures_not_expected = signatures.empty();
if (!signatures_not_expected && vin.size() != signatures.size())
return false;

for (size_t i = 0; i < vin.size(); ++i)
{
if (0 == signature_size)
continue;
else
size_t signature_size = get_signature_size(vin[i]);
if (signatures_not_expected)
{
if (0 == signature_size)
continue;
else
return false;
}

PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]);
if (signature_size != signatures[i].size())
return false;
}

PREPARE_CUSTOM_VECTOR_SERIALIZATION(signature_size, signatures[i]);
if (signature_size != signatures[i].size())
return false;

FIELDS(signatures[i]);
FIELDS(signatures[i]);

if (vin.size() - i > 1)
ar.delimit_array();
if (vin.size() - i > 1)
ar.delimit_array();
}
ar.end_array();
}
else
{
ar.tag("rct_signatures");
if (!vin.empty())
{
ar.begin_object();
bool r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout.size());
if (!r || !ar.stream().good()) return false;
ar.end_object();
if (rct_signatures.type != rct::RCTTypeNull)
{
ar.tag("rctsig_prunable");
ar.begin_object();
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout.size(),
vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 : 0);
if (!r || !ar.stream().good()) return false;
ar.end_object();
}
}
}
ar.end_array();
END_SERIALIZE()

private:
Expand Down Expand Up @@ -383,7 +408,6 @@ namespace cryptonote

BEGIN_SERIALIZE_OBJECT()
VARINT_FIELD_N("major_version", b.major_version);
if(b.major_version > CURRENT_BYTECOIN_BLOCK_MAJOR_VERSION) return false;
VARINT_FIELD_N("minor_version", b.minor_version);
VARINT_FIELD(timestamp);
FIELD_N("prev_id", b.prev_id);
Expand Down Expand Up @@ -456,17 +480,10 @@ namespace cryptonote

BEGIN_SERIALIZE()
VARINT_FIELD(major_version)
if(major_version > BLOCK_MAJOR_VERSION_2) return false;
VARINT_FIELD(minor_version)
if (BLOCK_MAJOR_VERSION_1 == major_version)
{
VARINT_FIELD(timestamp)
}
VARINT_FIELD(timestamp)
FIELD(prev_id)
if (BLOCK_MAJOR_VERSION_1 == major_version)
{
FIELD(nonce)
}
FIELD(nonce)
END_SERIALIZE()
};

Expand All @@ -479,11 +496,6 @@ namespace cryptonote

BEGIN_SERIALIZE_OBJECT()
FIELDS(*static_cast<block_header *>(this))
if (BLOCK_MAJOR_VERSION_2 <= major_version)
{
auto sbb = make_serializable_bytecoin_block(*this, false, false);
FIELD_N("parent_block", sbb);
}
FIELD(miner_tx)
FIELD(tx_hashes)
END_SERIALIZE()
Expand Down Expand Up @@ -547,7 +559,23 @@ namespace cryptonote
END_KV_SERIALIZE_MAP()
};

struct keypair
struct integrated_address {
account_public_address adr;
crypto::hash8 payment_id;

BEGIN_SERIALIZE_OBJECT()
FIELD(adr)
FIELD(payment_id)
END_SERIALIZE()

BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(adr)
KV_SERIALIZE(payment_id)
END_KV_SERIALIZE_MAP()
};


struct keypair
{
crypto::public_key pub;
crypto::secret_key sec;
Expand Down
Loading