Loading...
Searching...
No Matches
transaction.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include "absl/status/statusor.h"
25#include "proto/utxo/config.pb.h"
26#include "proto/utxo/utxo.pb.h"
27
28namespace resdb {
29namespace utxo {
30
32 public:
33 Transaction(const Config& config, Wallet* wallet);
35
36 int64_t AddTransaction(const std::string& utxo_string);
37 int64_t AddTransaction(const UTXO& utxo);
38
39 std::vector<UTXO> GetUTXO(int64_t end_id, int num);
40
41 private:
42 int AddCoin(const UTXO& utxo);
43 bool VerifyUTXO(const UTXO& utxo, const std::vector<UTXOOut>& ins);
44 int64_t GetUTXOOutValue(int64_t tx_id, int out_idx,
45 const std::string& address);
46
47 absl::StatusOr<std::vector<UTXOOut>> GetInput(const UTXO& utxo);
48
49 private:
50 std::unique_ptr<TxMempool> tx_mempool_;
51 Config config_;
52 Wallet* wallet_;
53};
54
55} // namespace utxo
56} // namespace resdb
std::vector< UTXO > GetUTXO(int64_t end_id, int num)
int64_t AddTransaction(const std::string &utxo_string)