-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathshiftcrypto.bitbox02.rs
2177 lines (2177 loc) · 87.8 KB
/
shiftcrypto.bitbox02.rs
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
// This file is @generated by prost-build.
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct PubResponse {
#[prost(string, tag = "1")]
pub r#pub: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct RootFingerprintRequest {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RootFingerprintResponse {
#[prost(bytes = "vec", tag = "1")]
#[cfg_attr(feature = "wasm", serde(deserialize_with = "hex::serde::deserialize"))]
pub fingerprint: ::prost::alloc::vec::Vec<u8>,
}
/// See <https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki.>
/// version field dropped as it will set dynamically based on the context (xpub, ypub, etc.).
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct XPub {
#[prost(bytes = "vec", tag = "1")]
pub depth: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "2")]
pub parent_fingerprint: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, tag = "3")]
pub child_num: u32,
#[prost(bytes = "vec", tag = "4")]
pub chain_code: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "5")]
pub public_key: ::prost::alloc::vec::Vec<u8>,
}
/// This message exists for use in oneof or repeated fields, where one can't inline `repeated uint32` due to protobuf rules.
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Keypath {
#[prost(uint32, repeated, tag = "1")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "wasm", serde(try_from = "crate::btc::KeyOriginInfo"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyOriginInfo {
#[prost(bytes = "vec", tag = "1")]
pub root_fingerprint: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, repeated, tag = "2")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
#[prost(message, optional, tag = "3")]
pub xpub: ::core::option::Option<XPub>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CheckBackupRequest {
#[prost(bool, tag = "1")]
pub silent: bool,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CheckBackupResponse {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
}
/// Timestamp must be in UTC
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CreateBackupRequest {
#[prost(uint32, tag = "1")]
pub timestamp: u32,
#[prost(int32, tag = "2")]
pub timezone_offset: i32,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ListBackupsRequest {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BackupInfo {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub timestamp: u32,
/// uint32 timezone_offset = 3;
#[prost(string, tag = "4")]
pub name: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ListBackupsResponse {
#[prost(message, repeated, tag = "1")]
pub info: ::prost::alloc::vec::Vec<BackupInfo>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct RestoreBackupRequest {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(uint32, tag = "2")]
pub timestamp: u32,
#[prost(int32, tag = "3")]
pub timezone_offset: i32,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CheckSdCardRequest {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct CheckSdCardResponse {
#[prost(bool, tag = "1")]
pub inserted: bool,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct DeviceInfoRequest {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DeviceInfoResponse {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
#[prost(bool, tag = "2")]
pub initialized: bool,
#[prost(string, tag = "3")]
pub version: ::prost::alloc::string::String,
#[prost(bool, tag = "4")]
pub mnemonic_passphrase_enabled: bool,
#[prost(uint32, tag = "5")]
pub monotonic_increments_remaining: u32,
/// From v9.6.0: "ATECC608A" or "ATECC608B".
#[prost(string, tag = "6")]
pub securechip_model: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct InsertRemoveSdCardRequest {
#[prost(enumeration = "insert_remove_sd_card_request::SdCardAction", tag = "1")]
pub action: i32,
}
/// Nested message and enum types in `InsertRemoveSDCardRequest`.
pub mod insert_remove_sd_card_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum SdCardAction {
RemoveCard = 0,
InsertCard = 1,
}
impl SdCardAction {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
SdCardAction::RemoveCard => "REMOVE_CARD",
SdCardAction::InsertCard => "INSERT_CARD",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"REMOVE_CARD" => Some(Self::RemoveCard),
"INSERT_CARD" => Some(Self::InsertCard),
_ => None,
}
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct ResetRequest {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetDeviceLanguageRequest {
#[prost(string, tag = "1")]
pub language: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetDeviceNameRequest {
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SetPasswordRequest {
#[prost(bytes = "vec", tag = "1")]
pub entropy: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AntiKleptoHostNonceCommitment {
#[prost(bytes = "vec", tag = "1")]
pub commitment: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AntiKleptoSignerCommitment {
#[prost(bytes = "vec", tag = "1")]
pub commitment: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AntiKleptoSignatureRequest {
#[prost(bytes = "vec", tag = "1")]
pub host_nonce: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[cfg_attr(feature = "wasm", serde(try_from = "crate::btc::SerdeScriptConfig"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcScriptConfig {
#[prost(oneof = "btc_script_config::Config", tags = "1, 2, 3")]
pub config: ::core::option::Option<btc_script_config::Config>,
}
/// Nested message and enum types in `BTCScriptConfig`.
pub mod btc_script_config {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Multisig {
#[prost(uint32, tag = "1")]
pub threshold: u32,
/// xpubs are acount-level xpubs. Addresses are going to be derived from it using: `m/<change>/<receive>`.
/// The number of xpubs defines the number of cosigners.
#[prost(message, repeated, tag = "2")]
pub xpubs: ::prost::alloc::vec::Vec<super::XPub>,
/// Index to the xpub of our keystore in xpubs. The keypath to it is provided via
/// BTCPubRequest/BTCSignInit.
#[prost(uint32, tag = "3")]
pub our_xpub_index: u32,
#[prost(enumeration = "multisig::ScriptType", tag = "4")]
pub script_type: i32,
}
/// Nested message and enum types in `Multisig`.
pub mod multisig {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ScriptType {
/// native segwit v0 multisig (bech32 addresses)
P2wsh = 0,
/// wrapped segwit for legacy address compatibility
P2wshP2sh = 1,
}
impl ScriptType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ScriptType::P2wsh => "P2WSH",
ScriptType::P2wshP2sh => "P2WSH_P2SH",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"P2WSH" => Some(Self::P2wsh),
"P2WSH_P2SH" => Some(Self::P2wshP2sh),
_ => None,
}
}
}
}
/// A policy as specified by 'Wallet policies':
/// <https://github.com/bitcoin/bips/pull/1389>
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Policy {
#[prost(string, tag = "1")]
pub policy: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub keys: ::prost::alloc::vec::Vec<super::KeyOriginInfo>,
}
/// SimpleType is a "simple" script: one public key, no additional inputs.
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum SimpleType {
P2wpkhP2sh = 0,
P2wpkh = 1,
P2tr = 2,
}
impl SimpleType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
SimpleType::P2wpkhP2sh => "P2WPKH_P2SH",
SimpleType::P2wpkh => "P2WPKH",
SimpleType::P2tr => "P2TR",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"P2WPKH_P2SH" => Some(Self::P2wpkhP2sh),
"P2WPKH" => Some(Self::P2wpkh),
"P2TR" => Some(Self::P2tr),
_ => None,
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Config {
#[prost(enumeration = "SimpleType", tag = "1")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::btc::serde_deserialize_simple_type")
)]
SimpleType(i32),
#[prost(message, tag = "2")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::btc::serde_deserialize_multisig")
)]
Multisig(Multisig),
#[prost(message, tag = "3")]
Policy(Policy),
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcPubRequest {
#[prost(enumeration = "BtcCoin", tag = "1")]
pub coin: i32,
#[prost(uint32, repeated, tag = "2")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
#[prost(bool, tag = "5")]
pub display: bool,
#[prost(oneof = "btc_pub_request::Output", tags = "3, 4")]
pub output: ::core::option::Option<btc_pub_request::Output>,
}
/// Nested message and enum types in `BTCPubRequest`.
pub mod btc_pub_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum XPubType {
Tpub = 0,
Xpub = 1,
Ypub = 2,
/// zpub
Zpub = 3,
/// vpub
Vpub = 4,
Upub = 5,
/// Vpub
#[cfg_attr(feature = "wasm", serde(rename = "Vpub"))]
CapitalVpub = 6,
/// Zpub
#[cfg_attr(feature = "wasm", serde(rename = "Zpub"))]
CapitalZpub = 7,
/// Upub
#[cfg_attr(feature = "wasm", serde(rename = "Upub"))]
CapitalUpub = 8,
/// Ypub
#[cfg_attr(feature = "wasm", serde(rename = "Ypub"))]
CapitalYpub = 9,
}
impl XPubType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
XPubType::Tpub => "TPUB",
XPubType::Xpub => "XPUB",
XPubType::Ypub => "YPUB",
XPubType::Zpub => "ZPUB",
XPubType::Vpub => "VPUB",
XPubType::Upub => "UPUB",
XPubType::CapitalVpub => "CAPITAL_VPUB",
XPubType::CapitalZpub => "CAPITAL_ZPUB",
XPubType::CapitalUpub => "CAPITAL_UPUB",
XPubType::CapitalYpub => "CAPITAL_YPUB",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"TPUB" => Some(Self::Tpub),
"XPUB" => Some(Self::Xpub),
"YPUB" => Some(Self::Ypub),
"ZPUB" => Some(Self::Zpub),
"VPUB" => Some(Self::Vpub),
"UPUB" => Some(Self::Upub),
"CAPITAL_VPUB" => Some(Self::CapitalVpub),
"CAPITAL_ZPUB" => Some(Self::CapitalZpub),
"CAPITAL_UPUB" => Some(Self::CapitalUpub),
"CAPITAL_YPUB" => Some(Self::CapitalYpub),
_ => None,
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Output {
#[prost(enumeration = "XPubType", tag = "3")]
XpubType(i32),
#[prost(message, tag = "4")]
ScriptConfig(super::BtcScriptConfig),
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcScriptConfigWithKeypath {
#[prost(message, optional, tag = "2")]
pub script_config: ::core::option::Option<BtcScriptConfig>,
#[prost(uint32, repeated, tag = "3")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignInitRequest {
#[prost(enumeration = "BtcCoin", tag = "1")]
pub coin: i32,
/// used script configs in inputs and changes
#[prost(message, repeated, tag = "2")]
pub script_configs: ::prost::alloc::vec::Vec<BtcScriptConfigWithKeypath>,
/// must be 1 or 2
#[prost(uint32, tag = "4")]
pub version: u32,
#[prost(uint32, tag = "5")]
pub num_inputs: u32,
#[prost(uint32, tag = "6")]
pub num_outputs: u32,
/// must be <500000000
#[prost(uint32, tag = "7")]
pub locktime: u32,
#[prost(enumeration = "btc_sign_init_request::FormatUnit", tag = "8")]
pub format_unit: i32,
#[prost(bool, tag = "9")]
pub contains_silent_payment_outputs: bool,
}
/// Nested message and enum types in `BTCSignInitRequest`.
pub mod btc_sign_init_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum FormatUnit {
/// According to `coin` (BTC, LTC, etc.).
Default = 0,
/// Only valid for BTC/TBTC, formats as "sat"/"tsat".
Sat = 1,
}
impl FormatUnit {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
FormatUnit::Default => "DEFAULT",
FormatUnit::Sat => "SAT",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"DEFAULT" => Some(Self::Default),
"SAT" => Some(Self::Sat),
_ => None,
}
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignNextResponse {
#[prost(enumeration = "btc_sign_next_response::Type", tag = "1")]
pub r#type: i32,
/// index of the current input or output
#[prost(uint32, tag = "2")]
pub index: u32,
/// only as a response to BTCSignInputRequest
#[prost(bool, tag = "3")]
pub has_signature: bool,
/// 64 bytes (32 bytes big endian R, 32 bytes big endian S). Only if has_signature is true.
#[prost(bytes = "vec", tag = "4")]
pub signature: ::prost::alloc::vec::Vec<u8>,
/// Previous tx's input/output index in case of PREV_INPUT or PREV_OUTPUT, for the input at `index`.
#[prost(uint32, tag = "5")]
pub prev_index: u32,
#[prost(message, optional, tag = "6")]
pub anti_klepto_signer_commitment: ::core::option::Option<
AntiKleptoSignerCommitment,
>,
/// Generated output. The host *must* verify its correctness using `silent_payment_dleq_proof`.
#[prost(bytes = "vec", tag = "7")]
pub generated_output_pkscript: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes = "vec", tag = "8")]
pub silent_payment_dleq_proof: ::prost::alloc::vec::Vec<u8>,
}
/// Nested message and enum types in `BTCSignNextResponse`.
pub mod btc_sign_next_response {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum Type {
Input = 0,
Output = 1,
Done = 2,
/// For the previous transaction at input `index`.
PrevtxInit = 3,
PrevtxInput = 4,
PrevtxOutput = 5,
HostNonce = 6,
PaymentRequest = 7,
}
impl Type {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Type::Input => "INPUT",
Type::Output => "OUTPUT",
Type::Done => "DONE",
Type::PrevtxInit => "PREVTX_INIT",
Type::PrevtxInput => "PREVTX_INPUT",
Type::PrevtxOutput => "PREVTX_OUTPUT",
Type::HostNonce => "HOST_NONCE",
Type::PaymentRequest => "PAYMENT_REQUEST",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"INPUT" => Some(Self::Input),
"OUTPUT" => Some(Self::Output),
"DONE" => Some(Self::Done),
"PREVTX_INIT" => Some(Self::PrevtxInit),
"PREVTX_INPUT" => Some(Self::PrevtxInput),
"PREVTX_OUTPUT" => Some(Self::PrevtxOutput),
"HOST_NONCE" => Some(Self::HostNonce),
"PAYMENT_REQUEST" => Some(Self::PaymentRequest),
_ => None,
}
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignInputRequest {
#[prost(bytes = "vec", tag = "1")]
pub prev_out_hash: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, tag = "2")]
pub prev_out_index: u32,
#[prost(uint64, tag = "3")]
pub prev_out_value: u64,
/// must be 0xffffffff-2, 0xffffffff-1 or 0xffffffff
#[prost(uint32, tag = "4")]
pub sequence: u32,
/// all inputs must be ours.
#[prost(uint32, repeated, tag = "6")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
/// References a script config from BTCSignInitRequest
#[prost(uint32, tag = "7")]
pub script_config_index: u32,
#[prost(message, optional, tag = "8")]
pub host_nonce_commitment: ::core::option::Option<AntiKleptoHostNonceCommitment>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignOutputRequest {
#[prost(bool, tag = "1")]
pub ours: bool,
/// if ours is false
#[prost(enumeration = "BtcOutputType", tag = "2")]
pub r#type: i32,
/// 20 bytes for p2pkh, p2sh, pw2wpkh. 32 bytes for p2wsh.
#[prost(uint64, tag = "3")]
pub value: u64,
/// if ours is false. Renamed from `hash`.
#[prost(bytes = "vec", tag = "4")]
pub payload: ::prost::alloc::vec::Vec<u8>,
/// if ours is true
#[prost(uint32, repeated, tag = "5")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
/// If ours is true. References a script config from BTCSignInitRequest
#[prost(uint32, tag = "6")]
pub script_config_index: u32,
#[prost(uint32, optional, tag = "7")]
pub payment_request_index: ::core::option::Option<u32>,
/// If provided, `type` and `payload` is ignored. The generated output pkScript is returned in
/// BTCSignNextResponse. `contains_silent_payment_outputs` in the init request must be true.
#[prost(message, optional, tag = "8")]
pub silent_payment: ::core::option::Option<btc_sign_output_request::SilentPayment>,
}
/// Nested message and enum types in `BTCSignOutputRequest`.
pub mod btc_sign_output_request {
/// <https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki>
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SilentPayment {
#[prost(string, tag = "1")]
pub address: ::prost::alloc::string::String,
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcScriptConfigRegistration {
#[prost(enumeration = "BtcCoin", tag = "1")]
pub coin: i32,
#[prost(message, optional, tag = "2")]
pub script_config: ::core::option::Option<BtcScriptConfig>,
/// Unused for policy registrations.
#[prost(uint32, repeated, tag = "3")]
#[cfg_attr(
feature = "wasm",
serde(deserialize_with = "crate::keypath::serde_deserialize")
)]
pub keypath: ::prost::alloc::vec::Vec<u32>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct BtcSuccess {}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcIsScriptConfigRegisteredRequest {
#[prost(message, optional, tag = "1")]
pub registration: ::core::option::Option<BtcScriptConfigRegistration>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct BtcIsScriptConfigRegisteredResponse {
#[prost(bool, tag = "1")]
pub is_registered: bool,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcRegisterScriptConfigRequest {
#[prost(message, optional, tag = "1")]
pub registration: ::core::option::Option<BtcScriptConfigRegistration>,
/// If empty, the name is entered on the device instead.
#[prost(string, tag = "2")]
pub name: ::prost::alloc::string::String,
#[prost(enumeration = "btc_register_script_config_request::XPubType", tag = "3")]
pub xpub_type: i32,
}
/// Nested message and enum types in `BTCRegisterScriptConfigRequest`.
pub mod btc_register_script_config_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum XPubType {
/// Automatically choose to match Electrum's xpub format (e.g. Zpub/Vpub for p2wsh multisig mainnet/testnet).
AutoElectrum = 0,
/// Always xpub for mainnets, tpub for testnets.
AutoXpubTpub = 1,
}
impl XPubType {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
XPubType::AutoElectrum => "AUTO_ELECTRUM",
XPubType::AutoXpubTpub => "AUTO_XPUB_TPUB",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"AUTO_ELECTRUM" => Some(Self::AutoElectrum),
"AUTO_XPUB_TPUB" => Some(Self::AutoXpubTpub),
_ => None,
}
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, PartialEq, ::prost::Message)]
pub struct BtcPrevTxInitRequest {
#[prost(uint32, tag = "1")]
pub version: u32,
#[prost(uint32, tag = "2")]
pub num_inputs: u32,
#[prost(uint32, tag = "3")]
pub num_outputs: u32,
#[prost(uint32, tag = "4")]
pub locktime: u32,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcPrevTxInputRequest {
#[prost(bytes = "vec", tag = "1")]
pub prev_out_hash: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, tag = "2")]
pub prev_out_index: u32,
#[prost(bytes = "vec", tag = "3")]
pub signature_script: ::prost::alloc::vec::Vec<u8>,
#[prost(uint32, tag = "4")]
pub sequence: u32,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcPrevTxOutputRequest {
#[prost(uint64, tag = "1")]
pub value: u64,
#[prost(bytes = "vec", tag = "2")]
pub pubkey_script: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcPaymentRequestRequest {
#[prost(string, tag = "1")]
pub recipient_name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
pub memos: ::prost::alloc::vec::Vec<btc_payment_request_request::Memo>,
#[prost(bytes = "vec", tag = "3")]
pub nonce: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag = "4")]
pub total_amount: u64,
#[prost(bytes = "vec", tag = "5")]
pub signature: ::prost::alloc::vec::Vec<u8>,
}
/// Nested message and enum types in `BTCPaymentRequestRequest`.
pub mod btc_payment_request_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Memo {
#[prost(oneof = "memo::Memo", tags = "1")]
pub memo: ::core::option::Option<memo::Memo>,
}
/// Nested message and enum types in `Memo`.
pub mod memo {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TextMemo {
#[prost(string, tag = "1")]
pub note: ::prost::alloc::string::String,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Memo {
#[prost(message, tag = "1")]
TextMemo(TextMemo),
}
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignMessageRequest {
#[prost(enumeration = "BtcCoin", tag = "1")]
pub coin: i32,
#[prost(message, optional, tag = "2")]
pub script_config: ::core::option::Option<BtcScriptConfigWithKeypath>,
#[prost(bytes = "vec", tag = "3")]
pub msg: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag = "4")]
pub host_nonce_commitment: ::core::option::Option<AntiKleptoHostNonceCommitment>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcSignMessageResponse {
/// 65 bytes (32 bytes big endian R, 32 bytes big endian S, 1 recid).
#[prost(bytes = "vec", tag = "1")]
pub signature: ::prost::alloc::vec::Vec<u8>,
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcRequest {
#[prost(oneof = "btc_request::Request", tags = "1, 2, 3, 4, 5, 6, 7, 8")]
pub request: ::core::option::Option<btc_request::Request>,
}
/// Nested message and enum types in `BTCRequest`.
pub mod btc_request {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
#[prost(message, tag = "1")]
IsScriptConfigRegistered(super::BtcIsScriptConfigRegisteredRequest),
#[prost(message, tag = "2")]
RegisterScriptConfig(super::BtcRegisterScriptConfigRequest),
#[prost(message, tag = "3")]
PrevtxInit(super::BtcPrevTxInitRequest),
#[prost(message, tag = "4")]
PrevtxInput(super::BtcPrevTxInputRequest),
#[prost(message, tag = "5")]
PrevtxOutput(super::BtcPrevTxOutputRequest),
#[prost(message, tag = "6")]
SignMessage(super::BtcSignMessageRequest),
#[prost(message, tag = "7")]
AntikleptoSignature(super::AntiKleptoSignatureRequest),
#[prost(message, tag = "8")]
PaymentRequest(super::BtcPaymentRequestRequest),
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BtcResponse {
#[prost(oneof = "btc_response::Response", tags = "1, 2, 3, 4, 5")]
pub response: ::core::option::Option<btc_response::Response>,
}
/// Nested message and enum types in `BTCResponse`.
pub mod btc_response {
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
#[prost(message, tag = "1")]
Success(super::BtcSuccess),
#[prost(message, tag = "2")]
IsScriptConfigRegistered(super::BtcIsScriptConfigRegisteredResponse),
#[prost(message, tag = "3")]
SignNext(super::BtcSignNextResponse),
#[prost(message, tag = "4")]
SignMessage(super::BtcSignMessageResponse),
#[prost(message, tag = "5")]
AntikleptoSignerCommitment(super::AntiKleptoSignerCommitment),
}
}
#[cfg_attr(feature = "wasm", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "wasm", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum BtcCoin {
Btc = 0,
Tbtc = 1,
Ltc = 2,
Tltc = 3,
/// Regtest
Rbtc = 4,
}
impl BtcCoin {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
BtcCoin::Btc => "BTC",
BtcCoin::Tbtc => "TBTC",
BtcCoin::Ltc => "LTC",
BtcCoin::Tltc => "TLTC",
BtcCoin::Rbtc => "RBTC",
}
}