Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a4f5cea7c | |||
| 16eba0d12d | |||
| aa39526fe8 | |||
| 44ee67d21f | |||
| 0f9c969b83 | |||
| ac5dcc2133 | |||
| 069c83ef32 | |||
| 655f79b0e0 | |||
| 01ed1460e3 | |||
| bd7fb25315 | |||
| cdf439d83f | |||
| d47d988a72 | |||
| 1c06a70b58 | |||
| 20c20f5522 | |||
| a275227d76 | |||
| ac1425cbcb | |||
| f1a39778cb | |||
| 79e5c63a7d |
@@ -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
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cryptoforknote-util",
|
"name": "cryptoforknote-util",
|
||||||
"version": "15.5.16",
|
"version": "15.6.2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "LucasJones",
|
"name": "LucasJones",
|
||||||
"email": "lucasjonesdev@hotmail.co.uk"
|
"email": "lucasjonesdev@hotmail.co.uk"
|
||||||
|
|||||||
@@ -447,8 +447,11 @@ namespace cryptonote
|
|||||||
// SALVIUM-SPECIFIC FIELDS
|
// SALVIUM-SPECIFIC FIELDS
|
||||||
// TX type
|
// TX type
|
||||||
cryptonote::salvium_transaction_type tx_type;
|
cryptonote::salvium_transaction_type tx_type;
|
||||||
// Return address
|
|
||||||
crypto::public_key return_address;
|
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
|
// Return TX public key
|
||||||
crypto::public_key return_pubkey;
|
crypto::public_key return_pubkey;
|
||||||
// Source asset type
|
// Source asset type
|
||||||
@@ -737,8 +740,13 @@ namespace cryptonote
|
|||||||
if (tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
|
if (tx_type != cryptonote::salvium_transaction_type::PROTOCOL) {
|
||||||
VARINT_FIELD(amount_burnt)
|
VARINT_FIELD(amount_burnt)
|
||||||
if (tx_type != cryptonote::salvium_transaction_type::MINER) {
|
if (tx_type != cryptonote::salvium_transaction_type::MINER) {
|
||||||
FIELD(return_address)
|
if (type == cryptonote::salvium_transaction_type::TRANSFER && version >= TRANSACTION_VERSION_N_OUTS) {
|
||||||
FIELD(return_pubkey)
|
FIELD(return_address_list)
|
||||||
|
FIELD(return_address_change_mask)
|
||||||
|
} else {
|
||||||
|
FIELD(return_address)
|
||||||
|
FIELD(return_pubkey)
|
||||||
|
}
|
||||||
FIELD(source_asset_type)
|
FIELD(source_asset_type)
|
||||||
FIELD(destination_asset_type)
|
FIELD(destination_asset_type)
|
||||||
VARINT_FIELD(amount_slippage_limit)
|
VARINT_FIELD(amount_slippage_limit)
|
||||||
@@ -915,6 +923,15 @@ namespace cryptonote
|
|||||||
amount_minted = 0;
|
amount_minted = 0;
|
||||||
output_unlock_times.clear();
|
output_unlock_times.clear();
|
||||||
collateral_indices.clear();
|
collateral_indices.clear();
|
||||||
|
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@@ -1080,12 +1097,26 @@ namespace cryptonote
|
|||||||
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
if (blob_type == BLOB_TYPE_CRYPTONOTE_XHV) {
|
||||||
FIELD(pricing_record)
|
FIELD(pricing_record)
|
||||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||||
if (major_version >= 2) FIELD(salvium_pricing_record)
|
if (major_version >= 255) FIELD(salvium_pricing_record)
|
||||||
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
} else if (blob_type == BLOB_TYPE_CRYPTONOTE_ZEPHYR) {
|
||||||
if (major_version >= 4)
|
if (major_version >= 6)
|
||||||
{
|
{
|
||||||
FIELD_N("pricing_record", zephyr_pricing_record)
|
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)
|
else if (major_version >= 3)
|
||||||
{
|
{
|
||||||
zephyr_oracle::pricing_record_v2 pr_v2;
|
zephyr_oracle::pricing_record_v2 pr_v2;
|
||||||
|
|||||||
@@ -287,7 +287,11 @@ namespace cryptonote
|
|||||||
}
|
}
|
||||||
crypto::hash tree_root_hash = get_tx_tree_hash(b);
|
crypto::hash tree_root_hash = get_tx_tree_hash(b);
|
||||||
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
|
blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash));
|
||||||
blob.append(tools::get_varint_data(b.tx_hashes.size()+1));
|
if (b.blob_type == BLOB_TYPE_CRYPTONOTE_SALVIUM) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) {
|
if (b.blob_type == BLOB_TYPE_CRYPTONOTE3) {
|
||||||
blob.append(reinterpret_cast<const char*>(&b.uncle), sizeof(b.uncle));
|
blob.append(reinterpret_cast<const char*>(&b.uncle), sizeof(b.uncle));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#define HF_VERSION_XASSET_FEES_V2 17
|
#define HF_VERSION_XASSET_FEES_V2 17
|
||||||
#define HF_VERSION_HAVEN2 18
|
#define HF_VERSION_HAVEN2 18
|
||||||
#define HF_VERSION_USE_COLLATERAL 20
|
#define HF_VERSION_USE_COLLATERAL 20
|
||||||
|
#define HF_VERSION_ENABLE_N_OUTS 2
|
||||||
|
#define TRANSACTION_VERSION_N_OUTS 3
|
||||||
|
|
||||||
// UNLOCK TIMES
|
// UNLOCK TIMES
|
||||||
#define TX_V6_OFFSHORE_UNLOCK_BLOCKS 21*720 // 21 day unlock time
|
#define TX_V6_OFFSHORE_UNLOCK_BLOCKS 21*720 // 21 day unlock time
|
||||||
|
|||||||
+70
-210
@@ -87,8 +87,18 @@ namespace rct {
|
|||||||
typedef std::vector<key> keyV; //vector of keys
|
typedef std::vector<key> keyV; //vector of keys
|
||||||
typedef std::vector<keyV> keyM; //matrix of keys (indexed by column first)
|
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
|
//containers For CT operations
|
||||||
//if it's representing a private ctkey then "dest" contains the secret key of the address
|
//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
|
// 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,
|
RCTTypeBulletproof = 3,
|
||||||
RCTTypeBulletproof2 = 4,
|
RCTTypeBulletproof2 = 4,
|
||||||
RCTTypeCLSAG = 5,
|
RCTTypeCLSAG = 5,
|
||||||
RCTTypeCLSAGN = 6,
|
RCTTypeBulletproofPlus = 6,
|
||||||
RCTTypeHaven2 = 7, // Add public mask sum terms, remove extraneous fields (txnFee_usd,txnFee_xasset,txnOffshoreFee_usd,txnOffshoreFee_xasset)
|
RCTTypeFullProofs = 7
|
||||||
RCTTypeHaven3 = 8, // Add public mask sum term for collateral
|
|
||||||
RCTTypeBulletproofPlus = 9,
|
|
||||||
};
|
};
|
||||||
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
|
enum RangeProofType { RangeProofBorromean, RangeProofBulletproof, RangeProofMultiOutputBulletproof, RangeProofPaddedBulletproof };
|
||||||
struct RCTConfig {
|
struct RCTConfig {
|
||||||
@@ -318,27 +326,24 @@ namespace rct {
|
|||||||
keyV pseudoOuts; //C - for simple rct
|
keyV pseudoOuts; //C - for simple rct
|
||||||
std::vector<ecdhTuple> ecdhInfo;
|
std::vector<ecdhTuple> ecdhInfo;
|
||||||
ctkeyV outPk;
|
ctkeyV outPk;
|
||||||
ctkeyV outPk_usd;
|
|
||||||
ctkeyV outPk_xasset;
|
|
||||||
xmr_amount txnFee = 0; // contains b
|
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;
|
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>
|
template<bool W, template <bool> class Archive>
|
||||||
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
|
bool serialize_rctsig_base(Archive<W> &ar, size_t inputs, size_t outputs)
|
||||||
{
|
{
|
||||||
FIELD(type)
|
FIELD(type)
|
||||||
if (type == RCTTypeNull)
|
if (type == RCTTypeNull)
|
||||||
return ar.stream().good();
|
return ar.stream().good();
|
||||||
if (type != RCTTypeBulletproofPlus)
|
if (type != RCTTypeFull && type != RCTTypeSimple && type != RCTTypeBulletproof && type != RCTTypeBulletproof2 && type != RCTTypeCLSAG && type != RCTTypeBulletproofPlus && type != RCTTypeFullProofs)
|
||||||
return serialize_rctsig_base_old(ar, inputs, outputs);
|
return false;
|
||||||
VARINT_FIELD(txnFee)
|
VARINT_FIELD(txnFee)
|
||||||
VARINT_FIELD(txnOffshoreFee)
|
|
||||||
// inputs/outputs not saved, only here for serialization help
|
// inputs/outputs not saved, only here for serialization help
|
||||||
// FIELD(message) - not serialized, it can be reconstructed
|
// FIELD(message) - not serialized, it can be reconstructed
|
||||||
// FIELD(mixRing) - not serialized, it can be reconstructed
|
// FIELD(mixRing) - not serialized, it can be reconstructed
|
||||||
@@ -349,193 +354,44 @@ namespace rct {
|
|||||||
return false;
|
return false;
|
||||||
for (size_t i = 0; i < outputs; ++i)
|
for (size_t i = 0; i < outputs; ++i)
|
||||||
{
|
{
|
||||||
ar.begin_object();
|
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
|
||||||
if (!typename Archive<W>::is_saving())
|
{
|
||||||
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
|
// Since RCTTypeBulletproof2 enote types, we don't serialize the blinding factor, and only serialize the
|
||||||
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
|
// first 8 bytes of ecdhInfo[i].amount
|
||||||
FIELD(amount);
|
ar.begin_object();
|
||||||
ar.end_object();
|
if (!typename Archive<W>::is_saving())
|
||||||
if (outputs - i > 1)
|
memset(ecdhInfo[i].amount.bytes, 0, sizeof(ecdhInfo[i].amount.bytes));
|
||||||
ar.delimit_array();
|
crypto::hash8 &amount = (crypto::hash8&)ecdhInfo[i].amount;
|
||||||
}
|
FIELD(amount);
|
||||||
ar.end_array();
|
ar.end_object();
|
||||||
|
}
|
||||||
ar.tag("outPk");
|
else
|
||||||
ar.begin_array();
|
{
|
||||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(outputs, outPk);
|
FIELDS(ecdhInfo[i])
|
||||||
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 (outputs - i > 1)
|
if (outputs - i > 1)
|
||||||
ar.delimit_array();
|
ar.delimit_array();
|
||||||
}
|
}
|
||||||
ar.end_array();
|
ar.end_array();
|
||||||
|
|
||||||
// if txnOffshoreFee is not 0, it is a conversion tx
|
ar.tag("outPk");
|
||||||
if (type == RCTTypeHaven3 && txnOffshoreFee) {
|
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");
|
FIELD(p_r)
|
||||||
ar.begin_array();
|
if (type == RCTTypeFullProofs)
|
||||||
PREPARE_CUSTOM_VECTOR_SERIALIZATION(3, maskSums);
|
{
|
||||||
if (maskSums.size() != 3)
|
FIELD(pr_proof)
|
||||||
return false;
|
FIELD(sa_proof)
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ar.stream().good();
|
return ar.stream().good();
|
||||||
}
|
}
|
||||||
@@ -548,8 +404,11 @@ namespace rct {
|
|||||||
FIELD(ecdhInfo)
|
FIELD(ecdhInfo)
|
||||||
FIELD(outPk)
|
FIELD(outPk)
|
||||||
VARINT_FIELD(txnFee)
|
VARINT_FIELD(txnFee)
|
||||||
VARINT_FIELD(txnOffshoreFee)
|
FIELD(p_r)
|
||||||
FIELD(maskSums)
|
if (type == RCTTypeFullProofs) {
|
||||||
|
FIELD(pr_proof)
|
||||||
|
FIELD(sa_proof)
|
||||||
|
}
|
||||||
END_SERIALIZE()
|
END_SERIALIZE()
|
||||||
};
|
};
|
||||||
struct rctSigPrunable {
|
struct rctSigPrunable {
|
||||||
@@ -572,9 +431,9 @@ namespace rct {
|
|||||||
return false;
|
return false;
|
||||||
if (type == RCTTypeNull)
|
if (type == RCTTypeNull)
|
||||||
return ar.stream().good();
|
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;
|
return false;
|
||||||
if (type == RCTTypeBulletproofPlus)
|
if (type == RCTTypeBulletproofPlus || type == RCTTypeFullProofs)
|
||||||
{
|
{
|
||||||
uint32_t nbp = bulletproofs_plus.size();
|
uint32_t nbp = bulletproofs_plus.size();
|
||||||
VARINT_FIELD(nbp)
|
VARINT_FIELD(nbp)
|
||||||
@@ -593,10 +452,10 @@ namespace rct {
|
|||||||
return false;
|
return false;
|
||||||
ar.end_array();
|
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();
|
uint32_t nbp = bulletproofs.size();
|
||||||
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG || type == RCTTypeCLSAGN || type == RCTTypeHaven2 || type == RCTTypeHaven3)
|
if (type == RCTTypeBulletproof2 || type == RCTTypeCLSAG)
|
||||||
VARINT_FIELD(nbp)
|
VARINT_FIELD(nbp)
|
||||||
else
|
else
|
||||||
FIELD(nbp)
|
FIELD(nbp)
|
||||||
@@ -631,7 +490,7 @@ namespace rct {
|
|||||||
ar.end_array();
|
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.tag("CLSAGs");
|
||||||
ar.begin_array();
|
ar.begin_array();
|
||||||
@@ -722,7 +581,7 @@ namespace rct {
|
|||||||
}
|
}
|
||||||
ar.end_array();
|
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.tag("pseudoOuts");
|
||||||
ar.begin_array();
|
ar.begin_array();
|
||||||
@@ -754,12 +613,12 @@ namespace rct {
|
|||||||
|
|
||||||
keyV& get_pseudo_outs()
|
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
|
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()
|
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::multisig_out, 0x9e);
|
||||||
VARIANT_TAG(binary_archive, rct::clsag, 0x9f);
|
VARIANT_TAG(binary_archive, rct::clsag, 0x9f);
|
||||||
VARIANT_TAG(binary_archive, rct::BulletproofPlus, 0xa0);
|
VARIANT_TAG(binary_archive, rct::BulletproofPlus, 0xa0);
|
||||||
|
VARIANT_TAG(binary_archive, rct::zk_proof, 0xa1);
|
||||||
|
|
||||||
#endif /* RCTTYPES_H */
|
#endif /* RCTTYPES_H */
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
template <template <bool> class Archive>
|
template <template <bool> class Archive>
|
||||||
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t version)
|
||||||
{
|
{
|
||||||
if (version >= 4)
|
if (version >= 6)
|
||||||
{
|
{
|
||||||
// very basic sanity check
|
// very basic sanity check
|
||||||
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record)) {
|
if (ar.remaining_bytes() < sizeof(zephyr_oracle::pricing_record)) {
|
||||||
@@ -51,6 +51,21 @@ bool do_serialize(Archive<false> &ar, zephyr_oracle::pricing_record &pr, uint8_t
|
|||||||
if (!ar.good())
|
if (!ar.good())
|
||||||
return false;
|
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)
|
else if (version >= 3)
|
||||||
{
|
{
|
||||||
// very basic sanity check
|
// very basic sanity check
|
||||||
@@ -91,10 +106,17 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record &pr, uint8_t
|
|||||||
{
|
{
|
||||||
ar.begin_string();
|
ar.begin_string();
|
||||||
|
|
||||||
if (version >= 4)
|
if (version >= 6)
|
||||||
{
|
{
|
||||||
ar.serialize_blob(&pr, sizeof(zephyr_oracle::pricing_record), "");
|
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)
|
else if (version >= 3)
|
||||||
{
|
{
|
||||||
zephyr_oracle::pricing_record_v2 pr_v2;
|
zephyr_oracle::pricing_record_v2 pr_v2;
|
||||||
@@ -172,6 +194,35 @@ bool do_serialize(Archive<true> &ar, zephyr_oracle::pricing_record_v2 &pr, uint8
|
|||||||
return true;
|
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);
|
||||||
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v1);
|
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v1);
|
||||||
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v2);
|
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v2);
|
||||||
|
BLOB_SERIALIZER(zephyr_oracle::pricing_record_v3);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
namespace zephyr_oracle {
|
namespace zephyr_oracle {
|
||||||
|
|
||||||
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV"};
|
const std::vector<std::string> ASSET_TYPES = {"ZEPH", "ZEPHUSD", "ZEPHRSV", "ZYIELD"};
|
||||||
|
|
||||||
class asset_type_counts
|
class asset_type_counts
|
||||||
{
|
{
|
||||||
@@ -42,11 +42,13 @@ namespace zephyr_oracle {
|
|||||||
uint64_t ZEPH;
|
uint64_t ZEPH;
|
||||||
uint64_t ZEPHUSD;
|
uint64_t ZEPHUSD;
|
||||||
uint64_t ZEPHRSV;
|
uint64_t ZEPHRSV;
|
||||||
|
uint64_t ZYIELD;
|
||||||
|
|
||||||
asset_type_counts() noexcept
|
asset_type_counts() noexcept
|
||||||
: ZEPH(0)
|
: ZEPH(0)
|
||||||
, ZEPHUSD(0)
|
, ZEPHUSD(0)
|
||||||
, ZEPHRSV(0)
|
, ZEPHRSV(0)
|
||||||
|
, ZYIELD(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +60,8 @@ namespace zephyr_oracle {
|
|||||||
return ZEPHUSD;
|
return ZEPHUSD;
|
||||||
} else if (asset_type == "ZEPHRSV") {
|
} else if (asset_type == "ZEPHRSV") {
|
||||||
return ZEPHRSV;
|
return ZEPHRSV;
|
||||||
|
} else if (asset_type == "ZYIELD") {
|
||||||
|
return ZYIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -71,6 +75,8 @@ namespace zephyr_oracle {
|
|||||||
ZEPHUSD += val;
|
ZEPHUSD += val;
|
||||||
} else if (asset_type == "ZEPHRSV") {
|
} else if (asset_type == "ZEPHRSV") {
|
||||||
ZEPHRSV += val;
|
ZEPHRSV += val;
|
||||||
|
} else if (asset_type == "ZYIELD") {
|
||||||
|
ZYIELD += val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ namespace zephyr_oracle
|
|||||||
uint64_t reserve_ma;
|
uint64_t reserve_ma;
|
||||||
uint64_t reserve_ratio;
|
uint64_t reserve_ratio;
|
||||||
uint64_t reserve_ratio_ma;
|
uint64_t reserve_ratio_ma;
|
||||||
|
uint64_t yield_price;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
std::string signature;
|
std::string signature;
|
||||||
|
|
||||||
@@ -60,6 +61,7 @@ namespace zephyr_oracle
|
|||||||
KV_SERIALIZE(reserve_ma)
|
KV_SERIALIZE(reserve_ma)
|
||||||
KV_SERIALIZE(reserve_ratio)
|
KV_SERIALIZE(reserve_ratio)
|
||||||
KV_SERIALIZE(reserve_ratio_ma)
|
KV_SERIALIZE(reserve_ratio_ma)
|
||||||
|
KV_SERIALIZE(yield_price)
|
||||||
KV_SERIALIZE(timestamp)
|
KV_SERIALIZE(timestamp)
|
||||||
KV_SERIALIZE(signature)
|
KV_SERIALIZE(signature)
|
||||||
END_KV_SERIALIZE_MAP()
|
END_KV_SERIALIZE_MAP()
|
||||||
@@ -75,6 +77,7 @@ namespace zephyr_oracle
|
|||||||
, reserve_ma(0)
|
, reserve_ma(0)
|
||||||
, reserve_ratio(0)
|
, reserve_ratio(0)
|
||||||
, reserve_ratio_ma(0)
|
, reserve_ratio_ma(0)
|
||||||
|
, yield_price(0)
|
||||||
, timestamp(0)
|
, timestamp(0)
|
||||||
{
|
{
|
||||||
std::memset(signature, 0, sizeof(signature));
|
std::memset(signature, 0, sizeof(signature));
|
||||||
@@ -94,6 +97,7 @@ namespace zephyr_oracle
|
|||||||
reserve_ma = in.reserve_ma;
|
reserve_ma = in.reserve_ma;
|
||||||
reserve_ratio = in.reserve_ratio;
|
reserve_ratio = in.reserve_ratio;
|
||||||
reserve_ratio_ma = in.reserve_ratio_ma;
|
reserve_ratio_ma = in.reserve_ratio_ma;
|
||||||
|
yield_price = in.yield_price;
|
||||||
timestamp = in.timestamp;
|
timestamp = in.timestamp;
|
||||||
for (unsigned int i = 0; i < in.signature.length(); i += 2) {
|
for (unsigned int i = 0; i < in.signature.length(); i += 2) {
|
||||||
std::string byteString = in.signature.substr(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]);
|
ss << std::hex << std::setw(2) << std::setfill('0') << (0xff & signature[i]);
|
||||||
sig_hex += ss.str();
|
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);
|
return out.store(dest, hparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,6 +131,7 @@ namespace zephyr_oracle
|
|||||||
, reserve_ma(orig.reserve_ma)
|
, reserve_ma(orig.reserve_ma)
|
||||||
, reserve_ratio(orig.reserve_ratio)
|
, reserve_ratio(orig.reserve_ratio)
|
||||||
, reserve_ratio_ma(orig.reserve_ratio_ma)
|
, reserve_ratio_ma(orig.reserve_ratio_ma)
|
||||||
|
, yield_price(orig.yield_price)
|
||||||
, timestamp(orig.timestamp)
|
, timestamp(orig.timestamp)
|
||||||
{
|
{
|
||||||
std::memcpy(signature, orig.signature, sizeof(signature));
|
std::memcpy(signature, orig.signature, sizeof(signature));
|
||||||
@@ -142,6 +147,7 @@ namespace zephyr_oracle
|
|||||||
reserve_ma = orig.reserve_ma;
|
reserve_ma = orig.reserve_ma;
|
||||||
reserve_ratio = orig.reserve_ratio;
|
reserve_ratio = orig.reserve_ratio;
|
||||||
reserve_ratio_ma = orig.reserve_ratio_ma;
|
reserve_ratio_ma = orig.reserve_ratio_ma;
|
||||||
|
yield_price = orig.yield_price;
|
||||||
timestamp = orig.timestamp;
|
timestamp = orig.timestamp;
|
||||||
::memcpy(signature, orig.signature, sizeof(signature));
|
::memcpy(signature, orig.signature, sizeof(signature));
|
||||||
return *this;
|
return *this;
|
||||||
@@ -157,6 +163,7 @@ namespace zephyr_oracle
|
|||||||
(reserve_ma == other.reserve_ma) &&
|
(reserve_ma == other.reserve_ma) &&
|
||||||
(reserve_ratio == other.reserve_ratio) &&
|
(reserve_ratio == other.reserve_ratio) &&
|
||||||
(reserve_ratio_ma == other.reserve_ratio_ma) &&
|
(reserve_ratio_ma == other.reserve_ratio_ma) &&
|
||||||
|
(yield_price == other.yield_price) &&
|
||||||
(timestamp == other.timestamp) &&
|
(timestamp == other.timestamp) &&
|
||||||
!::memcmp(signature, other.signature, sizeof(signature)));
|
!::memcmp(signature, other.signature, sizeof(signature)));
|
||||||
}
|
}
|
||||||
@@ -233,8 +240,10 @@ namespace zephyr_oracle
|
|||||||
return missing_rates;
|
return missing_rates;
|
||||||
} else if (hf_version <= 4) {
|
} else if (hf_version <= 4) {
|
||||||
return missing_rates || (reserve_ratio == 0);
|
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
|
bool pricing_record::has_essential_rates(const uint8_t hf_version) const noexcept
|
||||||
|
|||||||
@@ -73,6 +73,18 @@ namespace zephyr_oracle
|
|||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
unsigned char signature[64];
|
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)
|
#pragma pack(pop)
|
||||||
class pricing_record
|
class pricing_record
|
||||||
{
|
{
|
||||||
@@ -88,6 +100,7 @@ namespace zephyr_oracle
|
|||||||
uint64_t reserve_ma;
|
uint64_t reserve_ma;
|
||||||
uint64_t reserve_ratio;
|
uint64_t reserve_ratio;
|
||||||
uint64_t reserve_ratio_ma;
|
uint64_t reserve_ratio_ma;
|
||||||
|
uint64_t yield_price;
|
||||||
uint64_t timestamp;
|
uint64_t timestamp;
|
||||||
unsigned char signature[64];
|
unsigned char signature[64];
|
||||||
|
|
||||||
@@ -192,4 +205,51 @@ namespace zephyr_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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
} // oracle
|
} // oracle
|
||||||
|
|||||||
+3
-3
@@ -2,14 +2,14 @@
|
|||||||
let u = require('../build/Release/cryptoforknote');
|
let u = require('../build/Release/cryptoforknote');
|
||||||
|
|
||||||
const b = Buffer.from(
|
const b = Buffer.from(
|
||||||
'010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000020001ffcb6d018f9ffec12d03125e128c041c8a2d41fab9ebe2a7a4b10afbef4e134ec7ba3151c8c730a644310353414c3c7334015f99bdbbe70161dafb2da2fd9a4285da893a7519cff350981a959f525c43e5c60211000000000000000000000000000000000001e3c7bfb00b00020001ffcb6d0023016b6961b458286074406192961c1f0e5236455f45fcd6c175c7142d6353a481d60400020000'
|
'0202fdaca8b906b1670506d0dc45b11cbc87f9ceedfd0cbfa56c14da72ccc27c45105391d2340300000000020001ffbabe0501a1ca9fab2a035c20fce0617f61abf3872058e15b90650b2ac812bf344766f56ee54b680f571e0353414c3c863401618163d383093580900f735ea9ad5d3d0029dd94c2f2a35db88ec37dc32e863302110000bcdd9d15420000000000000000000001c8f2e7ca0a00020001ffbabe05002301bb1086494863ac8de0987e09f7193ac85a356f8abf8725202cbf4dea8b2611f20400020000'
|
||||||
, 'hex');
|
, 'hex');
|
||||||
const b2 = u.convert_blob(b, 15);
|
const b2 = u.convert_blob(b, 15);
|
||||||
const h1 = b2.toString('hex');
|
const h1 = b2.toString('hex');
|
||||||
|
|
||||||
if (h1 === '010194a5ebb406f613c4e7514facf3e5b9923c885357b53f2b02f8e17f9721371296b99113035f00000000ac81ca3e7bc9369e63563923187d2cfdb42eac839c7fe24e6d5d0080c96d758f01') {
|
if (h1 === '0202fdaca8b906b1670506d0dc45b11cbc87f9ceedfd0cbfa56c14da72ccc27c45105391d2340300000000604ec6923c81b6477bb224a9c53158cea5c5aee36100aad59c498d3dab92750402') {
|
||||||
console.log('PASSED');
|
console.log('PASSED');
|
||||||
} else {
|
} else {
|
||||||
console.log('FAILED: ' + h1);
|
console.log('FAILED: ' + h1);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user