Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5afa141942 | |||
| 088a0f4c00 | |||
| c75b1d464b | |||
| b3e74bffda | |||
| c696b5b43f | |||
| 084ea7fd77 | |||
| e7a1430242 | |||
| a138d12221 | |||
| dd63cb209d | |||
| 161ec204e6 | |||
| 2104ac35d5 | |||
| 30a1cf7813 | |||
| 32dfbcf8ea | |||
| b8d2ba017e | |||
| b18445f6e7 | |||
| bea129bb73 | |||
| 690e900011 | |||
| 516511da69 | |||
| 0aadf3db51 | |||
| be8c2e9c8f | |||
| 66854eb683 | |||
| a9f2317ffa | |||
| eea6d166b2 | |||
| 6bb5e00c17 | |||
| 7bbb0cf80e | |||
| 16f9569d0c | |||
| e6143eb9c0 | |||
| 1b2f6af8f8 |
@@ -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
|
||||
|
||||
+2
-1
@@ -4,9 +4,10 @@
|
||||
"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",
|
||||
"src/crypto/tree-hash.c",
|
||||
"src/crypto/crypto.cpp",
|
||||
"src/crypto/crypto-ops.c",
|
||||
|
||||
@@ -64,12 +64,12 @@ function transaction_hash3(transaction, forWitness) {
|
||||
return hash256_3(transaction.__toBuffer(undefined, undefined, forWitness));
|
||||
}
|
||||
|
||||
function getMerkleRoot(transactions, transaction_hash_func) {
|
||||
function getMerkleRoot(transactions, transaction_hash_func, detectWitness) {
|
||||
if (transactions.length === 0) return Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
|
||||
const forWitness = txesHaveWitnessCommit(transactions);
|
||||
const forWitness = detectWitness ? txesHaveWitnessCommit(transactions) : false;
|
||||
const hashes = transactions.map(transaction => transaction_hash_func(transaction, forWitness));
|
||||
const rootHash = fastMerkleRoot(hashes, hash256);
|
||||
return forWitness ? hash256_3(Buffer.concat([rootHash, transactions[0].ins[0].witness[0]])) : rootHash;
|
||||
return forWitness ? hash256(Buffer.concat([rootHash, transactions[0].ins[0].witness[0]])) : rootHash;
|
||||
}
|
||||
|
||||
let last_epoch_number;
|
||||
@@ -175,7 +175,7 @@ module.exports.RavenBlockTemplate = function(rpcData, poolAddress) {
|
||||
};
|
||||
};
|
||||
|
||||
function update_merkle_root_hash(offset, payload, blob_in, blob_out, transaction_hash_func) {
|
||||
function update_merkle_root_hash(offset, payload, blob_in, blob_out, transaction_hash_func, detectWitness) {
|
||||
const nTransactions = varuint.decode(blob_in, offset);
|
||||
offset += varuint.decode.bytes;
|
||||
let transactions = [];
|
||||
@@ -184,7 +184,7 @@ function update_merkle_root_hash(offset, payload, blob_in, blob_out, transaction
|
||||
transactions.push(tx);
|
||||
offset += tx.byteLength();
|
||||
}
|
||||
getMerkleRoot(transactions, transaction_hash_func).copy(blob_out, 4 + 32);
|
||||
getMerkleRoot(transactions, transaction_hash_func, detectWitness).copy(blob_out, 4 + 32);
|
||||
};
|
||||
|
||||
module.exports.blockHashBuff = function(blobBuffer) {
|
||||
@@ -197,12 +197,12 @@ module.exports.blockHashBuff3 = function(blobBuffer) {
|
||||
|
||||
module.exports.convertRavenBlob = function(blobBuffer) {
|
||||
let header = blobBuffer.slice(0, 80);
|
||||
update_merkle_root_hash(80 + 8 + 32, false, blobBuffer, header, transaction_hash);
|
||||
update_merkle_root_hash(80 + 8 + 32, false, blobBuffer, header, transaction_hash, true);
|
||||
return module.exports.blockHashBuff(header);
|
||||
};
|
||||
|
||||
module.exports.constructNewRavenBlob = function(blockTemplate, nonceBuff, mixhashBuff) {
|
||||
update_merkle_root_hash(80 + 8 + 32, false, blockTemplate, blockTemplate, transaction_hash);
|
||||
update_merkle_root_hash(80 + 8 + 32, false, blockTemplate, blockTemplate, transaction_hash, true);
|
||||
nonceBuff.copy (blockTemplate, 80, 0, 8);
|
||||
mixhashBuff.copy(blockTemplate, 88, 0, 32);
|
||||
return blockTemplate;
|
||||
@@ -239,24 +239,24 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||
|
||||
module.exports.convertRtmBlob = function(blobBuffer) {
|
||||
let header = blobBuffer.slice(0, 80);
|
||||
update_merkle_root_hash(80, true, blobBuffer, header, transaction_hash);
|
||||
update_merkle_root_hash(80, true, blobBuffer, header, transaction_hash, true);
|
||||
return header;
|
||||
};
|
||||
|
||||
module.exports.convertKcnBlob = function(blobBuffer) {
|
||||
let header = blobBuffer.slice(0, 80);
|
||||
update_merkle_root_hash(80, false, blobBuffer, header, transaction_hash3);
|
||||
update_merkle_root_hash(80, false, blobBuffer, header, transaction_hash3, false);
|
||||
return header;
|
||||
};
|
||||
|
||||
module.exports.constructNewRtmBlob = function(blockTemplate, nonceBuff) {
|
||||
update_merkle_root_hash(80, true, blockTemplate, blockTemplate, transaction_hash);
|
||||
update_merkle_root_hash(80, true, blockTemplate, blockTemplate, transaction_hash, true);
|
||||
nonceBuff.copy(blockTemplate, 76, 0, 4);
|
||||
return blockTemplate;
|
||||
};
|
||||
|
||||
module.exports.constructNewKcnBlob = function(blockTemplate, nonceBuff) {
|
||||
update_merkle_root_hash(80, false, blockTemplate, blockTemplate, transaction_hash3);
|
||||
update_merkle_root_hash(80, false, blockTemplate, blockTemplate, transaction_hash3, false);
|
||||
nonceBuff.copy(blockTemplate, 76, 0, 4);
|
||||
return blockTemplate;
|
||||
};
|
||||
|
||||
+8
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cryptoforknote-util",
|
||||
"version": "15.3.15",
|
||||
"version": "15.5.14",
|
||||
"author": {
|
||||
"name": "LucasJones",
|
||||
"email": "lucasjonesdev@hotmail.co.uk"
|
||||
@@ -10,16 +10,16 @@
|
||||
"url": "https://github.com/haven-protocol-org/node-cryptoforknote-util.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"promise": "*",
|
||||
"bindings": "*",
|
||||
"nan": "^2.14.2",
|
||||
"bignum": "^0.13.1",
|
||||
"sha3": "*",
|
||||
"base58-native": "*",
|
||||
"bech32": "*",
|
||||
"varuint-bitcoin": "^1.0.4",
|
||||
"bignum": "^0.13.1",
|
||||
"bindings": "*",
|
||||
"bitcoinjs-lib": "git+https://github.com/MoneroOcean/bitcoinjs-lib.git",
|
||||
"merkle-lib": "^2.0.10",
|
||||
"bitcoinjs-lib": "git+https://github.com/MoneroOcean/bitcoinjs-lib.git"
|
||||
"nan": "^2.20.0",
|
||||
"promise": "*",
|
||||
"sha3": "*",
|
||||
"varuint-bitcoin": "^1.0.4"
|
||||
},
|
||||
"keywords": [
|
||||
"cryptonight",
|
||||
|
||||
@@ -173,13 +173,13 @@ function createTransactionOutput(amount, payee, rewardToPool, reward, txOutputBu
|
||||
return { reward: reward - amount, rewardToPool: rewardToPool - amount };
|
||||
}
|
||||
|
||||
function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
||||
function generateTransactionOutputs(rpcData, poolAddress) {
|
||||
let reward = rpcData.coinbasevalue + (rpcData.coinbasedevreward ? rpcData.coinbasedevreward.value : 0);
|
||||
let rewardToPool = reward;
|
||||
let txOutputBuffers = [];
|
||||
|
||||
if (rpcData.coinbasedevreward) {
|
||||
const rewards = createTransactionOutput(rpcData.coinbasedevreward.value, rpcData.coinbasedevreward.address, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.coinbasedevreward.scriptpubkey, 'hex'));
|
||||
const rewards = createTransactionOutput(rpcData.coinbasedevreward.value, null, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.coinbasedevreward.scriptpubkey, 'hex'));
|
||||
reward = rewards.reward;
|
||||
rewardToPool = rewards.rewardToPool;
|
||||
}
|
||||
@@ -215,16 +215,16 @@ function generateTransactionOutputs(rpcData, poolAddress, is_witness) {
|
||||
|
||||
createTransactionOutput(rewardToPool, null, rewardToPool, reward, txOutputBuffers, Buffer.from(addressToScript(poolAddress), "hex"));
|
||||
|
||||
if (is_witness) {
|
||||
const witness_commitment = Buffer.from(rpcData.default_witness_commitment, 'hex');
|
||||
if (rpcData.default_witness_commitment) {
|
||||
createTransactionOutput(0, null, rewardToPool, reward, txOutputBuffers, Buffer.from(rpcData.default_witness_commitment, 'hex'));
|
||||
txOutputBuffers.push(Buffer.concat([
|
||||
varIntBuffer(1),
|
||||
varIntBuffer(witness_commitment.length),
|
||||
witness_commitment
|
||||
varIntBuffer(32),
|
||||
Buffer.alloc(32, 0)
|
||||
]));
|
||||
}
|
||||
|
||||
return Buffer.concat([ varIntBuffer(is_witness ? txOutputBuffers.length - 1 : txOutputBuffers.length), Buffer.concat(txOutputBuffers)]);
|
||||
return Buffer.concat([ varIntBuffer(rpcData.default_witness_commitment ? txOutputBuffers.length - 1 : txOutputBuffers.length), Buffer.concat(txOutputBuffers)]);
|
||||
}
|
||||
|
||||
module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||
@@ -240,7 +240,7 @@ module.exports.RtmBlockTemplate = function(rpcData, poolAddress) {
|
||||
|
||||
const scriptSigPart2 = serializeString('/nodeStratum/');
|
||||
|
||||
const is_witness = false; //rpcData.default_witness_commitment !== undefined;
|
||||
const is_witness = rpcData.default_witness_commitment !== undefined;
|
||||
|
||||
const blob1 = Buffer.concat([
|
||||
coinbaseVersion,
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "cryptonote_protocol/blobdatatype.h"
|
||||
#include "offshore/pricing_record.h"
|
||||
#include "zephyr_oracle/pricing_record.h"
|
||||
#include "salvium_oracle/pricing_record.h"
|
||||
|
||||
|
||||
namespace cryptonote
|
||||
@@ -48,7 +49,19 @@ namespace cryptonote
|
||||
|
||||
typedef std::vector<crypto::signature> ring_signature;
|
||||
|
||||
|
||||
enum salvium_transaction_type
|
||||
{
|
||||
UNSET = 0,
|
||||
MINER = 1,
|
||||
PROTOCOL = 2,
|
||||
TRANSFER = 3,
|
||||
CONVERT = 4,
|
||||
BURN = 5,
|
||||
STAKE = 6,
|
||||
RETURN = 7,
|
||||
MAX = 7
|
||||
};
|
||||
|
||||
/* outputs */
|
||||
|
||||
struct txout_to_script
|
||||
@@ -167,6 +180,41 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
// SALVIUM
|
||||
struct txout_salvium_key
|
||||
{
|
||||
txout_salvium_key() { }
|
||||
txout_salvium_key(const crypto::public_key &_key, const std::string &_asset_type, const uint64_t &_unlock_time) :
|
||||
key(_key), asset_type(_asset_type), unlock_time(_unlock_time) { }
|
||||
crypto::public_key key;
|
||||
std::string asset_type;
|
||||
uint64_t unlock_time;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key)
|
||||
FIELD(asset_type)
|
||||
VARINT_FIELD(unlock_time)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct txout_salvium_tagged_key
|
||||
{
|
||||
txout_salvium_tagged_key() { }
|
||||
txout_salvium_tagged_key(const crypto::public_key &_key, const std::string &_asset_type, const uint64_t &_unlock_time, const crypto::view_tag &_view_tag) :
|
||||
key(_key), asset_type(_asset_type), unlock_time(_unlock_time), view_tag(_view_tag) { }
|
||||
crypto::public_key key;
|
||||
std::string asset_type;
|
||||
uint64_t unlock_time;
|
||||
crypto::view_tag view_tag; // optimization to reduce scanning time
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key)
|
||||
FIELD(asset_type)
|
||||
VARINT_FIELD(unlock_time)
|
||||
FIELD(view_tag)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
/* inputs */
|
||||
|
||||
struct txin_gen
|
||||
@@ -290,11 +338,28 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct txin_salvium_key
|
||||
{
|
||||
uint64_t amount;
|
||||
std::string asset_type;
|
||||
std::vector<uint64_t> key_offsets;
|
||||
crypto::key_image k_image; // double spending protection
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(amount)
|
||||
FIELD(asset_type)
|
||||
FIELD(key_offsets)
|
||||
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;
|
||||
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key> txout_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_to_key, txout_offshore, txout_xasset, txout_haven_key, txout_haven_tagged_key> txout_xhv_target_v;
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_salvium_key, txout_salvium_tagged_key> txout_salvium_target_v;
|
||||
|
||||
typedef boost::variant<txout_to_script, txout_to_scripthash, txout_zephyr_tagged_key> txout_stablero_target_v;
|
||||
|
||||
@@ -331,6 +396,17 @@ namespace cryptonote
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
struct tx_out_salvium
|
||||
{
|
||||
uint64_t amount;
|
||||
txout_salvium_target_v target;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(amount)
|
||||
FIELD(target)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
|
||||
enum loki_version
|
||||
{
|
||||
@@ -352,9 +428,11 @@ namespace cryptonote
|
||||
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<txin_zephyr_v> vin_zephyr;
|
||||
std::vector<txin_salvium_v> vin_salvium;
|
||||
std::vector<tx_out> vout;
|
||||
std::vector<tx_out_xhv> vout_xhv;
|
||||
std::vector<tx_out_zephyr> vout_zephyr;
|
||||
std::vector<tx_out_salvium> vout_salvium;
|
||||
//extra
|
||||
std::vector<uint8_t> extra;
|
||||
// Block height to use PR from
|
||||
@@ -366,6 +444,23 @@ namespace cryptonote
|
||||
std::vector<uint64_t> output_unlock_times;
|
||||
std::vector<uint32_t> collateral_indices;
|
||||
|
||||
// SALVIUM-SPECIFIC FIELDS
|
||||
// TX type
|
||||
cryptonote::salvium_transaction_type tx_type;
|
||||
// Return address
|
||||
crypto::public_key return_address;
|
||||
// Return TX public key
|
||||
crypto::public_key return_pubkey;
|
||||
// Source asset type
|
||||
std::string source_asset_type;
|
||||
// Destination asset type (this is only necessary for CONVERT transactions)
|
||||
std::string destination_asset_type;
|
||||
// Circulating supply information - already provided by Haven
|
||||
//uint64_t amount_burnt;
|
||||
// Slippage limit
|
||||
uint64_t amount_slippage_limit;
|
||||
|
||||
|
||||
//
|
||||
// NOTE: Loki specific
|
||||
//
|
||||
@@ -629,7 +724,27 @@ namespace cryptonote
|
||||
VARINT_FIELD(pricing_record_height)
|
||||
VARINT_FIELD(amount_burnt)
|
||||
VARINT_FIELD(amount_minted)
|
||||
|
||||
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
|
||||
VARINT_FIELD(version)
|
||||
//if(version == 0 || CURRENT_TRANSACTION_VERSION < version) return false;
|
||||
VARINT_FIELD(unlock_time)
|
||||
FIELD(vin_salvium)
|
||||
FIELD(vout_salvium)
|
||||
FIELD(extra)
|
||||
VARINT_FIELD(tx_type)
|
||||
if (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)
|
||||
FIELD(source_asset_type)
|
||||
FIELD(destination_asset_type)
|
||||
VARINT_FIELD(amount_slippage_limit)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
VARINT_FIELD(version)
|
||||
@@ -722,7 +837,7 @@ namespace cryptonote
|
||||
else
|
||||
{
|
||||
ar.tag("rct_signatures");
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? !vin_zephyr.empty() : !vin.empty())
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM ? !vin_salvium.empty() : (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? !vin_zephyr.empty() : !vin.empty()))
|
||||
{
|
||||
ar.begin_object();
|
||||
bool r;
|
||||
@@ -730,6 +845,8 @@ namespace cryptonote
|
||||
r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout_xhv.size());
|
||||
else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR)
|
||||
r = rct_signatures.serialize_rctsig_base(ar, vin_zephyr.size(), vout_zephyr.size());
|
||||
else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM)
|
||||
r = rct_signatures.serialize_rctsig_base(ar, vin_salvium.size(), vout_salvium.size());
|
||||
else
|
||||
r = rct_signatures.serialize_rctsig_base(ar, vin.size(), vout.size());
|
||||
if (!r || !ar.stream().good()) return false;
|
||||
@@ -741,6 +858,9 @@ namespace cryptonote
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin_zephyr.size(), vout_zephyr.size(),
|
||||
vin_zephyr[0].type() == typeid(txin_zephyr_key) ? boost::get<txin_zephyr_key>(vin_zephyr[0]).key_offsets.size() - 1 : 0);
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin_salvium.size(), vout_salvium.size(),
|
||||
vin_salvium[0].type() == typeid(txin_salvium_key) ? boost::get<txin_salvium_key>(vin_salvium[0]).key_offsets.size() - 1 : 0);
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||
r = rct_signatures.p.serialize_rctsig_prunable(ar, rct_signatures.type, vin.size(), vout_xhv.size(),
|
||||
vin.size() > 0 && vin[0].type() == typeid(txin_to_key) ? boost::get<txin_to_key>(vin[0]).key_offsets.size() - 1 :
|
||||
@@ -932,6 +1052,7 @@ namespace cryptonote
|
||||
uint64_t nonce8;
|
||||
offshore::pricing_record pricing_record;
|
||||
zephyr_oracle::pricing_record zephyr_pricing_record;
|
||||
salvium_oracle::pricing_record salvium_pricing_record;
|
||||
crypto::cycle cycle;
|
||||
crypto::cycle40 cycle40;
|
||||
crypto::cycle48 cycle48;
|
||||
@@ -956,12 +1077,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)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
if (major_version >= 3)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||
FIELD(pricing_record)
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
if (major_version >= 2) FIELD(salvium_pricing_record)
|
||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
if (major_version >= 4)
|
||||
{
|
||||
FIELD_N("pricing_record", zephyr_pricing_record)
|
||||
}
|
||||
else if (major_version >= 3)
|
||||
{
|
||||
zephyr_oracle::pricing_record_v2 pr_v2;
|
||||
if (!typename Archive<W>::is_saving())
|
||||
{
|
||||
FIELD(pr_v2)
|
||||
pr_v2.write_to_pr(zephyr_pricing_record);
|
||||
}
|
||||
else
|
||||
{
|
||||
pr_v2.read_from_pr(zephyr_pricing_record);
|
||||
FIELD(pr_v2)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
zephyr_oracle::pricing_record_v1 pr_v1;
|
||||
@@ -987,10 +1125,11 @@ namespace cryptonote
|
||||
bytecoin_block parent_block;
|
||||
|
||||
transaction miner_tx;
|
||||
transaction protocol_tx;
|
||||
std::vector<crypto::hash> tx_hashes;
|
||||
mutable crypto::hash uncle = cryptonote::null_hash;
|
||||
|
||||
void set_blob_type(enum BLOB_TYPE bt) { miner_tx.blob_type = blob_type = bt; }
|
||||
void set_blob_type(enum BLOB_TYPE bt) { miner_tx.blob_type = protocol_tx.blob_type = blob_type = bt; }
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELDS(*static_cast<block_header *>(this))
|
||||
@@ -1000,6 +1139,10 @@ namespace cryptonote
|
||||
FIELD_N("parent_block", sbb);
|
||||
}
|
||||
FIELD(miner_tx)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM)
|
||||
{
|
||||
FIELD(protocol_tx)
|
||||
}
|
||||
FIELD(tx_hashes)
|
||||
if (blob_type == BLOB_TYPE_CRYPTONOTE3)
|
||||
{
|
||||
@@ -1061,14 +1204,17 @@ VARIANT_TAG(binary_archive, cryptonote::txin_to_scripthash, 0x1);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_to_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_zephyr_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_offshore, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_salvium_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_onshore, 0x4);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_xasset, 0x5);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txin_haven_key, 0x6);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_script, 0x0);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_scripthash, 0x1);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_salvium_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_zephyr_tagged_key, 0x2);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_to_tagged_key, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_salvium_tagged_key, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_offshore, 0x3);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_xasset, 0x5);
|
||||
VARIANT_TAG(binary_archive, cryptonote::txout_haven_key, 0x6);
|
||||
+13
-5
@@ -220,8 +220,8 @@ namespace cryptonote
|
||||
{
|
||||
std::stringstream ss;
|
||||
binary_archive<true> ba(ss);
|
||||
const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size();
|
||||
const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size();
|
||||
const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM ? t.vin_salvium.size() : (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size());
|
||||
const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM ? t.vout_salvium.size() : (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : (t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size()));
|
||||
bool r = tt.rct_signatures.serialize_rctsig_base(ba, inputs, outputs);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to serialize rct signatures base");
|
||||
cryptonote::get_blob_hash(ss.str(), hashes[1]);
|
||||
@@ -236,10 +236,12 @@ namespace cryptonote
|
||||
{
|
||||
std::stringstream ss;
|
||||
binary_archive<true> ba(ss);
|
||||
const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size();
|
||||
const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size();
|
||||
const size_t inputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM ? t.vin_salvium.size() : (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vin_zephyr.size() : t.vin.size());
|
||||
const size_t outputs = t.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM ? t.vout_salvium.size() : (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR ? t.vout_zephyr.size() : (t.blob_type != BLOB_TYPE_CRYPTONOTE_XHV ? t.vout.size() : t.vout_xhv.size()));
|
||||
size_t mixin;
|
||||
if (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
if (t.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
mixin = t.vin_salvium.empty() ? 0 : t.vin_salvium[0].type() == typeid(txin_salvium_key) ? boost::get<txin_salvium_key>(t.vin_salvium[0]).key_offsets.size() - 1 : 0;
|
||||
} else if (t.blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||
mixin = t.vin_zephyr.empty() ? 0 : t.vin_zephyr[0].type() == typeid(txin_zephyr_key) ? boost::get<txin_zephyr_key>(t.vin_zephyr[0]).key_offsets.size() - 1 : 0;
|
||||
} else if (t.blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||
mixin = t.vin.empty() ? 0 :
|
||||
@@ -413,6 +415,12 @@ namespace cryptonote
|
||||
crypto::hash h = null_hash;
|
||||
size_t bl_sz = 0;
|
||||
get_transaction_hash(b.miner_tx, h, bl_sz);
|
||||
if (b.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||
txs_ids.push_back(h);
|
||||
h = null_hash;
|
||||
bl_sz = 0;
|
||||
get_transaction_hash(b.protocol_tx, h, bl_sz);
|
||||
}
|
||||
txs_ids.push_back(h);
|
||||
BOOST_FOREACH(auto& th, b.tx_hashes)
|
||||
txs_ids.push_back(th);
|
||||
+2
-2
@@ -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"
|
||||
@@ -36,4 +36,5 @@ enum BLOB_TYPE {
|
||||
BLOB_TYPE_CRYPTONOTE_XTA = 12, // ITALO
|
||||
BLOB_TYPE_CRYPTONOTE_ZEPHYR = 13, // ZEPHYR
|
||||
BLOB_TYPE_CRYPTONOTE_XLA = 14, // XLA
|
||||
BLOB_TYPE_CRYPTONOTE_SALVIUM= 15, // Salvium
|
||||
};
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
#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 "common/base58.h"
|
||||
#include "serialization/binary_utils.h"
|
||||
#include <nan.h>
|
||||
|
||||
@@ -87,6 +87,8 @@ 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};
|
||||
|
||||
//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
|
||||
@@ -325,6 +327,7 @@ namespace rct {
|
||||
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;
|
||||
|
||||
template<bool W, template <bool> class Archive>
|
||||
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
|
||||
@@ -384,6 +387,8 @@ namespace rct {
|
||||
FIELDS(maskSums[2])
|
||||
ar.end_array();
|
||||
}
|
||||
if (crypto_verify_32(p_r.bytes, null_key.bytes))
|
||||
FIELD(p_r)
|
||||
return ar.stream().good();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright (c) 2021, 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.
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace salvium_oracle {
|
||||
|
||||
const std::vector<std::string> ASSET_TYPES = {"SAL", "VSD", "BURN"};
|
||||
|
||||
class asset_type_counts
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Fields
|
||||
uint64_t SAL;
|
||||
uint64_t VSD;
|
||||
uint64_t BURN;
|
||||
|
||||
asset_type_counts() noexcept
|
||||
: SAL(0)
|
||||
, VSD(0)
|
||||
, BURN(0)
|
||||
{
|
||||
}
|
||||
|
||||
uint64_t operator[](const std::string asset_type) const noexcept
|
||||
{
|
||||
if (asset_type == "SAL") {
|
||||
return SAL;
|
||||
} else if (asset_type == "VSD") {
|
||||
return VSD;
|
||||
} else if (asset_type == "BURN") {
|
||||
return BURN;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void add(const std::string asset_type, const uint64_t val)
|
||||
{
|
||||
if (asset_type == "SAL") {
|
||||
SAL += val;
|
||||
} else if (asset_type == "VSD") {
|
||||
VSD += val;
|
||||
} else if (asset_type == "BURN") {
|
||||
BURN += val;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
// 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.
|
||||
//
|
||||
// Portions of this code based upon code Copyright (c) 2019, The Monero Project
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
#include "pricing_record.h"
|
||||
|
||||
#include "serialization/keyvalue_serialization.h"
|
||||
#include "storages/portable_storage.h"
|
||||
|
||||
#include "string_tools.h"
|
||||
namespace salvium_oracle
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
struct asset_data_serialized
|
||||
{
|
||||
std::string asset_type;
|
||||
uint64_t spot_price;
|
||||
uint64_t ma_price;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(asset_type)
|
||||
KV_SERIALIZE(spot_price)
|
||||
KV_SERIALIZE(ma_price)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct supply_data_serialized
|
||||
{
|
||||
uint64_t SAL;
|
||||
uint64_t VSD;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(SAL)
|
||||
KV_SERIALIZE(VSD)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct pr_serialized
|
||||
{
|
||||
uint64_t pr_version;
|
||||
uint64_t height;
|
||||
supply_data supply;
|
||||
std::vector<asset_data> assets;
|
||||
uint64_t timestamp;
|
||||
std::string signature;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(pr_version)
|
||||
KV_SERIALIZE(height)
|
||||
KV_SERIALIZE(supply)
|
||||
KV_SERIALIZE(assets)
|
||||
KV_SERIALIZE(timestamp)
|
||||
KV_SERIALIZE(signature)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
}
|
||||
|
||||
pricing_record::pricing_record() noexcept
|
||||
: pr_version(0)
|
||||
, height(0)
|
||||
, supply()
|
||||
, assets()
|
||||
, timestamp(0)
|
||||
, signature()
|
||||
{
|
||||
}
|
||||
|
||||
pricing_record::~pricing_record() noexcept
|
||||
{
|
||||
}
|
||||
|
||||
bool supply_data::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
|
||||
{
|
||||
supply_data_serialized in{};
|
||||
if (in._load(src, hparent))
|
||||
{
|
||||
// Copy everything into the local instance
|
||||
sal = in.SAL;
|
||||
vsd = in.VSD;
|
||||
return true;
|
||||
}
|
||||
// Report error here?
|
||||
return false;
|
||||
}
|
||||
|
||||
bool supply_data::store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const
|
||||
{
|
||||
const supply_data_serialized out{sal, vsd};
|
||||
return out.store(dest, hparent);
|
||||
}
|
||||
|
||||
bool asset_data::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
|
||||
{
|
||||
asset_data_serialized in{};
|
||||
if (in._load(src, hparent))
|
||||
{
|
||||
// Copy everything into the local instance
|
||||
asset_type = in.asset_type;
|
||||
spot_price = in.spot_price;
|
||||
ma_price = in.ma_price;
|
||||
return true;
|
||||
}
|
||||
// Report error here?
|
||||
return false;
|
||||
}
|
||||
|
||||
bool asset_data::store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const
|
||||
{
|
||||
const asset_data_serialized out{asset_type, spot_price, ma_price};
|
||||
return out.store(dest, hparent);
|
||||
}
|
||||
|
||||
bool pricing_record::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
|
||||
{
|
||||
pr_serialized in{};
|
||||
if (in._load(src, hparent))
|
||||
{
|
||||
// Copy everything into the local instance
|
||||
pr_version = in.pr_version;
|
||||
height = in.height;
|
||||
supply = in.supply;
|
||||
assets = in.assets;
|
||||
timestamp = in.timestamp;
|
||||
|
||||
// Signature arrives in HEX format, but needs to be used in BINARY format - convert it here
|
||||
signature.resize(0);
|
||||
assert(in.signature.size()%2 == 0);
|
||||
signature.reserve(in.signature.size() >> 1);
|
||||
for (unsigned int i = 0; i < in.signature.size(); i += 2) {
|
||||
std::string byteString = in.signature.substr(i, 2);
|
||||
signature.emplace_back((uint8_t)strtol(byteString.c_str(), NULL, 16));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Report error here?
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pricing_record::store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const
|
||||
{
|
||||
std::string sig_hex;
|
||||
for (size_t i=0; i<signature.size(); ++i) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (0xff & signature.at(i));
|
||||
sig_hex += ss.str();
|
||||
}
|
||||
const pr_serialized out{pr_version, height, supply, assets, timestamp, sig_hex};
|
||||
return out.store(dest, hparent);
|
||||
}
|
||||
|
||||
pricing_record::pricing_record(const pricing_record& orig) noexcept
|
||||
: pr_version(orig.pr_version)
|
||||
, height(orig.height)
|
||||
, supply(orig.supply)
|
||||
, assets(orig.assets)
|
||||
, timestamp(orig.timestamp)
|
||||
, signature(orig.signature)
|
||||
{
|
||||
}
|
||||
|
||||
pricing_record& pricing_record::operator=(const pricing_record& orig) noexcept
|
||||
{
|
||||
pr_version = orig.pr_version;
|
||||
height = orig.height;
|
||||
supply = orig.supply;
|
||||
assets = orig.assets;
|
||||
timestamp = orig.timestamp;
|
||||
signature = orig.signature;
|
||||
return *this;
|
||||
}
|
||||
|
||||
uint64_t pricing_record::operator[](const std::string& asset_type) const
|
||||
{
|
||||
for (const auto& asset: assets) {
|
||||
if (asset.asset_type != asset_type) continue;
|
||||
return asset.spot_price;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool pricing_record::equal(const pricing_record& other) const noexcept
|
||||
{
|
||||
return ((pr_version == other.pr_version) &&
|
||||
(height == other.height) &&
|
||||
(supply == other.supply) &&
|
||||
(assets == other.assets) &&
|
||||
(timestamp == other.timestamp) &&
|
||||
(signature == other.signature));
|
||||
}
|
||||
|
||||
bool pricing_record::empty() const noexcept
|
||||
{
|
||||
const pricing_record empty_pr = salvium_oracle::pricing_record();
|
||||
return (*this).equal(empty_pr);
|
||||
}
|
||||
|
||||
// overload for pr validation for block
|
||||
bool pricing_record::valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const
|
||||
{
|
||||
if (this->empty())
|
||||
return true;
|
||||
|
||||
// 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.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->timestamp <= last_bl_timestamp) {
|
||||
LOG_ERROR("Pricing record timestamp: " << this->timestamp << ", block timestamp: " << bl_timestamp);
|
||||
LOG_ERROR("Pricing record timestamp is too old.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
// 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.
|
||||
//
|
||||
// Portions of this code based upon code Copyright (c) 2019, The Monero Project
|
||||
|
||||
#pragma once
|
||||
#include "common/pod-class.h"
|
||||
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/ecdsa.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "serialization/vector.h"
|
||||
|
||||
#include "cryptonote_config.h"
|
||||
#include "crypto/hash.h"
|
||||
|
||||
namespace epee
|
||||
{
|
||||
namespace serialization
|
||||
{
|
||||
class portable_storage;
|
||||
struct section;
|
||||
}
|
||||
}
|
||||
|
||||
namespace salvium_oracle
|
||||
{
|
||||
#pragma pack(push, 1)
|
||||
POD_CLASS pricing_record_pre {
|
||||
uint64_t pr_version;
|
||||
uint64_t price;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct supply_data {
|
||||
uint64_t sal;
|
||||
uint64_t vsd;
|
||||
|
||||
//! Load from epee p2p format
|
||||
bool _load(epee::serialization::portable_storage& src, epee::serialization::section* hparent);
|
||||
//! Store in epee p2p format
|
||||
bool store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(sal)
|
||||
VARINT_FIELD(vsd)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
inline bool operator==(const supply_data& a, const supply_data& b) noexcept
|
||||
{
|
||||
return (a.sal == b.sal &&
|
||||
a.vsd == b.vsd);
|
||||
}
|
||||
|
||||
struct asset_data {
|
||||
std::string asset_type;
|
||||
uint64_t spot_price;
|
||||
uint64_t ma_price;
|
||||
|
||||
//! Load from epee p2p format
|
||||
bool _load(epee::serialization::portable_storage& src, epee::serialization::section* hparent);
|
||||
//! Store in epee p2p format
|
||||
bool store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(asset_type)
|
||||
VARINT_FIELD(spot_price)
|
||||
VARINT_FIELD(ma_price)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
inline bool operator==(const asset_data& a, const asset_data& b) noexcept
|
||||
{
|
||||
return (a.asset_type == b.asset_type &&
|
||||
a.spot_price == b.spot_price &&
|
||||
a.ma_price == b.ma_price);
|
||||
}
|
||||
|
||||
struct pricing_record
|
||||
{
|
||||
// Fields
|
||||
uint64_t pr_version;
|
||||
uint64_t height;
|
||||
supply_data supply;
|
||||
std::vector<asset_data> assets;
|
||||
uint64_t timestamp;
|
||||
std::vector<uint8_t> signature;
|
||||
|
||||
// Default c'tor
|
||||
pricing_record() noexcept;
|
||||
//! Load from epee p2p format
|
||||
bool _load(epee::serialization::portable_storage& src, epee::serialization::section* hparent);
|
||||
//! Store in epee p2p format
|
||||
bool store(epee::serialization::portable_storage& dest, epee::serialization::section* hparent) const;
|
||||
pricing_record(const pricing_record& orig) noexcept;
|
||||
~pricing_record() noexcept;
|
||||
bool equal(const pricing_record& other) const noexcept;
|
||||
bool empty() const noexcept;
|
||||
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;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(pr_version)
|
||||
VARINT_FIELD(height)
|
||||
FIELD(supply)
|
||||
FIELD(assets)
|
||||
VARINT_FIELD(timestamp)
|
||||
FIELD(signature)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
inline bool operator==(const pricing_record& a, const pricing_record& b) noexcept
|
||||
{
|
||||
return a.equal(b);
|
||||
}
|
||||
|
||||
inline bool operator!=(const pricing_record& a, const pricing_record& b) noexcept
|
||||
{
|
||||
return !a.equal(b);
|
||||
}
|
||||
|
||||
} // salvium_oracle
|
||||
@@ -40,7 +40,33 @@
|
||||
template <template <bool> class Archive>
|
||||
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
||||
{
|
||||
if (version < 3)
|
||||
if (version >= 4)
|
||||
{
|
||||
// very basic sanity check
|
||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
|
||||
if (!ar.good())
|
||||
return false;
|
||||
}
|
||||
else if (version >= 3)
|
||||
{
|
||||
// very basic sanity check
|
||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record_v2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
zephyr_oracle::pricing_record_v2 pr_v2;
|
||||
ar.serialize_blob(&pr_v2, sizeof(zephyr_oracle::pricing_record_v2), "");
|
||||
if (!ar.good())
|
||||
return false;
|
||||
|
||||
if (!pr_v2.write_to_pr(pr))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// very basic sanity check
|
||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record_v1)) {
|
||||
@@ -55,17 +81,6 @@ bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t
|
||||
if (!pr_v1.write_to_pr(pr))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// very basic sanity check
|
||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
|
||||
if (!ar.good())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -76,17 +91,24 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record &pr, uint8_t
|
||||
{
|
||||
ar.begin_string();
|
||||
|
||||
if (version < 3)
|
||||
if (version >= 4)
|
||||
{
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
|
||||
}
|
||||
else if (version >= 3)
|
||||
{
|
||||
zephyr_oracle::pricing_record_v2 pr_v2;
|
||||
if (!pr_v2.read_from_pr(pr))
|
||||
return false;
|
||||
ar.serialize_blob(&pr_v2, sizeof(zephyr_oracle::pricing_record_v2), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
zephyr_oracle::pricing_record_v1 pr_v1;
|
||||
if (!pr_v1.read_from_pr(pr))
|
||||
return false;
|
||||
ar.serialize_blob(&pr_v1, sizeof(zephyr_oracle::pricing_record_v1), "");
|
||||
}
|
||||
else
|
||||
{
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
|
||||
}
|
||||
|
||||
if (!ar.good())
|
||||
return false;
|
||||
@@ -122,5 +144,34 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record_v1 &pr, uint8
|
||||
return true;
|
||||
}
|
||||
|
||||
// read
|
||||
template <template <bool> class Archive>
|
||||
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record_v2 &pr, uint8_t version)
|
||||
{
|
||||
// very basic sanity check
|
||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record_v2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record_v2), "");
|
||||
if (!ar.good())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// write
|
||||
template <template <bool> class Archive>
|
||||
bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record_v2 &pr, uint8_t version)
|
||||
{
|
||||
ar.begin_string();
|
||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record_v2), "");
|
||||
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);
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace zephyr_oracle
|
||||
uint64_t stable_ma;
|
||||
uint64_t reserve;
|
||||
uint64_t reserve_ma;
|
||||
uint64_t reserve_ratio;
|
||||
uint64_t reserve_ratio_ma;
|
||||
uint64_t timestamp;
|
||||
std::string signature;
|
||||
|
||||
@@ -56,6 +58,8 @@ namespace zephyr_oracle
|
||||
KV_SERIALIZE(stable_ma)
|
||||
KV_SERIALIZE(reserve)
|
||||
KV_SERIALIZE(reserve_ma)
|
||||
KV_SERIALIZE(reserve_ratio)
|
||||
KV_SERIALIZE(reserve_ratio_ma)
|
||||
KV_SERIALIZE(timestamp)
|
||||
KV_SERIALIZE(signature)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
@@ -69,6 +73,8 @@ namespace zephyr_oracle
|
||||
, stable_ma(0)
|
||||
, reserve(0)
|
||||
, reserve_ma(0)
|
||||
, reserve_ratio(0)
|
||||
, reserve_ratio_ma(0)
|
||||
, timestamp(0)
|
||||
{
|
||||
std::memset(signature, 0, sizeof(signature));
|
||||
@@ -86,6 +92,8 @@ namespace zephyr_oracle
|
||||
stable_ma = in.stable_ma;
|
||||
reserve = in.reserve;
|
||||
reserve_ma = in.reserve_ma;
|
||||
reserve_ratio = in.reserve_ratio;
|
||||
reserve_ratio_ma = in.reserve_ratio_ma;
|
||||
timestamp = in.timestamp;
|
||||
for (unsigned int i = 0; i < in.signature.length(); i += 2) {
|
||||
std::string byteString = in.signature.substr(i, 2);
|
||||
@@ -106,7 +114,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,timestamp,sig_hex};
|
||||
const pr_serialized out{spot,moving_average,stable,stable_ma,reserve,reserve_ma,reserve_ratio,reserve_ratio_ma,timestamp,sig_hex};
|
||||
return out.store(dest, hparent);
|
||||
}
|
||||
|
||||
@@ -117,6 +125,8 @@ namespace zephyr_oracle
|
||||
, stable_ma(orig.stable_ma)
|
||||
, reserve(orig.reserve)
|
||||
, reserve_ma(orig.reserve_ma)
|
||||
, reserve_ratio(orig.reserve_ratio)
|
||||
, reserve_ratio_ma(orig.reserve_ratio_ma)
|
||||
, timestamp(orig.timestamp)
|
||||
{
|
||||
std::memcpy(signature, orig.signature, sizeof(signature));
|
||||
@@ -130,6 +140,8 @@ namespace zephyr_oracle
|
||||
stable_ma = orig.stable_ma;
|
||||
reserve = orig.reserve;
|
||||
reserve_ma = orig.reserve_ma;
|
||||
reserve_ratio = orig.reserve_ratio;
|
||||
reserve_ratio_ma = orig.reserve_ratio_ma;
|
||||
timestamp = orig.timestamp;
|
||||
::memcpy(signature, orig.signature, sizeof(signature));
|
||||
return *this;
|
||||
@@ -143,6 +155,8 @@ namespace zephyr_oracle
|
||||
(stable_ma == other.stable_ma) &&
|
||||
(reserve == other.reserve) &&
|
||||
(reserve_ma == other.reserve_ma) &&
|
||||
(reserve_ratio == other.reserve_ratio) &&
|
||||
(reserve_ratio_ma == other.reserve_ratio_ma) &&
|
||||
(timestamp == other.timestamp) &&
|
||||
!::memcmp(signature, other.signature, sizeof(signature)));
|
||||
}
|
||||
@@ -153,7 +167,7 @@ namespace zephyr_oracle
|
||||
return (*this).equal(empty_pr);
|
||||
}
|
||||
|
||||
bool pricing_record::verifySignature(const std::string& public_key) const
|
||||
bool pricing_record::verifySignature(const std::string& public_key, const uint8_t hf_version) const
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(!public_key.empty(), "Pricing record verification failed. NULL public key. PK Size: " << public_key.size()); // TODO: is this necessary or the one below already covers this case, meannin it will produce empty pubkey?
|
||||
|
||||
@@ -178,7 +192,9 @@ namespace zephyr_oracle
|
||||
// Build the JSON string, so that we can verify the signature
|
||||
std::ostringstream oss;
|
||||
oss << "{\"spot\":" << spot;
|
||||
oss << ",\"moving_average\":" << moving_average;
|
||||
if (hf_version <= 4) {
|
||||
oss << ",\"moving_average\":" << moving_average;
|
||||
}
|
||||
oss << ",\"timestamp\":" << timestamp;
|
||||
oss << "}";
|
||||
std::string message = oss.str();
|
||||
@@ -210,9 +226,24 @@ namespace zephyr_oracle
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pricing_record::has_missing_rates() const noexcept
|
||||
bool pricing_record::has_missing_rates(const uint8_t hf_version) const noexcept
|
||||
{
|
||||
return (spot == 0) || (moving_average == 0) || (stable == 0) || (stable_ma == 0) || (reserve == 0) || (reserve_ma == 0);
|
||||
bool missing_rates = (spot == 0) || (moving_average == 0) || (stable == 0) || (stable_ma == 0) || (reserve == 0) || (reserve_ma == 0);
|
||||
if (hf_version <= 3) {
|
||||
return missing_rates;
|
||||
} else if (hf_version <= 4) {
|
||||
return missing_rates || (reserve_ratio == 0);
|
||||
}
|
||||
return missing_rates || (reserve_ratio == 0) || (reserve_ratio_ma == 0);
|
||||
}
|
||||
|
||||
bool pricing_record::has_essential_rates(const uint8_t hf_version) const noexcept
|
||||
{
|
||||
bool essential_rates = (spot != 0) && (stable != 0) && (reserve != 0);
|
||||
if (hf_version <= 3) {
|
||||
return essential_rates;
|
||||
}
|
||||
return essential_rates && (reserve_ratio != 0);
|
||||
}
|
||||
|
||||
// overload for pr validation for block
|
||||
@@ -226,9 +257,11 @@ namespace zephyr_oracle
|
||||
if (this->empty())
|
||||
return true;
|
||||
|
||||
if (this->has_missing_rates()) {
|
||||
LOG_ERROR("Pricing record has missing rates.");
|
||||
return false;
|
||||
if (this->has_missing_rates(hf_version)) {
|
||||
if (hf_version < 4 || !this->has_essential_rates(hf_version)) {
|
||||
LOG_ERROR("Pricing record has missing rates.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string const MAINNET_ORACLE_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\n"
|
||||
@@ -236,7 +269,7 @@ namespace zephyr_oracle
|
||||
"edsUmhQeYwBkelAaFyxhX4ZotP+b/cFr2mX5iuND1znEnMZkyg+YmtkCAwEAAQ==\n"
|
||||
"-----END PUBLIC KEY-----\n";
|
||||
|
||||
if (!verifySignature(MAINNET_ORACLE_PUBLIC_KEY)) {
|
||||
if (!verifySignature(MAINNET_ORACLE_PUBLIC_KEY, hf_version)) {
|
||||
LOG_ERROR("Invalid pricing record signature.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,16 @@ namespace zephyr_oracle
|
||||
uint64_t zEPHRSV;
|
||||
uint64_t timestamp;
|
||||
};
|
||||
POD_CLASS pricing_record_pre_v2 {
|
||||
uint64_t spot;
|
||||
uint64_t moving_average;
|
||||
uint64_t stable;
|
||||
uint64_t stable_ma;
|
||||
uint64_t reserve;
|
||||
uint64_t reserve_ma;
|
||||
uint64_t timestamp;
|
||||
unsigned char signature[64];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
class pricing_record
|
||||
{
|
||||
@@ -76,6 +86,8 @@ namespace zephyr_oracle
|
||||
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];
|
||||
|
||||
@@ -89,8 +101,9 @@ namespace zephyr_oracle
|
||||
~pricing_record() = default;
|
||||
bool equal(const pricing_record& other) const noexcept;
|
||||
bool empty() const noexcept;
|
||||
bool verifySignature(const std::string& public_key) const;
|
||||
bool has_missing_rates() const noexcept;
|
||||
bool verifySignature(const std::string& public_key, const uint8_t hf_version) const;
|
||||
bool has_missing_rates(const uint8_t hf_version) const noexcept;
|
||||
bool has_essential_rates(const uint8_t hf_version) const noexcept;
|
||||
bool valid(uint32_t hf_version, uint64_t bl_timestamp, uint64_t last_bl_timestamp) const;
|
||||
|
||||
pricing_record& operator=(const pricing_record& orig) noexcept;
|
||||
@@ -137,4 +150,46 @@ namespace zephyr_oracle
|
||||
};
|
||||
};
|
||||
|
||||
class pricing_record_v2
|
||||
{
|
||||
|
||||
public:
|
||||
uint64_t spot;
|
||||
uint64_t moving_average;
|
||||
uint64_t stable;
|
||||
uint64_t stable_ma;
|
||||
uint64_t reserve;
|
||||
uint64_t reserve_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 = 0;
|
||||
pr.reserve_ratio_ma = 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;
|
||||
timestamp = pr.timestamp;
|
||||
std::memcpy(signature, pr.signature, sizeof(signature));
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
} // oracle
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
cd $DIR
|
||||
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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
let u = require('../build/Release/cryptoforknote');
|
||||
|
||||
const b = Buffer.from(
|
||||
'010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000020001ffcb6d018f9ffec12d03125e128c041c8a2d41fab9ebe2a7a4b10afbef4e134ec7ba3151c8c730a644310353414c3c7334015f99bdbbe70161dafb2da2fd9a4285da893a7519cff350981a959f525c43e5c60211000000000000000000000000000000000001e3c7bfb00b00020001ffcb6d0023016b6961b458286074406192961c1f0e5236455f45fcd6c175c7142d6353a481d60400020000'
|
||||
, 'hex');
|
||||
const b2 = u.convert_blob(b, 15);
|
||||
const h1 = b2.toString('hex');
|
||||
|
||||
if (h1 === '010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000ac81ca3e7bc9369e63563923187d2cfdb42eac839c7fe24e6d5d0080c96d758f02') {
|
||||
console.log('PASSED');
|
||||
} else {
|
||||
console.log('FAILED: ' + h1);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user