-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathwally.hpp
3267 lines (2713 loc) · 167 KB
/
wally.hpp
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
#ifndef LIBWALLY_CORE_WALLY_HPP
#define LIBWALLY_CORE_WALLY_HPP
#pragma once
#include <type_traits>
#include <string>
#include <wally_address.h>
#include <wally_anti_exfil.h>
#include <wally_bip32.h>
#include <wally_bip38.h>
#include <wally_bip39.h>
#include <wally_bip85.h>
#include <wally_core.h>
#include <wally_coinselection.h>
#include <wally_crypto.h>
#include <wally_descriptor.h>
#include <wally_map.h>
#include <wally_psbt.h>
#include <wally_script.h>
#include <wally_symmetric.h>
#include <wally_transaction.h>
#include <wally_elements.h>
/* These wrappers allow passing containers such as std::vector, std::array,
* std::string and custom classes as input/output buffers to wally functions.
*/
namespace wally {
namespace detail {
// Caller must provide an implementation of this call for error checking.
// It may either throw an exception when ret != WALLY_OK or return the error code.
int check_ret(const char* func_name, int ret);
template <class P> inline auto get_p(const P& p, std::false_type, std::true_type) {
return &p[0];
}
template <class P> inline auto get_p(const P& p, std::true_type, std::false_type) {
return p;
}
template <class P> inline auto get_p(const P& p, std::false_type, std::false_type) {
return p.get();
}
template <class P> inline auto get_p(const P& p) {
return get_p(p, std::is_pointer<P>{}, std::is_array<P>{});
}
template <> inline auto get_p(const std::string& p) {
return p.c_str();
}
template <> inline auto get_p(const std::nullptr_t& p) {
return p;
}
} /* namespace detail */
/* BEGIN AUTOGENERATED */
inline int bip32_key_free(const struct ext_key* hdkey) {
int ret = ::bip32_key_free(hdkey);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BASE58>
inline int bip32_key_from_base58(const BASE58& base58, struct ext_key* output) {
int ret = ::bip32_key_from_base58(detail::get_p(base58), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BASE58>
inline int bip32_key_from_base58_alloc(const BASE58& base58, struct ext_key** output) {
int ret = ::bip32_key_from_base58_alloc(detail::get_p(base58), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BASE58>
inline int bip32_key_from_base58_n(const BASE58& base58, size_t base58_len, struct ext_key* output) {
int ret = ::bip32_key_from_base58_n(detail::get_p(base58), base58_len, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BASE58>
inline int bip32_key_from_base58_n_alloc(const BASE58& base58, size_t base58_len, struct ext_key** output) {
int ret = ::bip32_key_from_base58_n_alloc(detail::get_p(base58), base58_len, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY>
inline int bip32_key_from_parent(const HDKEY& hdkey, uint32_t child_num, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_parent(detail::get_p(hdkey), child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY>
inline int bip32_key_from_parent_alloc(const HDKEY& hdkey, uint32_t child_num, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_parent_alloc(detail::get_p(hdkey), child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class CHILD_PATH>
inline int bip32_key_from_parent_path(const HDKEY& hdkey, const CHILD_PATH& child_path, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_parent_path(detail::get_p(hdkey), child_path.data(), child_path.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class CHILD_PATH>
inline int bip32_key_from_parent_path_alloc(const HDKEY& hdkey, const CHILD_PATH& child_path, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_parent_path_alloc(detail::get_p(hdkey), child_path.data(), child_path.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class PATH_STR>
inline int bip32_key_from_parent_path_str(const HDKEY& hdkey, const PATH_STR& path_str, uint32_t child_num, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_parent_path_str(detail::get_p(hdkey), detail::get_p(path_str), child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class PATH_STR>
inline int bip32_key_from_parent_path_str_alloc(const HDKEY& hdkey, const PATH_STR& path_str, uint32_t child_num, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_parent_path_str_alloc(detail::get_p(hdkey), detail::get_p(path_str), child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class PATH_STR>
inline int bip32_key_from_parent_path_str_n(const HDKEY& hdkey, const PATH_STR& path_str, size_t path_str_len, uint32_t child_num, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_parent_path_str_n(detail::get_p(hdkey), detail::get_p(path_str), path_str_len, child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class PATH_STR>
inline int bip32_key_from_parent_path_str_n_alloc(const HDKEY& hdkey, const PATH_STR& path_str, size_t path_str_len, uint32_t child_num, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_parent_path_str_n_alloc(detail::get_p(hdkey), detail::get_p(path_str), path_str_len, child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bip32_key_from_seed(const BYTES& bytes, uint32_t version, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_seed(bytes.data(), bytes.size(), version, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bip32_key_from_seed_alloc(const BYTES& bytes, uint32_t version, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_seed_alloc(bytes.data(), bytes.size(), version, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class HMAC_KEY>
inline int bip32_key_from_seed_custom(const BYTES& bytes, uint32_t version, const HMAC_KEY& hmac_key, uint32_t flags, struct ext_key* output) {
int ret = ::bip32_key_from_seed_custom(bytes.data(), bytes.size(), version, hmac_key.data(), hmac_key.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class HMAC_KEY>
inline int bip32_key_from_seed_custom_alloc(const BYTES& bytes, uint32_t version, const HMAC_KEY& hmac_key, uint32_t flags, struct ext_key** output) {
int ret = ::bip32_key_from_seed_custom_alloc(bytes.data(), bytes.size(), version, hmac_key.data(), hmac_key.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class BYTES_OUT>
inline int bip32_key_get_fingerprint(const HDKEY& hdkey, BYTES_OUT& bytes_out) {
int ret = ::bip32_key_get_fingerprint(detail::get_p(hdkey), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class CHAIN_CODE, class PUB_KEY, class PRIV_KEY, class HASH160, class PARENT160>
inline int bip32_key_init(uint32_t version, uint32_t depth, uint32_t child_num, const CHAIN_CODE& chain_code, const PUB_KEY& pub_key, const PRIV_KEY& priv_key, const HASH160& hash160, const PARENT160& parent160, struct ext_key* output) {
int ret = ::bip32_key_init(version, depth, child_num, chain_code.data(), chain_code.size(), pub_key.data(), pub_key.size(), priv_key.data(), priv_key.size(), hash160.data(), hash160.size(), parent160.data(), parent160.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class CHAIN_CODE, class PUB_KEY, class PRIV_KEY, class HASH160, class PARENT160>
inline int bip32_key_init_alloc(uint32_t version, uint32_t depth, uint32_t child_num, const CHAIN_CODE& chain_code, const PUB_KEY& pub_key, const PRIV_KEY& priv_key, const HASH160& hash160, const PARENT160& parent160, struct ext_key** output) {
int ret = ::bip32_key_init_alloc(version, depth, child_num, chain_code.data(), chain_code.size(), pub_key.data(), pub_key.size(), priv_key.data(), priv_key.size(), hash160.data(), hash160.size(), parent160.data(), parent160.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class BYTES_OUT>
inline int bip32_key_serialize(const HDKEY& hdkey, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::bip32_key_serialize(detail::get_p(hdkey), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
inline int bip32_key_strip_private_key(struct ext_key* hdkey) {
int ret = ::bip32_key_strip_private_key(hdkey);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY>
inline int bip32_key_to_base58(const HDKEY& hdkey, uint32_t flags, char** output) {
int ret = ::bip32_key_to_base58(detail::get_p(hdkey), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bip32_key_unserialize(const BYTES& bytes, struct ext_key* output) {
int ret = ::bip32_key_unserialize(bytes.data(), bytes.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bip32_key_unserialize_alloc(const BYTES& bytes, struct ext_key** output) {
int ret = ::bip32_key_unserialize_alloc(bytes.data(), bytes.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_from_str(const PATH_STR& path_str, uint32_t child_num, uint32_t multi_index, uint32_t flags, uint32_t* child_path_out, size_t child_path_out_len, size_t* written) {
int ret = ::bip32_path_from_str(detail::get_p(path_str), child_num, multi_index, flags, child_path_out, child_path_out_len, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_from_str_len(const PATH_STR& path_str, uint32_t child_num, uint32_t multi_index, uint32_t flags, size_t* written) {
int ret = ::bip32_path_from_str_len(detail::get_p(path_str), child_num, multi_index, flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_from_str_n(const PATH_STR& path_str, size_t path_str_len, uint32_t child_num, uint32_t multi_index, uint32_t flags, uint32_t* child_path_out, size_t child_path_out_len, size_t* written) {
int ret = ::bip32_path_from_str_n(detail::get_p(path_str), path_str_len, child_num, multi_index, flags, child_path_out, child_path_out_len, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_from_str_n_len(const PATH_STR& path_str, size_t path_str_len, uint32_t child_num, uint32_t multi_index, uint32_t flags, size_t* written) {
int ret = ::bip32_path_from_str_n_len(detail::get_p(path_str), path_str_len, child_num, multi_index, flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_str_get_features(const PATH_STR& path_str, uint32_t* value_out) {
int ret = ::bip32_path_str_get_features(detail::get_p(path_str), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PATH_STR>
inline int bip32_path_str_n_get_features(const PATH_STR& path_str, size_t path_str_len, uint32_t* value_out) {
int ret = ::bip32_path_str_n_get_features(detail::get_p(path_str), path_str_len, value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class PASS>
inline int bip38_from_private_key(const BYTES& bytes, const PASS& pass, uint32_t flags, char** output) {
int ret = ::bip38_from_private_key(bytes.data(), bytes.size(), pass.data(), pass.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BIP38>
inline int bip38_get_flags(const BIP38& bip38, size_t* written) {
int ret = ::bip38_get_flags(detail::get_p(bip38), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class PASS, class BYTES_OUT>
inline int bip38_raw_from_private_key(const BYTES& bytes, const PASS& pass, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::bip38_raw_from_private_key(bytes.data(), bytes.size(), pass.data(), pass.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bip38_raw_get_flags(const BYTES& bytes, size_t* written) {
int ret = ::bip38_raw_get_flags(bytes.data(), bytes.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class PASS, class BYTES_OUT>
inline int bip38_raw_to_private_key(const BYTES& bytes, const PASS& pass, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::bip38_raw_to_private_key(bytes.data(), bytes.size(), pass.data(), pass.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class BIP38, class PASS, class BYTES_OUT>
inline int bip38_to_private_key(const BIP38& bip38, const PASS& pass, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::bip38_to_private_key(detail::get_p(bip38), pass.data(), pass.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
inline int bip39_get_languages(char** output) {
int ret = ::bip39_get_languages(output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class W>
inline int bip39_get_word(const W& w, size_t index, char** output) {
int ret = ::bip39_get_word(detail::get_p(w), index, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class LANG>
inline int bip39_get_wordlist(const LANG& lang, struct words** output) {
int ret = ::bip39_get_wordlist(detail::get_p(lang), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class W, class BYTES>
inline int bip39_mnemonic_from_bytes(const W& w, const BYTES& bytes, char** output) {
int ret = ::bip39_mnemonic_from_bytes(detail::get_p(w), bytes.data(), bytes.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class W, class MNEMONIC, class BYTES_OUT>
inline int bip39_mnemonic_to_bytes(const W& w, const MNEMONIC& mnemonic, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::bip39_mnemonic_to_bytes(detail::get_p(w), detail::get_p(mnemonic), bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MNEMONIC, class PASSPHRASE, class BYTES_OUT>
inline int bip39_mnemonic_to_seed(const MNEMONIC& mnemonic, const PASSPHRASE& passphrase, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::bip39_mnemonic_to_seed(detail::get_p(mnemonic), detail::get_p(passphrase), bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MNEMONIC, class PASSPHRASE, class BYTES_OUT>
inline int bip39_mnemonic_to_seed512(const MNEMONIC& mnemonic, const PASSPHRASE& passphrase, BYTES_OUT& bytes_out) {
int ret = ::bip39_mnemonic_to_seed512(detail::get_p(mnemonic), detail::get_p(passphrase), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class W>
inline int bip39_mnemonic_validate(const W& w, const char* mnemonic) {
int ret = ::bip39_mnemonic_validate(detail::get_p(w), mnemonic);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class LANG, class BYTES_OUT>
inline int bip85_get_bip39_entropy(const HDKEY& hdkey, const LANG& lang, uint32_t num_words, uint32_t index, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::bip85_get_bip39_entropy(detail::get_p(hdkey), detail::get_p(lang), num_words, index, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
inline int bip85_get_languages(char** output) {
int ret = ::bip85_get_languages(output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class BYTES_OUT>
inline int bip85_get_rsa_entropy(const HDKEY& hdkey, uint32_t key_bits, uint32_t index, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::bip85_get_rsa_entropy(detail::get_p(hdkey), key_bits, index, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class ADDR_FAMILY>
inline int addr_segwit_from_bytes(const BYTES& bytes, const ADDR_FAMILY& addr_family, uint32_t flags, char** output) {
int ret = ::wally_addr_segwit_from_bytes(bytes.data(), bytes.size(), detail::get_p(addr_family), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ADDR, class ADDR_FAMILY>
inline int addr_segwit_get_version(const ADDR& addr, const ADDR_FAMILY& addr_family, uint32_t flags, size_t* written) {
int ret = ::wally_addr_segwit_get_version(detail::get_p(addr), detail::get_p(addr_family), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ADDR, class ADDR_FAMILY>
inline int addr_segwit_n_get_version(const ADDR& addr, size_t addr_len, const ADDR_FAMILY& addr_family, size_t addr_family_len, uint32_t flags, size_t* written) {
int ret = ::wally_addr_segwit_n_get_version(detail::get_p(addr), addr_len, detail::get_p(addr_family), addr_family_len, flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ADDR, class ADDR_FAMILY, class BYTES_OUT>
inline int addr_segwit_n_to_bytes(const ADDR& addr, size_t addr_len, const ADDR_FAMILY& addr_family, size_t addr_family_len, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_addr_segwit_n_to_bytes(detail::get_p(addr), addr_len, detail::get_p(addr_family), addr_family_len, flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ADDR, class ADDR_FAMILY, class BYTES_OUT>
inline int addr_segwit_to_bytes(const ADDR& addr, const ADDR_FAMILY& addr_family, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_addr_segwit_to_bytes(detail::get_p(addr), detail::get_p(addr_family), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ADDR, class BYTES_OUT>
inline int address_to_scriptpubkey(const ADDR& addr, uint32_t network, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_address_to_scriptpubkey(detail::get_p(addr), network, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class ENTROPY, class BYTES_OUT>
inline int ae_host_commit_from_bytes(const ENTROPY& entropy, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ae_host_commit_from_bytes(entropy.data(), entropy.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES, class ENTROPY, class BYTES_OUT>
inline int ae_sig_from_bytes(const PRIV_KEY& priv_key, const BYTES& bytes, const ENTROPY& entropy, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ae_sig_from_bytes(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), entropy.data(), entropy.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES, class COMMITMENT, class S2C_OPENING_OUT>
inline int ae_signer_commit_from_bytes(const PRIV_KEY& priv_key, const BYTES& bytes, const COMMITMENT& commitment, uint32_t flags, S2C_OPENING_OUT& s2c_opening_out) {
int ret = ::wally_ae_signer_commit_from_bytes(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), commitment.data(), commitment.size(), flags, s2c_opening_out.data(), s2c_opening_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PUB_KEY, class BYTES, class ENTROPY, class S2C_OPENING, class SIG>
inline bool ae_verify(const PUB_KEY& pub_key, const BYTES& bytes, const ENTROPY& entropy, const S2C_OPENING& s2c_opening, uint32_t flags, const SIG& sig) {
int ret = ::wally_ae_verify(pub_key.data(), pub_key.size(), bytes.data(), bytes.size(), entropy.data(), entropy.size(), s2c_opening.data(), s2c_opening.size(), flags, sig.data(), sig.size());
return ret == WALLY_OK;
}
template <class KEY, class BYTES, class BYTES_OUT>
inline int aes(const KEY& key, const BYTES& bytes, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_aes(key.data(), key.size(), bytes.data(), bytes.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class IV, class BYTES, class BYTES_OUT>
inline int aes_cbc(const KEY& key, const IV& iv, const BYTES& bytes, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_aes_cbc(key.data(), key.size(), iv.data(), iv.size(), bytes.data(), bytes.size(), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class IV, class BYTES>
inline int aes_cbc_get_maximum_length(const KEY& key, const IV& iv, const BYTES& bytes, uint32_t flags, size_t* written) {
int ret = ::wally_aes_cbc_get_maximum_length(key.data(), key.size(), iv.data(), iv.size(), bytes.data(), bytes.size(), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class IV, class BYTES, class PUB_KEY, class LABEL, class BYTES_OUT>
inline int aes_cbc_with_ecdh_key(const PRIV_KEY& priv_key, const IV& iv, const BYTES& bytes, const PUB_KEY& pub_key, const LABEL& label, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_aes_cbc_with_ecdh_key(priv_key.data(), priv_key.size(), iv.data(), iv.size(), bytes.data(), bytes.size(), pub_key.data(), pub_key.size(), label.data(), label.size(), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class IV, class BYTES, class PUB_KEY, class LABEL>
inline int aes_cbc_with_ecdh_key_get_maximum_length(const PRIV_KEY& priv_key, const IV& iv, const BYTES& bytes, const PUB_KEY& pub_key, const LABEL& label, uint32_t flags, size_t* written) {
int ret = ::wally_aes_cbc_with_ecdh_key_get_maximum_length(priv_key.data(), priv_key.size(), iv.data(), iv.size(), bytes.data(), bytes.size(), pub_key.data(), pub_key.size(), label.data(), label.size(), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class BYTES>
inline int aes_len(const KEY& key, const BYTES& bytes, uint32_t flags, size_t* written) {
int ret = ::wally_aes_len(key.data(), key.size(), bytes.data(), bytes.size(), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int base58_from_bytes(const BYTES& bytes, uint32_t flags, char** output) {
int ret = ::wally_base58_from_bytes(bytes.data(), bytes.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN>
inline int base58_get_length(const STR_IN& str_in, size_t* written) {
int ret = ::wally_base58_get_length(detail::get_p(str_in), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN>
inline int base58_n_get_length(const STR_IN& str_in, size_t str_len, size_t* written) {
int ret = ::wally_base58_n_get_length(detail::get_p(str_in), str_len, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN, class BYTES_OUT>
inline int base58_n_to_bytes(const STR_IN& str_in, size_t str_len, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_base58_n_to_bytes(detail::get_p(str_in), str_len, flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN, class BYTES_OUT>
inline int base58_to_bytes(const STR_IN& str_in, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_base58_to_bytes(detail::get_p(str_in), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int base64_from_bytes(const BYTES& bytes, uint32_t flags, char** output) {
int ret = ::wally_base64_from_bytes(bytes.data(), bytes.size(), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN>
inline int base64_get_maximum_length(const STR_IN& str_in, uint32_t flags, size_t* written) {
int ret = ::wally_base64_get_maximum_length(detail::get_p(str_in), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN>
inline int base64_n_get_maximum_length(const STR_IN& str_in, size_t str_len, uint32_t flags, size_t* written) {
int ret = ::wally_base64_n_get_maximum_length(detail::get_p(str_in), str_len, flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN, class BYTES_OUT>
inline int base64_n_to_bytes(const STR_IN& str_in, size_t str_len, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_base64_n_to_bytes(detail::get_p(str_in), str_len, flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class STR_IN, class BYTES_OUT>
inline int base64_to_bytes(const STR_IN& str_in, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_base64_to_bytes(detail::get_p(str_in), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY, class ADDR_FAMILY>
inline int bip32_key_to_addr_segwit(const HDKEY& hdkey, const ADDR_FAMILY& addr_family, uint32_t flags, char** output) {
int ret = ::wally_bip32_key_to_addr_segwit(detail::get_p(hdkey), detail::get_p(addr_family), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HDKEY>
inline int bip32_key_to_address(const HDKEY& hdkey, uint32_t flags, uint32_t version, char** output) {
int ret = ::wally_bip32_key_to_address(detail::get_p(hdkey), flags, version, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class TAG, class BYTES_OUT>
inline int bip340_tagged_hash(const BYTES& bytes, const TAG& tag, BYTES_OUT& bytes_out) {
int ret = ::wally_bip340_tagged_hash(bytes.data(), bytes.size(), detail::get_p(tag), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int bzero(BYTES& bytes) {
int ret = ::wally_bzero(bytes.data(), bytes.size());
return detail::check_ret(__FUNCTION__, ret);
}
inline int cleanup(uint32_t flags) {
int ret = ::wally_cleanup(flags);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_canonicalize(const DESCRIPTOR& descriptor, uint32_t flags, char** output) {
int ret = ::wally_descriptor_canonicalize(detail::get_p(descriptor), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
inline int descriptor_free(struct wally_descriptor* descriptor) {
int ret = ::wally_descriptor_free(descriptor);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_checksum(const DESCRIPTOR& descriptor, uint32_t flags, char** output) {
int ret = ::wally_descriptor_get_checksum(detail::get_p(descriptor), flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_depth(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_depth(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_features(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_features(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key(const DESCRIPTOR& descriptor, size_t index, char** output) {
int ret = ::wally_descriptor_get_key(detail::get_p(descriptor), index, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key_child_path_str(const DESCRIPTOR& descriptor, size_t index, char** output) {
int ret = ::wally_descriptor_get_key_child_path_str(detail::get_p(descriptor), index, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key_child_path_str_len(const DESCRIPTOR& descriptor, size_t index, size_t* written) {
int ret = ::wally_descriptor_get_key_child_path_str_len(detail::get_p(descriptor), index, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key_features(const DESCRIPTOR& descriptor, size_t index, uint32_t* value_out) {
int ret = ::wally_descriptor_get_key_features(detail::get_p(descriptor), index, value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR, class BYTES_OUT>
inline int descriptor_get_key_origin_fingerprint(const DESCRIPTOR& descriptor, size_t index, BYTES_OUT& bytes_out) {
int ret = ::wally_descriptor_get_key_origin_fingerprint(detail::get_p(descriptor), index, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key_origin_path_str(const DESCRIPTOR& descriptor, size_t index, char** output) {
int ret = ::wally_descriptor_get_key_origin_path_str(detail::get_p(descriptor), index, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_key_origin_path_str_len(const DESCRIPTOR& descriptor, size_t index, size_t* written) {
int ret = ::wally_descriptor_get_key_origin_path_str_len(detail::get_p(descriptor), index, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_network(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_network(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_num_keys(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_num_keys(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_num_paths(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_num_paths(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_get_num_variants(const DESCRIPTOR& descriptor, uint32_t* value_out) {
int ret = ::wally_descriptor_get_num_variants(detail::get_p(descriptor), value_out);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR, class VARS_IN>
inline int descriptor_parse(const DESCRIPTOR& descriptor, const VARS_IN& vars_in, uint32_t network, uint32_t flags, struct wally_descriptor** output) {
int ret = ::wally_descriptor_parse(detail::get_p(descriptor), detail::get_p(vars_in), network, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_set_network(const DESCRIPTOR& descriptor, uint32_t network) {
int ret = ::wally_descriptor_set_network(detail::get_p(descriptor), network);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_to_address(const DESCRIPTOR& descriptor, uint32_t variant, uint32_t multi_index, uint32_t child_num, uint32_t flags, char** output) {
int ret = ::wally_descriptor_to_address(detail::get_p(descriptor), variant, multi_index, child_num, flags, output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_to_addresses(const DESCRIPTOR& descriptor, uint32_t variant, uint32_t multi_index, uint32_t child_num, uint32_t flags, char** output, size_t num_outputs) {
int ret = ::wally_descriptor_to_addresses(detail::get_p(descriptor), variant, multi_index, child_num, flags, output, num_outputs);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR, class BYTES_OUT>
inline int descriptor_to_script(const DESCRIPTOR& descriptor, uint32_t depth, uint32_t index, uint32_t variant, uint32_t multi_index, uint32_t child_num, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_descriptor_to_script(detail::get_p(descriptor), depth, index, variant, multi_index, child_num, flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class DESCRIPTOR>
inline int descriptor_to_script_get_maximum_length(const DESCRIPTOR& descriptor, uint32_t depth, uint32_t index, uint32_t variant, uint32_t multi_index, uint32_t child_num, uint32_t flags, size_t* written) {
int ret = ::wally_descriptor_to_script_get_maximum_length(detail::get_p(descriptor), depth, index, variant, multi_index, child_num, flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class MERKLE_ROOT, class BYTES_OUT>
inline int ec_private_key_bip341_tweak(const PRIV_KEY& priv_key, const MERKLE_ROOT& merkle_root, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_private_key_bip341_tweak(priv_key.data(), priv_key.size(), merkle_root.data(), merkle_root.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY>
inline bool ec_private_key_verify(const PRIV_KEY& priv_key) {
int ret = ::wally_ec_private_key_verify(priv_key.data(), priv_key.size());
return ret == WALLY_OK;
}
template <class PUB_KEY, class MERKLE_ROOT, class BYTES_OUT>
inline int ec_public_key_bip341_tweak(const PUB_KEY& pub_key, const MERKLE_ROOT& merkle_root, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_public_key_bip341_tweak(pub_key.data(), pub_key.size(), merkle_root.data(), merkle_root.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PUB_KEY, class BYTES_OUT>
inline int ec_public_key_decompress(const PUB_KEY& pub_key, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_public_key_decompress(pub_key.data(), pub_key.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES_OUT>
inline int ec_public_key_from_private_key(const PRIV_KEY& priv_key, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_public_key_from_private_key(priv_key.data(), priv_key.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PUB_KEY, class BYTES_OUT>
inline int ec_public_key_negate(const PUB_KEY& pub_key, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_public_key_negate(pub_key.data(), pub_key.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PUB_KEY>
inline bool ec_public_key_verify(const PUB_KEY& pub_key) {
int ret = ::wally_ec_public_key_verify(pub_key.data(), pub_key.size());
return ret == WALLY_OK;
}
template <class SCALAR, class OPERAND, class BYTES_OUT>
inline int ec_scalar_add(const SCALAR& scalar, const OPERAND& operand, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_scalar_add(scalar.data(), scalar.size(), operand.data(), operand.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR, class OPERAND>
inline int ec_scalar_add_to(SCALAR& scalar, const OPERAND& operand) {
int ret = ::wally_ec_scalar_add_to(scalar.data(), scalar.size(), operand.data(), operand.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR, class OPERAND, class BYTES_OUT>
inline int ec_scalar_multiply(const SCALAR& scalar, const OPERAND& operand, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_scalar_multiply(scalar.data(), scalar.size(), operand.data(), operand.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR, class OPERAND>
inline int ec_scalar_multiply_by(SCALAR& scalar, const OPERAND& operand) {
int ret = ::wally_ec_scalar_multiply_by(scalar.data(), scalar.size(), operand.data(), operand.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR, class OPERAND, class BYTES_OUT>
inline int ec_scalar_subtract(const SCALAR& scalar, const OPERAND& operand, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_scalar_subtract(scalar.data(), scalar.size(), operand.data(), operand.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR, class OPERAND>
inline int ec_scalar_subtract_from(SCALAR& scalar, const OPERAND& operand) {
int ret = ::wally_ec_scalar_subtract_from(scalar.data(), scalar.size(), operand.data(), operand.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SCALAR>
inline bool ec_scalar_verify(const SCALAR& scalar) {
int ret = ::wally_ec_scalar_verify(scalar.data(), scalar.size());
return ret == WALLY_OK;
}
template <class PRIV_KEY, class BYTES, class BYTES_OUT>
inline int ec_sig_from_bytes(const PRIV_KEY& priv_key, const BYTES& bytes, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_sig_from_bytes(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES, class AUX_RAND, class BYTES_OUT>
inline int ec_sig_from_bytes_aux(const PRIV_KEY& priv_key, const BYTES& bytes, const AUX_RAND& aux_rand, uint32_t flags, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_sig_from_bytes_aux(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), aux_rand.data(), aux_rand.size(), flags, bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES, class AUX_RAND>
inline int ec_sig_from_bytes_aux_len(const PRIV_KEY& priv_key, const BYTES& bytes, const AUX_RAND& aux_rand, uint32_t flags, size_t* written) {
int ret = ::wally_ec_sig_from_bytes_aux_len(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), aux_rand.data(), aux_rand.size(), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class PRIV_KEY, class BYTES>
inline int ec_sig_from_bytes_len(const PRIV_KEY& priv_key, const BYTES& bytes, uint32_t flags, size_t* written) {
int ret = ::wally_ec_sig_from_bytes_len(priv_key.data(), priv_key.size(), bytes.data(), bytes.size(), flags, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class BYTES_OUT>
inline int ec_sig_from_der(const BYTES& bytes, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_sig_from_der(bytes.data(), bytes.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SIG, class BYTES_OUT>
inline int ec_sig_normalize(const SIG& sig, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_sig_normalize(sig.data(), sig.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class SIG, class BYTES_OUT>
inline int ec_sig_to_der(const SIG& sig, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_ec_sig_to_der(sig.data(), sig.size(), bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class SIG, class BYTES_OUT>
inline int ec_sig_to_public_key(const BYTES& bytes, const SIG& sig, BYTES_OUT& bytes_out) {
int ret = ::wally_ec_sig_to_public_key(bytes.data(), bytes.size(), sig.data(), sig.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class PUB_KEY, class BYTES, class SIG>
inline bool ec_sig_verify(const PUB_KEY& pub_key, const BYTES& bytes, uint32_t flags, const SIG& sig) {
int ret = ::wally_ec_sig_verify(pub_key.data(), pub_key.size(), bytes.data(), bytes.size(), flags, sig.data(), sig.size());
return ret == WALLY_OK;
}
template <class PUB_KEY>
inline bool ec_xonly_public_key_verify(const PUB_KEY& pub_key) {
int ret = ::wally_ec_xonly_public_key_verify(pub_key.data(), pub_key.size());
return ret == WALLY_OK;
}
template <class PUB_KEY, class PRIV_KEY, class BYTES_OUT>
inline int ecdh(const PUB_KEY& pub_key, const PRIV_KEY& priv_key, BYTES_OUT& bytes_out) {
int ret = ::wally_ecdh(pub_key.data(), pub_key.size(), priv_key.data(), priv_key.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class BYTES_OUT>
inline int format_bitcoin_message(const BYTES& bytes, uint32_t flags, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_format_bitcoin_message(bytes.data(), bytes.size(), flags, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
inline int free_string(char* str) {
int ret = ::wally_free_string(str);
return detail::check_ret(__FUNCTION__, ret);
}
inline int get_build_version(uint32_t* value) {
int ret = ::wally_get_build_version(value);
return detail::check_ret(__FUNCTION__, ret);
}
template <class TXHASHES, class UTXO_INDICES, class BYTES_OUT>
inline int get_hash_prevouts(const TXHASHES& txhashes, const UTXO_INDICES& utxo_indices, BYTES_OUT& bytes_out) {
int ret = ::wally_get_hash_prevouts(txhashes.data(), txhashes.size(), utxo_indices.data(), utxo_indices.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
inline int get_operations(struct wally_operations* output) {
int ret = ::wally_get_operations(output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES, class BYTES_OUT>
inline int hash160(const BYTES& bytes, BYTES_OUT& bytes_out) {
int ret = ::wally_hash160(bytes.data(), bytes.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class BYTES>
inline int hex_from_bytes(const BYTES& bytes, char** output) {
int ret = ::wally_hex_from_bytes(bytes.data(), bytes.size(), output);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HEX, class BYTES_OUT>
inline int hex_n_to_bytes(const HEX& hex, size_t hex_len, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_hex_n_to_bytes(detail::get_p(hex), hex_len, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class HEX>
inline bool hex_n_verify(const HEX& hex, size_t hex_len) {
int ret = ::wally_hex_n_verify(detail::get_p(hex), hex_len);
return ret == WALLY_OK;
}
template <class HEX, class BYTES_OUT>
inline int hex_to_bytes(const HEX& hex, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_hex_to_bytes(detail::get_p(hex), bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
inline bool hex_verify(const char* hex) {
int ret = ::wally_hex_verify(hex);
return ret == WALLY_OK;
}
template <class KEY, class BYTES, class BYTES_OUT>
inline int hmac_sha256(const KEY& key, const BYTES& bytes, BYTES_OUT& bytes_out) {
int ret = ::wally_hmac_sha256(key.data(), key.size(), bytes.data(), bytes.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class BYTES, class BYTES_OUT>
inline int hmac_sha512(const KEY& key, const BYTES& bytes, BYTES_OUT& bytes_out) {
int ret = ::wally_hmac_sha512(key.data(), key.size(), bytes.data(), bytes.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
inline int init(uint32_t flags) {
int ret = ::wally_init(flags);
return detail::check_ret(__FUNCTION__, ret);
}
inline int is_elements_build(size_t* written) {
int ret = ::wally_is_elements_build(written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class VAL>
inline bool keypath_bip32_verify(const KEY& key, const VAL& val) {
int ret = ::wally_keypath_bip32_verify(key.data(), key.size(), val.data(), val.size());
return ret == WALLY_OK;
}
template <class VAL, class BYTES_OUT>
inline int keypath_get_fingerprint(const VAL& val, BYTES_OUT& bytes_out) {
int ret = ::wally_keypath_get_fingerprint(val.data(), val.size(), bytes_out.data(), bytes_out.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class VAL>
inline int keypath_get_path(const VAL& val, uint32_t* child_path_out, size_t child_path_out_len, size_t* written) {
int ret = ::wally_keypath_get_path(val.data(), val.size(), child_path_out, child_path_out_len, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class VAL>
inline int keypath_get_path_len(const VAL& val, size_t* written) {
int ret = ::wally_keypath_get_path_len(val.data(), val.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class KEY, class VAL>
inline bool keypath_public_key_verify(const KEY& key, const VAL& val) {
int ret = ::wally_keypath_public_key_verify(key.data(), key.size(), val.data(), val.size());
return ret == WALLY_OK;
}
template <class KEY, class VAL>
inline bool keypath_xonly_public_key_verify(const KEY& key, const VAL& val) {
int ret = ::wally_keypath_xonly_public_key_verify(key.data(), key.size(), val.data(), val.size());
return ret == WALLY_OK;
}
template <class MAP_IN, class KEY, class VALUE>
inline int map_add(const MAP_IN& map_in, const KEY& key, const VALUE& value) {
int ret = ::wally_map_add(detail::get_p(map_in), key.data(), key.size(), value.data(), value.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class VALUE>
inline int map_add_integer(const MAP_IN& map_in, uint32_t key, const VALUE& value) {
int ret = ::wally_map_add_integer(detail::get_p(map_in), key, value.data(), value.size());
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN>
inline int map_assign(const MAP_IN& map_in, const struct wally_map* source) {
int ret = ::wally_map_assign(detail::get_p(map_in), source);
return detail::check_ret(__FUNCTION__, ret);
}
inline int map_clear(struct wally_map* map_in) {
int ret = ::wally_map_clear(map_in);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN>
inline int map_combine(const MAP_IN& map_in, const struct wally_map* source) {
int ret = ::wally_map_combine(detail::get_p(map_in), source);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class KEY>
inline int map_find(const MAP_IN& map_in, const KEY& key, size_t* written) {
int ret = ::wally_map_find(detail::get_p(map_in), key.data(), key.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class HDKEY>
inline int map_find_bip32_public_key_from(const MAP_IN& map_in, size_t index, const HDKEY& hdkey, size_t* written) {
int ret = ::wally_map_find_bip32_public_key_from(detail::get_p(map_in), index, detail::get_p(hdkey), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class KEY>
inline int map_find_from(const MAP_IN& map_in, size_t index, const KEY& key, size_t* written) {
int ret = ::wally_map_find_from(detail::get_p(map_in), index, key.data(), key.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN>
inline int map_find_integer(const MAP_IN& map_in, uint32_t key, size_t* written) {
int ret = ::wally_map_find_integer(detail::get_p(map_in), key, written);
return detail::check_ret(__FUNCTION__, ret);
}
inline int map_free(struct wally_map* map_in) {
int ret = ::wally_map_free(map_in);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class BYTES_OUT>
inline int map_get_item(const MAP_IN& map_in, size_t index, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_map_get_item(detail::get_p(map_in), index, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN>
inline int map_get_item_integer_key(const MAP_IN& map_in, size_t index, size_t* written) {
int ret = ::wally_map_get_item_integer_key(detail::get_p(map_in), index, written);
return detail::check_ret(__FUNCTION__, ret);
}
template <class MAP_IN, class BYTES_OUT>
inline int map_get_item_key(const MAP_IN& map_in, size_t index, BYTES_OUT& bytes_out, size_t* written) {
int ret = ::wally_map_get_item_key(detail::get_p(map_in), index, bytes_out.data(), bytes_out.size(), written);
return detail::check_ret(__FUNCTION__, ret);
}