Monero
Loading...
Searching...
No Matches
pending_tx_validation.h
Go to the documentation of this file.
1// Copyright (c) 2025-2026, The Monero Project
2//
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without modification, are
6// permitted provided that the following conditions are met:
7//
8// 1. Redistributions of source code must retain the above copyright notice, this list of
9// conditions and the following disclaimer.
10//
11// 2. Redistributions in binary form must reproduce the above copyright notice, this list
12// of conditions and the following disclaimer in the documentation and/or other
13// materials provided with the distribution.
14//
15// 3. Neither the name of the copyright holder nor the names of its contributors may be
16// used to endorse or promote products derived from this software without specific
17// prior written permission.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29#pragma once
30
31//local headers
32#include "crypto/crypto.h"
35#include "cryptonote_config.h"
36#include "wallet2.h"
37
38//third party headers
39
40//standard headers
41#include <functional>
42#include <optional>
43#include <unordered_map>
44#include <vector>
45
46namespace tools
47{
48namespace wallet
49{
50// Checks that inputs are not duplicated across transactions in the set.
51// Checks that duplicate destination addresses across the tx set have the same normal/subaddress
52// designations.
53// Checks that input amounts summed across the tx set fit in uint64_t.
54// *Only* for checking consistency between txs (which may be proposals, partially signed, or fully signed).
55// Use `sanity_check_pending_tx` to validate internal consistency for individual `pending_tx`, or
56// `sanity_check_pending_tx_set` to check consistent ins/outs + internals.
57void check_consistent_ins_outs(const std::vector<wallet2::tx_construction_data> &txes);
58void check_consistent_ins_outs(const std::vector<wallet2::pending_tx> &txes);
59void sanity_check_tx_construction_data(const wallet2::tx_construction_data &tx);
60// Checks ins/outs consistency across the set, then validates each unsigned transaction.
61void sanity_check_unsigned_tx_set(const std::vector<wallet2::tx_construction_data> &txes,
62 const cryptonote::account_keys &account_keys,
63 const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses);
85void sanity_check_pending_tx(const wallet2::pending_tx &ptx,
86 const cryptonote::network_type nettype,
87 const cryptonote::account_keys &account_keys,
88 const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses,
89 const std::vector<wallet2::transfer_details> &transfers,
90 const bool redacted,
91 const boost::optional<std::function<const crypto::key_image(const size_t)>> &transfer_ki_resolver,
92 const bool allow_read_only);
93// Checks ins/outs consistency across the set, then validates each pending transaction.
94void sanity_check_pending_tx_set(const std::vector<wallet2::pending_tx> &ptxs,
95 const cryptonote::network_type nettype,
96 const cryptonote::account_keys &account_keys,
97 const std::unordered_map<crypto::public_key, cryptonote::subaddress_index> &subaddresses,
98 const std::vector<wallet2::transfer_details> &transfers,
99 const bool redacted,
100 const boost::optional<std::function<const crypto::key_image(const size_t)>> &transfer_ki_resolver,
101 const bool allow_read_only);
102} //namespace wallet
103} //namespace tools
std::vector< tools::wallet2::pending_tx > ptx
Definition cold-transaction.cpp:56
POD_CLASS key_image
Definition crypto.h:95
network_type
Definition cryptonote_config.h:302
Definition pending_tx_validation.cpp:65
void sanity_check_tx_construction_data(const wallet2::tx_construction_data &tx)
Definition pending_tx_validation.cpp:876
void check_consistent_ins_outs(const std::vector< wallet2::tx_construction_data > &txes)
Definition pending_tx_validation.cpp:866
void sanity_check_unsigned_tx_set(const std::vector< wallet2::tx_construction_data > &txes, const cryptonote::account_keys &account_keys, const std::unordered_map< crypto::public_key, cryptonote::subaddress_index > &subaddresses)
Definition pending_tx_validation.cpp:895
void sanity_check_pending_tx(const wallet2::pending_tx &ptx, const cryptonote::network_type nettype, const cryptonote::account_keys &account_keys, const std::unordered_map< crypto::public_key, cryptonote::subaddress_index > &subaddresses, const std::vector< wallet2::transfer_details > &transfers, const bool redacted, const boost::optional< std::function< const crypto::key_image(const size_t)> > &transfer_ki_resolver, const bool allow_read_only)
Definition pending_tx_validation.cpp:309
void sanity_check_pending_tx_set(const std::vector< wallet2::pending_tx > &ptxs, const cryptonote::network_type nettype, const cryptonote::account_keys &account_keys, const std::unordered_map< crypto::public_key, cryptonote::subaddress_index > &subaddresses, const std::vector< wallet2::transfer_details > &transfers, const bool redacted, const boost::optional< std::function< const crypto::key_image(const size_t)> > &transfer_ki_resolver, const bool allow_read_only)
Definition pending_tx_validation.cpp:905
Various Tools.
Definition apply_permutation.h:40
cryptonote::transaction tx
Definition transaction.cpp:40