-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtransaction_functions.cpp
216 lines (177 loc) · 6.99 KB
/
transaction_functions.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// // Copyright (c) 2016-2024 Knuth Project developers.
// // Distributed under the MIT software license, see the accompanying
// // file COPYING or http://www.opensource.org/licenses/mit-license.php.
// #include <kth/capi/wallet/transaction_functions.h>
// #include <kth/domain/wallet/payment_address.hpp>
// #include <kth/domain/wallet/transaction_functions.hpp>
// #include <kth/capi/conversions.hpp>
// #include <kth/capi/helpers.hpp>
// #include <kth/capi/primitives.h>
// // ---------------------------------------------------------------------------
// extern "C" {
// kth_error_code_t kth_wallet_tx_encode_with_extra_outputs(
// kth_point_list_t outputs_to_spend,
// kth_raw_output_list_t destiny_and_amount,
// kth_output_list_t extra_outputs,
// uint32_t locktime /*= 0*/,
// uint32_t tx_version /*= 1*/,
// uint8_t script_version /*= 5*/,
// kth_transaction_t* out_transaction) {
// auto p = kth::domain::wallet::tx_encode(
// kth_chain_point_list_const_cpp(outputs_to_spend),
// kth_wallet_raw_output_list_const_cpp(destiny_and_amount),
// kth_chain_output_list_const_cpp(extra_outputs),
// locktime,
// tx_version,
// script_version
// );
// if (p.first == kth::error::success) {
// *out_transaction = new kth::domain::chain::transaction(std::move(p.second));
// } else {
// *out_transaction = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// kth_error_code_t kth_wallet_tx_encode(
// kth_point_list_t outputs_to_spend,
// kth_raw_output_list_t destiny_and_amount,
// uint32_t locktime /*= 0*/,
// uint32_t tx_version /*= 1*/,
// uint8_t script_version /*= 5*/,
// kth_transaction_t* out_transaction) {
// auto p = kth::domain::wallet::tx_encode(
// kth_chain_point_list_const_cpp(outputs_to_spend),
// kth_wallet_raw_output_list_const_cpp(destiny_and_amount),
// locktime,
// tx_version,
// script_version
// );
// if (p.first == kth::error::success) {
// *out_transaction = new kth::domain::chain::transaction(std::move(p.second));
// } else {
// *out_transaction = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// kth_error_code_t input_signature_old(
// kth_ec_secret_t private_key, /*32 element byte array*/
// kth_script_t output_script,
// kth_transaction_t tx,
// uint32_t index,
// uint8_t sign_type /*= 0x01*/,
// kth_bool_t anyone_can_pay /*= false*/,
// uint8_t** out_signature,
// kth_size_t* out_signature_size) {
// auto p = kth::domain::wallet::input_signature_old(
// kth::to_array(private_key.hash),
// kth_chain_script_const_cpp(output_script),
// kth_chain_transaction_const_cpp(tx),
// index,
// sign_type,
// kth::int_to_bool(anyone_can_pay)
// );
// if (p.first == kth::error::success) {
// *out_signature = kth::create_c_array(p.second, *out_signature_size);
// } else {
// *out_signature_size = 0;
// *out_signature = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// kth_error_code_t input_signature_btc(
// kth_ec_secret_t private_key, /*32 element byte array*/
// kth_script_t output_script,
// kth_transaction_t tx,
// uint64_t amount,
// uint32_t index,
// uint8_t sign_type /*= 0x01*/,
// kth_bool_t anyone_can_pay /*= false*/,
// uint8_t** out_signature,
// kth_size_t* out_signature_size) {
// auto p = kth::domain::wallet::input_signature_btc(
// kth::to_array(private_key.hash),
// kth_chain_script_const_cpp(output_script),
// kth_chain_transaction_const_cpp(tx),
// amount,
// index,
// sign_type,
// kth::int_to_bool(anyone_can_pay)
// );
// if (p.first == kth::error::success) {
// *out_signature = kth::create_c_array(p.second, *out_signature_size);
// } else {
// *out_signature_size = 0;
// *out_signature = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// kth_error_code_t input_signature_bch(
// kth_ec_secret_t private_key, /*32 element byte array*/
// kth_script_t output_script,
// kth_transaction_t tx,
// uint64_t amount,
// uint32_t index,
// uint8_t sign_type /*= 0x01*/,
// kth_bool_t anyone_can_pay /*= false*/,
// uint8_t** out_signature,
// kth_size_t* out_signature_size) {
// auto p = kth::domain::wallet::input_signature_bch(
// kth::to_array(private_key.hash),
// kth_chain_script_const_cpp(output_script),
// kth_chain_transaction_const_cpp(tx),
// amount,
// index,
// sign_type,
// kth::int_to_bool(anyone_can_pay)
// );
// if (p.first == kth::error::success) {
// *out_signature = kth::create_c_array(p.second, *out_signature_size);
// } else {
// *out_signature_size = 0;
// *out_signature = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// kth_error_code_t input_set_script(
// kth_script_t script,
// kth_transaction_t tx,
// uint32_t index /*= 0*/,
// kth_transaction_t* out_transaction) {
// auto p = kth::domain::wallet::input_set(
// kth_chain_script_const_cpp(script),
// kth_chain_transaction_const_cpp(tx),
// index
// );
// if (p.first == kth::error::success) {
// *out_transaction = new kth::domain::chain::transaction(std::move(p.second));
// } else {
// *out_transaction = nullptr;
// }
// return kth::to_c_err(p.first);
// }
// // kth_error_code_t input_set_signature(
// // uint8_t* signature,
// // kth_size_t signature_n,
// // kth_ec_public_t public_key,
// // kth_transaction_t tx,
// // uint32_t index /*= 0*/,
// // kth_transaction_t* out_transaction) {
// // kth::data_chunk signature_cpp(signature, std::next(signature, signature_n));
// // auto p = kth::domain::wallet::input_set(
// // signature_cpp,
// // kth_wallet_ec_public_const_cpp(public_key),
// // kth_chain_transaction_const_cpp(tx),
// // index
// // );
// // if (p.first == kth::error::success) {
// // *out_transaction = new kth::domain::chain::transaction(std::move(p.second));
// // } else {
// // *out_transaction = nullptr;
// // }
// // return kth::to_c_err(p.first);
// // }
// // BC_API std::pair<error::kth_error_code_t, chain::transaction> input_set(data_chunk const& signature,
// // wallet::ec_public const& public_key,
// // chain::transaction const& tx,
// // uint32_t index = 0);
// } // extern "C"