aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/asset_wire.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cryptonote_basic/asset_wire.h')
-rw-r--r--src/cryptonote_basic/asset_wire.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/cryptonote_basic/asset_wire.h b/src/cryptonote_basic/asset_wire.h
new file mode 100644
index 000000000..e5f63a01b
--- /dev/null
+++ b/src/cryptonote_basic/asset_wire.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include <boost/optional.hpp>
+
+#include "asset_confidential.h"
+
+namespace cryptonote
+{
+namespace assets
+{
+ constexpr uint8_t ASSET_TRANSACTION_WIRE_VERSION = 1;
+ constexpr size_t MAX_ASSET_BALANCE_GROUPS = 8;
+ constexpr size_t MAX_ASSET_TOTAL_INPUTS = 64;
+ constexpr size_t MAX_ASSET_TOTAL_DESTINATIONS = 64;
+ constexpr size_t MAX_ASSET_OWNERSHIP_PROOFS = 64;
+ constexpr size_t MAX_ASSET_RANGE_PROOFS = 16;
+ constexpr size_t MAX_ASSET_WIRE_BYTES = 256 * 1024;
+
+ struct confidential_asset_output
+ {
+ rct::key destination{};
+ rct::key commitment{};
+ };
+
+ // Inactive canonical payload prototype. The carrier hash is computed from
+ // the native transaction prefix with this envelope omitted; activation code
+ // must enforce that procedure to avoid a self-referential hash.
+ struct asset_transaction_payload
+ {
+ uint8_t version = ASSET_TRANSACTION_WIRE_VERSION;
+ network_type network = UNDEFINED;
+ crypto::hash carrier_prefix_hash{};
+ boost::optional<issuance_payload> issuance;
+ std::vector<confidential_asset_balance> balances;
+ std::vector<std::vector<rct::key>> output_destinations;
+ std::vector<asset_ownership_proof> ownership_proofs;
+ };
+
+ bool validate_asset_transaction_payload_shape(
+ const asset_transaction_payload& payload,
+ std::string* error = nullptr);
+ bool encode_asset_transaction_payload(
+ const asset_transaction_payload& payload,
+ std::vector<uint8_t>& encoded,
+ std::string* error = nullptr);
+ bool decode_asset_transaction_payload(
+ const std::vector<uint8_t>& encoded,
+ asset_transaction_payload& payload,
+ std::string* error = nullptr);
+ bool verify_asset_transaction_payload(
+ const asset_transaction_payload& payload,
+ const std::set<crypto::hash>& known_assets,
+ network_type expected_network,
+ const crypto::hash& expected_carrier_prefix_hash,
+ std::string* error = nullptr);
+ bool derive_asset_output_id(
+ network_type network,
+ const crypto::hash& carrier_prefix_hash,
+ const crypto::hash& asset_id,
+ uint32_t output_index,
+ const confidential_asset_output& output,
+ crypto::hash& output_id,
+ std::string* error = nullptr);
+}
+}