aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/asset_db.h
blob: a43d865858f714c1853f5e5066ee336188be7fec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once

#include <string>
#include <vector>

#include "blockchain_db.h"
#include "cryptonote_basic/asset_confidential.h"
#include "cryptonote_basic/asset_types.h"
#include "cryptonote_basic/asset_wire.h"

namespace cryptonote
{
namespace assets
{
  bool load_registry_from_db(
    const BlockchainDB& db,
    network_type expected_network,
    asset_registry& registry,
    std::string* error = nullptr);

  // The caller must hold the blockchain write transaction. Semantic
  // validation finishes before the first database write, and any exception
  // raised by storage must cause that outer transaction to be aborted.
  bool apply_block_extensions_to_db(
    BlockchainDB& db,
    const std::vector<transaction_extension>& extensions,
    const std::vector<crypto::hash>& carrier_prefix_hashes,
    network_type expected_network,
    uint64_t height,
    std::vector<crypto::hash>& asset_ids,
    std::string* error = nullptr);

  // Resolve every claimed ring member against consensus storage and reject
  // key images already spent by an earlier accepted asset transaction before
  // performing the cryptographic ownership check.
  bool verify_asset_ownership_against_db(
    const BlockchainDB& db,
    const asset_ownership_proof& proof,
    network_type expected_network,
    const crypto::hash& carrier_prefix_hash,
    std::string* error = nullptr);

  // The caller owns the outer blockchain write transaction. Every semantic,
  // ownership, collision, and collection-authority check completes before the
  // first write so an accepted payload changes registry, output, and spent-key
  // state atomically.
  bool apply_asset_transaction_to_db(
    BlockchainDB& db,
    const asset_transaction_payload& payload,
    network_type expected_network,
    const crypto::hash& expected_carrier_prefix_hash,
    uint64_t height,
    std::vector<crypto::hash>& output_ids,
    std::string* error = nullptr);
}
}