Compare commits

...

39 Commits

Author SHA1 Message Date
MoneroOcean 49a238086e Updated ZEPH 2025-06-11 08:55:48 -07:00
MoneroOcean 91b90dbc01 ARQ support 2025-06-09 08:36:08 -07:00
MoneroOcean 8f3385902d PR fixes 2025-06-09 08:30:45 -07:00
MoneroOcean ad6ba0d7f0 PR fixes 2025-06-09 08:28:42 -07:00
MoneroOcean 1608a9e1a9 PR fixes 2025-06-09 08:26:03 -07:00
MoneroOcean 14e378aa0f PR fixes 2025-06-09 08:20:43 -07:00
MoneroOcean dd4be285f1 PR fixes 2025-06-09 08:18:40 -07:00
MoneroOcean b9260e0c7b PR fixes 2025-06-09 08:18:02 -07:00
MoneroOcean d93aaec6a5 Merge pull request #22 from malbit/ArqmaSN
New BLOB_TYPE for Arqma Service-Nodes version 16 Hard-Fork.
2025-06-09 07:57:37 -07:00
m@lbit bd1af278a5 New BLOB_TYPE for Arqma Service-Nodes version 16 Hard-Fork. 2025-06-09 15:18:22 +02:00
MoneroOcean 2a4f5cea7c SAL v0.7 support and removed RingCT XHV support 2024-12-19 06:47:15 +03:00
Some Random Crypto Guy 16eba0d12d updated to support v0.7.0 2024-12-19 06:43:51 +03:00
MoneroOcean aa39526fe8 Fixed SAL parse after fork 2024-11-05 16:44:07 +03:00
MoneroOcean 44ee67d21f Fixed SAL parse after fork 2024-11-05 16:33:11 +03:00
MoneroOcean 0f9c969b83 Fixed SAL parse after fork 2024-11-05 16:32:46 +03:00
MoneroOcean ac5dcc2133 Fixed previous commit 2024-10-23 17:54:15 +03:00
MoneroOcean 069c83ef32 Fixed previous commit 2024-10-23 17:51:50 +03:00
MoneroOcean 655f79b0e0 Updated for Salvium v0.6.0 2024-10-23 17:45:28 +03:00
MoneroOcean 01ed1460e3 ZEPH 2.0 support 2024-10-07 07:50:42 +03:00
MoneroOcean bd7fb25315 Fixed CI 2024-10-07 07:47:45 +03:00
MoneroOcean cdf439d83f Fixed CI 2024-10-07 07:42:49 +03:00
MoneroOcean d47d988a72 Fixed CI 2024-10-07 07:36:33 +03:00
MoneroOcean 1c06a70b58 Fixed merge 2024-10-07 07:33:17 +03:00
MoneroOcean 20c20f5522 Fixed CI 2024-10-07 07:28:51 +03:00
MoneroOcean a275227d76 Fixed CI 2024-10-07 07:26:39 +03:00
MoneroOcean ac1425cbcb Added CI tests 2024-10-07 07:19:59 +03:00
ZephyrProtocol f1a39778cb Fix ordering of PR fields for yield_price serialization 2024-10-07 07:12:11 +03:00
ZephyrProtocol 79e5c63a7d Update pricing record serialization for Zephyr version v2.0.0 2024-10-07 07:11:51 +03:00
MoneroOcean d58b8a8f8d Added SAL support 2024-07-20 19:17:54 +03:00
MoneroOcean 37d2297a2b Added SAL support 2024-07-20 19:12:47 +03:00
MoneroOcean 5afa141942 Added SAL support 2024-07-20 19:11:34 +03:00
MoneroOcean 088a0f4c00 Added SAL support 2024-07-20 05:18:49 +03:00
MoneroOcean c75b1d464b Added SAL support 2024-07-20 04:49:22 +03:00
MoneroOcean b3e74bffda Added SAL support 2024-07-20 04:41:43 +03:00
MoneroOcean c696b5b43f Added SAL support 2024-07-20 04:41:33 +03:00
MoneroOcean 084ea7fd77 Added SAL support 2024-07-20 01:24:23 +03:00
MoneroOcean e7a1430242 Added SAL support 2024-07-19 21:44:05 +03:00
MoneroOcean a138d12221 Added SAL support 2024-07-19 21:06:11 +03:00
MoneroOcean dd63cb209d Added SAL support 2024-07-19 21:01:48 +03:00
43 changed files with 739 additions and 799 deletions
+19
View File
@@ -0,0 +1,19 @@
on: push
name: Test
jobs:
build_lin:
name: Ubuntu test
runs-on: ubuntu-latest
steps:
- name: Prepare Ubuntu tools
run: |
sudo apt update
sudo apt-get install -y libboost-dev libboost-system-dev libboost-date-time-dev libsodium-dev
- name: Checkout code
uses: actions/checkout@master
- name: Test
run: |
npm install
./tests/run.sh
+2 -1
View File
@@ -4,7 +4,8 @@ Node-CryptoForkNote-Util with Merged Mining support
Installing locally and testing
-----
```
npm install https://github.com/MoneroOcean/node-cryptoforknote-util
JOBS=$(nproc) npm install https://github.com/MoneroOcean/node-cryptoforknote-util
node_modules/cryptoforknote-util/tests/run.sh
```
Dependencies
+1 -1
View File
@@ -4,7 +4,7 @@
"target_name": "cryptoforknote",
"sources": [
"src/main.cc",
"src/cryptonote_core/cryptonote_format_utils.cpp",
"src/cryptonote_basic/cryptonote_format_utils.cpp",
"src/offshore/pricing_record.cpp",
"src/zephyr_oracle/pricing_record.cpp",
"src/salvium_oracle/pricing_record.cpp",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cryptoforknote-util",
"version": "15.5.6",
"version": "15.7.1",
"author": {
"name": "LucasJones",
"email": "lucasjonesdev@hotmail.co.uk"
@@ -33,6 +33,7 @@
#include <deque>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/contains_fwd.hpp>
#include <cstdint>
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "serialization"
@@ -4,7 +4,7 @@
#pragma once
#include "cryptonote_core/cryptonote_basic.h"
#include "cryptonote_basic.h"
#include "crypto/crypto.h"
#include "serialization/keyvalue_serialization.h"
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include <cstdint>
namespace cryptonote_arq
{
enum class txversion : uint16_t
{
v0 = 0,
v1,
v2,
v3,
_count
};
enum class txtype : uint16_t
{
standard = 0,
state_change,
key_image_unlock,
stake,
_count
};
}
@@ -17,7 +17,6 @@
#include "serialization/crypto.h"
#include "serialization/pricing_record.h"
#include "serialization/zephyr_pricing_record.h"
#include "serialization/salvium_pricing_record.h"
#include "serialization/keyvalue_serialization.h" // eepe named serialization
#include "string_tools.h"
#include "cryptonote_config.h"
@@ -30,6 +29,7 @@
#include "offshore/pricing_record.h"
#include "zephyr_oracle/pricing_record.h"
#include "salvium_oracle/pricing_record.h"
#include "arq_txtypes.h"
namespace cryptonote
@@ -62,7 +62,7 @@ namespace cryptonote
RETURN = 7,
MAX = 7
};
/* outputs */
struct txout_to_script
@@ -286,7 +286,7 @@ namespace cryptonote
uint64_t amount;
std::vector<uint64_t> key_offsets;
crypto::key_image k_image;
BEGIN_SERIALIZE_OBJECT()
VARINT_FIELD(amount)
FIELD(key_offsets)
@@ -338,7 +338,7 @@ namespace cryptonote
FIELD(k_image)
END_SERIALIZE()
};
struct txin_salvium_key
{
uint64_t amount;
@@ -353,7 +353,7 @@ namespace cryptonote
FIELD(k_image)
END_SERIALIZE()
};
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_offshore, txin_onshore, txin_xasset, txin_haven_key> txin_v;
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_zephyr_key> txin_zephyr_v;
typedef boost::variant<txin_gen, txin_to_script, txin_to_scripthash, txin_salvium_key> txin_salvium_v;
@@ -427,6 +427,8 @@ namespace cryptonote
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
cryptonote_arq::txtype arq_tx_type;
std::vector<txin_v> vin;
std::vector<txin_zephyr_v> vin_zephyr;
std::vector<txin_salvium_v> vin_salvium;
@@ -447,9 +449,12 @@ namespace cryptonote
// SALVIUM-SPECIFIC FIELDS
// TX type
cryptonote::salvium_transaction_type tx_type;
// Return address
cryptonote::salvium_transaction_type sal_tx_type;
crypto::public_key return_address;
// Return address list (must be at least 1 and at most BULLETPROOF_MAX_OUTPUTS-1 - the "-1" is for the change output)
std::vector<crypto::public_key> return_address_list;
//return_address_change_mask
std::vector<uint8_t> return_address_change_mask;
// Return TX public key
crypto::public_key return_pubkey;
// Source asset type
@@ -483,10 +488,10 @@ namespace cryptonote
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
VARINT_FIELD(version)
//if(version == 0 || CURRENT_TRANSACTION_VERSION < version) return false;
// Only transactions prior to HAVEN_TYPES_TRANSACTION_VERSION are permitted to be anything other than HAVEN_TYPES and need translation
if (version < HAVEN_TYPES_TRANSACTION_VERSION) {
if (version < POU_TRANSACTION_VERSION) {
VARINT_FIELD(unlock_time)
}
@@ -718,7 +723,7 @@ namespace cryptonote
}
return true;
}
FIELD(vin)
FIELD(vout_xhv)
FIELD(extra)
@@ -734,20 +739,25 @@ namespace cryptonote
FIELD(vin_salvium)
FIELD(vout_salvium)
FIELD(extra)
VARINT_FIELD(tx_type)
if (tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
VARINT_FIELD(sal_tx_type)
if (sal_tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
VARINT_FIELD(amount_burnt)
if (tx_type != cryptonote::salvium_transaction_type::MINER) {
FIELD(return_address)
FIELD(return_pubkey)
if (sal_tx_type != cryptonote::salvium_transaction_type::MINER) {
if (type == cryptonote::salvium_transaction_type::TRANSFER && version >= TRANSACTION_VERSION_N_OUTS) {
FIELD(return_address_list)
FIELD(return_address_change_mask)
} else {
FIELD(return_address)
FIELD(return_pubkey)
}
FIELD(source_asset_type)
FIELD(destination_asset_type)
VARINT_FIELD(amount_slippage_limit)
}
}
} else {
VARINT_FIELD(version)
if (version > loki_version_2 && (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC))
{
@@ -755,22 +765,31 @@ namespace cryptonote
if (version == loki_version_3_per_output_unlock_times)
FIELD(is_deregister)
}
if (version >= static_cast<size_t>(cryptonote_arq::txversion::v3) && (blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA))
{
VARINT_FIELD(arq_tx_type)
if (static_cast<uint16_t>(arq_tx_type) >= static_cast<uint16_t>(cryptonote_arq::txtype::_count))
return false;
FIELD(output_unlock_times)
}
VARINT_FIELD(unlock_time)
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR)
FIELD(vin_zephyr)
else
else
FIELD(vin)
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR)
FIELD(vout_zephyr)
else
FIELD(vout)
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC)
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA)
{
if (version >= loki_version_3_per_output_unlock_times && vout.size() != output_unlock_times.size()) return false;
if ((version >= loki_version_3_per_output_unlock_times || version >= static_cast<size_t>(cryptonote_arq::txversion::v3)) && vout.size() != output_unlock_times.size())
return false;
}
FIELD(extra)
if ((blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) && version >= loki_version_4_tx_types)
@@ -916,6 +935,17 @@ namespace cryptonote
amount_minted = 0;
output_unlock_times.clear();
collateral_indices.clear();
// SAL
sal_tx_type = cryptonote::salvium_transaction_type::UNSET;
return_address = cryptonote::null_pkey;
return_address_list.clear();
return_address_change_mask.clear();
return_pubkey = cryptonote::null_pkey;
source_asset_type.clear();
destination_asset_type.clear();
amount_slippage_limit = 0;
// ARQ
arq_tx_type = cryptonote_arq::txtype::standard;
}
inline
@@ -1078,13 +1108,29 @@ namespace cryptonote
if (blob_type == BLOB_TYPE_CRYPTONOTE_XTNC || blob_type == BLOB_TYPE_CRYPTONOTE_CUCKOO) FIELD(cycle)
if (blob_type == BLOB_TYPE_CRYPTONOTE_TUBE) FIELD(cycle40)
if (blob_type == BLOB_TYPE_CRYPTONOTE_XTA) FIELD(cycle48)
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) FIELD(pricing_record)
else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) FIELD(salvium_pricing_record)
else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
if (major_version >= 4)
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
FIELD(pricing_record)
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
if (major_version >= 255) FIELD(salvium_pricing_record)
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
if (major_version >= 6)
{
FIELD_N("pricing_record", zephyr_pricing_record)
}
else if (major_version >= 4)
{
zephyr_oracle::pricing_record_v3 pr_v3;
if (!typename Archive<W>::is_saving())
{
FIELD(pr_v3)
pr_v3.write_to_pr(zephyr_pricing_record);
}
else
{
pr_v3.read_from_pr(zephyr_pricing_record);
FIELD(pr_v3)
}
}
else if (major_version >= 3)
{
zephyr_oracle::pricing_record_v2 pr_v2;
@@ -288,7 +288,7 @@ 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));
if (b.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
blob.append(tools::get_varint_data(b.tx_hashes.size()+2));
blob.append(tools::get_varint_data(b.tx_hashes.size() + (b.major_version >= HF_VERSION_ENABLE_N_OUTS ? 2 : 1)));
} else {
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
}
@@ -4,8 +4,8 @@
#pragma once
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
#include "cryptonote_core/cryptonote_basic_impl.h"
#include "cryptonote_core/difficulty.h"
#include "cryptonote_basic_impl.h"
#include "difficulty.h"
#include "account.h"
#include "include_base_utils.h"
#include "crypto/crypto.h"
@@ -30,30 +30,43 @@
#pragma once
#define TX_EXTRA_PADDING_MAX_COUNT 255
#define TX_EXTRA_NONCE_MAX_COUNT 255
#define TX_EXTRA_OFFSHORE_MAX_COUNT 255
#define TX_EXTRA_MEMO_MAX_COUNT 255
#define TX_EXTRA_PADDING_MAX_COUNT 255
#define TX_EXTRA_NONCE_MAX_COUNT 255
#define TX_EXTRA_OFFSHORE_MAX_COUNT 255
#define TX_EXTRA_MEMO_MAX_COUNT 255
#define TX_EXTRA_TAG_PADDING 0x00
#define TX_EXTRA_TAG_PUBKEY 0x01
#define TX_EXTRA_NONCE 0x02
#define TX_EXTRA_MERGE_MINING_TAG 0x03
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS 0x04
#define TX_EXTRA_TAG_OFFSHORE 0x17
#define TX_EXTRA_TAG_MEMO 0x18
#define TX_EXTRA_TAG_SERVICE_NODE_REGISTER 0x70
#define TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER 0x71
#define TX_EXTRA_TAG_SERVICE_NODE_WINNER 0x72
#define TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR 0x73
#define TX_EXTRA_TAG_SERVICE_NODE_PUBKEY 0x74
#define TX_EXTRA_TAG_TX_SECRET_KEY 0x75
#define TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS 0x76
#define TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK 0x77
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG 0xDE
#define TX_EXTRA_TAG_PADDING 0x00
#define TX_EXTRA_TAG_PUBKEY 0x01
#define TX_EXTRA_NONCE 0x02
#define TX_EXTRA_MERGE_MINING_TAG 0x03
#define TX_EXTRA_TAG_ADDITIONAL_PUBKEYS 0x04
#define TX_EXTRA_TAG_OFFSHORE 0x17
#define TX_EXTRA_TAG_MEMO 0x18
#define TX_EXTRA_TAG_SERVICE_NODE_REGISTER 0x70
#define TX_EXTRA_TAG_SERVICE_NODE_STATE_CHANGE 0x71
#define TX_EXTRA_TAG_SERVICE_NODE_WINNER 0x72
#define TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR 0x73
#define TX_EXTRA_TAG_SERVICE_NODE_PUBKEY 0x74
#define TX_EXTRA_TAG_TX_SECRET_KEY 0x75
#define TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS 0x76
#define TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK 0x77
#define TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER 0x78
#define TX_EXTRA_MYSTERIOUS_MINERGATE_TAG 0xDE
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
#define TX_EXTRA_NONCE_PAYMENT_ID 0x00
#define TX_EXTRA_NONCE_ENCRYPTED_PAYMENT_ID 0x01
namespace service_nodes
{
enum class new_state : uint16_t
{
deregister = 0,
decommission,
recommission,
ip_change_penalty,
_count,
};
};
namespace cryptonote
{
@@ -277,6 +290,45 @@ namespace cryptonote
END_SERIALIZE()
};
struct tx_extra_service_node_state_change
{
struct vote
{
vote() = default;
vote(crypto::signature const &signature, uint32_t validator_index) : signature(signature), validator_index(validator_index) {}
crypto::signature signature;
uint32_t validator_index;
BEGIN_SERIALIZE()
VARINT_FIELD(validator_index)
FIELD(signature)
END_SERIALIZE()
};
service_nodes::new_state state;
uint64_t block_height;
uint32_t service_node_index;
std::vector<vote> votes;
tx_extra_service_node_state_change() = default;
template<typename... VotesArgs>
tx_extra_service_node_state_change(service_nodes::new_state state, uint64_t block_height, uint32_t service_node_index, VotesArgs &&...votes)
: state{state}, block_height{block_height}, service_node_index{service_node_index}, votes{std::forward<VotesArgs>(votes)...} {}
bool operator==(const tx_extra_service_node_state_change &sc) const
{
return state == sc.state && block_height == sc.block_height && service_node_index == sc.service_node_index;
}
BEGIN_SERIALIZE()
ENUM_FIELD(state, state < service_nodes::new_state::_count)
FIELD(block_height)
FIELD(service_node_index)
FIELD(votes)
END_SERIALIZE()
};
struct tx_extra_tx_secret_key
{
crypto::secret_key key;
@@ -324,35 +376,37 @@ namespace cryptonote
tx_extra_merge_mining_tag,
tx_extra_additional_pub_keys,
tx_extra_mysterious_minergate,
tx_extra_offshore,
tx_extra_memo,
tx_extra_offshore,
tx_extra_memo,
tx_extra_service_node_pubkey,
tx_extra_service_node_register,
tx_extra_service_node_contributor,
tx_extra_service_node_winner,
tx_extra_service_node_deregister,
tx_extra_service_node_state_change,
tx_extra_tx_secret_key,
tx_extra_tx_key_image_proofs,
tx_extra_tx_key_image_unlock
tx_extra_tx_key_image_unlock,
tx_extra_service_node_deregister
> tx_extra_field;
}
BLOB_SERIALIZER(cryptonote::tx_extra_service_node_deregister::vote);
BLOB_SERIALIZER(cryptonote::tx_extra_tx_key_image_proofs::proof);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_padding, TX_EXTRA_TAG_PADDING);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_pub_key, TX_EXTRA_TAG_PUBKEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_nonce, TX_EXTRA_NONCE);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_merge_mining_tag, TX_EXTRA_MERGE_MINING_TAG);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_additional_pub_keys, TX_EXTRA_TAG_ADDITIONAL_PUBKEYS);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_mysterious_minergate, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_offshore, TX_EXTRA_TAG_OFFSHORE);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_memo, TX_EXTRA_TAG_MEMO);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_register, TX_EXTRA_TAG_SERVICE_NODE_REGISTER);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_deregister, TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_contributor, TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_winner, TX_EXTRA_TAG_SERVICE_NODE_WINNER);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_pubkey, TX_EXTRA_TAG_SERVICE_NODE_PUBKEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_secret_key, TX_EXTRA_TAG_TX_SECRET_KEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_proofs, TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_unlock, TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_padding, TX_EXTRA_TAG_PADDING);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_pub_key, TX_EXTRA_TAG_PUBKEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_nonce, TX_EXTRA_NONCE);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_merge_mining_tag, TX_EXTRA_MERGE_MINING_TAG);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_additional_pub_keys, TX_EXTRA_TAG_ADDITIONAL_PUBKEYS);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_mysterious_minergate, TX_EXTRA_MYSTERIOUS_MINERGATE_TAG);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_offshore, TX_EXTRA_TAG_OFFSHORE);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_memo, TX_EXTRA_TAG_MEMO);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_register, TX_EXTRA_TAG_SERVICE_NODE_REGISTER);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_state_change, TX_EXTRA_TAG_SERVICE_NODE_STATE_CHANGE);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_contributor, TX_EXTRA_TAG_SERVICE_NODE_CONTRIBUTOR);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_winner, TX_EXTRA_TAG_SERVICE_NODE_WINNER);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_pubkey, TX_EXTRA_TAG_SERVICE_NODE_PUBKEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_secret_key, TX_EXTRA_TAG_TX_SECRET_KEY);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_proofs, TX_EXTRA_TAG_TX_KEY_IMAGE_PROOFS);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_tx_key_image_unlock, TX_EXTRA_TAG_TX_KEY_IMAGE_UNLOCK);
VARIANT_TAG(binary_archive, cryptonote::tx_extra_service_node_deregister, TX_EXTRA_TAG_SERVICE_NODE_DEREGISTER);
+3
View File
@@ -8,6 +8,8 @@
#define HF_VERSION_XASSET_FEES_V2 17
#define HF_VERSION_HAVEN2 18
#define HF_VERSION_USE_COLLATERAL 20
#define HF_VERSION_ENABLE_N_OUTS 2
#define TRANSACTION_VERSION_N_OUTS 3
// UNLOCK TIMES
#define TX_V6_OFFSHORE_UNLOCK_BLOCKS 21*720 // 21 day unlock time
@@ -37,4 +39,5 @@ enum BLOB_TYPE {
BLOB_TYPE_CRYPTONOTE_ZEPHYR = 13, // ZEPHYR
BLOB_TYPE_CRYPTONOTE_XLA = 14, // XLA
BLOB_TYPE_CRYPTONOTE_SALVIUM= 15, // Salvium
BLOB_TYPE_CRYPTONOTE_ARQMA = 16 // Arqma
};
@@ -6,7 +6,7 @@
#include <list>
#include "serialization/keyvalue_serialization.h"
#include "cryptonote_core/cryptonote_basic.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_protocol/blobdatatype.h"
namespace cryptonote
{
+11 -6
View File
@@ -5,8 +5,9 @@
#include <stdint.h>
#include <string>
#include <algorithm>
#include "cryptonote_core/cryptonote_basic.h"
#include "cryptonote_core/cryptonote_format_utils.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_basic/tx_extra.h"
#include "common/base58.h"
#include "serialization/binary_utils.h"
#include <nan.h>
@@ -32,7 +33,7 @@ blobdata uint64be_to_blob(uint64_t num) {
res[7] = num & 0xff;
return res;
}
static bool fillExtra(cryptonote::block& block1, const cryptonote::block& block2) {
cryptonote::tx_extra_merge_mining_tag mm_tag;
mm_tag.depth = 0;
@@ -250,7 +251,7 @@ NAN_METHOD(address_decode) {
Local<Object> target = info[0]->ToObject(isolate->GetCurrentContext()).ToLocalChecked();
if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object.");
blobdata input = std::string(Buffer::Data(target), Buffer::Length(target));
blobdata data;
@@ -330,7 +331,11 @@ NAN_METHOD(construct_mm_parent_block_blob) { // (parentBlockTemplate, blob_type,
b.set_blob_type(blob_type);
if (!parse_and_validate_block_from_blob(input, b)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse prent block");
if (blob_type == BLOB_TYPE_CRYPTONOTE_LOKI || blob_type == BLOB_TYPE_CRYPTONOTE_XTNC) b.miner_tx.version = cryptonote::loki_version_2;
if (blob_type == BLOB_TYPE_CRYPTONOTE_ARQMA) {
b.miner_tx.version = static_cast<size_t>(cryptonote_arq::txversion::v3);
b.miner_tx.arq_tx_type = cryptonote_arq::txtype::standard;
}
block b2 = AUTO_VAL_INIT(b2);
b2.set_blob_type(BLOB_TYPE_FORKNOTE2);
if (!parse_and_validate_block_from_blob(child_input, b2)) return THROW_ERROR_EXCEPTION("construct_mm_parent_block_blob: Failed to parse child block");
@@ -369,7 +374,7 @@ NAN_METHOD(construct_mm_child_block_blob) { // (shareBuffer, blob_type, childBlo
if (!parse_and_validate_block_from_blob(child_block_template_blob, b2)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to parse child block");
if (!mergeBlocks(b, b2, std::vector<crypto::hash>())) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to postprocess mining block");
blobdata output = "";
if (!block_to_blob(b2, output)) return THROW_ERROR_EXCEPTION("construct_mm_child_block_blob: Failed to convert child block to blob");
+70 -210
View File
@@ -87,8 +87,18 @@ namespace rct {
typedef std::vector<key> keyV; //vector of keys
typedef std::vector<keyV> keyM; //matrix of keys (indexed by column first)
static key null_key = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
struct zk_proof {
key R; // Commitment
key z1; // Response
key z2; // Response
BEGIN_SERIALIZE_OBJECT()
FIELD(R)
FIELD(z1)
FIELD(z2)
END_SERIALIZE()
};
//containers For CT operations
//if it's representing a private ctkey then "dest" contains the secret key of the address
// while "mask" contains a where C = aG + bH is CT pedersen commitment and b is the amount
@@ -294,10 +304,8 @@ namespace rct {
RCTTypeBulletproof = 3,
RCTTypeBulletproof2 = 4,
RCTTypeCLSAG = 5,
RCTTypeCLSAGN = 6,
RCTTypeHaven2 = 7, // Add public mask sum terms, remove extraneous fields (txnFee_usd,txnFee_xasset,txnOffshoreFee_usd,txnOffshoreFee_xasset)
RCTTypeHaven3 = 8, // Add public mask sum term for collateral
RCTTypeBulletproofPlus = 9,
RCTTypeBulletproofPlus = 6,
RCTTypeFullProofs = 7
};
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
struct RCTConfig {
@@ -318,27 +326,24 @@ namespace rct {
keyV pseudoOuts; //C - for simple rct
std::vector<ecdhTuple> ecdhInfo;
ctkeyV outPk;
ctkeyV outPk_usd;
ctkeyV outPk_xasset;
xmr_amount txnFee = 0; // contains b
xmr_amount txnFee_usd = 0;
xmr_amount txnFee_xasset = 0;
xmr_amount txnOffshoreFee = 0;
xmr_amount txnOffshoreFee_usd = 0;
xmr_amount txnOffshoreFee_xasset = 0;
keyV maskSums; // contains 2 or 3 elements. 1. is the sum of masks of inputs. 2. is the sum of masks of change outputs. 3. mask of the col output.
key p_r;
zk_proof pr_proof; // p_r
zk_proof sa_proof; // spend authority proof
rctSigBase() :
type(RCTTypeNull), message{}, mixRing{}, pseudoOuts{}, ecdhInfo{}, outPk{}, txnFee(0), p_r{}, pr_proof{}, sa_proof{}
{}
template<bool W, template <bool> class Archive>
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
{
FIELD(type)
if (type == RCTTypeNull)
return ar.stream().good();
if (type != RCTTypeBulletproofPlus)
return serialize_rctsig_base_old(ar, inputs, outputs);
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeBulletproofPlus && type != RCTTypeFullProofs)
return false;
VARINT_FIELD(txnFee)
VARINT_FIELD(txnOffshoreFee)
// inputs/outputs not saved, only here for serialization help
// FIELD(message) - not serialized, it can be reconstructed
// FIELD(mixRing) - not serialized, it can be reconstructed
@@ -349,193 +354,44 @@ namespace rct {
return false;
for (size_t i = 0; i < outputs; ++i)
{
ar.begin_object();
if (!typename Archive<W>::is_saving())
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
FIELD(amount);
ar.end_object();
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
ar.tag("outPk");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
if (outPk.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
FIELDS(outPk[i].mask)
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
// if txnOffshoreFee is not 0, it is a conversion tx
if (txnOffshoreFee) {
ar.tag("maskSums");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
if (maskSums.size() != 3)
return false;
FIELDS(maskSums[0])
ar.delimit_array();
FIELDS(maskSums[1])
ar.delimit_array();
FIELDS(maskSums[2])
ar.end_array();
}
if (crypto_verify_32(p_r.bytes, null_key.bytes))
FIELD(p_r)
return ar.stream().good();
}
template<bool W, template <bool> class Archive>
bool serialize_rctsig_base_old(Archive<W> &ar, size_t inputs, size_t outputs)
{
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3)
return false;
VARINT_FIELD(txnFee)
if (type == RCTTypeHaven2 || type == RCTTypeHaven3) {
// serialize offshore fee
VARINT_FIELD(txnOffshoreFee)
} else if (type == RCTTypeCLSAG || type == RCTTypeCLSAGN) {
VARINT_FIELD(txnFee_usd)
if (type == RCTTypeCLSAGN)
{
VARINT_FIELD(txnFee_xasset)
}
VARINT_FIELD(txnOffshoreFee)
VARINT_FIELD(txnOffshoreFee_usd)
if (type == RCTTypeCLSAGN)
{
VARINT_FIELD(txnOffshoreFee_xasset)
}
} else {
txnFee_usd = 0;
txnFee_xasset = 0;
txnOffshoreFee = 0;
txnOffshoreFee_usd = 0;
txnOffshoreFee_xasset = 0;
}
// inputs/outputs not saved, only here for serialization help
// FIELD(message) - not serialized, it can be reconstructed
// FIELD(mixRing) - not serialized, it can be reconstructed
if (type == RCTTypeSimple) // moved to prunable with bulletproofs
{
ar.tag("pseudoOuts");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(inputs, pseudoOuts);
if (pseudoOuts.size() != inputs)
return false;
for (size_t i = 0; i < inputs; ++i)
{
FIELDS(pseudoOuts[i])
if (inputs - i > 1)
ar.delimit_array();
}
ar.end_array();
}
ar.tag("ecdhInfo");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, ecdhInfo);
if (ecdhInfo.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
{
ar.begin_object();
if (!typename Archive<W>::is_saving())
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
FIELD(amount);
ar.end_object();
}
else
{
FIELDS(ecdhInfo[i])
}
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
ar.tag("outPk");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
if (outPk.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
FIELDS(outPk[i].mask)
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
{
// Since RCTTypeBulletproof2 enote types, we don't serialize the blinding factor, and only serialize the
// first 8 bytes of ecdhInfo[i].amount
ar.begin_object();
if (!typename Archive<W>::is_saving())
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
FIELD(amount);
ar.end_object();
}
else
{
FIELDS(ecdhInfo[i])
}
if (outputs - i > 1)
ar.delimit_array();
ar.delimit_array();
}
ar.end_array();
// if txnOffshoreFee is not 0, it is a conversion tx
if (type == RCTTypeHaven3 && txnOffshoreFee) {
ar.tag("outPk");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
if (outPk.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
FIELDS(outPk[i].mask)
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
ar.tag("maskSums");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
if (maskSums.size() != 3)
return false;
FIELDS(maskSums[0])
ar.delimit_array();
FIELDS(maskSums[1])
ar.delimit_array();
FIELDS(maskSums[2])
ar.end_array();
} else if (type == RCTTypeHaven2) {
ar.tag("maskSums");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(2, maskSums);
if (maskSums.size() != 2)
return false;
FIELDS(maskSums[0])
ar.delimit_array();
FIELDS(maskSums[1])
ar.end_array();
} else {
if ((type == RCTTypeCLSAG) || (type == RCTTypeCLSAGN))
{
ar.tag("outPk_usd");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk_usd);
if (outPk_usd.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
FIELDS(outPk_usd[i].mask)
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
}
if (type == RCTTypeCLSAGN)
{
ar.tag("outPk_xasset");
ar.begin_array();
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk_xasset);
if (outPk_xasset.size() != outputs)
return false;
for (size_t i = 0; i < outputs; ++i)
{
FIELDS(outPk_xasset[i].mask)
if (outputs - i > 1)
ar.delimit_array();
}
ar.end_array();
}
FIELD(p_r)
if (type == RCTTypeFullProofs)
{
FIELD(pr_proof)
FIELD(sa_proof)
}
return ar.stream().good();
}
@@ -548,8 +404,11 @@ namespace rct {
FIELD(ecdhInfo)
FIELD(outPk)
VARINT_FIELD(txnFee)
VARINT_FIELD(txnOffshoreFee)
FIELD(maskSums)
FIELD(p_r)
if (type == RCTTypeFullProofs) {
FIELD(pr_proof)
FIELD(sa_proof)
}
END_SERIALIZE()
};
struct rctSigPrunable {
@@ -572,9 +431,9 @@ namespace rct {
return false;
if (type == RCTTypeNull)
return ar.stream().good();
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeCLSAGN && type != RCTTypeHaven2 && type != RCTTypeHaven3 && type != RCTTypeBulletproofPlus)
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeBulletproofPlus && type != RCTTypeFullProofs)
return false;
if (type == RCTTypeBulletproofPlus)
if (type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
{
uint32_t nbp = bulletproofs_plus.size();
VARINT_FIELD(nbp)
@@ -593,10 +452,10 @@ namespace rct {
return false;
ar.end_array();
}
else if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
else if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG)
{
uint32_t nbp = bulletproofs.size();
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG)
VARINT_FIELD(nbp)
else
FIELD(nbp)
@@ -631,7 +490,7 @@ namespace rct {
ar.end_array();
}
if (type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus)
if (type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
{
ar.tag("CLSAGs");
ar.begin_array();
@@ -722,7 +581,7 @@ namespace rct {
}
ar.end_array();
}
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus)
if (type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
{
ar.tag("pseudoOuts");
ar.begin_array();
@@ -754,12 +613,12 @@ namespace rct {
keyV& get_pseudo_outs()
{
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus ? p.pseudoOuts : pseudoOuts;
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs ? p.pseudoOuts : pseudoOuts;
}
keyV const& get_pseudo_outs() const
{
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3 || type == RCTTypeBulletproofPlus ? p.pseudoOuts : pseudoOuts;
return type == RCTTypeBulletproof || type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs ? p.pseudoOuts : pseudoOuts;
}
BEGIN_SERIALIZE_OBJECT()
@@ -930,5 +789,6 @@ VARIANT_TAG(binary_archive, rct::multisig_kLRki, 0x9d);
VARIANT_TAG(binary_archive, rct::multisig_out, 0x9e);
VARIANT_TAG(binary_archive, rct::clsag, 0x9f);
VARIANT_TAG(binary_archive, rct::BulletproofPlus, 0xa0);
VARIANT_TAG(binary_archive, rct::zk_proof, 0xa1);
#endif /* RCTTYPES_H */
+1 -71
View File
@@ -223,82 +223,12 @@ namespace salvium_oracle
return (*this).equal(empty_pr);
}
bool pricing_record::verifySignature(const std::string& public_key) const
{
CHECK_AND_ASSERT_THROW_MES(!public_key.empty(), "Pricing record verification failed. NULL public key. PK Size: " << public_key.size());
// extract the key
EVP_PKEY* pubkey;
BIO* bio = BIO_new_mem_buf(public_key.c_str(), public_key.size());
if (!bio) {
return false;
}
pubkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
BIO_free(bio);
CHECK_AND_ASSERT_THROW_MES(pubkey != NULL, "Pricing record verification failed. NULL public key.");
// Build the JSON string, so that we can verify the signature
std::ostringstream oss;
oss << "{\"pr_version\":" << pr_version;
oss << ",\"height\":" << height;
oss << ",\"supply\":{\"SAL\":" << supply.sal <<",\"VSD\":" << supply.vsd << "}";
oss << ",\"assets\":[";
bool first = true;
for (const auto& asset: assets) {
if (first)
first=false;
else
oss << ",";
oss << "{\"asset_type\":\"" << asset.asset_type << "\",\"spot_price\":" << asset.spot_price << ",\"ma_price\":" << asset.ma_price << "}";
}
oss << "]";
oss << ",\"timestamp\":" << timestamp;
oss << "}";
std::string message = oss.str();
// Create a verify digest from the message
EVP_MD_CTX *ctx = EVP_MD_CTX_create();
int ret = 0;
if (ctx) {
ret = EVP_DigestVerifyInit(ctx, NULL, EVP_sha256(), NULL, pubkey);
if (ret == 1) {
ret = EVP_DigestVerifyUpdate(ctx, message.data(), message.length());
if (ret == 1) {
ret = EVP_DigestVerifyFinal(ctx, (const unsigned char *)signature.data(), signature.size());
}
}
}
// Cleanup the context we created
EVP_MD_CTX_destroy(ctx);
// Cleanup the openssl stuff
EVP_PKEY_free(pubkey);
if (ret == 1)
return true;
// Get the errors from OpenSSL
ERR_print_errors_fp (stderr);
return false;
}
// overload for pr validation for block
bool pricing_record::valid(cryptonote::network_type nettype, uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
{
if (hf_version < HF_VERSION_SLIPPAGE_YIELD) {
if (!this->empty())
return false;
}
if (this->empty())
return true;
if (!verifySignature(get_config(nettype).ORACLE_PUBLIC_KEY)) {
LOG_ERROR("Invalid pricing record signature.");
return false;
}
// validate the timestmap
if (this->timestamp > bl_timestamp + PRICING_RECORD_VALID_TIME_DIFF_FROM_BLOCK) {
LOG_ERROR("Pricing record timestamp is too far in the future.");
+2 -3
View File
@@ -42,7 +42,7 @@
#include <cstdint>
#include <string>
#include <cstring>
#include "serialization/containers.h"
#include "serialization/vector.h"
#include "cryptonote_config.h"
#include "crypto/hash.h"
@@ -131,8 +131,7 @@ namespace salvium_oracle
~pricing_record() noexcept;
bool equal(const pricing_record& other) const noexcept;
bool empty() const noexcept;
bool verifySignature(const std::string& public_key) const;
bool valid(cryptonote::network_type nettype, uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const;
bool valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const;
pricing_record& operator=(const pricing_record& orig) noexcept;
uint64_t operator[](const std::string& asset_type) const;
-114
View File
@@ -1,114 +0,0 @@
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
namespace serialization
{
namespace detail
{
template<typename T>
inline constexpr bool use_container_varint() noexcept
{
return std::is_integral<T>::value && std::is_unsigned<T>::value && sizeof(T) > 1;
}
template <typename Archive, class T>
typename std::enable_if<!use_container_varint<T>(), bool>::type
serialize_container_element(Archive& ar, T& e)
{
return do_serialize(ar, e);
}
template<typename Archive, typename T>
typename std::enable_if<use_container_varint<T>(), bool>::type
serialize_container_element(Archive& ar, T& e)
{
static constexpr const bool previously_varint = std::is_same<uint64_t, T>() || std::is_same<uint32_t, T>();
if (!previously_varint && ar.varint_bug_backward_compatibility_enabled() && !typename Archive::is_saving())
return do_serialize(ar, e);
ar.serialize_varint(e);
return true;
}
template <typename C>
void do_reserve(C &c, size_t N) {}
}
}
template <template <bool> class Archive, typename C>
bool do_serialize_container(Archive<false> &ar, C &v)
{
size_t cnt;
ar.begin_array(cnt);
if (!ar.good())
return false;
v.clear();
// very basic sanity check
if (ar.remaining_bytes() < cnt) {
ar.set_fail();
return false;
}
::serialization::detail::do_reserve(v, cnt);
for (size_t i = 0; i < cnt; i++) {
if (i > 0)
ar.delimit_array();
typename C::value_type e;
if (!::serialization::detail::serialize_container_element(ar, e))
return false;
::serialization::detail::do_add(v, std::move(e));
if (!ar.good())
return false;
}
ar.end_array();
return true;
}
template <template <bool> class Archive, typename C>
bool do_serialize_container(Archive<true> &ar, C &v)
{
size_t cnt = v.size();
ar.begin_array(cnt);
for (auto i = v.begin(); i != v.end(); ++i)
{
if (!ar.good())
return false;
if (i != v.begin())
ar.delimit_array();
if(!::serialization::detail::serialize_container_element(ar, (typename C::value_type&)*i))
return false;
if (!ar.good())
return false;
}
ar.end_array();
return true;
}
-128
View File
@@ -1,128 +0,0 @@
// Copyright (c) 2014-2022, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
#include <vector>
#include <deque>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include "serialization.h"
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::vector<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::vector<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::deque<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::deque<T> &v);
template<typename K, typename V>
class serializable_unordered_map: public std::unordered_map<K, V>
{
public:
typedef typename std::pair<K, V> value_type;
typename std::unordered_map<K, V> &parent() { return *this; }
};
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_unordered_map<K, V> &v);
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_unordered_map<K, V> &v);
template<typename K, typename V>
class serializable_map: public std::map<K, V>
{
public:
typedef typename std::pair<K, V> value_type;
typename std::map<K, V> &parent() { return *this; }
};
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_map<K, V> &v);
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_map<K, V> &v);
template<typename K, typename V>
class serializable_unordered_multimap: public std::unordered_multimap<K, V>
{
public:
typedef typename std::pair<K, V> value_type;
typename std::unordered_multimap<K, V> &parent() { return *this; }
};
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_unordered_multimap<K, V> &v);
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_unordered_multimap<K, V> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::unordered_set<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::unordered_set<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::set<T> &v);
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::set<T> &v);
namespace serialization
{
namespace detail
{
template <typename T> void do_reserve(std::vector<T> &c, size_t N) { c.reserve(N); }
template <typename T> void do_add(std::vector<T> &c, T &&e) { c.emplace_back(std::forward<T>(e)); }
template <typename T> void do_add(std::deque<T> &c, T &&e) { c.emplace_back(std::forward<T>(e)); }
template <typename K, typename V> void do_add(serializable_unordered_map<K, V> &c, std::pair<K, V> &&e) { c.insert(std::forward<std::pair<K, V>>(e)); }
template <typename K, typename V> void do_add(serializable_map<K, V> &c, std::pair<K, V> &&e) { c.insert(std::forward<std::pair<K, V>>(e)); }
template <typename K, typename V> void do_add(serializable_unordered_multimap<K, V> &c, std::pair<K, V> &&e) { c.insert(std::forward<std::pair<K, V>>(e)); }
template <typename T> void do_add(std::unordered_set<T> &c, T &&e) { c.insert(std::forward<T>(e)); }
template <typename T> void do_add(std::set<T> &c, T &&e) { c.insert(std::forward<T>(e)); }
}
}
#include "container.h"
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::vector<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::vector<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::deque<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::deque<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_unordered_map<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_unordered_map<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_map<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_map<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<false> &ar, serializable_unordered_multimap<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, typename K, typename V> bool do_serialize(Archive<true> &ar, serializable_unordered_multimap<K, V> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::unordered_set<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::unordered_set<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::set<T> &v) { return do_serialize_container(ar, v); }
template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::set<T> &v) { return do_serialize_container(ar, v); }
-169
View File
@@ -1,169 +0,0 @@
// Copyright (c) 2019, Haven Protocol
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
#include <vector>
#include "serialization.h"
#include "debug_archive.h"
#include "salvium_oracle/pricing_record.h"
#include "cryptonote_config.h"
// read
template <template <bool> class Archive>
bool do_serialize(Archive<false> &ar, salvium_oracle::supply_data &sd, uint8_t version)
{
ar.serialize_varint(sd.sal);
if (!ar.good())
return false;
ar.serialize_varint(sd.vsd);
if (!ar.good())
return false;
return true;
}
// write
template <template <bool> class Archive>
bool do_serialize(Archive<true> &ar, salvium_oracle::supply_data &sd, uint8_t version)
{
if (!ar.good())
return false;
ar.serialize_varint(sd.sal);
ar.serialize_varint(sd.vsd);
if (!ar.good())
return false;
return true;
}
// read
template <template <bool> class Archive>
bool do_serialize(Archive<false> &ar, salvium_oracle::asset_data &ad, uint8_t version)
{
ar.serialize_string(ad.asset_type);
if (!ar.good())
return false;
ar.serialize_varint(ad.spot_price);
if (!ar.good())
return false;
ar.serialize_varint(ad.ma_price);
if (!ar.good())
return false;
return true;
}
// write
template <template <bool> class Archive>
bool do_serialize(Archive<true> &ar, salvium_oracle::asset_data &ad, uint8_t version)
{
if (!ar.good())
return false;
ar.serialize_string(ad.asset_type);
if (!ar.good())
return false;
ar.serialize_varint(ad.spot_price);
if (!ar.good())
return false;
ar.serialize_varint(ad.ma_price);
if (!ar.good())
return false;
return true;
}
// read
template <template <bool> class Archive>
bool do_serialize(Archive<false> &ar, salvium_oracle::pricing_record &pr, uint8_t version)
{
// very basic sanity checks
if (!ar.good())
return false;
ar.serialize_varint(pr.pr_version);
if (!ar.good())
return false;
ar.serialize_varint(pr.height);
if (!ar.good())
return false;
if (!do_serialize(ar, pr.supply, version))
return false;
/*
// The next line should never do anything, but better safe than sorry
pr.asset_data.empty();
size_t asset_count;
ar.begin_array(asset_count);
if (!ar.good())
return false;
for (size_t idx=0; idx<asset_count; idx++) {
if (idx > 0) ar.delimit_array();
asset_data ad;
if (!do_serialize(ar, ad, version))
return false;
pr.asset_data.emplace_back(ad);
}
ar.end_array();
*/
if (!do_serialize_container(ar, pr.assets))
return false;
ar.serialize_varint(pr.timestamp);
if (!ar.good())
return false;
if (!do_serialize_container(ar, pr.signature))
return false;
return true;
}
// write
template <template <bool> class Archive>
bool do_serialize(Archive<true> &ar, salvium_oracle::pricing_record &pr, uint8_t version)
{
// very basic sanity checks
if (!ar.good())
return false;
ar.serialize_varint(pr.pr_version);
if (!ar.good())
return false;
ar.serialize_varint(pr.height);
if (!ar.good())
return false;
if (!do_serialize(ar, pr.supply, version))
return false;
if (!do_serialize_container(ar, pr.assets))
return false;
ar.serialize_varint(pr.timestamp);
if (!ar.good())
return false;
pr.signature.empty();
if (!do_serialize_container(ar, pr.signature))
return false;
return true;
}
//BLOB_SERIALIZER(salvium_oracle::supply_data);
//BLOB_SERIALIZER(salvium_oracle::asset_data);
//BLOB_SERIALIZER(salvium_oracle::pricing_record);
+23
View File
@@ -97,6 +97,29 @@ inline bool do_serialize(Archive &ar, bool &v)
bool r = ::do_serialize(ar, f); \
if (!r || !ar.stream().good()) return false; \
} while(0);
/*! \macro ENUM_FIELD(f, test)
* \brief tags and serializes (as a varint) the scoped enum \a f with a requirement that expression\
* \a test be true(typically for range testing).
*/
#define ENUM_FIELD(f, test) ENUM_FIELD_N(#f, f, test)
/*! \macro ENUM_FIELD_N(t, f, begin, end)
*
* \brief tags (as \a t) and serializes (as a varint) the scoped enum \a f with a requirement that
* expression \a test be true (typically for range testing).
*/
#define ENUM_FIELD_N(t, f, test) \
do { \
using enum_t = decltype(f); \
using int_t = typename std::underlying_type<enum_t>::type; \
int_t int_value = W ? static_cast<int_t>(f) : 0; \
ar.tag(t); \
ar.serialize_varint(int_value); \
if(!ar.stream().good()) return false; \
if(!W) { \
f = static_cast<enum_t>(int_value); \
if(!(test)) return false; \
} \
} while(0);
#define VARINT_FIELD(f) \
do { \
ar.tag(#f); \
+61 -9
View File
@@ -1,21 +1,21 @@
// Copyright (c) 2019, Haven Protocol
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
@@ -25,7 +25,7 @@
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
@@ -40,7 +40,8 @@
template <template <bool> class Archive>
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
{
if (version >= 4)
if (version >= 6)
{
// very basic sanity check
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record)) {
@@ -51,6 +52,21 @@ bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t
if (!ar.good())
return false;
}
else if (version >= 4)
{
// very basic sanity check
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record_v3)) {
return false;
}
zephyr_oracle::pricing_record_v3 pr_v3;
ar.serialize_blob(&pr_v3, sizeof(zephyr_oracle::pricing_record_v3), "");
if (!ar.good())
return false;
if (!pr_v3.write_to_pr(pr))
return false;
}
else if (version >= 3)
{
// very basic sanity check
@@ -91,10 +107,17 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record &pr, uint8_t
{
ar.begin_string();
if (version >= 4)
if (version >= 6)
{
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
}
else if (version >= 4)
{
zephyr_oracle::pricing_record_v3 pr_v3;
if (!pr_v3.read_from_pr(pr))
return false;
ar.serialize_blob(&pr_v3, sizeof(zephyr_oracle::pricing_record_v3), "");
}
else if (version >= 3)
{
zephyr_oracle::pricing_record_v2 pr_v2;
@@ -172,6 +195,35 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record_v2 &pr, uint8
return true;
}
// read
template <template <bool> class Archive>
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record_v3 &pr, uint8_t version)
{
// very basic sanity check
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record_v3)) {
return false;
}
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record_v3), "");
if (!ar.good())
return false;
return true;
}
// write
template <template <bool> class Archive>
bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record_v3 &pr, uint8_t version)
{
ar.begin_string();
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record_v3), "");
if (!ar.good())
return false;
ar.end_string();
return true;
}
BLOB_SERIALIZER(zephyr_oracle::pricing_record);
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v1);
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v2);
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v3);
+38 -2
View File
@@ -31,22 +31,38 @@
namespace zephyr_oracle {
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV"};
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD"};
const std::vector<std::string> RESERVE_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD", "ZYIELDRSV"};
const std::vector<std::string> ASSET_TYPES_V2 = {"ZPH", "ZSD", "ZRS", "ZYS"};
const std::vector<std::string> RESERVE_TYPES_V2 = {"DJED", "YIELD"};
class asset_type_counts
{
public:
// Fields
// Fields
uint64_t ZEPH;
uint64_t ZEPHUSD;
uint64_t ZEPHRSV;
uint64_t ZYIELD;
// v2 fields
uint64_t ZPH;
uint64_t ZSD;
uint64_t ZRS;
uint64_t ZYS;
asset_type_counts() noexcept
: ZEPH(0)
, ZEPHUSD(0)
, ZEPHRSV(0)
, ZYIELD(0)
, ZPH(0)
, ZSD(0)
, ZRS(0)
, ZYS(0)
{
}
@@ -58,6 +74,16 @@ namespace zephyr_oracle {
return ZEPHUSD;
} else if (asset_type == "ZEPHRSV") {
return ZEPHRSV;
} else if (asset_type == "ZYIELD") {
return ZYIELD;
} else if (asset_type == "ZPH") {
return ZPH;
} else if (asset_type == "ZSD") {
return ZSD;
} else if (asset_type == "ZRS") {
return ZRS;
} else if (asset_type == "ZYS") {
return ZYS;
}
return 0;
@@ -71,6 +97,16 @@ namespace zephyr_oracle {
ZEPHUSD += val;
} else if (asset_type == "ZEPHRSV") {
ZEPHRSV += val;
} else if (asset_type == "ZYIELD") {
ZYIELD += val;
} else if (asset_type == "ZPH") {
ZPH += val;
} else if (asset_type == "ZSD") {
ZSD += val;
} else if (asset_type == "ZRS") {
ZRS += val;
} else if (asset_type == "ZYS") {
ZYS += val;
}
}
};
+14 -6
View File
@@ -48,6 +48,7 @@ namespace zephyr_oracle
uint64_t reserve_ma;
uint64_t reserve_ratio;
uint64_t reserve_ratio_ma;
uint64_t yield_price;
uint64_t timestamp;
std::string signature;
@@ -60,12 +61,13 @@ namespace zephyr_oracle
KV_SERIALIZE(reserve_ma)
KV_SERIALIZE(reserve_ratio)
KV_SERIALIZE(reserve_ratio_ma)
KV_SERIALIZE(yield_price)
KV_SERIALIZE(timestamp)
KV_SERIALIZE(signature)
END_KV_SERIALIZE_MAP()
};
}
pricing_record::pricing_record() noexcept
: spot(0)
, moving_average(0)
@@ -75,6 +77,7 @@ namespace zephyr_oracle
, reserve_ma(0)
, reserve_ratio(0)
, reserve_ratio_ma(0)
, yield_price(0)
, timestamp(0)
{
std::memset(signature, 0, sizeof(signature));
@@ -94,6 +97,7 @@ namespace zephyr_oracle
reserve_ma = in.reserve_ma;
reserve_ratio = in.reserve_ratio;
reserve_ratio_ma = in.reserve_ratio_ma;
yield_price = in.yield_price;
timestamp = in.timestamp;
for (unsigned int i = 0; i < in.signature.length(); i += 2) {
std::string byteString = in.signature.substr(i, 2);
@@ -114,7 +118,7 @@ namespace zephyr_oracle
ss << std::hex << std::setw(2) << std::setfill('0') << (0xff & signature[i]);
sig_hex += ss.str();
}
const pr_serialized out{spot,moving_average,stable,stable_ma,reserve,reserve_ma,reserve_ratio,reserve_ratio_ma,timestamp,sig_hex};
const pr_serialized out{spot,moving_average,stable,stable_ma,reserve,reserve_ma,reserve_ratio,reserve_ratio_ma,yield_price,timestamp,sig_hex};
return out.store(dest, hparent);
}
@@ -127,6 +131,7 @@ namespace zephyr_oracle
, reserve_ma(orig.reserve_ma)
, reserve_ratio(orig.reserve_ratio)
, reserve_ratio_ma(orig.reserve_ratio_ma)
, yield_price(orig.yield_price)
, timestamp(orig.timestamp)
{
std::memcpy(signature, orig.signature, sizeof(signature));
@@ -142,11 +147,12 @@ namespace zephyr_oracle
reserve_ma = orig.reserve_ma;
reserve_ratio = orig.reserve_ratio;
reserve_ratio_ma = orig.reserve_ratio_ma;
yield_price = orig.yield_price;
timestamp = orig.timestamp;
::memcpy(signature, orig.signature, sizeof(signature));
return *this;
}
bool pricing_record::equal(const pricing_record& other) const noexcept
{
return ((spot == other.spot) &&
@@ -157,6 +163,7 @@ namespace zephyr_oracle
(reserve_ma == other.reserve_ma) &&
(reserve_ratio == other.reserve_ratio) &&
(reserve_ratio_ma == other.reserve_ratio_ma) &&
(yield_price == other.yield_price) &&
(timestamp == other.timestamp) &&
!::memcmp(signature, other.signature, sizeof(signature)));
}
@@ -233,8 +240,10 @@ namespace zephyr_oracle
return missing_rates;
} else if (hf_version <= 4) {
return missing_rates || (reserve_ratio == 0);
} else if (hf_version == 5) {
return missing_rates || (reserve_ratio == 0) || (reserve_ratio_ma == 0);
}
return missing_rates || (reserve_ratio == 0) || (reserve_ratio_ma == 0);
return missing_rates || (reserve_ratio == 0) || (reserve_ratio_ma == 0) || (yield_price == 0);
}
bool pricing_record::has_essential_rates(const uint8_t hf_version) const noexcept
@@ -247,7 +256,7 @@ namespace zephyr_oracle
}
// overload for pr validation for block
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
{
if (hf_version < 3) {
if (!this->empty())
@@ -289,4 +298,3 @@ namespace zephyr_oracle
return true;
}
}
+63 -3
View File
@@ -73,13 +73,25 @@ namespace zephyr_oracle
uint64_t timestamp;
unsigned char signature[64];
};
POD_CLASS pricing_record_pre_v3 {
uint64_t spot;
uint64_t moving_average;
uint64_t stable;
uint64_t stable_ma;
uint64_t reserve;
uint64_t reserve_ma;
uint64_t reserve_ratio;
uint64_t reserve_ratio_ma;
uint64_t timestamp;
unsigned char signature[64];
};
#pragma pack(pop)
class pricing_record
{
public:
// Fields
// Fields
uint64_t spot;
uint64_t moving_average;
uint64_t stable;
@@ -88,6 +100,7 @@ namespace zephyr_oracle
uint64_t reserve_ma;
uint64_t reserve_ratio;
uint64_t reserve_ratio_ma;
uint64_t yield_price;
uint64_t timestamp;
unsigned char signature[64];
@@ -114,7 +127,7 @@ namespace zephyr_oracle
{
return a.equal(b);
}
inline bool operator!=(const pricing_record& a, const pricing_record& b) noexcept
{
return !a.equal(b);
@@ -192,4 +205,51 @@ namespace zephyr_oracle
};
};
} // oracle
class pricing_record_v3
{
public:
uint64_t spot;
uint64_t moving_average;
uint64_t stable;
uint64_t stable_ma;
uint64_t reserve;
uint64_t reserve_ma;
uint64_t reserve_ratio;
uint64_t reserve_ratio_ma;
uint64_t timestamp;
unsigned char signature[64];
bool write_to_pr(zephyr_oracle::pricing_record &pr)
{
pr.spot = spot;
pr.moving_average = moving_average;
pr.stable = stable;
pr.stable_ma = stable_ma;
pr.reserve = reserve;
pr.reserve_ma = reserve_ma;
pr.reserve_ratio = reserve_ratio;
pr.reserve_ratio_ma = reserve_ratio_ma;
pr.yield_price = 0;
pr.timestamp = timestamp;
std::memcpy(pr.signature, signature, sizeof(pr.signature));
return true;
};
bool read_from_pr(zephyr_oracle::pricing_record &pr)
{
spot = pr.spot;
moving_average = pr.moving_average;
stable = pr.stable;
stable_ma = pr.stable_ma;
reserve = pr.reserve;
reserve_ma = pr.reserve_ma;
reserve_ratio = pr.reserve_ratio;
reserve_ratio_ma = pr.reserve_ratio_ma;
timestamp = pr.timestamp;
std::memcpy(signature, pr.signature, sizeof(signature));
return true;
};
};
} // zephyr_oracle
+14
View File
@@ -0,0 +1,14 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'1010c59099c206028309f83a444da29afb16cc97126b0d82a0ef9dacdc5f5384e4d14f2bed221f00000000030005bbd769abd769abd769abd769abd769abd76901ff99d7690580c8afa02502c7a7d056ac171af27f081eb7113ee31eb6eac4c523960f31bc54ae4150fd087a80c8afa025022a74a3c4c36d32e95633d44ba9a7b8188297b2ac91afecab826b86fabaa7091680bcc1960b02a42e0bf2c44c7c5f43798f4be091a04d36e21b7a2f85008ff939dc028c1d14e980bcc1960b02c8b180ae1eef14bb14953eb6b0f8d66111c80067dfe9e689fdf72cf1b0d9d58580bcc1960b027d3ab388e3e7844bc42562edf05fb34d4b30b281b1307c75d7d3acfc90ed69b57601a15624111f421a5b16fd3350b5b234d288aa9e369a090fcdaeab7079361a74600211000000228f09650000000000000000000001cb6e8a28b50d5427f24dd6ede582e5eb895d739ad2cfe7eb7df31d7dcf1531c47200000000000000000000000000000000000000000000000000000000000000000000', 'hex');
const b2 = u.convert_blob(b, 16);
const h1 = b2.toString('hex');
if (h1 === '1010c59099c206028309f83a444da29afb16cc97126b0d82a0ef9dacdc5f5384e4d14f2bed221f000000006ebc660a5f50595d256087798e91ff9184878de2db66d791108ec4149dcd01fc01') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0500ecb2ecb40646f61cfb8f3eb6f3527297eadd29125668008dc74c1ebb177cfb7d5c7c498dcd000000000199b25c01ffe7b15c043c02e42fc85c385aa98b9e83a75481a3fcd2ad049d59f3535c2775a15fae521aa37fc8010259fe9bb8bddfabed25331c90c1b478edb76fd9a94ced48c7b220498936f63268a01f02cbb7bf2ea054b438040c70bf8ba6c530b9890c0c8ca7019fef1c49d010321f61a08d060214c04c168d52662ac27d43c08c4941c4d7db9955bff0ec7e7ce1f0cd5f3bc68034014574cd7358bdee9f682543d2fa0cc23b207bf676688f40fd425d4f0477110cab02110000000000000000000000000000000000010df5931907c66fac569c743451aad0936db4d70f4d0fbcec44c504a2e02bd260'
, 'hex');
const b2 = u.convert_blob(b, 1);
const h1 = b2.toString('hex');
if (h1 === '0500ecb2ecb40646f61cfb8f3eb6f3527297eadd29125668008dc74c1ebb177cfb7d5c7c498dcd000000004baf51b919538baa7bdbad14d2b63817df2d301f6e7ccd9cf78ff95adad647a702') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0500d073b1220184edacc32f2186e7d8ed46ffa5473628d9388f1624e80e9c0e9a10000085b7ecb406000000000000000000000000000000000000000000000000000000000000000000000000010000000023032100000000000000000000000000000000000000000000000000000000000000000001b5e34501ffa1e34506ee240215b84a8550c5fd6d91c6d062b03eae5b2a6a20f080730d1fc44e2a94af6e3ecde0d403028001f4b155617d81db4d827c81898d11487e9bd047365843928bd0b01d317d5280ea30028091199c6ab679ca5e92a488ebe0c74175d1492a6477e35c3f27970358c29c8cc0843d024fe9895a4b8108f2ea4db2c1efabbb91fe0f9495cbc66b3905e37a61fb1942d180dac4090255b17d1462c3be7b994d91959a24112c55910e69d88a4eab539dab297355129980c2d72f02dca4f2d185fdf90d2255aa1801d5b5003df01587f17656862ec71b68b3b95b3434015706f2bc147c91ab357c5783c355967557df13d474844f0e0a0af8a2ae93f85b0211000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 2);
const h1 = b2.toString('hex');
if (h1 === '010085b7ecb406d073b1220184edacc32f2186e7d8ed46ffa5473628d9388f1624e80e9c0e9a10000000007f6c5d24796ce8a92079a8e6a93c1599b53bc48fa7654765512f1dc1060dcf5d01') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'08089eb3ecb406b35852af53db5ed822f0c51cfcfeb36a0c83fa55230a791add87087d221308c70000000001abd2c30101ffefd1c30101f7d7c0c084110220323306fc36cf0fed316f4d90f6ce0e04ec5b8e26b52886025f7a77957676cc340165706e1dd751a5bd9a72e58caf30104216b60fba751e8d681af90bc4df00cdd40211000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 6);
const h1 = b2.toString('hex');
if (h1 === '08089eb3ecb406b35852af53db5ed822f0c51cfcfeb36a0c83fa55230a791add87087d221308c700000000ab937b64d0d1087c03155686ae5bdd27b79233f43dae45977f620b863590596c010000000000000000000000000000000000000000000000000000000000000000') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
Executable
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash -x
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
node arq.js || exit 1
node bloc.js || exit 1
node ird.js || exit 1
node msr.js || exit 1
node ryo.js || exit 1
node sal.js || exit 1
node tube.js || exit 1
node xeq.js || exit 1
node xhv.js || exit 1
node xla.js || exit 1
node xmr.js || exit 1
node xmv.js || exit 1
node xtnc.js || exit 1
node zeph.js || exit 1
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0909bcb7ecb406e417dd02e55e8c3f6368749df3e761b000f87001e28ccb9c24f1d65f2cc848d70000000003e5f93701ffa9f9370181a0f693710231510ef639f6848581cc3df0ab1783f73fd401d4ab03df62dfad68f8557bad943401f3cc08c30d31a225b46514edfccc4b3c0d429cac30b23e1e4fd9e1c514f5b350021100000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 4);
const h1 = b2.toString('hex');
if (h1 === '0909bcb7ecb406e417dd02e55e8c3f6368749df3e761b000f87001e28ccb9c24f1d65f2cc848d7000000008c95c259fa076f11347c4129bf1020da140d44f3948410c0f3a77d1b4d18a21f01') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0202fdaca8b906b1670506d0dc45b11cbc87f9ceedfd0cbfa56c14da72ccc27c45105391d2340300000000020001ffbabe0501a1ca9fab2a035c20fce0617f61abf3872058e15b90650b2ac812bf344766f56ee54b680f571e0353414c3c863401618163d383093580900f735ea9ad5d3d0029dd94c2f2a35db88ec37dc32e863302110000bcdd9d15420000000000000000000001c8f2e7ca0a00020001ffbabe05002301bb1086494863ac8de0987e09f7193ac85a356f8abf8725202cbf4dea8b2611f20400020000'
, 'hex');
const b2 = u.convert_blob(b, 15);
const h1 = b2.toString('hex');
if (h1 === '0202fdaca8b906b1670506d0dc45b11cbc87f9ceedfd0cbfa56c14da72ccc27c45105391d2340300000000604ec6923c81b6477bb224a9c53158cea5c5aee36100aad59c498d3dab92750402') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0d0df9baecb4060567fc85623e264062d2d0593b8d63a956249d0b2588fd53111f446694b02110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000282b1d00301ffc6b0d00301b798fdd01602cee1a6bd4cce3cab8daccc0cef76dea2302af21e576c00957f8f7fd4bace7d4b34018571692c36ef35b1802ccc87b968684fa2581d7f6f634312bf4d66e2347a6c49021100000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 10);
const h1 = b2.toString('hex');
if (h1 === '0d0d791d9b66000000000567fc85623e264062d2d0593b8d63a956249d0b2588fd53111f446694b02110beef88d4195143229591bb6efd2d40780d7da377d165a39afadead64e4add0b1010000000000000000') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'151593b6ecb406b4018d3e3a5d07eb8af63e106bd53c773d6a46957758d8e6aba76c8744fe2536000000000403b8a353b8a353b8a353b8a35301fffca25303d6960302cb745225654660476da30e1f2e120a45d253ec764f37b68789f43dba417c6c90ff79026de51b2d1226d359075b5d1ae4d62658976598d4b1d8ac6780b01aaa6d47156cf9c90802dffece08e302c8258e61d55e8788a10804b0ca0276c8036709dee77d1a0f22627601bcab5b456bf3c2f097ca6b719c29d51766acaec6b9694da2234a02f6f466a1130211000000000000000000000000000000000001ecbaeea4421709ed164473327633de0fb7c4180dc805afa388e7fc5c45a7a0c87299d794018183ea0fa1e697647f7bc6f92bfec1d65ac1b4795527c86483a0ed4f000000'
, 'hex');
const b2 = u.convert_blob(b, 5);
const h1 = b2.toString('hex');
if (h1 === '151593b6ecb406b4018d3e3a5d07eb8af63e106bd53c773d6a46957758d8e6aba76c8744fe253600000000775fb8dc7335f11e8c7f381effe8e94a1a7f0e5dca3b9c97b775de1ed434317101') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'1717c3b0ecb40661bb2e3f4c03e0feb67a7a48a1739630d157da8b945a0f7de88fd12174073293000000009085dbf70700000060e5d3180000000070aac5495c010000f056e500000000000000000000000000003108edce000000b0254fc09b060000f0f49af4d5000000406eea2ab4000000d079eb28268f000000000000000000000300000000000000ac22ea6b06000000007073910800000050393df8220000000097727e2c00000044189b66000000001efdfe115f5b28a68f373b71720171f844f348676fed7ea239522b64d215af629909b820c571c282826fe024a4a44d3b86aa8848193ca1c3240f2335d971e5f30801ffa9cb6504ae9ecd82d62807ab26cbcc59cbb14ca430ba3a5b0bae8f6fc9f626c43f8989d6922e5e41cb13e503584856e5cb650000f0fbc491809202071ee8bb35868f6fa6c981446d1965e7e2ebbbf8b484858ec5102527f48e74aca303584856e5cb6500000e94ae8f5b070ec031da424efb260e3cbb9fc95aedd4f372a9a71d7b06213b3768fa085bf8d503584856e5cb650000729ceee5040709183028fb4169646a11fa6abacdf95b266c7ed29f8950fc219f215b7ae4f1ea03584856e5cb6500009c5501d1ee9ada2dadb688034c51d7b50ade575d4240628c3ca2f1ec27560f0587411d0211000000000000000000000000000000000001efa3c7bc5a333d0e37729347a844695dafada545f7817cdefbb53ebe624191eb0000000001a08b2344a3ab1756ef88d6d0e37565f114698ac6353b88629e059c74ebdb3bc6'
, 'hex');
const b2 = u.convert_blob(b, 11);
const h1 = b2.toString('hex');
if (h1 === '1717c3b0ecb40661bb2e3f4c03e0feb67a7a48a1739630d157da8b945a0f7de88fd12174073293000000009085dbf70700000060e5d3180000000070aac5495c010000f056e500000000000000000000000000003108edce000000b0254fc09b060000f0f49af4d5000000406eea2ab4000000d079eb28268f000000000000000000000300000000000000ac22ea6b06000000007073910800000050393df8220000000097727e2c00000044189b66000000001efdfe115f5b28a68f373b71720171f844f348676fed7ea239522b64d215af629909b820c571c282826fe024a4a44d3b86aa8848193ca1c3240f2335d971e5f3961bdcdf2cada4fd0f498612e2680fedb0dbe06788ed69e60cfb465366f33f6402') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'1010b9b7ecb4060404b45248c01f9a65d5b2e5ec3fd875de7e8bff8eb79453fd87c0d39e04546b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002b6ea3f01fffae93f01dcc50a0308686987f2c9643b5c20a29f1d124b4330b5e7c94f242f4be451303a82a2c635123401c2ea0da83a76b72a1e4b581143febf8f08155eeb3482955e2b4d0c43507ebba4021100000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 14);
const h1 = b2.toString('hex');
if (h1 === '1010b9b7ecb4060404b45248c01f9a65d5b2e5ec3fd875de7e8bff8eb79453fd87c0d39e04546b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004fed0302f50f72bf1ac330a367b4ea32a24fb5de5b91a927392eaa318b342cca01') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'1010f4b3ecb406a7e85c45ba044af4a16e0e790032f31727e3daef1a7da5ab12c9894c191713e30000000002a18ec30101ffe58dc30101c084aa98d21103d71cd8a7478f0c74e191f3dac85b4c396ec76a07311a94db04721676634ab49b1e34014f9b1e0434876de264409d8f024f5f61fdcb9297ef671518310e7add0e69bc270211000000000000000000000000000000000000238dc39cf2f9eef8084b911d6086075ea57b58793ec2a0a8683f5d890a5be1c92583892a3f5127cb3469da37719047fbdd5bc32034c996a9e3919485d36ac5f609c646379ca888796d7485d403f45ab2230b66920c8f0b1e160d4b6529f531ca95bc04dfc96e7643a9f86526ba4e899fa52d2279abf2cf8b60e4be19f9f9b293211f508353cb5496f04b7e9824395828385e7724a2e2fa42097962028fd7c5083fa3e827d9f46dbf3741181d4f4897aea254bbc2081a3455603c81bfd75961541cb3f1ad55fa277111b5e4b3b7ce10c1bbdca7e158d36deac6c09ef9827edea7d6dce44f1145831d29d7ac59e497050af0a19de855302ff70079e60761d6bae70dc45a766e7088e764e6950e5a9704e03e5a455b23a572af2950c613d6d109b2007a7c943e4b0c2513ced71179b0dd0388fa0c397b83d4ebeb616cbe89c6c2d12972bdbbe845f78189fd3b0494bcac392b8ec9a6c2d49d88c391c54fd2bf0ba45aded1dbff66fe6311c293b6ae1f47127ad936890cfc2379427be0360b68007ae3dd56083a4eb90d736370b23471dd5d2b7ee2107bd44016e20b9a948e745b2de2cbcd7780e981b0eeb646175137e8b42a9b9724263d9a84d9ba892caa209c73ca03ab832e504d309a6714e8554b13b3c05f306f0e46c06c801978e7f69727b8333709fe7c836286cefd36ef22a4681653d04a96ce91d5f97aee107f93cd5f57c3f5f553e435a910c60f426b3f3658754e72a55ea8b40eda985147558159296bfa23ab9cbbd2e8316a00b87ea81195d8b4a3d4ec2889a788af0d4ce53b4e261a1087eae0f54cc92132f87a5aadadd3ea70228df71a615b85a1d96bc031d08e6fafb41117b055c9db533d27fcacc14a251369654c377d451e2eeb7aa7d26ff12542c5b7194d2b783b493435c0bee44b9ee315aa373dd79ed7abebe2095e547867f0db8cda9a8544f306a74e96a7023e637642f63bc5fa27dcfae1a59655b7170fee88c7362f676b6b4e5aee6c94cdfda39075138bf4fb0da0f7490ea33d85d8d72a23695f30f14f65edd4715aacc897d6be2df0e6566c3d484945f2b4ac5e6dab45306d2e8704ba8590388d7d41620ed4171701c5d8eab8b0e1192075606b70dc00014089e31fee4ae2aaa3dc49c9018ec93497818eb1348bedf3b2d0af7ccc4bb5bb151a7e9b1759d46db0e3b4acb08f639ae61a43aff57f1f9f8baff9205d4350733a8bd2f99acb417ef81fd5affb56cf85019fc23bcc03359b0d57c62a94efae9028a7353f11edc5f304fd59cc24ecfcd40db5e5354ebb288d64934c4bf3e56a37c612043d49335e52a1788998cbf3a1cc09bc78c9ffbac1346a4fad340727ee9aa20c00ebf5131556fbdbf842469d31c8121feae78c3a56ba1eae5bde78c18371108601e8ae7f5698d0918be8e52afc500fa67c35b46e8011b686e9a5e20008b7dfd3eb85011f54a70832823611dc06373d1b98052a503313a6e4d0eab3ad97f04dac2305cbb4fa094c6634270289593f90ffcd460529d0835bdfe780074488d531ebb06558ba4b28ece031cfd981062beec659c6a50addfefaf2e4e1e11f95'
, 'hex');
const b2 = u.convert_blob(b, 0);
const h1 = b2.toString('hex');
if (h1 === '1010f4b3ecb406a7e85c45ba044af4a16e0e790032f31727e3daef1a7da5ab12c9894c191713e300000000980c1b19961064ad5ceba387074e29030eac8378bcb38f5a50189f8892c4578324') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0d0d9ab8ecb406317c2fb5d01d1baccedab49650312ee4c5390f0f569a77f6703f9c617e9de92f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002d5ef8e0101ff99ef8e0101bea394bad10802a50df09ab1bbdb1e9be7e626b9746266c0a8193f649db53affe59ff69ff268843401ed630c83e0a68cc91762ba50312078e4299aff7eb9aa011c751c760c4ee15f2c021100000000000000000000000000000000000000'
, 'hex');
const b2 = u.convert_blob(b, 8);
const h1 = b2.toString('hex');
if (h1 === '0d0d1a1c9b6600000000317c2fb5d01d1baccedab49650312ee4c5390f0f569a77f6703f9c617e9de92fe8e1af3e87d14e8aa51dd2cc397f8d455ac486ec069fb832b45fe7123dca5d42010000000000000000') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'0c0cabb9ecb406eef6a95a820ac36c32f1903e87623cae5483806e8cfa5b3dd30847c6c8b1c0760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000302b3e049b3e04900b3e04901ff95e04902a2a794f82e0213b0b305b676cf7df3dd4acec81b8a76cb11fa4afc2ddde258e8d18f8fe2f91aa4d6dd93340231b43a96d2a95423341311b94d1bf0e0a800900ed52969058cd18090d142d4437601122ea38d8e53fe2fd288c0e3f47842fd27b99229422b703dd7f2c0c4c15dec8c02110000000000000000000000000000000000018e08c827ececc945a2111283aed96225a00c67b8e549c22a557f15548bdb552b72c80438e83eb7bc50eda08e45a86c0f763d7120eb61185f2763377d24e0b4eaa90000'
, 'hex');
const b2 = u.convert_blob(b, 9);
const h1 = b2.toString('hex');
if (h1 === '0c0cab1c9b6600000000eef6a95a820ac36c32f1903e87623cae5483806e8cfa5b3dd30847c6c8b1c076df4dfa482c794850801d547e98d954b0eae288c2cd74d7378de62fa44f83d2e301') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}
+15
View File
@@ -0,0 +1,15 @@
"use strict";
let u = require('../build/Release/cryptoforknote');
const b = Buffer.from(
'050592b8ecb406407f1bf945d1f437a1705b323f46a86e18d0882a516f7b0582a4b208bf577e710000000090cbdb40c1020000903f4ebcb9020000f0d8bbdd4c00000070b623b84d0000006045baf33701000070a2fd163701000040521b4fda05000010758b35c8050000131c9b66000000005f9669b40d9a190f51d226502bad1bbc8fea45e18f4c87dee8cd273efbfd69e27219defe1a6480b68f1a5205e72d63246d5565a2f19bbfc9816005bc8ebb89f703c99d1201ff8d9d1202b5c3c8a38099020208f52c744b1455ec58ab17ea0202a64b605ed1c6cffc88fd41eb3cc76b7d2abd045a455048cdfbfba6f1dd120235aebd0d4d356555503a5460b569a4e0e8b7ded8757b85531ed5b02fa2d998ba045a455048ce55014b0868384957bedcd9b70d6c141f3f811a41bcee8f44813f92fcc6cb428e037c021100000000000000000000000000000000000129cb6a3ab186d3fbccedb4fcc119931ab8e9aee73f4aea4e77778a0ba987a99e0000000000'
, 'hex');
const b2 = u.convert_blob(b, 13);
const h1 = b2.toString('hex');
if (h1 === '050592b8ecb406407f1bf945d1f437a1705b323f46a86e18d0882a516f7b0582a4b208bf577e710000000090cbdb40c1020000903f4ebcb9020000f0d8bbdd4c00000070b623b84d0000006045baf33701000070a2fd163701000040521b4fda05000010758b35c8050000131c9b66000000005f9669b40d9a190f51d226502bad1bbc8fea45e18f4c87dee8cd273efbfd69e27219defe1a6480b68f1a5205e72d63246d5565a2f19bbfc9816005bc8ebb89f7220309a73319964e8560ce2be3f523d1cd4f36d366a503acb1d44dadeb9e8c8101') {
console.log('PASSED');
} else {
console.log('FAILED: ' + h1);
process.exit(1);
}