-
Notifications
You must be signed in to change notification settings - Fork 25
/
wallet.h
4088 lines (3830 loc) · 149 KB
/
wallet.h
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2022. The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
// This file was generated by cargo-bindgen. Please do not edit manually.
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
/**
* The number of unique fields available. This always matches the number of variants in `OutputField`.
*/
#define OutputFields_NUM_FIELDS 10
enum TariTypeTag {
Text = 0,
Utxo = 1,
Commitment = 2,
U64 = 3,
I64 = 4,
};
enum TariUtxoSort {
ValueAsc = 0,
ValueDesc = 1,
MinedHeightAsc = 2,
MinedHeightDesc = 3,
};
/**
* This struct holds the detailed balance of the Output Manager Service.
*/
struct Balance;
struct ByteVector;
/**
* # Commitment and public key (CAPK) signatures
*
* Given a commitment `commitment = a*H + x*G` and group element `pubkey = y*G`, a CAPK signature is based on
* a representation proof of both openings: `(a, x)` and `y`. It additionally binds to arbitrary message data `m`
* via the challenge to produce a signature construction.
*
* It is used in Tari protocols as part of transaction authorization.
*
* The construction works as follows:
* - Sample scalar nonces `r_a, r_x, r_y` uniformly at random.
* - Compute ephemeral values `ephemeral_commitment = r_a*H + r_x*G` and `ephemeral_pubkey = r_y*G`.
* - Use strong Fiat-Shamir to produce a challenge `e`. If `e == 0` (this is unlikely), abort and start over.
* - Compute the responses `u_a = r_a + e*a` and `u_x = r_x + e*x` and `u_y = r_y + e*y`.
*
* The signature is the tuple `(ephemeral_commitment, ephemeral_pubkey, u_a, u_x, u_y)`.
*
* To verify:
* - The verifier computes the challenge `e` and rejects the signature if `e == 0` (this is unlikely).
* - Verification succeeds if and only if the following equations hold: `u_a*H + u*x*G == ephemeral_commitment +
* e*commitment` `u_y*G == ephemeral_pubkey + e*pubkey`
*
* We note that it is possible to make verification slightly more efficient. To do so, the verifier selects a nonzero
* scalar weight `w` uniformly at random (not through Fiat-Shamir!) and accepts the signature if and only if the
* following equation holds:
* `u_a*H + (u_x + w*u_y)*G - ephemeral_commitment - w*ephemeral_pubkey - e*commitment - (w*e)*pubkey == 0`
* The use of efficient multiscalar multiplication algorithms may also be useful for efficiency.
* The use of precomputation tables for `G` and `H` may also be useful for efficiency.
*/
struct CommitmentAndPublicKeySignature_RistrettoPublicKey__RistrettoSecretKey;
struct CompletedTransaction;
struct Contact;
struct ContactsLivenessData;
struct Covenant;
struct EmojiSet;
/**
* Encrypted data for the extended-nonce variant XChaCha20-Poly1305 encryption
* Borsh schema only accept array sizes 0 - 32, 64, 65, 128, 256, 512, 1024 and 2048
*/
struct EncryptedData;
struct FeePerGramStat;
struct FeePerGramStatsResponse;
struct InboundTransaction;
struct OutboundTransaction;
/**
* Options for UTXO's
*/
struct OutputFeatures;
/**
* Configuration for a comms node
*/
struct P2pConfig;
/**
* The [PublicKey](trait.PublicKey.html) implementation for `ristretto255` is a thin wrapper around the dalek
* library's [RistrettoPoint](struct.RistrettoPoint.html).
*
* ## Creating public keys
* Both [PublicKey](trait.PublicKey.html) and [ByteArray](trait.ByteArray.html) are implemented on
* `RistrettoPublicKey` so all of the following will work:
* ```edition2018
* use rand;
* use tari_crypto::{
* keys::{PublicKey, SecretKey},
* ristretto::{RistrettoPublicKey, RistrettoSecretKey},
* };
* use tari_utilities::{hex::Hex, ByteArray};
*
* let mut rng = rand::thread_rng();
* let _p1 = RistrettoPublicKey::from_bytes(&[
* 224, 196, 24, 247, 200, 217, 196, 205, 215, 57, 91, 147, 234, 18, 79, 58, 217, 144, 33,
* 187, 104, 29, 252, 51, 2, 169, 217, 154, 46, 83, 230, 78,
* ]);
* let _p2 = RistrettoPublicKey::from_hex(
* &"e882b131016b52c1d3337080187cf768423efccbb517bb495ab812c4160ff44e",
* );
* let sk = RistrettoSecretKey::random(&mut rng);
* let _p3 = RistrettoPublicKey::from_secret_key(&sk);
* ```
*/
struct RistrettoPublicKey;
/**
* The [SecretKey](trait.SecretKey.html) implementation for [Ristretto](https://ristretto.group) is a thin wrapper
* around the Dalek [Scalar](struct.Scalar.html) type, representing a 256-bit integer (mod the group order).
*
* ## Creating secret keys
* [ByteArray](trait.ByteArray.html) and [SecretKeyFactory](trait.SecretKeyFactory.html) are implemented for
* [SecretKey](struct .SecretKey.html), so any of the following work (note that hex strings and byte array are
* little-endian):
*
* ```edition2018
* use rand;
* use tari_crypto::{keys::SecretKey, ristretto::RistrettoSecretKey};
* use tari_utilities::{hex::Hex, ByteArray};
*
* let mut rng = rand::thread_rng();
* let _k1 = RistrettoSecretKey::from_bytes(&[
* 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
* 0, 0,
* ]);
* let _k2 = RistrettoSecretKey::from_hex(&"100000002000000030000000040000000");
* let _k3 = RistrettoSecretKey::random(&mut rng);
* ```
*/
struct RistrettoSecretKey;
struct TariAddress;
struct TariBaseNodeState;
struct TariCompletedTransactions;
struct TariContacts;
struct TariPendingInboundTransactions;
struct TariPendingOutboundTransactions;
struct TariPublicKeys;
struct TariSeedWords;
struct TariUnblindedOutputs;
struct TariWallet;
/**
* The transaction kernel tracks the excess for a given transaction. For an explanation of what the excess is, and
* why it is necessary, refer to the
* [Mimblewimble TLU post](https://tlu.tarilabs.com/protocols/mimblewimble-1/sources/PITCHME.link.html?highlight=mimblewimble#mimblewimble).
* The kernel also tracks other transaction metadata, such as the lock height for the transaction (i.e. the earliest
* this transaction can be mined) and the transaction fee, in cleartext.
*/
struct TransactionKernel;
struct TransactionSendStatus;
struct TransportConfig;
/**
* An unblinded output is one where the value and spending key (blinding factor) are known. This can be used to
* build both inputs and outputs (every input comes from an output)
*/
struct UnblindedOutput;
/**
* -------------------------------- Vector ------------------------------------------------ ///
*/
struct TariVector {
enum TariTypeTag tag;
uintptr_t len;
uintptr_t cap;
void *ptr;
};
struct TariCoinPreview {
struct TariVector *expected_outputs;
uint64_t fee;
};
typedef struct TransactionKernel TariTransactionKernel;
/**
* Define the explicit Public key implementation for the Tari base layer
*/
typedef struct RistrettoPublicKey PublicKey;
typedef PublicKey TariPublicKey;
/**
* Define the explicit Secret key implementation for the Tari base layer.
*/
typedef struct RistrettoSecretKey PrivateKey;
typedef PrivateKey TariPrivateKey;
typedef struct TariAddress TariWalletAddress;
/**
* # A commitment and public key (CAPK) signature implementation on Ristretto
*
* `RistrettoComAndPubSig` utilises the [curve25519-dalek](https://github.com/dalek-cryptography/curve25519-dalek1)
* implementation of `ristretto255` to provide CAPK signature functionality.
*
* ## Examples
*
* You can create a `RistrettoComAndPubSig` from its component parts:
*
* ```edition2018
* # use tari_crypto::ristretto::*;
* # use tari_crypto::keys::*;
* # use tari_crypto::commitment::HomomorphicCommitment;
* # use tari_utilities::ByteArray;
* # use tari_utilities::hex::Hex;
*
* let ephemeral_commitment = HomomorphicCommitment::from_hex(
* "8063d85e151abee630e643e2b3dc47bfaeb8aa859c9d10d60847985f286aad19",
* )
* .unwrap();
* let ephemeral_pubkey = RistrettoPublicKey::from_hex(
* "8063d85e151abee630e643e2b3dc47bfaeb8aa859c9d10d60847985f286aad19",
* )
* .unwrap();
* let u_a = RistrettoSecretKey::from_bytes(b"10000000000000000000000010000000").unwrap();
* let u_x = RistrettoSecretKey::from_bytes(b"a00000000000000000000000a0000000").unwrap();
* let u_y = RistrettoSecretKey::from_bytes(b"a00000000000000000000000a0000000").unwrap();
* let sig = RistrettoComAndPubSig::new(ephemeral_commitment, ephemeral_pubkey, u_a, u_x, u_y);
* ```
*
* or you can create a signature for a commitment by signing a message with knowledge of the commitment and then
* verify it by calling the `verify_challenge` method:
*
* ```rust
* # use tari_crypto::ristretto::*;
* # use tari_crypto::keys::*;
* # use tari_crypto::hash::blake2::Blake256;
* # use digest::Digest;
* # use tari_crypto::commitment::HomomorphicCommitmentFactory;
* # use tari_crypto::ristretto::pedersen::*;
* use tari_crypto::ristretto::pedersen::commitment_factory::PedersenCommitmentFactory;
* use tari_utilities::hex::Hex;
*
* let mut rng = rand::thread_rng();
* let a_val = RistrettoSecretKey::random(&mut rng);
* let x_val = RistrettoSecretKey::random(&mut rng);
* let y_val = RistrettoSecretKey::random(&mut rng);
* let a_nonce = RistrettoSecretKey::random(&mut rng);
* let x_nonce = RistrettoSecretKey::random(&mut rng);
* let y_nonce = RistrettoSecretKey::random(&mut rng);
* let e = Blake256::digest(b"Maskerade"); // In real life, this should be strong Fiat-Shamir!
* let factory = PedersenCommitmentFactory::default();
* let commitment = factory.commit(&x_val, &a_val);
* let pubkey = RistrettoPublicKey::from_secret_key(&y_val);
* let sig = RistrettoComAndPubSig::sign(
* &a_val, &x_val, &y_val, &a_nonce, &x_nonce, &y_nonce, &e, &factory,
* )
* .unwrap();
* assert!(sig.verify_challenge(&commitment, &pubkey, &e, &factory, &mut rng));
* ```
*/
typedef struct CommitmentAndPublicKeySignature_RistrettoPublicKey__RistrettoSecretKey RistrettoComAndPubSig;
/**
* Define the explicit Commitment Signature implementation for the Tari base layer.
*/
typedef RistrettoComAndPubSig ComAndPubSignature;
typedef ComAndPubSignature TariComAndPubSignature;
typedef struct UnblindedOutput TariUnblindedOutput;
typedef struct OutputFeatures TariOutputFeatures;
typedef struct Covenant TariCovenant;
typedef struct EncryptedData TariEncryptedOpenings;
typedef struct Contact TariContact;
typedef struct ContactsLivenessData TariContactsLivenessData;
typedef struct CompletedTransaction TariCompletedTransaction;
typedef struct OutboundTransaction TariPendingOutboundTransaction;
typedef struct InboundTransaction TariPendingInboundTransaction;
typedef struct TransactionSendStatus TariTransactionSendStatus;
typedef struct TransportConfig TariTransportConfig;
typedef struct P2pConfig TariCommsConfig;
typedef struct Balance TariBalance;
typedef struct FeePerGramStatsResponse TariFeePerGramStats;
typedef struct FeePerGramStat TariFeePerGramStat;
struct TariUtxo {
const char *commitment;
uint64_t value;
uint64_t mined_height;
uint64_t mined_timestamp;
uint8_t status;
};
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
/**
* Initialize a new `TariVector`
*
* ## Arguments
* `tag` - A predefined type-tag of the vector's payload.
*
* ## Returns
* `*mut TariVector` - Returns a pointer to a `TariVector`.
*
* # Safety
* `destroy_tari_vector()` must be called to free the allocated memory.
*/
struct TariVector *create_tari_vector(enum TariTypeTag tag);
/**
* Appending a given value to the back of the vector.
*
* ## Arguments
* `s` - An item to push.
*
* ## Returns
*
*
* # Safety
* `destroy_tari_vector()` must be called to free the allocated memory.
*/
void tari_vector_push_string(struct TariVector *tv, const char *s, int32_t *error_ptr);
/**
* Frees memory allocated for `TariVector`.
*
* ## Arguments
* `v` - The pointer to `TariVector`
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void destroy_tari_vector(struct TariVector *v);
/**
* Frees memory allocated for `TariCoinPreview`.
*
* ## Arguments
* `v` - The pointer to `TariCoinPreview`
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void destroy_tari_coin_preview(struct TariCoinPreview *p);
/**
* -------------------------------- Strings ------------------------------------------------ ///
* Frees memory for a char array
*
* ## Arguments
* `ptr` - The pointer to be freed
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C.
*
* # Safety
* None
*/
void string_destroy(char *ptr);
/**
* -------------------------------------------------------------------------------------------- ///
* ----------------------------------- Transaction Kernel ------------------------------------- ///
* Gets the excess for a TariTransactionKernel
*
* ## Arguments
* `x` - The pointer to a TariTransactionKernel
*
* ## Returns
* `*mut c_char` - Returns a pointer to a char array. Note that it returns empty if there
* was an error
*
* # Safety
* The ```string_destroy``` method must be called when finished with a string from rust to prevent a memory leak
*/
char *transaction_kernel_get_excess_hex(TariTransactionKernel *kernel,
int *error_out);
/**
* Gets the public nonce for a TariTransactionKernel
*
* ## Arguments
* `x` - The pointer to a TariTransactionKernel
*
* ## Returns
* `*mut c_char` - Returns a pointer to a char array. Note that it returns empty if there
* was an error
*
* # Safety
* The ```string_destroy``` method must be called when finished with a string from rust to prevent a memory leak
*/
char *transaction_kernel_get_excess_public_nonce_hex(TariTransactionKernel *kernel,
int *error_out);
/**
* Gets the signature for a TariTransactionKernel
*
* ## Arguments
* `x` - The pointer to a TariTransactionKernel
*
* ## Returns
* `*mut c_char` - Returns a pointer to a char array. Note that it returns empty if there
* was an error
*
* # Safety
* The ```string_destroy``` method must be called when finished with a string from rust to prevent a memory leak
*/
char *transaction_kernel_get_excess_signature_hex(TariTransactionKernel *kernel,
int *error_out);
/**
* Frees memory for a TariTransactionKernel
*
* ## Arguments
* `x` - The pointer to a TariTransactionKernel
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void transaction_kernel_destroy(TariTransactionKernel *x);
/**
* -------------------------------------------------------------------------------------------- ///
* -------------------------------- ByteVector ------------------------------------------------ ///
* Creates a ByteVector
*
* ## Arguments
* `byte_array` - The pointer to the byte array
* `element_count` - The number of elements in byte_array
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut ByteVector` - Pointer to the created ByteVector. Note that it will be ptr::null_mut()
* if the byte_array pointer was null or if the elements in the byte_vector don't match
* element_count when it is created
*
* # Safety
* The ```byte_vector_destroy``` function must be called when finished with a ByteVector to prevent a memory leak
*/
struct ByteVector *byte_vector_create(const unsigned char *byte_array,
unsigned int element_count,
int *error_out);
/**
* Frees memory for a ByteVector
*
* ## Arguments
* `bytes` - The pointer to a ByteVector
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void byte_vector_destroy(struct ByteVector *bytes);
/**
* Gets a c_uchar at position in a ByteVector
*
* ## Arguments
* `ptr` - The pointer to a ByteVector
* `position` - The integer position
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `c_uchar` - Returns a character. Note that the character will be a null terminator (0) if ptr
* is null or if the position is invalid
*
* # Safety
* None
*/
unsigned char byte_vector_get_at(struct ByteVector *ptr,
unsigned int position,
int *error_out);
/**
* Gets the number of elements in a ByteVector
*
* ## Arguments
* `ptr` - The pointer to a ByteVector
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `c_uint` - Returns the integer number of elements in the ByteVector. Note that it will be zero
* if ptr is null
*
* # Safety
* None
*/
unsigned int byte_vector_get_length(const struct ByteVector *vec,
int *error_out);
/**
* -------------------------------------------------------------------------------------------- ///
* -------------------------------- Public Key ------------------------------------------------ ///
* Creates a TariPublicKey from a ByteVector
*
* ## Arguments
* `bytes` - The pointer to a ByteVector
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `TariPublicKey` - Returns a public key. Note that it will be ptr::null_mut() if bytes is null or
* if there was an error with the contents of bytes
*
* # Safety
* The ```public_key_destroy``` function must be called when finished with a TariPublicKey to prevent a memory leak
*/
TariPublicKey *public_key_create(struct ByteVector *bytes,
int *error_out);
/**
* Frees memory for a TariPublicKey
*
* ## Arguments
* `pk` - The pointer to a TariPublicKey
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void public_key_destroy(TariPublicKey *pk);
/**
* Frees memory for TariPublicKeys
*
* ## Arguments
* `pks` - The pointer to TariPublicKeys
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void public_keys_destroy(struct TariPublicKeys *pks);
/**
* Gets a ByteVector from a TariPublicKey
*
* ## Arguments
* `pk` - The pointer to a TariPublicKey
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut ByteVector` - Returns a pointer to a ByteVector. Note that it returns ptr::null_mut() if pk is null
*
* # Safety
* The ```byte_vector_destroy``` function must be called when finished with the ByteVector to prevent a memory leak.
*/
struct ByteVector *public_key_get_bytes(TariPublicKey *pk,
int *error_out);
/**
* Creates a TariPublicKey from a TariPrivateKey
*
* ## Arguments
* `secret_key` - The pointer to a TariPrivateKey
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariPublicKey` - Returns a pointer to a TariPublicKey
*
* # Safety
* The ```private_key_destroy``` method must be called when finished with a private key to prevent a memory leak
*/
TariPublicKey *public_key_from_private_key(TariPrivateKey *secret_key,
int *error_out);
/**
* Creates a TariPublicKey from a char array
*
* ## Arguments
* `key` - The pointer to a char array which is hex encoded
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariPublicKey` - Returns a pointer to a TariPublicKey. Note that it returns ptr::null_mut()
* if key is null or if there was an error creating the TariPublicKey from key
*
* # Safety
* The ```public_key_destroy``` method must be called when finished with a TariPublicKey to prevent a memory leak
*/
TariPublicKey *public_key_from_hex(const char *key,
int *error_out);
/**
* -------------------------------------------------------------------------------------------- ///
* -------------------------------- Tari Address ---------------------------------------------- ///
* Creates a TariWalletAddress from a ByteVector
*
* ## Arguments
* `bytes` - The pointer to a ByteVector
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `TariWalletAddress` - Returns a public key. Note that it will be ptr::null_mut() if bytes is null or
* if there was an error with the contents of bytes
*
* # Safety
* The ```public_key_destroy``` function must be called when finished with a TariWalletAddress to prevent a memory leak
*/
TariWalletAddress *tari_address_create(struct ByteVector *bytes,
int *error_out);
/**
* Frees memory for a TariWalletAddress
*
* ## Arguments
* `pk` - The pointer to a TariWalletAddress
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void tari_address_destroy(TariWalletAddress *address);
/**
* Gets a ByteVector from a TariWalletAddress
*
* ## Arguments
* `address` - The pointer to a TariWalletAddress
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut ByteVector` - Returns a pointer to a ByteVector. Note that it returns ptr::null_mut() if address is null
*
* # Safety
* The ```byte_vector_destroy``` function must be called when finished with the ByteVector to prevent a memory leak.
*/
struct ByteVector *tari_address_get_bytes(TariWalletAddress *address,
int *error_out);
/**
* Creates a TariWalletAddress from a TariPrivateKey
*
* ## Arguments
* `secret_key` - The pointer to a TariPrivateKey
* `network` - an u8 indicating the network
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariWalletAddress` - Returns a pointer to a TariWalletAddress
*
* # Safety
* The ```private_key_destroy``` method must be called when finished with a private key to prevent a memory leak
*/
TariWalletAddress *tari_address_from_private_key(TariPrivateKey *secret_key,
unsigned int network,
int *error_out);
/**
* Creates a TariWalletAddress from a char array
*
* ## Arguments
* `address` - The pointer to a char array which is hex encoded
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariWalletAddress` - Returns a pointer to a TariWalletAddress. Note that it returns ptr::null_mut()
* if key is null or if there was an error creating the TariWalletAddress from key
*
* # Safety
* The ```public_key_destroy``` method must be called when finished with a TariWalletAddress to prevent a memory leak
*/
TariWalletAddress *tari_address_from_hex(const char *address,
int *error_out);
/**
* Creates a char array from a TariWalletAddress in emoji format
*
* ## Arguments
* `address` - The pointer to a TariWalletAddress
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut c_char` - Returns a pointer to a char array. Note that it returns empty
* if emoji is null or if there was an error creating the emoji string from TariWalletAddress
*
* # Safety
* The ```string_destroy``` method must be called when finished with a string from rust to prevent a memory leak
*/
char *tari_address_to_emoji_id(TariWalletAddress *address,
int *error_out);
/**
* Creates a TariWalletAddress from a char array in emoji format
*
* ## Arguments
* `const *c_char` - The pointer to a TariWalletAddress
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut c_char` - Returns a pointer to a TariWalletAddress. Note that it returns null on error.
*
* # Safety
* The ```public_key_destroy``` method must be called when finished with a TariWalletAddress to prevent a memory leak
*/
TariWalletAddress *emoji_id_to_tari_address(const char *emoji,
int *error_out);
/**
* -------------------------------------------------------------------------------------------- ///
*
* ------------------------------- ComAndPubSignature Signature ---------------------------------------///
* Creates a TariComAndPubSignature from `u_a`. `u_x`, `u_y`, `ephemeral_pubkey` and `ephemeral_commitment_bytes`
* ByteVectors
*
* ## Arguments
* `ephemeral_commitment_bytes` - The public ephemeral commitment component as a ByteVector
* `ephemeral_pubkey_bytes` - The public ephemeral pubkey component as a ByteVector
* `u_a_bytes` - The u_a signature component as a ByteVector
* `u_x_bytes` - The u_x signature component as a ByteVector
* `u_y_bytes` - The u_y signature component as a ByteVector
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `TariComAndPubSignature` - Returns a ComAndPubS signature. Note that it will be ptr::null_mut() if any argument is
* null or if there was an error with the contents of bytes
*
* # Safety
* The ```commitment_signature_destroy``` function must be called when finished with a TariComAndPubSignature to
* prevent a memory leak
*/
TariComAndPubSignature *commitment_and_public_signature_create_from_bytes(const struct ByteVector *ephemeral_commitment_bytes,
const struct ByteVector *ephemeral_pubkey_bytes,
const struct ByteVector *u_a_bytes,
const struct ByteVector *u_x_bytes,
const struct ByteVector *u_y_bytes,
int *error_out);
/**
* Frees memory for a TariComAndPubSignature
*
* ## Arguments
* `compub_sig` - The pointer to a TariComAndPubSignature
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void commitment_and_public_signature_destroy(TariComAndPubSignature *compub_sig);
/**
* -------------------------------------------------------------------------------------------- ///
* -------------------------------- Unblinded utxo -------------------------------------------- ///
* Creates an unblinded output
*
* ## Arguments
* `amount` - The value of the UTXO in MicroTari
* `spending_key` - The private spending key
* `source_address` - The tari address of the source of the transaction
* `features` - Options for an output's structure or use
* `metadata_signature` - UTXO signature with the script offset private key, k_O
* `sender_offset_public_key` - Tari script offset pubkey, K_O
* `script_private_key` - Tari script private key, k_S, is used to create the script signature
* `covenant` - The covenant that will be executed when spending this output
* `message` - The message that the transaction will have
* `encrypted_data` - Encrypted data.
* `minimum_value_promise` - The minimum value of the commitment that is proven by the range proof
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* TariUnblindedOutput - Returns the TransactionID of the generated transaction, note that it will be zero if the
* transaction is null
*
* # Safety
* The ```tari_unblinded_output_destroy``` function must be called when finished with a TariUnblindedOutput to
* prevent a memory leak
*/
TariUnblindedOutput *create_tari_unblinded_output(unsigned long long amount,
TariPrivateKey *spending_key,
TariOutputFeatures *features,
const char *script,
const char *input_data,
TariComAndPubSignature *metadata_signature,
TariPublicKey *sender_offset_public_key,
TariPrivateKey *script_private_key,
TariCovenant *covenant,
TariEncryptedOpenings *encrypted_data,
unsigned long long minimum_value_promise,
unsigned long long script_lock_height,
int *error_out);
/**
* Frees memory for a TariUnblindedOutput
*
* ## Arguments
* `output` - The pointer to a TariUnblindedOutput
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void tari_unblinded_output_destroy(TariUnblindedOutput *output);
/**
* returns the TariUnblindedOutput as a json string
*
* ## Arguments
* `output` - The pointer to a TariUnblindedOutput
*
* ## Returns
* `*mut c_char` - Returns a pointer to a char array. Note that it returns an empty char array if
* TariUnblindedOutput is null or the position is invalid
*
* # Safety
* The ```tari_unblinded_output_destroy``` function must be called when finished with a TariUnblindedOutput to
* prevent a memory leak
*/
char *tari_unblinded_output_to_json(TariUnblindedOutput *output,
int *error_out);
/**
* Creates a TariUnblindedOutput from a char array
*
* ## Arguments
* `output_json` - The pointer to a char array which is json of the TariUnblindedOutput
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariUnblindedOutput` - Returns a pointer to a TariUnblindedOutput. Note that it returns ptr::null_mut()
* if key is null or if there was an error creating the TariUnblindedOutput from key
*
* # Safety
* The ```tari_unblinded_output_destroy``` function must be called when finished with a TariUnblindedOutput to
*/
TariUnblindedOutput *create_tari_unblinded_output_from_json(const char *output_json,
int *error_out);
/**
* -------------------------------------------------------------------------------------------- ///
* ----------------------------------- TariUnblindedOutputs ------------------------------------///
* Gets the length of TariUnblindedOutputs
*
* ## Arguments
* `outputs` - The pointer to a TariUnblindedOutputs
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `c_uint` - Returns number of elements in , zero if outputs is null
*
* # Safety
* None
*/
unsigned int unblinded_outputs_get_length(struct TariUnblindedOutputs *outputs,
int *error_out);
/**
* Gets a TariUnblindedOutput from TariUnblindedOutputs at position
*
* ## Arguments
* `outputs` - The pointer to a TariUnblindedOutputs
* `position` - The integer position
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariUnblindedOutput` - Returns a TariUnblindedOutput, note that it returns ptr::null_mut() if
* TariUnblindedOutputs is null or position is invalid
*
* # Safety
* The ```contact_destroy``` method must be called when finished with a TariContact to prevent a memory leak
*/
TariUnblindedOutput *unblinded_outputs_get_at(struct TariUnblindedOutputs *outputs,
unsigned int position,
int *error_out);
/**
* Gets a TariUnblindedOutput from TariUnblindedOutputs at position
*
* ## Arguments
* `outputs` - The pointer to a TariUnblindedOutputs
* `position` - The integer position
* `error_out` - Pointer to an int which will be modified to an error code should one occur, may not be null. Functions
* as an out parameter.
*
* ## Returns
* `*mut TariUnblindedOutput` - Returns a TariUnblindedOutput, note that it returns ptr::null_mut() if
* TariUnblindedOutputs is null or position is invalid
*
* # Safety
* The ```contact_destroy``` method must be called when finished with a TariContact to prevent a memory leak
*/
unsigned long long *unblinded_outputs_received_tx_id_get_at(struct TariUnblindedOutputs *outputs,
unsigned int position,
int *error_out);
/**
* Frees memory for a TariUnblindedOutputs
*
* ## Arguments
* `outputs` - The pointer to a TariUnblindedOutputs
*
* ## Returns
* `()` - Does not return a value, equivalent to void in C
*
* # Safety
* None
*/
void unblinded_outputs_destroy(struct TariUnblindedOutputs *outputs);
/**
* Import an external UTXO into the wallet as a non-rewindable (i.e. non-recoverable) output. This will add a spendable
* UTXO (as EncumberedToBeReceived) and create a faux completed transaction to record the event.
*
* ## Arguments
* `wallet` - The TariWallet pointer
* `amount` - The value of the UTXO in MicroTari
* `spending_key` - The private spending key
* `source_address` - The tari address of the source of the transaction
* `features` - Options for an output's structure or use
* `metadata_signature` - UTXO signature with the script offset private key, k_O
* `sender_offset_public_key` - Tari script offset pubkey, K_O
* `script_private_key` - Tari script private key, k_S, is used to create the script signature
* `covenant` - The covenant that will be executed when spending this output
* `message` - The message that the transaction will have
* `encrypted_data` - Encrypted data.
* `minimum_value_promise` - The minimum value of the commitment that is proven by the range proof