breez-sdk-spark 0.1.1__cp38-cp38-win32.whl → 0.6.2__cp38-cp38-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4806 +0,0 @@
1
-
2
-
3
- # This file was autogenerated by some hot garbage in the `uniffi` crate.
4
- # Trust me, you don't want to mess with it!
5
-
6
- # Common helper code.
7
- #
8
- # Ideally this would live in a separate .py file where it can be unittested etc
9
- # in isolation, and perhaps even published as a re-useable package.
10
- #
11
- # However, it's important that the details of how this helper code works (e.g. the
12
- # way that different builtin types are passed across the FFI) exactly match what's
13
- # expected by the rust code on the other side of the interface. In practice right
14
- # now that means coming from the exact some version of `uniffi` that was used to
15
- # compile the rust component. The easiest way to ensure this is to bundle the Python
16
- # helpers directly inline like we're doing here.
17
-
18
- from __future__ import annotations
19
- import os
20
- import sys
21
- import ctypes
22
- import enum
23
- import struct
24
- import contextlib
25
- import datetime
26
- import threading
27
- import itertools
28
- import traceback
29
- import typing
30
- import asyncio
31
- import platform
32
-
33
- # Used for default argument values
34
- _DEFAULT = object() # type: typing.Any
35
-
36
-
37
- class _UniffiRustBuffer(ctypes.Structure):
38
- _fields_ = [
39
- ("capacity", ctypes.c_uint64),
40
- ("len", ctypes.c_uint64),
41
- ("data", ctypes.POINTER(ctypes.c_char)),
42
- ]
43
-
44
- @staticmethod
45
- def default():
46
- return _UniffiRustBuffer(0, 0, None)
47
-
48
- @staticmethod
49
- def alloc(size):
50
- return _uniffi_rust_call(_UniffiLib.ffi_breez_sdk_common_rustbuffer_alloc, size)
51
-
52
- @staticmethod
53
- def reserve(rbuf, additional):
54
- return _uniffi_rust_call(_UniffiLib.ffi_breez_sdk_common_rustbuffer_reserve, rbuf, additional)
55
-
56
- def free(self):
57
- return _uniffi_rust_call(_UniffiLib.ffi_breez_sdk_common_rustbuffer_free, self)
58
-
59
- def __str__(self):
60
- return "_UniffiRustBuffer(capacity={}, len={}, data={})".format(
61
- self.capacity,
62
- self.len,
63
- self.data[0:self.len]
64
- )
65
-
66
- @contextlib.contextmanager
67
- def alloc_with_builder(*args):
68
- """Context-manger to allocate a buffer using a _UniffiRustBufferBuilder.
69
-
70
- The allocated buffer will be automatically freed if an error occurs, ensuring that
71
- we don't accidentally leak it.
72
- """
73
- builder = _UniffiRustBufferBuilder()
74
- try:
75
- yield builder
76
- except:
77
- builder.discard()
78
- raise
79
-
80
- @contextlib.contextmanager
81
- def consume_with_stream(self):
82
- """Context-manager to consume a buffer using a _UniffiRustBufferStream.
83
-
84
- The _UniffiRustBuffer will be freed once the context-manager exits, ensuring that we don't
85
- leak it even if an error occurs.
86
- """
87
- try:
88
- s = _UniffiRustBufferStream.from_rust_buffer(self)
89
- yield s
90
- if s.remaining() != 0:
91
- raise RuntimeError("junk data left in buffer at end of consume_with_stream")
92
- finally:
93
- self.free()
94
-
95
- @contextlib.contextmanager
96
- def read_with_stream(self):
97
- """Context-manager to read a buffer using a _UniffiRustBufferStream.
98
-
99
- This is like consume_with_stream, but doesn't free the buffer afterwards.
100
- It should only be used with borrowed `_UniffiRustBuffer` data.
101
- """
102
- s = _UniffiRustBufferStream.from_rust_buffer(self)
103
- yield s
104
- if s.remaining() != 0:
105
- raise RuntimeError("junk data left in buffer at end of read_with_stream")
106
-
107
- class _UniffiForeignBytes(ctypes.Structure):
108
- _fields_ = [
109
- ("len", ctypes.c_int32),
110
- ("data", ctypes.POINTER(ctypes.c_char)),
111
- ]
112
-
113
- def __str__(self):
114
- return "_UniffiForeignBytes(len={}, data={})".format(self.len, self.data[0:self.len])
115
-
116
-
117
- class _UniffiRustBufferStream:
118
- """
119
- Helper for structured reading of bytes from a _UniffiRustBuffer
120
- """
121
-
122
- def __init__(self, data, len):
123
- self.data = data
124
- self.len = len
125
- self.offset = 0
126
-
127
- @classmethod
128
- def from_rust_buffer(cls, buf):
129
- return cls(buf.data, buf.len)
130
-
131
- def remaining(self):
132
- return self.len - self.offset
133
-
134
- def _unpack_from(self, size, format):
135
- if self.offset + size > self.len:
136
- raise InternalError("read past end of rust buffer")
137
- value = struct.unpack(format, self.data[self.offset:self.offset+size])[0]
138
- self.offset += size
139
- return value
140
-
141
- def read(self, size):
142
- if self.offset + size > self.len:
143
- raise InternalError("read past end of rust buffer")
144
- data = self.data[self.offset:self.offset+size]
145
- self.offset += size
146
- return data
147
-
148
- def read_i8(self):
149
- return self._unpack_from(1, ">b")
150
-
151
- def read_u8(self):
152
- return self._unpack_from(1, ">B")
153
-
154
- def read_i16(self):
155
- return self._unpack_from(2, ">h")
156
-
157
- def read_u16(self):
158
- return self._unpack_from(2, ">H")
159
-
160
- def read_i32(self):
161
- return self._unpack_from(4, ">i")
162
-
163
- def read_u32(self):
164
- return self._unpack_from(4, ">I")
165
-
166
- def read_i64(self):
167
- return self._unpack_from(8, ">q")
168
-
169
- def read_u64(self):
170
- return self._unpack_from(8, ">Q")
171
-
172
- def read_float(self):
173
- v = self._unpack_from(4, ">f")
174
- return v
175
-
176
- def read_double(self):
177
- return self._unpack_from(8, ">d")
178
-
179
- class _UniffiRustBufferBuilder:
180
- """
181
- Helper for structured writing of bytes into a _UniffiRustBuffer.
182
- """
183
-
184
- def __init__(self):
185
- self.rbuf = _UniffiRustBuffer.alloc(16)
186
- self.rbuf.len = 0
187
-
188
- def finalize(self):
189
- rbuf = self.rbuf
190
- self.rbuf = None
191
- return rbuf
192
-
193
- def discard(self):
194
- if self.rbuf is not None:
195
- rbuf = self.finalize()
196
- rbuf.free()
197
-
198
- @contextlib.contextmanager
199
- def _reserve(self, num_bytes):
200
- if self.rbuf.len + num_bytes > self.rbuf.capacity:
201
- self.rbuf = _UniffiRustBuffer.reserve(self.rbuf, num_bytes)
202
- yield None
203
- self.rbuf.len += num_bytes
204
-
205
- def _pack_into(self, size, format, value):
206
- with self._reserve(size):
207
- # XXX TODO: I feel like I should be able to use `struct.pack_into` here but can't figure it out.
208
- for i, byte in enumerate(struct.pack(format, value)):
209
- self.rbuf.data[self.rbuf.len + i] = byte
210
-
211
- def write(self, value):
212
- with self._reserve(len(value)):
213
- for i, byte in enumerate(value):
214
- self.rbuf.data[self.rbuf.len + i] = byte
215
-
216
- def write_i8(self, v):
217
- self._pack_into(1, ">b", v)
218
-
219
- def write_u8(self, v):
220
- self._pack_into(1, ">B", v)
221
-
222
- def write_i16(self, v):
223
- self._pack_into(2, ">h", v)
224
-
225
- def write_u16(self, v):
226
- self._pack_into(2, ">H", v)
227
-
228
- def write_i32(self, v):
229
- self._pack_into(4, ">i", v)
230
-
231
- def write_u32(self, v):
232
- self._pack_into(4, ">I", v)
233
-
234
- def write_i64(self, v):
235
- self._pack_into(8, ">q", v)
236
-
237
- def write_u64(self, v):
238
- self._pack_into(8, ">Q", v)
239
-
240
- def write_float(self, v):
241
- self._pack_into(4, ">f", v)
242
-
243
- def write_double(self, v):
244
- self._pack_into(8, ">d", v)
245
-
246
- def write_c_size_t(self, v):
247
- self._pack_into(ctypes.sizeof(ctypes.c_size_t) , "@N", v)
248
- # A handful of classes and functions to support the generated data structures.
249
- # This would be a good candidate for isolating in its own ffi-support lib.
250
-
251
- class InternalError(Exception):
252
- pass
253
-
254
- class _UniffiRustCallStatus(ctypes.Structure):
255
- """
256
- Error runtime.
257
- """
258
- _fields_ = [
259
- ("code", ctypes.c_int8),
260
- ("error_buf", _UniffiRustBuffer),
261
- ]
262
-
263
- # These match the values from the uniffi::rustcalls module
264
- CALL_SUCCESS = 0
265
- CALL_ERROR = 1
266
- CALL_UNEXPECTED_ERROR = 2
267
-
268
- @staticmethod
269
- def default():
270
- return _UniffiRustCallStatus(code=_UniffiRustCallStatus.CALL_SUCCESS, error_buf=_UniffiRustBuffer.default())
271
-
272
- def __str__(self):
273
- if self.code == _UniffiRustCallStatus.CALL_SUCCESS:
274
- return "_UniffiRustCallStatus(CALL_SUCCESS)"
275
- elif self.code == _UniffiRustCallStatus.CALL_ERROR:
276
- return "_UniffiRustCallStatus(CALL_ERROR)"
277
- elif self.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
278
- return "_UniffiRustCallStatus(CALL_UNEXPECTED_ERROR)"
279
- else:
280
- return "_UniffiRustCallStatus(<invalid code>)"
281
-
282
- def _uniffi_rust_call(fn, *args):
283
- # Call a rust function
284
- return _uniffi_rust_call_with_error(None, fn, *args)
285
-
286
- def _uniffi_rust_call_with_error(error_ffi_converter, fn, *args):
287
- # Call a rust function and handle any errors
288
- #
289
- # This function is used for rust calls that return Result<> and therefore can set the CALL_ERROR status code.
290
- # error_ffi_converter must be set to the _UniffiConverter for the error class that corresponds to the result.
291
- call_status = _UniffiRustCallStatus.default()
292
-
293
- args_with_error = args + (ctypes.byref(call_status),)
294
- result = fn(*args_with_error)
295
- _uniffi_check_call_status(error_ffi_converter, call_status)
296
- return result
297
-
298
- def _uniffi_check_call_status(error_ffi_converter, call_status):
299
- if call_status.code == _UniffiRustCallStatus.CALL_SUCCESS:
300
- pass
301
- elif call_status.code == _UniffiRustCallStatus.CALL_ERROR:
302
- if error_ffi_converter is None:
303
- call_status.error_buf.free()
304
- raise InternalError("_uniffi_rust_call_with_error: CALL_ERROR, but error_ffi_converter is None")
305
- else:
306
- raise error_ffi_converter.lift(call_status.error_buf)
307
- elif call_status.code == _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR:
308
- # When the rust code sees a panic, it tries to construct a _UniffiRustBuffer
309
- # with the message. But if that code panics, then it just sends back
310
- # an empty buffer.
311
- if call_status.error_buf.len > 0:
312
- msg = _UniffiConverterString.lift(call_status.error_buf)
313
- else:
314
- msg = "Unknown rust panic"
315
- raise InternalError(msg)
316
- else:
317
- raise InternalError("Invalid _UniffiRustCallStatus code: {}".format(
318
- call_status.code))
319
-
320
- def _uniffi_trait_interface_call(call_status, make_call, write_return_value):
321
- try:
322
- return write_return_value(make_call())
323
- except Exception as e:
324
- call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
325
- call_status.error_buf = _UniffiConverterString.lower(repr(e))
326
-
327
- def _uniffi_trait_interface_call_with_error(call_status, make_call, write_return_value, error_type, lower_error):
328
- try:
329
- try:
330
- return write_return_value(make_call())
331
- except error_type as e:
332
- call_status.code = _UniffiRustCallStatus.CALL_ERROR
333
- call_status.error_buf = lower_error(e)
334
- except Exception as e:
335
- call_status.code = _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR
336
- call_status.error_buf = _UniffiConverterString.lower(repr(e))
337
- class _UniffiHandleMap:
338
- """
339
- A map where inserting, getting and removing data is synchronized with a lock.
340
- """
341
-
342
- def __init__(self):
343
- # type Handle = int
344
- self._map = {} # type: Dict[Handle, Any]
345
- self._lock = threading.Lock()
346
- self._counter = itertools.count()
347
-
348
- def insert(self, obj):
349
- with self._lock:
350
- handle = next(self._counter)
351
- self._map[handle] = obj
352
- return handle
353
-
354
- def get(self, handle):
355
- try:
356
- with self._lock:
357
- return self._map[handle]
358
- except KeyError:
359
- raise InternalError("_UniffiHandleMap.get: Invalid handle")
360
-
361
- def remove(self, handle):
362
- try:
363
- with self._lock:
364
- return self._map.pop(handle)
365
- except KeyError:
366
- raise InternalError("_UniffiHandleMap.remove: Invalid handle")
367
-
368
- def __len__(self):
369
- return len(self._map)
370
- # Types conforming to `_UniffiConverterPrimitive` pass themselves directly over the FFI.
371
- class _UniffiConverterPrimitive:
372
- @classmethod
373
- def lift(cls, value):
374
- return value
375
-
376
- @classmethod
377
- def lower(cls, value):
378
- return value
379
-
380
- class _UniffiConverterPrimitiveInt(_UniffiConverterPrimitive):
381
- @classmethod
382
- def check_lower(cls, value):
383
- try:
384
- value = value.__index__()
385
- except Exception:
386
- raise TypeError("'{}' object cannot be interpreted as an integer".format(type(value).__name__))
387
- if not isinstance(value, int):
388
- raise TypeError("__index__ returned non-int (type {})".format(type(value).__name__))
389
- if not cls.VALUE_MIN <= value < cls.VALUE_MAX:
390
- raise ValueError("{} requires {} <= value < {}".format(cls.CLASS_NAME, cls.VALUE_MIN, cls.VALUE_MAX))
391
-
392
- class _UniffiConverterPrimitiveFloat(_UniffiConverterPrimitive):
393
- @classmethod
394
- def check_lower(cls, value):
395
- try:
396
- value = value.__float__()
397
- except Exception:
398
- raise TypeError("must be real number, not {}".format(type(value).__name__))
399
- if not isinstance(value, float):
400
- raise TypeError("__float__ returned non-float (type {})".format(type(value).__name__))
401
-
402
- # Helper class for wrapper types that will always go through a _UniffiRustBuffer.
403
- # Classes should inherit from this and implement the `read` and `write` static methods.
404
- class _UniffiConverterRustBuffer:
405
- @classmethod
406
- def lift(cls, rbuf):
407
- with rbuf.consume_with_stream() as stream:
408
- return cls.read(stream)
409
-
410
- @classmethod
411
- def lower(cls, value):
412
- with _UniffiRustBuffer.alloc_with_builder() as builder:
413
- cls.write(value, builder)
414
- return builder.finalize()
415
-
416
- # Contains loading, initialization code, and the FFI Function declarations.
417
- # Define some ctypes FFI types that we use in the library
418
-
419
- """
420
- Function pointer for a Rust task, which a callback function that takes a opaque pointer
421
- """
422
- _UNIFFI_RUST_TASK = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int8)
423
-
424
- def _uniffi_future_callback_t(return_type):
425
- """
426
- Factory function to create callback function types for async functions
427
- """
428
- return ctypes.CFUNCTYPE(None, ctypes.c_uint64, return_type, _UniffiRustCallStatus)
429
-
430
- def _uniffi_load_indirect():
431
- """
432
- This is how we find and load the dynamic library provided by the component.
433
- For now we just look it up by name.
434
- """
435
- if sys.platform == "darwin":
436
- libname = "lib{}.dylib"
437
- elif sys.platform.startswith("win"):
438
- # As of python3.8, ctypes does not seem to search $PATH when loading DLLs.
439
- # We could use `os.add_dll_directory` to configure the search path, but
440
- # it doesn't feel right to mess with application-wide settings. Let's
441
- # assume that the `.dll` is next to the `.py` file and load by full path.
442
- libname = os.path.join(
443
- os.path.dirname(__file__),
444
- "{}.dll",
445
- )
446
- else:
447
- # Anything else must be an ELF platform - Linux, *BSD, Solaris/illumos
448
- libname = "lib{}.so"
449
-
450
- libname = libname.format("breez_sdk_spark_bindings")
451
- path = os.path.join(os.path.dirname(__file__), libname)
452
- lib = ctypes.cdll.LoadLibrary(path)
453
- return lib
454
-
455
- def _uniffi_check_contract_api_version(lib):
456
- # Get the bindings contract version from our ComponentInterface
457
- bindings_contract_version = 26
458
- # Get the scaffolding contract version by calling the into the dylib
459
- scaffolding_contract_version = lib.ffi_breez_sdk_common_uniffi_contract_version()
460
- if bindings_contract_version != scaffolding_contract_version:
461
- raise InternalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
462
-
463
- def _uniffi_check_api_checksums(lib):
464
- if lib.uniffi_breez_sdk_common_checksum_method_restclient_get() != 32450:
465
- raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
466
- if lib.uniffi_breez_sdk_common_checksum_method_restclient_post() != 14213:
467
- raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
468
-
469
- # A ctypes library to expose the extern-C FFI definitions.
470
- # This is an implementation detail which will be called internally by the public API.
471
-
472
- _UniffiLib = _uniffi_load_indirect()
473
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK = ctypes.CFUNCTYPE(None,ctypes.c_uint64,ctypes.c_int8,
474
- )
475
- _UNIFFI_FOREIGN_FUTURE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64,
476
- )
477
- _UNIFFI_CALLBACK_INTERFACE_FREE = ctypes.CFUNCTYPE(None,ctypes.c_uint64,
478
- )
479
- class _UniffiForeignFuture(ctypes.Structure):
480
- _fields_ = [
481
- ("handle", ctypes.c_uint64),
482
- ("free", _UNIFFI_FOREIGN_FUTURE_FREE),
483
- ]
484
- class _UniffiForeignFutureStructU8(ctypes.Structure):
485
- _fields_ = [
486
- ("return_value", ctypes.c_uint8),
487
- ("call_status", _UniffiRustCallStatus),
488
- ]
489
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_U8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU8,
490
- )
491
- class _UniffiForeignFutureStructI8(ctypes.Structure):
492
- _fields_ = [
493
- ("return_value", ctypes.c_int8),
494
- ("call_status", _UniffiRustCallStatus),
495
- ]
496
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_I8 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI8,
497
- )
498
- class _UniffiForeignFutureStructU16(ctypes.Structure):
499
- _fields_ = [
500
- ("return_value", ctypes.c_uint16),
501
- ("call_status", _UniffiRustCallStatus),
502
- ]
503
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_U16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU16,
504
- )
505
- class _UniffiForeignFutureStructI16(ctypes.Structure):
506
- _fields_ = [
507
- ("return_value", ctypes.c_int16),
508
- ("call_status", _UniffiRustCallStatus),
509
- ]
510
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_I16 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI16,
511
- )
512
- class _UniffiForeignFutureStructU32(ctypes.Structure):
513
- _fields_ = [
514
- ("return_value", ctypes.c_uint32),
515
- ("call_status", _UniffiRustCallStatus),
516
- ]
517
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_U32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU32,
518
- )
519
- class _UniffiForeignFutureStructI32(ctypes.Structure):
520
- _fields_ = [
521
- ("return_value", ctypes.c_int32),
522
- ("call_status", _UniffiRustCallStatus),
523
- ]
524
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_I32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI32,
525
- )
526
- class _UniffiForeignFutureStructU64(ctypes.Structure):
527
- _fields_ = [
528
- ("return_value", ctypes.c_uint64),
529
- ("call_status", _UniffiRustCallStatus),
530
- ]
531
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_U64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructU64,
532
- )
533
- class _UniffiForeignFutureStructI64(ctypes.Structure):
534
- _fields_ = [
535
- ("return_value", ctypes.c_int64),
536
- ("call_status", _UniffiRustCallStatus),
537
- ]
538
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_I64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructI64,
539
- )
540
- class _UniffiForeignFutureStructF32(ctypes.Structure):
541
- _fields_ = [
542
- ("return_value", ctypes.c_float),
543
- ("call_status", _UniffiRustCallStatus),
544
- ]
545
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_F32 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructF32,
546
- )
547
- class _UniffiForeignFutureStructF64(ctypes.Structure):
548
- _fields_ = [
549
- ("return_value", ctypes.c_double),
550
- ("call_status", _UniffiRustCallStatus),
551
- ]
552
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_F64 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructF64,
553
- )
554
- class _UniffiForeignFutureStructPointer(ctypes.Structure):
555
- _fields_ = [
556
- ("return_value", ctypes.c_void_p),
557
- ("call_status", _UniffiRustCallStatus),
558
- ]
559
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_POINTER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructPointer,
560
- )
561
- class _UniffiForeignFutureStructRustBuffer(ctypes.Structure):
562
- _fields_ = [
563
- ("return_value", _UniffiRustBuffer),
564
- ("call_status", _UniffiRustCallStatus),
565
- ]
566
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructRustBuffer,
567
- )
568
- class _UniffiForeignFutureStructVoid(ctypes.Structure):
569
- _fields_ = [
570
- ("call_status", _UniffiRustCallStatus),
571
- ]
572
- _UNIFFI_FOREIGN_FUTURE_COMPLETE_VOID = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiForeignFutureStructVoid,
573
- )
574
- _UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD0 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,_UNIFFI_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER,ctypes.c_uint64,ctypes.POINTER(_UniffiForeignFuture),
575
- )
576
- _UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD1 = ctypes.CFUNCTYPE(None,ctypes.c_uint64,_UniffiRustBuffer,_UniffiRustBuffer,_UniffiRustBuffer,_UNIFFI_FOREIGN_FUTURE_COMPLETE_RUST_BUFFER,ctypes.c_uint64,ctypes.POINTER(_UniffiForeignFuture),
577
- )
578
- class _UniffiVTableCallbackInterfaceRestClient(ctypes.Structure):
579
- _fields_ = [
580
- ("get", _UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD0),
581
- ("post", _UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD1),
582
- ("uniffi_free", _UNIFFI_CALLBACK_INTERFACE_FREE),
583
- ]
584
- _UniffiLib.uniffi_breez_sdk_common_fn_clone_restclient.argtypes = (
585
- ctypes.c_void_p,
586
- ctypes.POINTER(_UniffiRustCallStatus),
587
- )
588
- _UniffiLib.uniffi_breez_sdk_common_fn_clone_restclient.restype = ctypes.c_void_p
589
- _UniffiLib.uniffi_breez_sdk_common_fn_free_restclient.argtypes = (
590
- ctypes.c_void_p,
591
- ctypes.POINTER(_UniffiRustCallStatus),
592
- )
593
- _UniffiLib.uniffi_breez_sdk_common_fn_free_restclient.restype = None
594
- _UniffiLib.uniffi_breez_sdk_common_fn_init_callback_vtable_restclient.argtypes = (
595
- ctypes.POINTER(_UniffiVTableCallbackInterfaceRestClient),
596
- )
597
- _UniffiLib.uniffi_breez_sdk_common_fn_init_callback_vtable_restclient.restype = None
598
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_get.argtypes = (
599
- ctypes.c_void_p,
600
- _UniffiRustBuffer,
601
- _UniffiRustBuffer,
602
- )
603
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_get.restype = ctypes.c_uint64
604
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_post.argtypes = (
605
- ctypes.c_void_p,
606
- _UniffiRustBuffer,
607
- _UniffiRustBuffer,
608
- _UniffiRustBuffer,
609
- )
610
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_post.restype = ctypes.c_uint64
611
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_alloc.argtypes = (
612
- ctypes.c_uint64,
613
- ctypes.POINTER(_UniffiRustCallStatus),
614
- )
615
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_alloc.restype = _UniffiRustBuffer
616
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_from_bytes.argtypes = (
617
- _UniffiForeignBytes,
618
- ctypes.POINTER(_UniffiRustCallStatus),
619
- )
620
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_from_bytes.restype = _UniffiRustBuffer
621
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_free.argtypes = (
622
- _UniffiRustBuffer,
623
- ctypes.POINTER(_UniffiRustCallStatus),
624
- )
625
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_free.restype = None
626
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_reserve.argtypes = (
627
- _UniffiRustBuffer,
628
- ctypes.c_uint64,
629
- ctypes.POINTER(_UniffiRustCallStatus),
630
- )
631
- _UniffiLib.ffi_breez_sdk_common_rustbuffer_reserve.restype = _UniffiRustBuffer
632
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u8.argtypes = (
633
- ctypes.c_uint64,
634
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
635
- ctypes.c_uint64,
636
- )
637
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u8.restype = None
638
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u8.argtypes = (
639
- ctypes.c_uint64,
640
- )
641
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u8.restype = None
642
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u8.argtypes = (
643
- ctypes.c_uint64,
644
- )
645
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u8.restype = None
646
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u8.argtypes = (
647
- ctypes.c_uint64,
648
- ctypes.POINTER(_UniffiRustCallStatus),
649
- )
650
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u8.restype = ctypes.c_uint8
651
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i8.argtypes = (
652
- ctypes.c_uint64,
653
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
654
- ctypes.c_uint64,
655
- )
656
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i8.restype = None
657
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i8.argtypes = (
658
- ctypes.c_uint64,
659
- )
660
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i8.restype = None
661
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i8.argtypes = (
662
- ctypes.c_uint64,
663
- )
664
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i8.restype = None
665
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i8.argtypes = (
666
- ctypes.c_uint64,
667
- ctypes.POINTER(_UniffiRustCallStatus),
668
- )
669
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i8.restype = ctypes.c_int8
670
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u16.argtypes = (
671
- ctypes.c_uint64,
672
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
673
- ctypes.c_uint64,
674
- )
675
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u16.restype = None
676
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u16.argtypes = (
677
- ctypes.c_uint64,
678
- )
679
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u16.restype = None
680
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u16.argtypes = (
681
- ctypes.c_uint64,
682
- )
683
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u16.restype = None
684
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u16.argtypes = (
685
- ctypes.c_uint64,
686
- ctypes.POINTER(_UniffiRustCallStatus),
687
- )
688
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u16.restype = ctypes.c_uint16
689
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i16.argtypes = (
690
- ctypes.c_uint64,
691
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
692
- ctypes.c_uint64,
693
- )
694
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i16.restype = None
695
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i16.argtypes = (
696
- ctypes.c_uint64,
697
- )
698
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i16.restype = None
699
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i16.argtypes = (
700
- ctypes.c_uint64,
701
- )
702
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i16.restype = None
703
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i16.argtypes = (
704
- ctypes.c_uint64,
705
- ctypes.POINTER(_UniffiRustCallStatus),
706
- )
707
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i16.restype = ctypes.c_int16
708
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u32.argtypes = (
709
- ctypes.c_uint64,
710
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
711
- ctypes.c_uint64,
712
- )
713
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u32.restype = None
714
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u32.argtypes = (
715
- ctypes.c_uint64,
716
- )
717
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u32.restype = None
718
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u32.argtypes = (
719
- ctypes.c_uint64,
720
- )
721
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u32.restype = None
722
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u32.argtypes = (
723
- ctypes.c_uint64,
724
- ctypes.POINTER(_UniffiRustCallStatus),
725
- )
726
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u32.restype = ctypes.c_uint32
727
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i32.argtypes = (
728
- ctypes.c_uint64,
729
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
730
- ctypes.c_uint64,
731
- )
732
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i32.restype = None
733
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i32.argtypes = (
734
- ctypes.c_uint64,
735
- )
736
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i32.restype = None
737
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i32.argtypes = (
738
- ctypes.c_uint64,
739
- )
740
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i32.restype = None
741
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i32.argtypes = (
742
- ctypes.c_uint64,
743
- ctypes.POINTER(_UniffiRustCallStatus),
744
- )
745
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i32.restype = ctypes.c_int32
746
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u64.argtypes = (
747
- ctypes.c_uint64,
748
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
749
- ctypes.c_uint64,
750
- )
751
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_u64.restype = None
752
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u64.argtypes = (
753
- ctypes.c_uint64,
754
- )
755
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_u64.restype = None
756
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u64.argtypes = (
757
- ctypes.c_uint64,
758
- )
759
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_u64.restype = None
760
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u64.argtypes = (
761
- ctypes.c_uint64,
762
- ctypes.POINTER(_UniffiRustCallStatus),
763
- )
764
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_u64.restype = ctypes.c_uint64
765
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i64.argtypes = (
766
- ctypes.c_uint64,
767
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
768
- ctypes.c_uint64,
769
- )
770
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_i64.restype = None
771
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i64.argtypes = (
772
- ctypes.c_uint64,
773
- )
774
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_i64.restype = None
775
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i64.argtypes = (
776
- ctypes.c_uint64,
777
- )
778
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_i64.restype = None
779
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i64.argtypes = (
780
- ctypes.c_uint64,
781
- ctypes.POINTER(_UniffiRustCallStatus),
782
- )
783
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_i64.restype = ctypes.c_int64
784
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_f32.argtypes = (
785
- ctypes.c_uint64,
786
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
787
- ctypes.c_uint64,
788
- )
789
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_f32.restype = None
790
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_f32.argtypes = (
791
- ctypes.c_uint64,
792
- )
793
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_f32.restype = None
794
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_f32.argtypes = (
795
- ctypes.c_uint64,
796
- )
797
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_f32.restype = None
798
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_f32.argtypes = (
799
- ctypes.c_uint64,
800
- ctypes.POINTER(_UniffiRustCallStatus),
801
- )
802
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_f32.restype = ctypes.c_float
803
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_f64.argtypes = (
804
- ctypes.c_uint64,
805
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
806
- ctypes.c_uint64,
807
- )
808
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_f64.restype = None
809
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_f64.argtypes = (
810
- ctypes.c_uint64,
811
- )
812
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_f64.restype = None
813
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_f64.argtypes = (
814
- ctypes.c_uint64,
815
- )
816
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_f64.restype = None
817
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_f64.argtypes = (
818
- ctypes.c_uint64,
819
- ctypes.POINTER(_UniffiRustCallStatus),
820
- )
821
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_f64.restype = ctypes.c_double
822
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_pointer.argtypes = (
823
- ctypes.c_uint64,
824
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
825
- ctypes.c_uint64,
826
- )
827
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_pointer.restype = None
828
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_pointer.argtypes = (
829
- ctypes.c_uint64,
830
- )
831
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_pointer.restype = None
832
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_pointer.argtypes = (
833
- ctypes.c_uint64,
834
- )
835
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_pointer.restype = None
836
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_pointer.argtypes = (
837
- ctypes.c_uint64,
838
- ctypes.POINTER(_UniffiRustCallStatus),
839
- )
840
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_pointer.restype = ctypes.c_void_p
841
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_rust_buffer.argtypes = (
842
- ctypes.c_uint64,
843
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
844
- ctypes.c_uint64,
845
- )
846
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_rust_buffer.restype = None
847
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_rust_buffer.argtypes = (
848
- ctypes.c_uint64,
849
- )
850
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_rust_buffer.restype = None
851
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_rust_buffer.argtypes = (
852
- ctypes.c_uint64,
853
- )
854
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_rust_buffer.restype = None
855
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_rust_buffer.argtypes = (
856
- ctypes.c_uint64,
857
- ctypes.POINTER(_UniffiRustCallStatus),
858
- )
859
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_rust_buffer.restype = _UniffiRustBuffer
860
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_void.argtypes = (
861
- ctypes.c_uint64,
862
- _UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK,
863
- ctypes.c_uint64,
864
- )
865
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_void.restype = None
866
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_void.argtypes = (
867
- ctypes.c_uint64,
868
- )
869
- _UniffiLib.ffi_breez_sdk_common_rust_future_cancel_void.restype = None
870
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_void.argtypes = (
871
- ctypes.c_uint64,
872
- )
873
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_void.restype = None
874
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_void.argtypes = (
875
- ctypes.c_uint64,
876
- ctypes.POINTER(_UniffiRustCallStatus),
877
- )
878
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_void.restype = None
879
- _UniffiLib.uniffi_breez_sdk_common_checksum_method_restclient_get.argtypes = (
880
- )
881
- _UniffiLib.uniffi_breez_sdk_common_checksum_method_restclient_get.restype = ctypes.c_uint16
882
- _UniffiLib.uniffi_breez_sdk_common_checksum_method_restclient_post.argtypes = (
883
- )
884
- _UniffiLib.uniffi_breez_sdk_common_checksum_method_restclient_post.restype = ctypes.c_uint16
885
- _UniffiLib.ffi_breez_sdk_common_uniffi_contract_version.argtypes = (
886
- )
887
- _UniffiLib.ffi_breez_sdk_common_uniffi_contract_version.restype = ctypes.c_uint32
888
-
889
- _uniffi_check_contract_api_version(_UniffiLib)
890
- # _uniffi_check_api_checksums(_UniffiLib)
891
-
892
- # Public interface members begin here.
893
-
894
-
895
- class _UniffiConverterUInt16(_UniffiConverterPrimitiveInt):
896
- CLASS_NAME = "u16"
897
- VALUE_MIN = 0
898
- VALUE_MAX = 2**16
899
-
900
- @staticmethod
901
- def read(buf):
902
- return buf.read_u16()
903
-
904
- @staticmethod
905
- def write(value, buf):
906
- buf.write_u16(value)
907
-
908
- class _UniffiConverterUInt32(_UniffiConverterPrimitiveInt):
909
- CLASS_NAME = "u32"
910
- VALUE_MIN = 0
911
- VALUE_MAX = 2**32
912
-
913
- @staticmethod
914
- def read(buf):
915
- return buf.read_u32()
916
-
917
- @staticmethod
918
- def write(value, buf):
919
- buf.write_u32(value)
920
-
921
- class _UniffiConverterUInt64(_UniffiConverterPrimitiveInt):
922
- CLASS_NAME = "u64"
923
- VALUE_MIN = 0
924
- VALUE_MAX = 2**64
925
-
926
- @staticmethod
927
- def read(buf):
928
- return buf.read_u64()
929
-
930
- @staticmethod
931
- def write(value, buf):
932
- buf.write_u64(value)
933
-
934
- class _UniffiConverterDouble(_UniffiConverterPrimitiveFloat):
935
- @staticmethod
936
- def read(buf):
937
- return buf.read_double()
938
-
939
- @staticmethod
940
- def write(value, buf):
941
- buf.write_double(value)
942
-
943
- class _UniffiConverterBool:
944
- @classmethod
945
- def check_lower(cls, value):
946
- return not not value
947
-
948
- @classmethod
949
- def lower(cls, value):
950
- return 1 if value else 0
951
-
952
- @staticmethod
953
- def lift(value):
954
- return value != 0
955
-
956
- @classmethod
957
- def read(cls, buf):
958
- return cls.lift(buf.read_u8())
959
-
960
- @classmethod
961
- def write(cls, value, buf):
962
- buf.write_u8(value)
963
-
964
- class _UniffiConverterString:
965
- @staticmethod
966
- def check_lower(value):
967
- if not isinstance(value, str):
968
- raise TypeError("argument must be str, not {}".format(type(value).__name__))
969
- return value
970
-
971
- @staticmethod
972
- def read(buf):
973
- size = buf.read_i32()
974
- if size < 0:
975
- raise InternalError("Unexpected negative string length")
976
- utf8_bytes = buf.read(size)
977
- return utf8_bytes.decode("utf-8")
978
-
979
- @staticmethod
980
- def write(value, buf):
981
- utf8_bytes = value.encode("utf-8")
982
- buf.write_i32(len(utf8_bytes))
983
- buf.write(utf8_bytes)
984
-
985
- @staticmethod
986
- def lift(buf):
987
- with buf.consume_with_stream() as stream:
988
- return stream.read(stream.remaining()).decode("utf-8")
989
-
990
- @staticmethod
991
- def lower(value):
992
- with _UniffiRustBuffer.alloc_with_builder() as builder:
993
- builder.write(value.encode("utf-8"))
994
- return builder.finalize()
995
-
996
-
997
-
998
- class RestClient(typing.Protocol):
999
- def get(self, url: "str",headers: "typing.Optional[dict[str, str]]"):
1000
- """
1001
- Makes a GET request and logs on DEBUG.
1002
- ### Arguments
1003
- - `url`: the URL on which GET will be called
1004
- - `headers`: optional headers that will be set on the request
1005
- """
1006
-
1007
- raise NotImplementedError
1008
- def post(self, url: "str",headers: "typing.Optional[dict[str, str]]",body: "typing.Optional[str]"):
1009
- """
1010
- Makes a POST request, and logs on DEBUG.
1011
- ### Arguments
1012
- - `url`: the URL on which POST will be called
1013
- - `headers`: the optional POST headers
1014
- - `body`: the optional POST body
1015
- """
1016
-
1017
- raise NotImplementedError
1018
-
1019
-
1020
- class RestClientImpl:
1021
- _pointer: ctypes.c_void_p
1022
-
1023
- def __init__(self, *args, **kwargs):
1024
- raise ValueError("This class has no default constructor")
1025
-
1026
- def __del__(self):
1027
- # In case of partial initialization of instances.
1028
- pointer = getattr(self, "_pointer", None)
1029
- if pointer is not None:
1030
- _uniffi_rust_call(_UniffiLib.uniffi_breez_sdk_common_fn_free_restclient, pointer)
1031
-
1032
- def _uniffi_clone_pointer(self):
1033
- return _uniffi_rust_call(_UniffiLib.uniffi_breez_sdk_common_fn_clone_restclient, self._pointer)
1034
-
1035
- # Used by alternative constructors or any methods which return this type.
1036
- @classmethod
1037
- def _make_instance_(cls, pointer):
1038
- # Lightly yucky way to bypass the usual __init__ logic
1039
- # and just create a new instance with the required pointer.
1040
- inst = cls.__new__(cls)
1041
- inst._pointer = pointer
1042
- return inst
1043
-
1044
- async def get(self, url: "str",headers: "typing.Optional[dict[str, str]]") -> "RestResponse":
1045
- """
1046
- Makes a GET request and logs on DEBUG.
1047
- ### Arguments
1048
- - `url`: the URL on which GET will be called
1049
- - `headers`: optional headers that will be set on the request
1050
- """
1051
-
1052
- _UniffiConverterString.check_lower(url)
1053
-
1054
- _UniffiConverterOptionalMapStringString.check_lower(headers)
1055
-
1056
- return await _uniffi_rust_call_async(
1057
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_get(
1058
- self._uniffi_clone_pointer(),
1059
- _UniffiConverterString.lower(url),
1060
- _UniffiConverterOptionalMapStringString.lower(headers)
1061
- ),
1062
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_rust_buffer,
1063
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_rust_buffer,
1064
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_rust_buffer,
1065
- # lift function
1066
- _UniffiConverterTypeRestResponse.lift,
1067
-
1068
- # Error FFI converter
1069
- _UniffiConverterTypeServiceConnectivityError,
1070
-
1071
- )
1072
-
1073
-
1074
-
1075
- async def post(self, url: "str",headers: "typing.Optional[dict[str, str]]",body: "typing.Optional[str]") -> "RestResponse":
1076
- """
1077
- Makes a POST request, and logs on DEBUG.
1078
- ### Arguments
1079
- - `url`: the URL on which POST will be called
1080
- - `headers`: the optional POST headers
1081
- - `body`: the optional POST body
1082
- """
1083
-
1084
- _UniffiConverterString.check_lower(url)
1085
-
1086
- _UniffiConverterOptionalMapStringString.check_lower(headers)
1087
-
1088
- _UniffiConverterOptionalString.check_lower(body)
1089
-
1090
- return await _uniffi_rust_call_async(
1091
- _UniffiLib.uniffi_breez_sdk_common_fn_method_restclient_post(
1092
- self._uniffi_clone_pointer(),
1093
- _UniffiConverterString.lower(url),
1094
- _UniffiConverterOptionalMapStringString.lower(headers),
1095
- _UniffiConverterOptionalString.lower(body)
1096
- ),
1097
- _UniffiLib.ffi_breez_sdk_common_rust_future_poll_rust_buffer,
1098
- _UniffiLib.ffi_breez_sdk_common_rust_future_complete_rust_buffer,
1099
- _UniffiLib.ffi_breez_sdk_common_rust_future_free_rust_buffer,
1100
- # lift function
1101
- _UniffiConverterTypeRestResponse.lift,
1102
-
1103
- # Error FFI converter
1104
- _UniffiConverterTypeServiceConnectivityError,
1105
-
1106
- )
1107
-
1108
-
1109
- # Magic number for the Rust proxy to call using the same mechanism as every other method,
1110
- # to free the callback once it's dropped by Rust.
1111
- _UNIFFI_IDX_CALLBACK_FREE = 0
1112
- # Return codes for callback calls
1113
- _UNIFFI_CALLBACK_SUCCESS = 0
1114
- _UNIFFI_CALLBACK_ERROR = 1
1115
- _UNIFFI_CALLBACK_UNEXPECTED_ERROR = 2
1116
-
1117
- class _UniffiCallbackInterfaceFfiConverter:
1118
- _handle_map = _UniffiHandleMap()
1119
-
1120
- @classmethod
1121
- def lift(cls, handle):
1122
- return cls._handle_map.get(handle)
1123
-
1124
- @classmethod
1125
- def read(cls, buf):
1126
- handle = buf.read_u64()
1127
- cls.lift(handle)
1128
-
1129
- @classmethod
1130
- def check_lower(cls, cb):
1131
- pass
1132
-
1133
- @classmethod
1134
- def lower(cls, cb):
1135
- handle = cls._handle_map.insert(cb)
1136
- return handle
1137
-
1138
- @classmethod
1139
- def write(cls, cb, buf):
1140
- buf.write_u64(cls.lower(cb))
1141
-
1142
- # Put all the bits inside a class to keep the top-level namespace clean
1143
- class _UniffiTraitImplRestClient:
1144
- # For each method, generate a callback function to pass to Rust
1145
-
1146
- @_UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD0
1147
- def get(
1148
- uniffi_handle,
1149
- url,
1150
- headers,
1151
- uniffi_future_callback,
1152
- uniffi_callback_data,
1153
- uniffi_out_return,
1154
- ):
1155
- uniffi_obj = _UniffiConverterTypeRestClient._handle_map.get(uniffi_handle)
1156
- def make_call():
1157
- args = (_UniffiConverterString.lift(url), _UniffiConverterOptionalMapStringString.lift(headers), )
1158
- method = uniffi_obj.get
1159
- return method(*args)
1160
-
1161
-
1162
- def handle_success(return_value):
1163
- uniffi_future_callback(
1164
- uniffi_callback_data,
1165
- _UniffiForeignFutureStructRustBuffer(
1166
- _UniffiConverterTypeRestResponse.lower(return_value),
1167
- _UniffiRustCallStatus.default()
1168
- )
1169
- )
1170
-
1171
- def handle_error(status_code, rust_buffer):
1172
- uniffi_future_callback(
1173
- uniffi_callback_data,
1174
- _UniffiForeignFutureStructRustBuffer(
1175
- _UniffiRustBuffer.default(),
1176
- _UniffiRustCallStatus(status_code, rust_buffer),
1177
- )
1178
- )
1179
- uniffi_out_return[0] = _uniffi_trait_interface_call_async_with_error(make_call, handle_success, handle_error, ServiceConnectivityError, _UniffiConverterTypeServiceConnectivityError.lower)
1180
-
1181
- @_UNIFFI_CALLBACK_INTERFACE_REST_CLIENT_METHOD1
1182
- def post(
1183
- uniffi_handle,
1184
- url,
1185
- headers,
1186
- body,
1187
- uniffi_future_callback,
1188
- uniffi_callback_data,
1189
- uniffi_out_return,
1190
- ):
1191
- uniffi_obj = _UniffiConverterTypeRestClient._handle_map.get(uniffi_handle)
1192
- def make_call():
1193
- args = (_UniffiConverterString.lift(url), _UniffiConverterOptionalMapStringString.lift(headers), _UniffiConverterOptionalString.lift(body), )
1194
- method = uniffi_obj.post
1195
- return method(*args)
1196
-
1197
-
1198
- def handle_success(return_value):
1199
- uniffi_future_callback(
1200
- uniffi_callback_data,
1201
- _UniffiForeignFutureStructRustBuffer(
1202
- _UniffiConverterTypeRestResponse.lower(return_value),
1203
- _UniffiRustCallStatus.default()
1204
- )
1205
- )
1206
-
1207
- def handle_error(status_code, rust_buffer):
1208
- uniffi_future_callback(
1209
- uniffi_callback_data,
1210
- _UniffiForeignFutureStructRustBuffer(
1211
- _UniffiRustBuffer.default(),
1212
- _UniffiRustCallStatus(status_code, rust_buffer),
1213
- )
1214
- )
1215
- uniffi_out_return[0] = _uniffi_trait_interface_call_async_with_error(make_call, handle_success, handle_error, ServiceConnectivityError, _UniffiConverterTypeServiceConnectivityError.lower)
1216
-
1217
- @_UNIFFI_CALLBACK_INTERFACE_FREE
1218
- def _uniffi_free(uniffi_handle):
1219
- _UniffiConverterTypeRestClient._handle_map.remove(uniffi_handle)
1220
-
1221
- # Generate the FFI VTable. This has a field for each callback interface method.
1222
- _uniffi_vtable = _UniffiVTableCallbackInterfaceRestClient(
1223
- get,
1224
- post,
1225
- _uniffi_free
1226
- )
1227
- # Send Rust a pointer to the VTable. Note: this means we need to keep the struct alive forever,
1228
- # or else bad things will happen when Rust tries to access it.
1229
- _UniffiLib.uniffi_breez_sdk_common_fn_init_callback_vtable_restclient(ctypes.byref(_uniffi_vtable))
1230
-
1231
-
1232
-
1233
- class _UniffiConverterTypeRestClient:
1234
- _handle_map = _UniffiHandleMap()
1235
-
1236
- @staticmethod
1237
- def lift(value: int):
1238
- return RestClientImpl._make_instance_(value)
1239
-
1240
- @staticmethod
1241
- def check_lower(value: RestClient):
1242
- pass
1243
-
1244
- @staticmethod
1245
- def lower(value: RestClient):
1246
- return _UniffiConverterTypeRestClient._handle_map.insert(value)
1247
-
1248
- @classmethod
1249
- def read(cls, buf: _UniffiRustBuffer):
1250
- ptr = buf.read_u64()
1251
- if ptr == 0:
1252
- raise InternalError("Raw pointer value was null")
1253
- return cls.lift(ptr)
1254
-
1255
- @classmethod
1256
- def write(cls, value: RestClient, buf: _UniffiRustBuffer):
1257
- buf.write_u64(cls.lower(value))
1258
-
1259
-
1260
- class AesSuccessActionData:
1261
- """
1262
- Payload of the AES success action, as received from the LNURL endpoint
1263
-
1264
- See [`AesSuccessActionDataDecrypted`] for a similar wrapper containing the decrypted payload
1265
- """
1266
-
1267
- description: "str"
1268
- """
1269
- Contents description, up to 144 characters
1270
- """
1271
-
1272
- ciphertext: "str"
1273
- """
1274
- Base64, AES-encrypted data where encryption key is payment preimage, up to 4kb of characters
1275
- """
1276
-
1277
- iv: "str"
1278
- """
1279
- Base64, initialization vector, exactly 24 characters
1280
- """
1281
-
1282
- def __init__(self, *, description: "str", ciphertext: "str", iv: "str"):
1283
- self.description = description
1284
- self.ciphertext = ciphertext
1285
- self.iv = iv
1286
-
1287
- def __str__(self):
1288
- return "AesSuccessActionData(description={}, ciphertext={}, iv={})".format(self.description, self.ciphertext, self.iv)
1289
-
1290
- def __eq__(self, other):
1291
- if self.description != other.description:
1292
- return False
1293
- if self.ciphertext != other.ciphertext:
1294
- return False
1295
- if self.iv != other.iv:
1296
- return False
1297
- return True
1298
-
1299
- class _UniffiConverterTypeAesSuccessActionData(_UniffiConverterRustBuffer):
1300
- @staticmethod
1301
- def read(buf):
1302
- return AesSuccessActionData(
1303
- description=_UniffiConverterString.read(buf),
1304
- ciphertext=_UniffiConverterString.read(buf),
1305
- iv=_UniffiConverterString.read(buf),
1306
- )
1307
-
1308
- @staticmethod
1309
- def check_lower(value):
1310
- _UniffiConverterString.check_lower(value.description)
1311
- _UniffiConverterString.check_lower(value.ciphertext)
1312
- _UniffiConverterString.check_lower(value.iv)
1313
-
1314
- @staticmethod
1315
- def write(value, buf):
1316
- _UniffiConverterString.write(value.description, buf)
1317
- _UniffiConverterString.write(value.ciphertext, buf)
1318
- _UniffiConverterString.write(value.iv, buf)
1319
-
1320
-
1321
- class AesSuccessActionDataDecrypted:
1322
- """
1323
- Wrapper for the decrypted [`AesSuccessActionData`] payload
1324
- """
1325
-
1326
- description: "str"
1327
- """
1328
- Contents description, up to 144 characters
1329
- """
1330
-
1331
- plaintext: "str"
1332
- """
1333
- Decrypted content
1334
- """
1335
-
1336
- def __init__(self, *, description: "str", plaintext: "str"):
1337
- self.description = description
1338
- self.plaintext = plaintext
1339
-
1340
- def __str__(self):
1341
- return "AesSuccessActionDataDecrypted(description={}, plaintext={})".format(self.description, self.plaintext)
1342
-
1343
- def __eq__(self, other):
1344
- if self.description != other.description:
1345
- return False
1346
- if self.plaintext != other.plaintext:
1347
- return False
1348
- return True
1349
-
1350
- class _UniffiConverterTypeAesSuccessActionDataDecrypted(_UniffiConverterRustBuffer):
1351
- @staticmethod
1352
- def read(buf):
1353
- return AesSuccessActionDataDecrypted(
1354
- description=_UniffiConverterString.read(buf),
1355
- plaintext=_UniffiConverterString.read(buf),
1356
- )
1357
-
1358
- @staticmethod
1359
- def check_lower(value):
1360
- _UniffiConverterString.check_lower(value.description)
1361
- _UniffiConverterString.check_lower(value.plaintext)
1362
-
1363
- @staticmethod
1364
- def write(value, buf):
1365
- _UniffiConverterString.write(value.description, buf)
1366
- _UniffiConverterString.write(value.plaintext, buf)
1367
-
1368
-
1369
- class Bip21Details:
1370
- amount_sat: "typing.Optional[int]"
1371
- asset_id: "typing.Optional[str]"
1372
- uri: "str"
1373
- extras: "typing.List[Bip21Extra]"
1374
- label: "typing.Optional[str]"
1375
- message: "typing.Optional[str]"
1376
- payment_methods: "typing.List[InputType]"
1377
- def __init__(self, *, amount_sat: "typing.Optional[int]", asset_id: "typing.Optional[str]", uri: "str", extras: "typing.List[Bip21Extra]", label: "typing.Optional[str]", message: "typing.Optional[str]", payment_methods: "typing.List[InputType]"):
1378
- self.amount_sat = amount_sat
1379
- self.asset_id = asset_id
1380
- self.uri = uri
1381
- self.extras = extras
1382
- self.label = label
1383
- self.message = message
1384
- self.payment_methods = payment_methods
1385
-
1386
- def __str__(self):
1387
- return "Bip21Details(amount_sat={}, asset_id={}, uri={}, extras={}, label={}, message={}, payment_methods={})".format(self.amount_sat, self.asset_id, self.uri, self.extras, self.label, self.message, self.payment_methods)
1388
-
1389
- def __eq__(self, other):
1390
- if self.amount_sat != other.amount_sat:
1391
- return False
1392
- if self.asset_id != other.asset_id:
1393
- return False
1394
- if self.uri != other.uri:
1395
- return False
1396
- if self.extras != other.extras:
1397
- return False
1398
- if self.label != other.label:
1399
- return False
1400
- if self.message != other.message:
1401
- return False
1402
- if self.payment_methods != other.payment_methods:
1403
- return False
1404
- return True
1405
-
1406
- class _UniffiConverterTypeBip21Details(_UniffiConverterRustBuffer):
1407
- @staticmethod
1408
- def read(buf):
1409
- return Bip21Details(
1410
- amount_sat=_UniffiConverterOptionalUInt64.read(buf),
1411
- asset_id=_UniffiConverterOptionalString.read(buf),
1412
- uri=_UniffiConverterString.read(buf),
1413
- extras=_UniffiConverterSequenceTypeBip21Extra.read(buf),
1414
- label=_UniffiConverterOptionalString.read(buf),
1415
- message=_UniffiConverterOptionalString.read(buf),
1416
- payment_methods=_UniffiConverterSequenceTypeInputType.read(buf),
1417
- )
1418
-
1419
- @staticmethod
1420
- def check_lower(value):
1421
- _UniffiConverterOptionalUInt64.check_lower(value.amount_sat)
1422
- _UniffiConverterOptionalString.check_lower(value.asset_id)
1423
- _UniffiConverterString.check_lower(value.uri)
1424
- _UniffiConverterSequenceTypeBip21Extra.check_lower(value.extras)
1425
- _UniffiConverterOptionalString.check_lower(value.label)
1426
- _UniffiConverterOptionalString.check_lower(value.message)
1427
- _UniffiConverterSequenceTypeInputType.check_lower(value.payment_methods)
1428
-
1429
- @staticmethod
1430
- def write(value, buf):
1431
- _UniffiConverterOptionalUInt64.write(value.amount_sat, buf)
1432
- _UniffiConverterOptionalString.write(value.asset_id, buf)
1433
- _UniffiConverterString.write(value.uri, buf)
1434
- _UniffiConverterSequenceTypeBip21Extra.write(value.extras, buf)
1435
- _UniffiConverterOptionalString.write(value.label, buf)
1436
- _UniffiConverterOptionalString.write(value.message, buf)
1437
- _UniffiConverterSequenceTypeInputType.write(value.payment_methods, buf)
1438
-
1439
-
1440
- class Bip21Extra:
1441
- key: "str"
1442
- value: "str"
1443
- def __init__(self, *, key: "str", value: "str"):
1444
- self.key = key
1445
- self.value = value
1446
-
1447
- def __str__(self):
1448
- return "Bip21Extra(key={}, value={})".format(self.key, self.value)
1449
-
1450
- def __eq__(self, other):
1451
- if self.key != other.key:
1452
- return False
1453
- if self.value != other.value:
1454
- return False
1455
- return True
1456
-
1457
- class _UniffiConverterTypeBip21Extra(_UniffiConverterRustBuffer):
1458
- @staticmethod
1459
- def read(buf):
1460
- return Bip21Extra(
1461
- key=_UniffiConverterString.read(buf),
1462
- value=_UniffiConverterString.read(buf),
1463
- )
1464
-
1465
- @staticmethod
1466
- def check_lower(value):
1467
- _UniffiConverterString.check_lower(value.key)
1468
- _UniffiConverterString.check_lower(value.value)
1469
-
1470
- @staticmethod
1471
- def write(value, buf):
1472
- _UniffiConverterString.write(value.key, buf)
1473
- _UniffiConverterString.write(value.value, buf)
1474
-
1475
-
1476
- class BitcoinAddressDetails:
1477
- address: "str"
1478
- network: "BitcoinNetwork"
1479
- source: "PaymentRequestSource"
1480
- def __init__(self, *, address: "str", network: "BitcoinNetwork", source: "PaymentRequestSource"):
1481
- self.address = address
1482
- self.network = network
1483
- self.source = source
1484
-
1485
- def __str__(self):
1486
- return "BitcoinAddressDetails(address={}, network={}, source={})".format(self.address, self.network, self.source)
1487
-
1488
- def __eq__(self, other):
1489
- if self.address != other.address:
1490
- return False
1491
- if self.network != other.network:
1492
- return False
1493
- if self.source != other.source:
1494
- return False
1495
- return True
1496
-
1497
- class _UniffiConverterTypeBitcoinAddressDetails(_UniffiConverterRustBuffer):
1498
- @staticmethod
1499
- def read(buf):
1500
- return BitcoinAddressDetails(
1501
- address=_UniffiConverterString.read(buf),
1502
- network=_UniffiConverterTypeBitcoinNetwork.read(buf),
1503
- source=_UniffiConverterTypePaymentRequestSource.read(buf),
1504
- )
1505
-
1506
- @staticmethod
1507
- def check_lower(value):
1508
- _UniffiConverterString.check_lower(value.address)
1509
- _UniffiConverterTypeBitcoinNetwork.check_lower(value.network)
1510
- _UniffiConverterTypePaymentRequestSource.check_lower(value.source)
1511
-
1512
- @staticmethod
1513
- def write(value, buf):
1514
- _UniffiConverterString.write(value.address, buf)
1515
- _UniffiConverterTypeBitcoinNetwork.write(value.network, buf)
1516
- _UniffiConverterTypePaymentRequestSource.write(value.source, buf)
1517
-
1518
-
1519
- class Bolt11Invoice:
1520
- bolt11: "str"
1521
- source: "PaymentRequestSource"
1522
- def __init__(self, *, bolt11: "str", source: "PaymentRequestSource"):
1523
- self.bolt11 = bolt11
1524
- self.source = source
1525
-
1526
- def __str__(self):
1527
- return "Bolt11Invoice(bolt11={}, source={})".format(self.bolt11, self.source)
1528
-
1529
- def __eq__(self, other):
1530
- if self.bolt11 != other.bolt11:
1531
- return False
1532
- if self.source != other.source:
1533
- return False
1534
- return True
1535
-
1536
- class _UniffiConverterTypeBolt11Invoice(_UniffiConverterRustBuffer):
1537
- @staticmethod
1538
- def read(buf):
1539
- return Bolt11Invoice(
1540
- bolt11=_UniffiConverterString.read(buf),
1541
- source=_UniffiConverterTypePaymentRequestSource.read(buf),
1542
- )
1543
-
1544
- @staticmethod
1545
- def check_lower(value):
1546
- _UniffiConverterString.check_lower(value.bolt11)
1547
- _UniffiConverterTypePaymentRequestSource.check_lower(value.source)
1548
-
1549
- @staticmethod
1550
- def write(value, buf):
1551
- _UniffiConverterString.write(value.bolt11, buf)
1552
- _UniffiConverterTypePaymentRequestSource.write(value.source, buf)
1553
-
1554
-
1555
- class Bolt11InvoiceDetails:
1556
- amount_msat: "typing.Optional[int]"
1557
- description: "typing.Optional[str]"
1558
- description_hash: "typing.Optional[str]"
1559
- expiry: "int"
1560
- invoice: "Bolt11Invoice"
1561
- min_final_cltv_expiry_delta: "int"
1562
- network: "BitcoinNetwork"
1563
- payee_pubkey: "str"
1564
- payment_hash: "str"
1565
- payment_secret: "str"
1566
- routing_hints: "typing.List[Bolt11RouteHint]"
1567
- timestamp: "int"
1568
- def __init__(self, *, amount_msat: "typing.Optional[int]", description: "typing.Optional[str]", description_hash: "typing.Optional[str]", expiry: "int", invoice: "Bolt11Invoice", min_final_cltv_expiry_delta: "int", network: "BitcoinNetwork", payee_pubkey: "str", payment_hash: "str", payment_secret: "str", routing_hints: "typing.List[Bolt11RouteHint]", timestamp: "int"):
1569
- self.amount_msat = amount_msat
1570
- self.description = description
1571
- self.description_hash = description_hash
1572
- self.expiry = expiry
1573
- self.invoice = invoice
1574
- self.min_final_cltv_expiry_delta = min_final_cltv_expiry_delta
1575
- self.network = network
1576
- self.payee_pubkey = payee_pubkey
1577
- self.payment_hash = payment_hash
1578
- self.payment_secret = payment_secret
1579
- self.routing_hints = routing_hints
1580
- self.timestamp = timestamp
1581
-
1582
- def __str__(self):
1583
- return "Bolt11InvoiceDetails(amount_msat={}, description={}, description_hash={}, expiry={}, invoice={}, min_final_cltv_expiry_delta={}, network={}, payee_pubkey={}, payment_hash={}, payment_secret={}, routing_hints={}, timestamp={})".format(self.amount_msat, self.description, self.description_hash, self.expiry, self.invoice, self.min_final_cltv_expiry_delta, self.network, self.payee_pubkey, self.payment_hash, self.payment_secret, self.routing_hints, self.timestamp)
1584
-
1585
- def __eq__(self, other):
1586
- if self.amount_msat != other.amount_msat:
1587
- return False
1588
- if self.description != other.description:
1589
- return False
1590
- if self.description_hash != other.description_hash:
1591
- return False
1592
- if self.expiry != other.expiry:
1593
- return False
1594
- if self.invoice != other.invoice:
1595
- return False
1596
- if self.min_final_cltv_expiry_delta != other.min_final_cltv_expiry_delta:
1597
- return False
1598
- if self.network != other.network:
1599
- return False
1600
- if self.payee_pubkey != other.payee_pubkey:
1601
- return False
1602
- if self.payment_hash != other.payment_hash:
1603
- return False
1604
- if self.payment_secret != other.payment_secret:
1605
- return False
1606
- if self.routing_hints != other.routing_hints:
1607
- return False
1608
- if self.timestamp != other.timestamp:
1609
- return False
1610
- return True
1611
-
1612
- class _UniffiConverterTypeBolt11InvoiceDetails(_UniffiConverterRustBuffer):
1613
- @staticmethod
1614
- def read(buf):
1615
- return Bolt11InvoiceDetails(
1616
- amount_msat=_UniffiConverterOptionalUInt64.read(buf),
1617
- description=_UniffiConverterOptionalString.read(buf),
1618
- description_hash=_UniffiConverterOptionalString.read(buf),
1619
- expiry=_UniffiConverterUInt64.read(buf),
1620
- invoice=_UniffiConverterTypeBolt11Invoice.read(buf),
1621
- min_final_cltv_expiry_delta=_UniffiConverterUInt64.read(buf),
1622
- network=_UniffiConverterTypeBitcoinNetwork.read(buf),
1623
- payee_pubkey=_UniffiConverterString.read(buf),
1624
- payment_hash=_UniffiConverterString.read(buf),
1625
- payment_secret=_UniffiConverterString.read(buf),
1626
- routing_hints=_UniffiConverterSequenceTypeBolt11RouteHint.read(buf),
1627
- timestamp=_UniffiConverterUInt64.read(buf),
1628
- )
1629
-
1630
- @staticmethod
1631
- def check_lower(value):
1632
- _UniffiConverterOptionalUInt64.check_lower(value.amount_msat)
1633
- _UniffiConverterOptionalString.check_lower(value.description)
1634
- _UniffiConverterOptionalString.check_lower(value.description_hash)
1635
- _UniffiConverterUInt64.check_lower(value.expiry)
1636
- _UniffiConverterTypeBolt11Invoice.check_lower(value.invoice)
1637
- _UniffiConverterUInt64.check_lower(value.min_final_cltv_expiry_delta)
1638
- _UniffiConverterTypeBitcoinNetwork.check_lower(value.network)
1639
- _UniffiConverterString.check_lower(value.payee_pubkey)
1640
- _UniffiConverterString.check_lower(value.payment_hash)
1641
- _UniffiConverterString.check_lower(value.payment_secret)
1642
- _UniffiConverterSequenceTypeBolt11RouteHint.check_lower(value.routing_hints)
1643
- _UniffiConverterUInt64.check_lower(value.timestamp)
1644
-
1645
- @staticmethod
1646
- def write(value, buf):
1647
- _UniffiConverterOptionalUInt64.write(value.amount_msat, buf)
1648
- _UniffiConverterOptionalString.write(value.description, buf)
1649
- _UniffiConverterOptionalString.write(value.description_hash, buf)
1650
- _UniffiConverterUInt64.write(value.expiry, buf)
1651
- _UniffiConverterTypeBolt11Invoice.write(value.invoice, buf)
1652
- _UniffiConverterUInt64.write(value.min_final_cltv_expiry_delta, buf)
1653
- _UniffiConverterTypeBitcoinNetwork.write(value.network, buf)
1654
- _UniffiConverterString.write(value.payee_pubkey, buf)
1655
- _UniffiConverterString.write(value.payment_hash, buf)
1656
- _UniffiConverterString.write(value.payment_secret, buf)
1657
- _UniffiConverterSequenceTypeBolt11RouteHint.write(value.routing_hints, buf)
1658
- _UniffiConverterUInt64.write(value.timestamp, buf)
1659
-
1660
-
1661
- class Bolt11RouteHint:
1662
- hops: "typing.List[Bolt11RouteHintHop]"
1663
- def __init__(self, *, hops: "typing.List[Bolt11RouteHintHop]"):
1664
- self.hops = hops
1665
-
1666
- def __str__(self):
1667
- return "Bolt11RouteHint(hops={})".format(self.hops)
1668
-
1669
- def __eq__(self, other):
1670
- if self.hops != other.hops:
1671
- return False
1672
- return True
1673
-
1674
- class _UniffiConverterTypeBolt11RouteHint(_UniffiConverterRustBuffer):
1675
- @staticmethod
1676
- def read(buf):
1677
- return Bolt11RouteHint(
1678
- hops=_UniffiConverterSequenceTypeBolt11RouteHintHop.read(buf),
1679
- )
1680
-
1681
- @staticmethod
1682
- def check_lower(value):
1683
- _UniffiConverterSequenceTypeBolt11RouteHintHop.check_lower(value.hops)
1684
-
1685
- @staticmethod
1686
- def write(value, buf):
1687
- _UniffiConverterSequenceTypeBolt11RouteHintHop.write(value.hops, buf)
1688
-
1689
-
1690
- class Bolt11RouteHintHop:
1691
- src_node_id: "str"
1692
- """
1693
- The `node_id` of the non-target end of the route
1694
- """
1695
-
1696
- short_channel_id: "str"
1697
- """
1698
- The `short_channel_id` of this channel
1699
- """
1700
-
1701
- fees_base_msat: "int"
1702
- """
1703
- The fees which must be paid to use this channel
1704
- """
1705
-
1706
- fees_proportional_millionths: "int"
1707
- cltv_expiry_delta: "int"
1708
- """
1709
- The difference in CLTV values between this node and the next node.
1710
- """
1711
-
1712
- htlc_minimum_msat: "typing.Optional[int]"
1713
- """
1714
- The minimum value, in msat, which must be relayed to the next hop.
1715
- """
1716
-
1717
- htlc_maximum_msat: "typing.Optional[int]"
1718
- """
1719
- The maximum value in msat available for routing with a single HTLC.
1720
- """
1721
-
1722
- def __init__(self, *, src_node_id: "str", short_channel_id: "str", fees_base_msat: "int", fees_proportional_millionths: "int", cltv_expiry_delta: "int", htlc_minimum_msat: "typing.Optional[int]", htlc_maximum_msat: "typing.Optional[int]"):
1723
- self.src_node_id = src_node_id
1724
- self.short_channel_id = short_channel_id
1725
- self.fees_base_msat = fees_base_msat
1726
- self.fees_proportional_millionths = fees_proportional_millionths
1727
- self.cltv_expiry_delta = cltv_expiry_delta
1728
- self.htlc_minimum_msat = htlc_minimum_msat
1729
- self.htlc_maximum_msat = htlc_maximum_msat
1730
-
1731
- def __str__(self):
1732
- return "Bolt11RouteHintHop(src_node_id={}, short_channel_id={}, fees_base_msat={}, fees_proportional_millionths={}, cltv_expiry_delta={}, htlc_minimum_msat={}, htlc_maximum_msat={})".format(self.src_node_id, self.short_channel_id, self.fees_base_msat, self.fees_proportional_millionths, self.cltv_expiry_delta, self.htlc_minimum_msat, self.htlc_maximum_msat)
1733
-
1734
- def __eq__(self, other):
1735
- if self.src_node_id != other.src_node_id:
1736
- return False
1737
- if self.short_channel_id != other.short_channel_id:
1738
- return False
1739
- if self.fees_base_msat != other.fees_base_msat:
1740
- return False
1741
- if self.fees_proportional_millionths != other.fees_proportional_millionths:
1742
- return False
1743
- if self.cltv_expiry_delta != other.cltv_expiry_delta:
1744
- return False
1745
- if self.htlc_minimum_msat != other.htlc_minimum_msat:
1746
- return False
1747
- if self.htlc_maximum_msat != other.htlc_maximum_msat:
1748
- return False
1749
- return True
1750
-
1751
- class _UniffiConverterTypeBolt11RouteHintHop(_UniffiConverterRustBuffer):
1752
- @staticmethod
1753
- def read(buf):
1754
- return Bolt11RouteHintHop(
1755
- src_node_id=_UniffiConverterString.read(buf),
1756
- short_channel_id=_UniffiConverterString.read(buf),
1757
- fees_base_msat=_UniffiConverterUInt32.read(buf),
1758
- fees_proportional_millionths=_UniffiConverterUInt32.read(buf),
1759
- cltv_expiry_delta=_UniffiConverterUInt16.read(buf),
1760
- htlc_minimum_msat=_UniffiConverterOptionalUInt64.read(buf),
1761
- htlc_maximum_msat=_UniffiConverterOptionalUInt64.read(buf),
1762
- )
1763
-
1764
- @staticmethod
1765
- def check_lower(value):
1766
- _UniffiConverterString.check_lower(value.src_node_id)
1767
- _UniffiConverterString.check_lower(value.short_channel_id)
1768
- _UniffiConverterUInt32.check_lower(value.fees_base_msat)
1769
- _UniffiConverterUInt32.check_lower(value.fees_proportional_millionths)
1770
- _UniffiConverterUInt16.check_lower(value.cltv_expiry_delta)
1771
- _UniffiConverterOptionalUInt64.check_lower(value.htlc_minimum_msat)
1772
- _UniffiConverterOptionalUInt64.check_lower(value.htlc_maximum_msat)
1773
-
1774
- @staticmethod
1775
- def write(value, buf):
1776
- _UniffiConverterString.write(value.src_node_id, buf)
1777
- _UniffiConverterString.write(value.short_channel_id, buf)
1778
- _UniffiConverterUInt32.write(value.fees_base_msat, buf)
1779
- _UniffiConverterUInt32.write(value.fees_proportional_millionths, buf)
1780
- _UniffiConverterUInt16.write(value.cltv_expiry_delta, buf)
1781
- _UniffiConverterOptionalUInt64.write(value.htlc_minimum_msat, buf)
1782
- _UniffiConverterOptionalUInt64.write(value.htlc_maximum_msat, buf)
1783
-
1784
-
1785
- class Bolt12Invoice:
1786
- invoice: "str"
1787
- source: "PaymentRequestSource"
1788
- def __init__(self, *, invoice: "str", source: "PaymentRequestSource"):
1789
- self.invoice = invoice
1790
- self.source = source
1791
-
1792
- def __str__(self):
1793
- return "Bolt12Invoice(invoice={}, source={})".format(self.invoice, self.source)
1794
-
1795
- def __eq__(self, other):
1796
- if self.invoice != other.invoice:
1797
- return False
1798
- if self.source != other.source:
1799
- return False
1800
- return True
1801
-
1802
- class _UniffiConverterTypeBolt12Invoice(_UniffiConverterRustBuffer):
1803
- @staticmethod
1804
- def read(buf):
1805
- return Bolt12Invoice(
1806
- invoice=_UniffiConverterString.read(buf),
1807
- source=_UniffiConverterTypePaymentRequestSource.read(buf),
1808
- )
1809
-
1810
- @staticmethod
1811
- def check_lower(value):
1812
- _UniffiConverterString.check_lower(value.invoice)
1813
- _UniffiConverterTypePaymentRequestSource.check_lower(value.source)
1814
-
1815
- @staticmethod
1816
- def write(value, buf):
1817
- _UniffiConverterString.write(value.invoice, buf)
1818
- _UniffiConverterTypePaymentRequestSource.write(value.source, buf)
1819
-
1820
-
1821
- class Bolt12InvoiceDetails:
1822
- amount_msat: "int"
1823
- invoice: "Bolt12Invoice"
1824
- def __init__(self, *, amount_msat: "int", invoice: "Bolt12Invoice"):
1825
- self.amount_msat = amount_msat
1826
- self.invoice = invoice
1827
-
1828
- def __str__(self):
1829
- return "Bolt12InvoiceDetails(amount_msat={}, invoice={})".format(self.amount_msat, self.invoice)
1830
-
1831
- def __eq__(self, other):
1832
- if self.amount_msat != other.amount_msat:
1833
- return False
1834
- if self.invoice != other.invoice:
1835
- return False
1836
- return True
1837
-
1838
- class _UniffiConverterTypeBolt12InvoiceDetails(_UniffiConverterRustBuffer):
1839
- @staticmethod
1840
- def read(buf):
1841
- return Bolt12InvoiceDetails(
1842
- amount_msat=_UniffiConverterUInt64.read(buf),
1843
- invoice=_UniffiConverterTypeBolt12Invoice.read(buf),
1844
- )
1845
-
1846
- @staticmethod
1847
- def check_lower(value):
1848
- _UniffiConverterUInt64.check_lower(value.amount_msat)
1849
- _UniffiConverterTypeBolt12Invoice.check_lower(value.invoice)
1850
-
1851
- @staticmethod
1852
- def write(value, buf):
1853
- _UniffiConverterUInt64.write(value.amount_msat, buf)
1854
- _UniffiConverterTypeBolt12Invoice.write(value.invoice, buf)
1855
-
1856
-
1857
- class Bolt12InvoiceRequestDetails:
1858
-
1859
- def __str__(self):
1860
- return "Bolt12InvoiceRequestDetails()".format()
1861
-
1862
- def __eq__(self, other):
1863
- return True
1864
-
1865
- class _UniffiConverterTypeBolt12InvoiceRequestDetails(_UniffiConverterRustBuffer):
1866
- @staticmethod
1867
- def read(buf):
1868
- return Bolt12InvoiceRequestDetails(
1869
- )
1870
-
1871
- @staticmethod
1872
- def check_lower(value):
1873
- pass
1874
-
1875
- @staticmethod
1876
- def write(value, buf):
1877
- pass
1878
-
1879
-
1880
- class Bolt12Offer:
1881
- offer: "str"
1882
- source: "PaymentRequestSource"
1883
- def __init__(self, *, offer: "str", source: "PaymentRequestSource"):
1884
- self.offer = offer
1885
- self.source = source
1886
-
1887
- def __str__(self):
1888
- return "Bolt12Offer(offer={}, source={})".format(self.offer, self.source)
1889
-
1890
- def __eq__(self, other):
1891
- if self.offer != other.offer:
1892
- return False
1893
- if self.source != other.source:
1894
- return False
1895
- return True
1896
-
1897
- class _UniffiConverterTypeBolt12Offer(_UniffiConverterRustBuffer):
1898
- @staticmethod
1899
- def read(buf):
1900
- return Bolt12Offer(
1901
- offer=_UniffiConverterString.read(buf),
1902
- source=_UniffiConverterTypePaymentRequestSource.read(buf),
1903
- )
1904
-
1905
- @staticmethod
1906
- def check_lower(value):
1907
- _UniffiConverterString.check_lower(value.offer)
1908
- _UniffiConverterTypePaymentRequestSource.check_lower(value.source)
1909
-
1910
- @staticmethod
1911
- def write(value, buf):
1912
- _UniffiConverterString.write(value.offer, buf)
1913
- _UniffiConverterTypePaymentRequestSource.write(value.source, buf)
1914
-
1915
-
1916
- class Bolt12OfferBlindedPath:
1917
- blinded_hops: "typing.List[str]"
1918
- def __init__(self, *, blinded_hops: "typing.List[str]"):
1919
- self.blinded_hops = blinded_hops
1920
-
1921
- def __str__(self):
1922
- return "Bolt12OfferBlindedPath(blinded_hops={})".format(self.blinded_hops)
1923
-
1924
- def __eq__(self, other):
1925
- if self.blinded_hops != other.blinded_hops:
1926
- return False
1927
- return True
1928
-
1929
- class _UniffiConverterTypeBolt12OfferBlindedPath(_UniffiConverterRustBuffer):
1930
- @staticmethod
1931
- def read(buf):
1932
- return Bolt12OfferBlindedPath(
1933
- blinded_hops=_UniffiConverterSequenceString.read(buf),
1934
- )
1935
-
1936
- @staticmethod
1937
- def check_lower(value):
1938
- _UniffiConverterSequenceString.check_lower(value.blinded_hops)
1939
-
1940
- @staticmethod
1941
- def write(value, buf):
1942
- _UniffiConverterSequenceString.write(value.blinded_hops, buf)
1943
-
1944
-
1945
- class Bolt12OfferDetails:
1946
- absolute_expiry: "typing.Optional[int]"
1947
- chains: "typing.List[str]"
1948
- description: "typing.Optional[str]"
1949
- issuer: "typing.Optional[str]"
1950
- min_amount: "typing.Optional[Amount]"
1951
- offer: "Bolt12Offer"
1952
- paths: "typing.List[Bolt12OfferBlindedPath]"
1953
- signing_pubkey: "typing.Optional[str]"
1954
- def __init__(self, *, absolute_expiry: "typing.Optional[int]", chains: "typing.List[str]", description: "typing.Optional[str]", issuer: "typing.Optional[str]", min_amount: "typing.Optional[Amount]", offer: "Bolt12Offer", paths: "typing.List[Bolt12OfferBlindedPath]", signing_pubkey: "typing.Optional[str]"):
1955
- self.absolute_expiry = absolute_expiry
1956
- self.chains = chains
1957
- self.description = description
1958
- self.issuer = issuer
1959
- self.min_amount = min_amount
1960
- self.offer = offer
1961
- self.paths = paths
1962
- self.signing_pubkey = signing_pubkey
1963
-
1964
- def __str__(self):
1965
- return "Bolt12OfferDetails(absolute_expiry={}, chains={}, description={}, issuer={}, min_amount={}, offer={}, paths={}, signing_pubkey={})".format(self.absolute_expiry, self.chains, self.description, self.issuer, self.min_amount, self.offer, self.paths, self.signing_pubkey)
1966
-
1967
- def __eq__(self, other):
1968
- if self.absolute_expiry != other.absolute_expiry:
1969
- return False
1970
- if self.chains != other.chains:
1971
- return False
1972
- if self.description != other.description:
1973
- return False
1974
- if self.issuer != other.issuer:
1975
- return False
1976
- if self.min_amount != other.min_amount:
1977
- return False
1978
- if self.offer != other.offer:
1979
- return False
1980
- if self.paths != other.paths:
1981
- return False
1982
- if self.signing_pubkey != other.signing_pubkey:
1983
- return False
1984
- return True
1985
-
1986
- class _UniffiConverterTypeBolt12OfferDetails(_UniffiConverterRustBuffer):
1987
- @staticmethod
1988
- def read(buf):
1989
- return Bolt12OfferDetails(
1990
- absolute_expiry=_UniffiConverterOptionalUInt64.read(buf),
1991
- chains=_UniffiConverterSequenceString.read(buf),
1992
- description=_UniffiConverterOptionalString.read(buf),
1993
- issuer=_UniffiConverterOptionalString.read(buf),
1994
- min_amount=_UniffiConverterOptionalTypeAmount.read(buf),
1995
- offer=_UniffiConverterTypeBolt12Offer.read(buf),
1996
- paths=_UniffiConverterSequenceTypeBolt12OfferBlindedPath.read(buf),
1997
- signing_pubkey=_UniffiConverterOptionalString.read(buf),
1998
- )
1999
-
2000
- @staticmethod
2001
- def check_lower(value):
2002
- _UniffiConverterOptionalUInt64.check_lower(value.absolute_expiry)
2003
- _UniffiConverterSequenceString.check_lower(value.chains)
2004
- _UniffiConverterOptionalString.check_lower(value.description)
2005
- _UniffiConverterOptionalString.check_lower(value.issuer)
2006
- _UniffiConverterOptionalTypeAmount.check_lower(value.min_amount)
2007
- _UniffiConverterTypeBolt12Offer.check_lower(value.offer)
2008
- _UniffiConverterSequenceTypeBolt12OfferBlindedPath.check_lower(value.paths)
2009
- _UniffiConverterOptionalString.check_lower(value.signing_pubkey)
2010
-
2011
- @staticmethod
2012
- def write(value, buf):
2013
- _UniffiConverterOptionalUInt64.write(value.absolute_expiry, buf)
2014
- _UniffiConverterSequenceString.write(value.chains, buf)
2015
- _UniffiConverterOptionalString.write(value.description, buf)
2016
- _UniffiConverterOptionalString.write(value.issuer, buf)
2017
- _UniffiConverterOptionalTypeAmount.write(value.min_amount, buf)
2018
- _UniffiConverterTypeBolt12Offer.write(value.offer, buf)
2019
- _UniffiConverterSequenceTypeBolt12OfferBlindedPath.write(value.paths, buf)
2020
- _UniffiConverterOptionalString.write(value.signing_pubkey, buf)
2021
-
2022
-
2023
- class CurrencyInfo:
2024
- """
2025
- Details about a supported currency in the fiat rate feed
2026
- """
2027
-
2028
- name: "str"
2029
- fraction_size: "int"
2030
- spacing: "typing.Optional[int]"
2031
- symbol: "typing.Optional[Symbol]"
2032
- uniq_symbol: "typing.Optional[Symbol]"
2033
- localized_name: "typing.List[LocalizedName]"
2034
- locale_overrides: "typing.List[LocaleOverrides]"
2035
- def __init__(self, *, name: "str", fraction_size: "int", spacing: "typing.Optional[int]", symbol: "typing.Optional[Symbol]", uniq_symbol: "typing.Optional[Symbol]", localized_name: "typing.List[LocalizedName]", locale_overrides: "typing.List[LocaleOverrides]"):
2036
- self.name = name
2037
- self.fraction_size = fraction_size
2038
- self.spacing = spacing
2039
- self.symbol = symbol
2040
- self.uniq_symbol = uniq_symbol
2041
- self.localized_name = localized_name
2042
- self.locale_overrides = locale_overrides
2043
-
2044
- def __str__(self):
2045
- return "CurrencyInfo(name={}, fraction_size={}, spacing={}, symbol={}, uniq_symbol={}, localized_name={}, locale_overrides={})".format(self.name, self.fraction_size, self.spacing, self.symbol, self.uniq_symbol, self.localized_name, self.locale_overrides)
2046
-
2047
- def __eq__(self, other):
2048
- if self.name != other.name:
2049
- return False
2050
- if self.fraction_size != other.fraction_size:
2051
- return False
2052
- if self.spacing != other.spacing:
2053
- return False
2054
- if self.symbol != other.symbol:
2055
- return False
2056
- if self.uniq_symbol != other.uniq_symbol:
2057
- return False
2058
- if self.localized_name != other.localized_name:
2059
- return False
2060
- if self.locale_overrides != other.locale_overrides:
2061
- return False
2062
- return True
2063
-
2064
- class _UniffiConverterTypeCurrencyInfo(_UniffiConverterRustBuffer):
2065
- @staticmethod
2066
- def read(buf):
2067
- return CurrencyInfo(
2068
- name=_UniffiConverterString.read(buf),
2069
- fraction_size=_UniffiConverterUInt32.read(buf),
2070
- spacing=_UniffiConverterOptionalUInt32.read(buf),
2071
- symbol=_UniffiConverterOptionalTypeSymbol.read(buf),
2072
- uniq_symbol=_UniffiConverterOptionalTypeSymbol.read(buf),
2073
- localized_name=_UniffiConverterSequenceTypeLocalizedName.read(buf),
2074
- locale_overrides=_UniffiConverterSequenceTypeLocaleOverrides.read(buf),
2075
- )
2076
-
2077
- @staticmethod
2078
- def check_lower(value):
2079
- _UniffiConverterString.check_lower(value.name)
2080
- _UniffiConverterUInt32.check_lower(value.fraction_size)
2081
- _UniffiConverterOptionalUInt32.check_lower(value.spacing)
2082
- _UniffiConverterOptionalTypeSymbol.check_lower(value.symbol)
2083
- _UniffiConverterOptionalTypeSymbol.check_lower(value.uniq_symbol)
2084
- _UniffiConverterSequenceTypeLocalizedName.check_lower(value.localized_name)
2085
- _UniffiConverterSequenceTypeLocaleOverrides.check_lower(value.locale_overrides)
2086
-
2087
- @staticmethod
2088
- def write(value, buf):
2089
- _UniffiConverterString.write(value.name, buf)
2090
- _UniffiConverterUInt32.write(value.fraction_size, buf)
2091
- _UniffiConverterOptionalUInt32.write(value.spacing, buf)
2092
- _UniffiConverterOptionalTypeSymbol.write(value.symbol, buf)
2093
- _UniffiConverterOptionalTypeSymbol.write(value.uniq_symbol, buf)
2094
- _UniffiConverterSequenceTypeLocalizedName.write(value.localized_name, buf)
2095
- _UniffiConverterSequenceTypeLocaleOverrides.write(value.locale_overrides, buf)
2096
-
2097
-
2098
- class FiatCurrency:
2099
- """
2100
- Wrapper around the [`CurrencyInfo`] of a fiat currency
2101
- """
2102
-
2103
- id: "str"
2104
- info: "CurrencyInfo"
2105
- def __init__(self, *, id: "str", info: "CurrencyInfo"):
2106
- self.id = id
2107
- self.info = info
2108
-
2109
- def __str__(self):
2110
- return "FiatCurrency(id={}, info={})".format(self.id, self.info)
2111
-
2112
- def __eq__(self, other):
2113
- if self.id != other.id:
2114
- return False
2115
- if self.info != other.info:
2116
- return False
2117
- return True
2118
-
2119
- class _UniffiConverterTypeFiatCurrency(_UniffiConverterRustBuffer):
2120
- @staticmethod
2121
- def read(buf):
2122
- return FiatCurrency(
2123
- id=_UniffiConverterString.read(buf),
2124
- info=_UniffiConverterTypeCurrencyInfo.read(buf),
2125
- )
2126
-
2127
- @staticmethod
2128
- def check_lower(value):
2129
- _UniffiConverterString.check_lower(value.id)
2130
- _UniffiConverterTypeCurrencyInfo.check_lower(value.info)
2131
-
2132
- @staticmethod
2133
- def write(value, buf):
2134
- _UniffiConverterString.write(value.id, buf)
2135
- _UniffiConverterTypeCurrencyInfo.write(value.info, buf)
2136
-
2137
-
2138
- class LightningAddressDetails:
2139
- address: "str"
2140
- pay_request: "LnurlPayRequestDetails"
2141
- def __init__(self, *, address: "str", pay_request: "LnurlPayRequestDetails"):
2142
- self.address = address
2143
- self.pay_request = pay_request
2144
-
2145
- def __str__(self):
2146
- return "LightningAddressDetails(address={}, pay_request={})".format(self.address, self.pay_request)
2147
-
2148
- def __eq__(self, other):
2149
- if self.address != other.address:
2150
- return False
2151
- if self.pay_request != other.pay_request:
2152
- return False
2153
- return True
2154
-
2155
- class _UniffiConverterTypeLightningAddressDetails(_UniffiConverterRustBuffer):
2156
- @staticmethod
2157
- def read(buf):
2158
- return LightningAddressDetails(
2159
- address=_UniffiConverterString.read(buf),
2160
- pay_request=_UniffiConverterTypeLnurlPayRequestDetails.read(buf),
2161
- )
2162
-
2163
- @staticmethod
2164
- def check_lower(value):
2165
- _UniffiConverterString.check_lower(value.address)
2166
- _UniffiConverterTypeLnurlPayRequestDetails.check_lower(value.pay_request)
2167
-
2168
- @staticmethod
2169
- def write(value, buf):
2170
- _UniffiConverterString.write(value.address, buf)
2171
- _UniffiConverterTypeLnurlPayRequestDetails.write(value.pay_request, buf)
2172
-
2173
-
2174
- class LnurlAuthRequestDetails:
2175
- """
2176
- Wrapped in a [`LnurlAuth`], this is the result of [`parse`] when given a LNURL-auth endpoint.
2177
-
2178
- It represents the endpoint's parameters for the LNURL workflow.
2179
-
2180
- See <https://github.com/lnurl/luds/blob/luds/04.md>
2181
- """
2182
-
2183
- k1: "str"
2184
- """
2185
- Hex encoded 32 bytes of challenge
2186
- """
2187
-
2188
- action: "typing.Optional[str]"
2189
- """
2190
- When available, one of: register, login, link, auth
2191
- """
2192
-
2193
- domain: "str"
2194
- """
2195
- Indicates the domain of the LNURL-auth service, to be shown to the user when asking for
2196
- auth confirmation, as per LUD-04 spec.
2197
- """
2198
-
2199
- url: "str"
2200
- """
2201
- Indicates the URL of the LNURL-auth service, including the query arguments. This will be
2202
- extended with the signed challenge and the linking key, then called in the second step of the workflow.
2203
- """
2204
-
2205
- def __init__(self, *, k1: "str", action: "typing.Optional[str]", domain: "str", url: "str"):
2206
- self.k1 = k1
2207
- self.action = action
2208
- self.domain = domain
2209
- self.url = url
2210
-
2211
- def __str__(self):
2212
- return "LnurlAuthRequestDetails(k1={}, action={}, domain={}, url={})".format(self.k1, self.action, self.domain, self.url)
2213
-
2214
- def __eq__(self, other):
2215
- if self.k1 != other.k1:
2216
- return False
2217
- if self.action != other.action:
2218
- return False
2219
- if self.domain != other.domain:
2220
- return False
2221
- if self.url != other.url:
2222
- return False
2223
- return True
2224
-
2225
- class _UniffiConverterTypeLnurlAuthRequestDetails(_UniffiConverterRustBuffer):
2226
- @staticmethod
2227
- def read(buf):
2228
- return LnurlAuthRequestDetails(
2229
- k1=_UniffiConverterString.read(buf),
2230
- action=_UniffiConverterOptionalString.read(buf),
2231
- domain=_UniffiConverterString.read(buf),
2232
- url=_UniffiConverterString.read(buf),
2233
- )
2234
-
2235
- @staticmethod
2236
- def check_lower(value):
2237
- _UniffiConverterString.check_lower(value.k1)
2238
- _UniffiConverterOptionalString.check_lower(value.action)
2239
- _UniffiConverterString.check_lower(value.domain)
2240
- _UniffiConverterString.check_lower(value.url)
2241
-
2242
- @staticmethod
2243
- def write(value, buf):
2244
- _UniffiConverterString.write(value.k1, buf)
2245
- _UniffiConverterOptionalString.write(value.action, buf)
2246
- _UniffiConverterString.write(value.domain, buf)
2247
- _UniffiConverterString.write(value.url, buf)
2248
-
2249
-
2250
- class LnurlErrorDetails:
2251
- """
2252
- Wrapped in a [`LnUrlError`], this represents a LNURL-endpoint error.
2253
- """
2254
-
2255
- reason: "str"
2256
- def __init__(self, *, reason: "str"):
2257
- self.reason = reason
2258
-
2259
- def __str__(self):
2260
- return "LnurlErrorDetails(reason={})".format(self.reason)
2261
-
2262
- def __eq__(self, other):
2263
- if self.reason != other.reason:
2264
- return False
2265
- return True
2266
-
2267
- class _UniffiConverterTypeLnurlErrorDetails(_UniffiConverterRustBuffer):
2268
- @staticmethod
2269
- def read(buf):
2270
- return LnurlErrorDetails(
2271
- reason=_UniffiConverterString.read(buf),
2272
- )
2273
-
2274
- @staticmethod
2275
- def check_lower(value):
2276
- _UniffiConverterString.check_lower(value.reason)
2277
-
2278
- @staticmethod
2279
- def write(value, buf):
2280
- _UniffiConverterString.write(value.reason, buf)
2281
-
2282
-
2283
- class LnurlPayRequestDetails:
2284
- callback: "str"
2285
- min_sendable: "int"
2286
- """
2287
- The minimum amount, in millisats, that this LNURL-pay endpoint accepts
2288
- """
2289
-
2290
- max_sendable: "int"
2291
- """
2292
- The maximum amount, in millisats, that this LNURL-pay endpoint accepts
2293
- """
2294
-
2295
- metadata_str: "str"
2296
- """
2297
- As per LUD-06, `metadata` is a raw string (e.g. a json representation of the inner map).
2298
- Use `metadata_vec()` to get the parsed items.
2299
- """
2300
-
2301
- comment_allowed: "int"
2302
- """
2303
- The comment length accepted by this endpoint
2304
-
2305
- See <https://github.com/lnurl/luds/blob/luds/12.md>
2306
- """
2307
-
2308
- domain: "str"
2309
- """
2310
- Indicates the domain of the LNURL-pay service, to be shown to the user when asking for
2311
- payment input, as per LUD-06 spec.
2312
-
2313
- Note: this is not the domain of the callback, but the domain of the LNURL-pay endpoint.
2314
- """
2315
-
2316
- url: "str"
2317
- address: "typing.Optional[str]"
2318
- """
2319
- Optional lightning address if that was used to resolve the lnurl.
2320
- """
2321
-
2322
- allows_nostr: "bool"
2323
- """
2324
- Value indicating whether the recipient supports Nostr Zaps through NIP-57.
2325
-
2326
- See <https://github.com/nostr-protocol/nips/blob/master/57.md>
2327
- """
2328
-
2329
- nostr_pubkey: "typing.Optional[str]"
2330
- """
2331
- Optional recipient's lnurl provider's Nostr pubkey for NIP-57. If it exists it should be a
2332
- valid BIP 340 public key in hex.
2333
-
2334
- See <https://github.com/nostr-protocol/nips/blob/master/57.md>
2335
- See <https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki>
2336
- """
2337
-
2338
- def __init__(self, *, callback: "str", min_sendable: "int", max_sendable: "int", metadata_str: "str", comment_allowed: "int", domain: "str", url: "str", address: "typing.Optional[str]", allows_nostr: "bool", nostr_pubkey: "typing.Optional[str]"):
2339
- self.callback = callback
2340
- self.min_sendable = min_sendable
2341
- self.max_sendable = max_sendable
2342
- self.metadata_str = metadata_str
2343
- self.comment_allowed = comment_allowed
2344
- self.domain = domain
2345
- self.url = url
2346
- self.address = address
2347
- self.allows_nostr = allows_nostr
2348
- self.nostr_pubkey = nostr_pubkey
2349
-
2350
- def __str__(self):
2351
- return "LnurlPayRequestDetails(callback={}, min_sendable={}, max_sendable={}, metadata_str={}, comment_allowed={}, domain={}, url={}, address={}, allows_nostr={}, nostr_pubkey={})".format(self.callback, self.min_sendable, self.max_sendable, self.metadata_str, self.comment_allowed, self.domain, self.url, self.address, self.allows_nostr, self.nostr_pubkey)
2352
-
2353
- def __eq__(self, other):
2354
- if self.callback != other.callback:
2355
- return False
2356
- if self.min_sendable != other.min_sendable:
2357
- return False
2358
- if self.max_sendable != other.max_sendable:
2359
- return False
2360
- if self.metadata_str != other.metadata_str:
2361
- return False
2362
- if self.comment_allowed != other.comment_allowed:
2363
- return False
2364
- if self.domain != other.domain:
2365
- return False
2366
- if self.url != other.url:
2367
- return False
2368
- if self.address != other.address:
2369
- return False
2370
- if self.allows_nostr != other.allows_nostr:
2371
- return False
2372
- if self.nostr_pubkey != other.nostr_pubkey:
2373
- return False
2374
- return True
2375
-
2376
- class _UniffiConverterTypeLnurlPayRequestDetails(_UniffiConverterRustBuffer):
2377
- @staticmethod
2378
- def read(buf):
2379
- return LnurlPayRequestDetails(
2380
- callback=_UniffiConverterString.read(buf),
2381
- min_sendable=_UniffiConverterUInt64.read(buf),
2382
- max_sendable=_UniffiConverterUInt64.read(buf),
2383
- metadata_str=_UniffiConverterString.read(buf),
2384
- comment_allowed=_UniffiConverterUInt16.read(buf),
2385
- domain=_UniffiConverterString.read(buf),
2386
- url=_UniffiConverterString.read(buf),
2387
- address=_UniffiConverterOptionalString.read(buf),
2388
- allows_nostr=_UniffiConverterBool.read(buf),
2389
- nostr_pubkey=_UniffiConverterOptionalString.read(buf),
2390
- )
2391
-
2392
- @staticmethod
2393
- def check_lower(value):
2394
- _UniffiConverterString.check_lower(value.callback)
2395
- _UniffiConverterUInt64.check_lower(value.min_sendable)
2396
- _UniffiConverterUInt64.check_lower(value.max_sendable)
2397
- _UniffiConverterString.check_lower(value.metadata_str)
2398
- _UniffiConverterUInt16.check_lower(value.comment_allowed)
2399
- _UniffiConverterString.check_lower(value.domain)
2400
- _UniffiConverterString.check_lower(value.url)
2401
- _UniffiConverterOptionalString.check_lower(value.address)
2402
- _UniffiConverterBool.check_lower(value.allows_nostr)
2403
- _UniffiConverterOptionalString.check_lower(value.nostr_pubkey)
2404
-
2405
- @staticmethod
2406
- def write(value, buf):
2407
- _UniffiConverterString.write(value.callback, buf)
2408
- _UniffiConverterUInt64.write(value.min_sendable, buf)
2409
- _UniffiConverterUInt64.write(value.max_sendable, buf)
2410
- _UniffiConverterString.write(value.metadata_str, buf)
2411
- _UniffiConverterUInt16.write(value.comment_allowed, buf)
2412
- _UniffiConverterString.write(value.domain, buf)
2413
- _UniffiConverterString.write(value.url, buf)
2414
- _UniffiConverterOptionalString.write(value.address, buf)
2415
- _UniffiConverterBool.write(value.allows_nostr, buf)
2416
- _UniffiConverterOptionalString.write(value.nostr_pubkey, buf)
2417
-
2418
-
2419
- class LnurlWithdrawRequestDetails:
2420
- callback: "str"
2421
- k1: "str"
2422
- default_description: "str"
2423
- min_withdrawable: "int"
2424
- """
2425
- The minimum amount, in millisats, that this LNURL-withdraw endpoint accepts
2426
- """
2427
-
2428
- max_withdrawable: "int"
2429
- """
2430
- The maximum amount, in millisats, that this LNURL-withdraw endpoint accepts
2431
- """
2432
-
2433
- def __init__(self, *, callback: "str", k1: "str", default_description: "str", min_withdrawable: "int", max_withdrawable: "int"):
2434
- self.callback = callback
2435
- self.k1 = k1
2436
- self.default_description = default_description
2437
- self.min_withdrawable = min_withdrawable
2438
- self.max_withdrawable = max_withdrawable
2439
-
2440
- def __str__(self):
2441
- return "LnurlWithdrawRequestDetails(callback={}, k1={}, default_description={}, min_withdrawable={}, max_withdrawable={})".format(self.callback, self.k1, self.default_description, self.min_withdrawable, self.max_withdrawable)
2442
-
2443
- def __eq__(self, other):
2444
- if self.callback != other.callback:
2445
- return False
2446
- if self.k1 != other.k1:
2447
- return False
2448
- if self.default_description != other.default_description:
2449
- return False
2450
- if self.min_withdrawable != other.min_withdrawable:
2451
- return False
2452
- if self.max_withdrawable != other.max_withdrawable:
2453
- return False
2454
- return True
2455
-
2456
- class _UniffiConverterTypeLnurlWithdrawRequestDetails(_UniffiConverterRustBuffer):
2457
- @staticmethod
2458
- def read(buf):
2459
- return LnurlWithdrawRequestDetails(
2460
- callback=_UniffiConverterString.read(buf),
2461
- k1=_UniffiConverterString.read(buf),
2462
- default_description=_UniffiConverterString.read(buf),
2463
- min_withdrawable=_UniffiConverterUInt64.read(buf),
2464
- max_withdrawable=_UniffiConverterUInt64.read(buf),
2465
- )
2466
-
2467
- @staticmethod
2468
- def check_lower(value):
2469
- _UniffiConverterString.check_lower(value.callback)
2470
- _UniffiConverterString.check_lower(value.k1)
2471
- _UniffiConverterString.check_lower(value.default_description)
2472
- _UniffiConverterUInt64.check_lower(value.min_withdrawable)
2473
- _UniffiConverterUInt64.check_lower(value.max_withdrawable)
2474
-
2475
- @staticmethod
2476
- def write(value, buf):
2477
- _UniffiConverterString.write(value.callback, buf)
2478
- _UniffiConverterString.write(value.k1, buf)
2479
- _UniffiConverterString.write(value.default_description, buf)
2480
- _UniffiConverterUInt64.write(value.min_withdrawable, buf)
2481
- _UniffiConverterUInt64.write(value.max_withdrawable, buf)
2482
-
2483
-
2484
- class LocaleOverrides:
2485
- """
2486
- Locale-specific settings for the representation of a currency
2487
- """
2488
-
2489
- locale: "str"
2490
- spacing: "typing.Optional[int]"
2491
- symbol: "Symbol"
2492
- def __init__(self, *, locale: "str", spacing: "typing.Optional[int]", symbol: "Symbol"):
2493
- self.locale = locale
2494
- self.spacing = spacing
2495
- self.symbol = symbol
2496
-
2497
- def __str__(self):
2498
- return "LocaleOverrides(locale={}, spacing={}, symbol={})".format(self.locale, self.spacing, self.symbol)
2499
-
2500
- def __eq__(self, other):
2501
- if self.locale != other.locale:
2502
- return False
2503
- if self.spacing != other.spacing:
2504
- return False
2505
- if self.symbol != other.symbol:
2506
- return False
2507
- return True
2508
-
2509
- class _UniffiConverterTypeLocaleOverrides(_UniffiConverterRustBuffer):
2510
- @staticmethod
2511
- def read(buf):
2512
- return LocaleOverrides(
2513
- locale=_UniffiConverterString.read(buf),
2514
- spacing=_UniffiConverterOptionalUInt32.read(buf),
2515
- symbol=_UniffiConverterTypeSymbol.read(buf),
2516
- )
2517
-
2518
- @staticmethod
2519
- def check_lower(value):
2520
- _UniffiConverterString.check_lower(value.locale)
2521
- _UniffiConverterOptionalUInt32.check_lower(value.spacing)
2522
- _UniffiConverterTypeSymbol.check_lower(value.symbol)
2523
-
2524
- @staticmethod
2525
- def write(value, buf):
2526
- _UniffiConverterString.write(value.locale, buf)
2527
- _UniffiConverterOptionalUInt32.write(value.spacing, buf)
2528
- _UniffiConverterTypeSymbol.write(value.symbol, buf)
2529
-
2530
-
2531
- class LocalizedName:
2532
- """
2533
- Localized name of a currency
2534
- """
2535
-
2536
- locale: "str"
2537
- name: "str"
2538
- def __init__(self, *, locale: "str", name: "str"):
2539
- self.locale = locale
2540
- self.name = name
2541
-
2542
- def __str__(self):
2543
- return "LocalizedName(locale={}, name={})".format(self.locale, self.name)
2544
-
2545
- def __eq__(self, other):
2546
- if self.locale != other.locale:
2547
- return False
2548
- if self.name != other.name:
2549
- return False
2550
- return True
2551
-
2552
- class _UniffiConverterTypeLocalizedName(_UniffiConverterRustBuffer):
2553
- @staticmethod
2554
- def read(buf):
2555
- return LocalizedName(
2556
- locale=_UniffiConverterString.read(buf),
2557
- name=_UniffiConverterString.read(buf),
2558
- )
2559
-
2560
- @staticmethod
2561
- def check_lower(value):
2562
- _UniffiConverterString.check_lower(value.locale)
2563
- _UniffiConverterString.check_lower(value.name)
2564
-
2565
- @staticmethod
2566
- def write(value, buf):
2567
- _UniffiConverterString.write(value.locale, buf)
2568
- _UniffiConverterString.write(value.name, buf)
2569
-
2570
-
2571
- class MessageSuccessActionData:
2572
- message: "str"
2573
- def __init__(self, *, message: "str"):
2574
- self.message = message
2575
-
2576
- def __str__(self):
2577
- return "MessageSuccessActionData(message={})".format(self.message)
2578
-
2579
- def __eq__(self, other):
2580
- if self.message != other.message:
2581
- return False
2582
- return True
2583
-
2584
- class _UniffiConverterTypeMessageSuccessActionData(_UniffiConverterRustBuffer):
2585
- @staticmethod
2586
- def read(buf):
2587
- return MessageSuccessActionData(
2588
- message=_UniffiConverterString.read(buf),
2589
- )
2590
-
2591
- @staticmethod
2592
- def check_lower(value):
2593
- _UniffiConverterString.check_lower(value.message)
2594
-
2595
- @staticmethod
2596
- def write(value, buf):
2597
- _UniffiConverterString.write(value.message, buf)
2598
-
2599
-
2600
- class PaymentRequestSource:
2601
- bip_21_uri: "typing.Optional[str]"
2602
- bip_353_address: "typing.Optional[str]"
2603
- def __init__(self, *, bip_21_uri: "typing.Optional[str]", bip_353_address: "typing.Optional[str]"):
2604
- self.bip_21_uri = bip_21_uri
2605
- self.bip_353_address = bip_353_address
2606
-
2607
- def __str__(self):
2608
- return "PaymentRequestSource(bip_21_uri={}, bip_353_address={})".format(self.bip_21_uri, self.bip_353_address)
2609
-
2610
- def __eq__(self, other):
2611
- if self.bip_21_uri != other.bip_21_uri:
2612
- return False
2613
- if self.bip_353_address != other.bip_353_address:
2614
- return False
2615
- return True
2616
-
2617
- class _UniffiConverterTypePaymentRequestSource(_UniffiConverterRustBuffer):
2618
- @staticmethod
2619
- def read(buf):
2620
- return PaymentRequestSource(
2621
- bip_21_uri=_UniffiConverterOptionalString.read(buf),
2622
- bip_353_address=_UniffiConverterOptionalString.read(buf),
2623
- )
2624
-
2625
- @staticmethod
2626
- def check_lower(value):
2627
- _UniffiConverterOptionalString.check_lower(value.bip_21_uri)
2628
- _UniffiConverterOptionalString.check_lower(value.bip_353_address)
2629
-
2630
- @staticmethod
2631
- def write(value, buf):
2632
- _UniffiConverterOptionalString.write(value.bip_21_uri, buf)
2633
- _UniffiConverterOptionalString.write(value.bip_353_address, buf)
2634
-
2635
-
2636
- class Rate:
2637
- """
2638
- Denominator in an exchange rate
2639
- """
2640
-
2641
- coin: "str"
2642
- value: "float"
2643
- def __init__(self, *, coin: "str", value: "float"):
2644
- self.coin = coin
2645
- self.value = value
2646
-
2647
- def __str__(self):
2648
- return "Rate(coin={}, value={})".format(self.coin, self.value)
2649
-
2650
- def __eq__(self, other):
2651
- if self.coin != other.coin:
2652
- return False
2653
- if self.value != other.value:
2654
- return False
2655
- return True
2656
-
2657
- class _UniffiConverterTypeRate(_UniffiConverterRustBuffer):
2658
- @staticmethod
2659
- def read(buf):
2660
- return Rate(
2661
- coin=_UniffiConverterString.read(buf),
2662
- value=_UniffiConverterDouble.read(buf),
2663
- )
2664
-
2665
- @staticmethod
2666
- def check_lower(value):
2667
- _UniffiConverterString.check_lower(value.coin)
2668
- _UniffiConverterDouble.check_lower(value.value)
2669
-
2670
- @staticmethod
2671
- def write(value, buf):
2672
- _UniffiConverterString.write(value.coin, buf)
2673
- _UniffiConverterDouble.write(value.value, buf)
2674
-
2675
-
2676
- class RestResponse:
2677
- status: "int"
2678
- body: "str"
2679
- def __init__(self, *, status: "int", body: "str"):
2680
- self.status = status
2681
- self.body = body
2682
-
2683
- def __str__(self):
2684
- return "RestResponse(status={}, body={})".format(self.status, self.body)
2685
-
2686
- def __eq__(self, other):
2687
- if self.status != other.status:
2688
- return False
2689
- if self.body != other.body:
2690
- return False
2691
- return True
2692
-
2693
- class _UniffiConverterTypeRestResponse(_UniffiConverterRustBuffer):
2694
- @staticmethod
2695
- def read(buf):
2696
- return RestResponse(
2697
- status=_UniffiConverterUInt16.read(buf),
2698
- body=_UniffiConverterString.read(buf),
2699
- )
2700
-
2701
- @staticmethod
2702
- def check_lower(value):
2703
- _UniffiConverterUInt16.check_lower(value.status)
2704
- _UniffiConverterString.check_lower(value.body)
2705
-
2706
- @staticmethod
2707
- def write(value, buf):
2708
- _UniffiConverterUInt16.write(value.status, buf)
2709
- _UniffiConverterString.write(value.body, buf)
2710
-
2711
-
2712
- class SilentPaymentAddressDetails:
2713
- address: "str"
2714
- network: "BitcoinNetwork"
2715
- source: "PaymentRequestSource"
2716
- def __init__(self, *, address: "str", network: "BitcoinNetwork", source: "PaymentRequestSource"):
2717
- self.address = address
2718
- self.network = network
2719
- self.source = source
2720
-
2721
- def __str__(self):
2722
- return "SilentPaymentAddressDetails(address={}, network={}, source={})".format(self.address, self.network, self.source)
2723
-
2724
- def __eq__(self, other):
2725
- if self.address != other.address:
2726
- return False
2727
- if self.network != other.network:
2728
- return False
2729
- if self.source != other.source:
2730
- return False
2731
- return True
2732
-
2733
- class _UniffiConverterTypeSilentPaymentAddressDetails(_UniffiConverterRustBuffer):
2734
- @staticmethod
2735
- def read(buf):
2736
- return SilentPaymentAddressDetails(
2737
- address=_UniffiConverterString.read(buf),
2738
- network=_UniffiConverterTypeBitcoinNetwork.read(buf),
2739
- source=_UniffiConverterTypePaymentRequestSource.read(buf),
2740
- )
2741
-
2742
- @staticmethod
2743
- def check_lower(value):
2744
- _UniffiConverterString.check_lower(value.address)
2745
- _UniffiConverterTypeBitcoinNetwork.check_lower(value.network)
2746
- _UniffiConverterTypePaymentRequestSource.check_lower(value.source)
2747
-
2748
- @staticmethod
2749
- def write(value, buf):
2750
- _UniffiConverterString.write(value.address, buf)
2751
- _UniffiConverterTypeBitcoinNetwork.write(value.network, buf)
2752
- _UniffiConverterTypePaymentRequestSource.write(value.source, buf)
2753
-
2754
-
2755
- class Symbol:
2756
- """
2757
- Settings for the symbol representation of a currency
2758
- """
2759
-
2760
- grapheme: "typing.Optional[str]"
2761
- template: "typing.Optional[str]"
2762
- rtl: "typing.Optional[bool]"
2763
- position: "typing.Optional[int]"
2764
- def __init__(self, *, grapheme: "typing.Optional[str]", template: "typing.Optional[str]", rtl: "typing.Optional[bool]", position: "typing.Optional[int]"):
2765
- self.grapheme = grapheme
2766
- self.template = template
2767
- self.rtl = rtl
2768
- self.position = position
2769
-
2770
- def __str__(self):
2771
- return "Symbol(grapheme={}, template={}, rtl={}, position={})".format(self.grapheme, self.template, self.rtl, self.position)
2772
-
2773
- def __eq__(self, other):
2774
- if self.grapheme != other.grapheme:
2775
- return False
2776
- if self.template != other.template:
2777
- return False
2778
- if self.rtl != other.rtl:
2779
- return False
2780
- if self.position != other.position:
2781
- return False
2782
- return True
2783
-
2784
- class _UniffiConverterTypeSymbol(_UniffiConverterRustBuffer):
2785
- @staticmethod
2786
- def read(buf):
2787
- return Symbol(
2788
- grapheme=_UniffiConverterOptionalString.read(buf),
2789
- template=_UniffiConverterOptionalString.read(buf),
2790
- rtl=_UniffiConverterOptionalBool.read(buf),
2791
- position=_UniffiConverterOptionalUInt32.read(buf),
2792
- )
2793
-
2794
- @staticmethod
2795
- def check_lower(value):
2796
- _UniffiConverterOptionalString.check_lower(value.grapheme)
2797
- _UniffiConverterOptionalString.check_lower(value.template)
2798
- _UniffiConverterOptionalBool.check_lower(value.rtl)
2799
- _UniffiConverterOptionalUInt32.check_lower(value.position)
2800
-
2801
- @staticmethod
2802
- def write(value, buf):
2803
- _UniffiConverterOptionalString.write(value.grapheme, buf)
2804
- _UniffiConverterOptionalString.write(value.template, buf)
2805
- _UniffiConverterOptionalBool.write(value.rtl, buf)
2806
- _UniffiConverterOptionalUInt32.write(value.position, buf)
2807
-
2808
-
2809
- class UrlSuccessActionData:
2810
- description: "str"
2811
- """
2812
- Contents description, up to 144 characters
2813
- """
2814
-
2815
- url: "str"
2816
- """
2817
- URL of the success action
2818
- """
2819
-
2820
- matches_callback_domain: "bool"
2821
- """
2822
- Indicates the success URL domain matches the LNURL callback domain.
2823
-
2824
- See <https://github.com/lnurl/luds/blob/luds/09.md>
2825
- """
2826
-
2827
- def __init__(self, *, description: "str", url: "str", matches_callback_domain: "bool"):
2828
- self.description = description
2829
- self.url = url
2830
- self.matches_callback_domain = matches_callback_domain
2831
-
2832
- def __str__(self):
2833
- return "UrlSuccessActionData(description={}, url={}, matches_callback_domain={})".format(self.description, self.url, self.matches_callback_domain)
2834
-
2835
- def __eq__(self, other):
2836
- if self.description != other.description:
2837
- return False
2838
- if self.url != other.url:
2839
- return False
2840
- if self.matches_callback_domain != other.matches_callback_domain:
2841
- return False
2842
- return True
2843
-
2844
- class _UniffiConverterTypeUrlSuccessActionData(_UniffiConverterRustBuffer):
2845
- @staticmethod
2846
- def read(buf):
2847
- return UrlSuccessActionData(
2848
- description=_UniffiConverterString.read(buf),
2849
- url=_UniffiConverterString.read(buf),
2850
- matches_callback_domain=_UniffiConverterBool.read(buf),
2851
- )
2852
-
2853
- @staticmethod
2854
- def check_lower(value):
2855
- _UniffiConverterString.check_lower(value.description)
2856
- _UniffiConverterString.check_lower(value.url)
2857
- _UniffiConverterBool.check_lower(value.matches_callback_domain)
2858
-
2859
- @staticmethod
2860
- def write(value, buf):
2861
- _UniffiConverterString.write(value.description, buf)
2862
- _UniffiConverterString.write(value.url, buf)
2863
- _UniffiConverterBool.write(value.matches_callback_domain, buf)
2864
-
2865
-
2866
-
2867
-
2868
-
2869
- class AesSuccessActionDataResult:
2870
- """
2871
- Result of decryption of [`AesSuccessActionData`] payload
2872
- """
2873
-
2874
- def __init__(self):
2875
- raise RuntimeError("AesSuccessActionDataResult cannot be instantiated directly")
2876
-
2877
- # Each enum variant is a nested class of the enum itself.
2878
- class DECRYPTED:
2879
- data: "AesSuccessActionDataDecrypted"
2880
-
2881
- def __init__(self,data: "AesSuccessActionDataDecrypted"):
2882
- self.data = data
2883
-
2884
- def __str__(self):
2885
- return "AesSuccessActionDataResult.DECRYPTED(data={})".format(self.data)
2886
-
2887
- def __eq__(self, other):
2888
- if not other.is_decrypted():
2889
- return False
2890
- if self.data != other.data:
2891
- return False
2892
- return True
2893
-
2894
- class ERROR_STATUS:
2895
- reason: "str"
2896
-
2897
- def __init__(self,reason: "str"):
2898
- self.reason = reason
2899
-
2900
- def __str__(self):
2901
- return "AesSuccessActionDataResult.ERROR_STATUS(reason={})".format(self.reason)
2902
-
2903
- def __eq__(self, other):
2904
- if not other.is_error_status():
2905
- return False
2906
- if self.reason != other.reason:
2907
- return False
2908
- return True
2909
-
2910
-
2911
-
2912
- # For each variant, we have an `is_NAME` method for easily checking
2913
- # whether an instance is that variant.
2914
- def is_decrypted(self) -> bool:
2915
- return isinstance(self, AesSuccessActionDataResult.DECRYPTED)
2916
- def is_error_status(self) -> bool:
2917
- return isinstance(self, AesSuccessActionDataResult.ERROR_STATUS)
2918
-
2919
-
2920
- # Now, a little trick - we make each nested variant class be a subclass of the main
2921
- # enum class, so that method calls and instance checks etc will work intuitively.
2922
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
2923
- AesSuccessActionDataResult.DECRYPTED = type("AesSuccessActionDataResult.DECRYPTED", (AesSuccessActionDataResult.DECRYPTED, AesSuccessActionDataResult,), {}) # type: ignore
2924
- AesSuccessActionDataResult.ERROR_STATUS = type("AesSuccessActionDataResult.ERROR_STATUS", (AesSuccessActionDataResult.ERROR_STATUS, AesSuccessActionDataResult,), {}) # type: ignore
2925
-
2926
-
2927
-
2928
-
2929
- class _UniffiConverterTypeAesSuccessActionDataResult(_UniffiConverterRustBuffer):
2930
- @staticmethod
2931
- def read(buf):
2932
- variant = buf.read_i32()
2933
- if variant == 1:
2934
- return AesSuccessActionDataResult.DECRYPTED(
2935
- _UniffiConverterTypeAesSuccessActionDataDecrypted.read(buf),
2936
- )
2937
- if variant == 2:
2938
- return AesSuccessActionDataResult.ERROR_STATUS(
2939
- _UniffiConverterString.read(buf),
2940
- )
2941
- raise InternalError("Raw enum value doesn't match any cases")
2942
-
2943
- @staticmethod
2944
- def check_lower(value):
2945
- if value.is_decrypted():
2946
- _UniffiConverterTypeAesSuccessActionDataDecrypted.check_lower(value.data)
2947
- return
2948
- if value.is_error_status():
2949
- _UniffiConverterString.check_lower(value.reason)
2950
- return
2951
- raise ValueError(value)
2952
-
2953
- @staticmethod
2954
- def write(value, buf):
2955
- if value.is_decrypted():
2956
- buf.write_i32(1)
2957
- _UniffiConverterTypeAesSuccessActionDataDecrypted.write(value.data, buf)
2958
- if value.is_error_status():
2959
- buf.write_i32(2)
2960
- _UniffiConverterString.write(value.reason, buf)
2961
-
2962
-
2963
-
2964
-
2965
-
2966
-
2967
-
2968
- class Amount:
2969
- def __init__(self):
2970
- raise RuntimeError("Amount cannot be instantiated directly")
2971
-
2972
- # Each enum variant is a nested class of the enum itself.
2973
- class BITCOIN:
2974
- amount_msat: "int"
2975
-
2976
- def __init__(self,amount_msat: "int"):
2977
- self.amount_msat = amount_msat
2978
-
2979
- def __str__(self):
2980
- return "Amount.BITCOIN(amount_msat={})".format(self.amount_msat)
2981
-
2982
- def __eq__(self, other):
2983
- if not other.is_bitcoin():
2984
- return False
2985
- if self.amount_msat != other.amount_msat:
2986
- return False
2987
- return True
2988
-
2989
- class CURRENCY:
2990
- """
2991
- An amount of currency specified using ISO 4712.
2992
- """
2993
-
2994
- iso4217_code: "str"
2995
- """
2996
- The currency that the amount is denominated in.
2997
- """
2998
-
2999
- fractional_amount: "int"
3000
- """
3001
- The amount in the currency unit adjusted by the ISO 4712 exponent (e.g., USD cents).
3002
- """
3003
-
3004
-
3005
- def __init__(self,iso4217_code: "str", fractional_amount: "int"):
3006
- self.iso4217_code = iso4217_code
3007
- self.fractional_amount = fractional_amount
3008
-
3009
- def __str__(self):
3010
- return "Amount.CURRENCY(iso4217_code={}, fractional_amount={})".format(self.iso4217_code, self.fractional_amount)
3011
-
3012
- def __eq__(self, other):
3013
- if not other.is_currency():
3014
- return False
3015
- if self.iso4217_code != other.iso4217_code:
3016
- return False
3017
- if self.fractional_amount != other.fractional_amount:
3018
- return False
3019
- return True
3020
-
3021
-
3022
-
3023
- # For each variant, we have an `is_NAME` method for easily checking
3024
- # whether an instance is that variant.
3025
- def is_bitcoin(self) -> bool:
3026
- return isinstance(self, Amount.BITCOIN)
3027
- def is_currency(self) -> bool:
3028
- return isinstance(self, Amount.CURRENCY)
3029
-
3030
-
3031
- # Now, a little trick - we make each nested variant class be a subclass of the main
3032
- # enum class, so that method calls and instance checks etc will work intuitively.
3033
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
3034
- Amount.BITCOIN = type("Amount.BITCOIN", (Amount.BITCOIN, Amount,), {}) # type: ignore
3035
- Amount.CURRENCY = type("Amount.CURRENCY", (Amount.CURRENCY, Amount,), {}) # type: ignore
3036
-
3037
-
3038
-
3039
-
3040
- class _UniffiConverterTypeAmount(_UniffiConverterRustBuffer):
3041
- @staticmethod
3042
- def read(buf):
3043
- variant = buf.read_i32()
3044
- if variant == 1:
3045
- return Amount.BITCOIN(
3046
- _UniffiConverterUInt64.read(buf),
3047
- )
3048
- if variant == 2:
3049
- return Amount.CURRENCY(
3050
- _UniffiConverterString.read(buf),
3051
- _UniffiConverterUInt64.read(buf),
3052
- )
3053
- raise InternalError("Raw enum value doesn't match any cases")
3054
-
3055
- @staticmethod
3056
- def check_lower(value):
3057
- if value.is_bitcoin():
3058
- _UniffiConverterUInt64.check_lower(value.amount_msat)
3059
- return
3060
- if value.is_currency():
3061
- _UniffiConverterString.check_lower(value.iso4217_code)
3062
- _UniffiConverterUInt64.check_lower(value.fractional_amount)
3063
- return
3064
- raise ValueError(value)
3065
-
3066
- @staticmethod
3067
- def write(value, buf):
3068
- if value.is_bitcoin():
3069
- buf.write_i32(1)
3070
- _UniffiConverterUInt64.write(value.amount_msat, buf)
3071
- if value.is_currency():
3072
- buf.write_i32(2)
3073
- _UniffiConverterString.write(value.iso4217_code, buf)
3074
- _UniffiConverterUInt64.write(value.fractional_amount, buf)
3075
-
3076
-
3077
-
3078
-
3079
-
3080
-
3081
-
3082
- class BitcoinNetwork(enum.Enum):
3083
- BITCOIN = 0
3084
- """
3085
- Mainnet
3086
- """
3087
-
3088
-
3089
- TESTNET3 = 1
3090
-
3091
- TESTNET4 = 2
3092
-
3093
- SIGNET = 3
3094
-
3095
- REGTEST = 4
3096
-
3097
-
3098
-
3099
- class _UniffiConverterTypeBitcoinNetwork(_UniffiConverterRustBuffer):
3100
- @staticmethod
3101
- def read(buf):
3102
- variant = buf.read_i32()
3103
- if variant == 1:
3104
- return BitcoinNetwork.BITCOIN
3105
- if variant == 2:
3106
- return BitcoinNetwork.TESTNET3
3107
- if variant == 3:
3108
- return BitcoinNetwork.TESTNET4
3109
- if variant == 4:
3110
- return BitcoinNetwork.SIGNET
3111
- if variant == 5:
3112
- return BitcoinNetwork.REGTEST
3113
- raise InternalError("Raw enum value doesn't match any cases")
3114
-
3115
- @staticmethod
3116
- def check_lower(value):
3117
- if value == BitcoinNetwork.BITCOIN:
3118
- return
3119
- if value == BitcoinNetwork.TESTNET3:
3120
- return
3121
- if value == BitcoinNetwork.TESTNET4:
3122
- return
3123
- if value == BitcoinNetwork.SIGNET:
3124
- return
3125
- if value == BitcoinNetwork.REGTEST:
3126
- return
3127
- raise ValueError(value)
3128
-
3129
- @staticmethod
3130
- def write(value, buf):
3131
- if value == BitcoinNetwork.BITCOIN:
3132
- buf.write_i32(1)
3133
- if value == BitcoinNetwork.TESTNET3:
3134
- buf.write_i32(2)
3135
- if value == BitcoinNetwork.TESTNET4:
3136
- buf.write_i32(3)
3137
- if value == BitcoinNetwork.SIGNET:
3138
- buf.write_i32(4)
3139
- if value == BitcoinNetwork.REGTEST:
3140
- buf.write_i32(5)
3141
-
3142
-
3143
-
3144
-
3145
-
3146
-
3147
-
3148
- class InputType:
3149
- def __init__(self):
3150
- raise RuntimeError("InputType cannot be instantiated directly")
3151
-
3152
- # Each enum variant is a nested class of the enum itself.
3153
- class BITCOIN_ADDRESS:
3154
- def __init__(self, *values):
3155
- if len(values) != 1:
3156
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3157
- if not isinstance(values[0], BitcoinAddressDetails):
3158
- raise TypeError(f"unexpected type for tuple element 0 - expected 'BitcoinAddressDetails', got '{type(values[0])}'")
3159
- self._values = values
3160
-
3161
- def __getitem__(self, index):
3162
- return self._values[index]
3163
-
3164
- def __str__(self):
3165
- return f"InputType.BITCOIN_ADDRESS{self._values!r}"
3166
-
3167
- def __eq__(self, other):
3168
- if not other.is_bitcoin_address():
3169
- return False
3170
- return self._values == other._values
3171
- class BOLT11_INVOICE:
3172
- def __init__(self, *values):
3173
- if len(values) != 1:
3174
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3175
- if not isinstance(values[0], Bolt11InvoiceDetails):
3176
- raise TypeError(f"unexpected type for tuple element 0 - expected 'Bolt11InvoiceDetails', got '{type(values[0])}'")
3177
- self._values = values
3178
-
3179
- def __getitem__(self, index):
3180
- return self._values[index]
3181
-
3182
- def __str__(self):
3183
- return f"InputType.BOLT11_INVOICE{self._values!r}"
3184
-
3185
- def __eq__(self, other):
3186
- if not other.is_bolt11_invoice():
3187
- return False
3188
- return self._values == other._values
3189
- class BOLT12_INVOICE:
3190
- def __init__(self, *values):
3191
- if len(values) != 1:
3192
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3193
- if not isinstance(values[0], Bolt12InvoiceDetails):
3194
- raise TypeError(f"unexpected type for tuple element 0 - expected 'Bolt12InvoiceDetails', got '{type(values[0])}'")
3195
- self._values = values
3196
-
3197
- def __getitem__(self, index):
3198
- return self._values[index]
3199
-
3200
- def __str__(self):
3201
- return f"InputType.BOLT12_INVOICE{self._values!r}"
3202
-
3203
- def __eq__(self, other):
3204
- if not other.is_bolt12_invoice():
3205
- return False
3206
- return self._values == other._values
3207
- class BOLT12_OFFER:
3208
- def __init__(self, *values):
3209
- if len(values) != 1:
3210
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3211
- if not isinstance(values[0], Bolt12OfferDetails):
3212
- raise TypeError(f"unexpected type for tuple element 0 - expected 'Bolt12OfferDetails', got '{type(values[0])}'")
3213
- self._values = values
3214
-
3215
- def __getitem__(self, index):
3216
- return self._values[index]
3217
-
3218
- def __str__(self):
3219
- return f"InputType.BOLT12_OFFER{self._values!r}"
3220
-
3221
- def __eq__(self, other):
3222
- if not other.is_bolt12_offer():
3223
- return False
3224
- return self._values == other._values
3225
- class LIGHTNING_ADDRESS:
3226
- def __init__(self, *values):
3227
- if len(values) != 1:
3228
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3229
- if not isinstance(values[0], LightningAddressDetails):
3230
- raise TypeError(f"unexpected type for tuple element 0 - expected 'LightningAddressDetails', got '{type(values[0])}'")
3231
- self._values = values
3232
-
3233
- def __getitem__(self, index):
3234
- return self._values[index]
3235
-
3236
- def __str__(self):
3237
- return f"InputType.LIGHTNING_ADDRESS{self._values!r}"
3238
-
3239
- def __eq__(self, other):
3240
- if not other.is_lightning_address():
3241
- return False
3242
- return self._values == other._values
3243
- class LNURL_PAY:
3244
- def __init__(self, *values):
3245
- if len(values) != 1:
3246
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3247
- if not isinstance(values[0], LnurlPayRequestDetails):
3248
- raise TypeError(f"unexpected type for tuple element 0 - expected 'LnurlPayRequestDetails', got '{type(values[0])}'")
3249
- self._values = values
3250
-
3251
- def __getitem__(self, index):
3252
- return self._values[index]
3253
-
3254
- def __str__(self):
3255
- return f"InputType.LNURL_PAY{self._values!r}"
3256
-
3257
- def __eq__(self, other):
3258
- if not other.is_lnurl_pay():
3259
- return False
3260
- return self._values == other._values
3261
- class SILENT_PAYMENT_ADDRESS:
3262
- def __init__(self, *values):
3263
- if len(values) != 1:
3264
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3265
- if not isinstance(values[0], SilentPaymentAddressDetails):
3266
- raise TypeError(f"unexpected type for tuple element 0 - expected 'SilentPaymentAddressDetails', got '{type(values[0])}'")
3267
- self._values = values
3268
-
3269
- def __getitem__(self, index):
3270
- return self._values[index]
3271
-
3272
- def __str__(self):
3273
- return f"InputType.SILENT_PAYMENT_ADDRESS{self._values!r}"
3274
-
3275
- def __eq__(self, other):
3276
- if not other.is_silent_payment_address():
3277
- return False
3278
- return self._values == other._values
3279
- class LNURL_AUTH:
3280
- def __init__(self, *values):
3281
- if len(values) != 1:
3282
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3283
- if not isinstance(values[0], LnurlAuthRequestDetails):
3284
- raise TypeError(f"unexpected type for tuple element 0 - expected 'LnurlAuthRequestDetails', got '{type(values[0])}'")
3285
- self._values = values
3286
-
3287
- def __getitem__(self, index):
3288
- return self._values[index]
3289
-
3290
- def __str__(self):
3291
- return f"InputType.LNURL_AUTH{self._values!r}"
3292
-
3293
- def __eq__(self, other):
3294
- if not other.is_lnurl_auth():
3295
- return False
3296
- return self._values == other._values
3297
- class URL:
3298
- def __init__(self, *values):
3299
- if len(values) != 1:
3300
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3301
- if not isinstance(values[0], str):
3302
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3303
- self._values = values
3304
-
3305
- def __getitem__(self, index):
3306
- return self._values[index]
3307
-
3308
- def __str__(self):
3309
- return f"InputType.URL{self._values!r}"
3310
-
3311
- def __eq__(self, other):
3312
- if not other.is_url():
3313
- return False
3314
- return self._values == other._values
3315
- class BIP21:
3316
- def __init__(self, *values):
3317
- if len(values) != 1:
3318
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3319
- if not isinstance(values[0], Bip21Details):
3320
- raise TypeError(f"unexpected type for tuple element 0 - expected 'Bip21Details', got '{type(values[0])}'")
3321
- self._values = values
3322
-
3323
- def __getitem__(self, index):
3324
- return self._values[index]
3325
-
3326
- def __str__(self):
3327
- return f"InputType.BIP21{self._values!r}"
3328
-
3329
- def __eq__(self, other):
3330
- if not other.is_bip21():
3331
- return False
3332
- return self._values == other._values
3333
- class BOLT12_INVOICE_REQUEST:
3334
- def __init__(self, *values):
3335
- if len(values) != 1:
3336
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3337
- if not isinstance(values[0], Bolt12InvoiceRequestDetails):
3338
- raise TypeError(f"unexpected type for tuple element 0 - expected 'Bolt12InvoiceRequestDetails', got '{type(values[0])}'")
3339
- self._values = values
3340
-
3341
- def __getitem__(self, index):
3342
- return self._values[index]
3343
-
3344
- def __str__(self):
3345
- return f"InputType.BOLT12_INVOICE_REQUEST{self._values!r}"
3346
-
3347
- def __eq__(self, other):
3348
- if not other.is_bolt12_invoice_request():
3349
- return False
3350
- return self._values == other._values
3351
- class LNURL_WITHDRAW:
3352
- def __init__(self, *values):
3353
- if len(values) != 1:
3354
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3355
- if not isinstance(values[0], LnurlWithdrawRequestDetails):
3356
- raise TypeError(f"unexpected type for tuple element 0 - expected 'LnurlWithdrawRequestDetails', got '{type(values[0])}'")
3357
- self._values = values
3358
-
3359
- def __getitem__(self, index):
3360
- return self._values[index]
3361
-
3362
- def __str__(self):
3363
- return f"InputType.LNURL_WITHDRAW{self._values!r}"
3364
-
3365
- def __eq__(self, other):
3366
- if not other.is_lnurl_withdraw():
3367
- return False
3368
- return self._values == other._values
3369
-
3370
-
3371
- # For each variant, we have an `is_NAME` method for easily checking
3372
- # whether an instance is that variant.
3373
- def is_bitcoin_address(self) -> bool:
3374
- return isinstance(self, InputType.BITCOIN_ADDRESS)
3375
- def is_bolt11_invoice(self) -> bool:
3376
- return isinstance(self, InputType.BOLT11_INVOICE)
3377
- def is_bolt12_invoice(self) -> bool:
3378
- return isinstance(self, InputType.BOLT12_INVOICE)
3379
- def is_bolt12_offer(self) -> bool:
3380
- return isinstance(self, InputType.BOLT12_OFFER)
3381
- def is_lightning_address(self) -> bool:
3382
- return isinstance(self, InputType.LIGHTNING_ADDRESS)
3383
- def is_lnurl_pay(self) -> bool:
3384
- return isinstance(self, InputType.LNURL_PAY)
3385
- def is_silent_payment_address(self) -> bool:
3386
- return isinstance(self, InputType.SILENT_PAYMENT_ADDRESS)
3387
- def is_lnurl_auth(self) -> bool:
3388
- return isinstance(self, InputType.LNURL_AUTH)
3389
- def is_url(self) -> bool:
3390
- return isinstance(self, InputType.URL)
3391
- def is_bip21(self) -> bool:
3392
- return isinstance(self, InputType.BIP21)
3393
- def is_bolt12_invoice_request(self) -> bool:
3394
- return isinstance(self, InputType.BOLT12_INVOICE_REQUEST)
3395
- def is_lnurl_withdraw(self) -> bool:
3396
- return isinstance(self, InputType.LNURL_WITHDRAW)
3397
-
3398
-
3399
- # Now, a little trick - we make each nested variant class be a subclass of the main
3400
- # enum class, so that method calls and instance checks etc will work intuitively.
3401
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
3402
- InputType.BITCOIN_ADDRESS = type("InputType.BITCOIN_ADDRESS", (InputType.BITCOIN_ADDRESS, InputType,), {}) # type: ignore
3403
- InputType.BOLT11_INVOICE = type("InputType.BOLT11_INVOICE", (InputType.BOLT11_INVOICE, InputType,), {}) # type: ignore
3404
- InputType.BOLT12_INVOICE = type("InputType.BOLT12_INVOICE", (InputType.BOLT12_INVOICE, InputType,), {}) # type: ignore
3405
- InputType.BOLT12_OFFER = type("InputType.BOLT12_OFFER", (InputType.BOLT12_OFFER, InputType,), {}) # type: ignore
3406
- InputType.LIGHTNING_ADDRESS = type("InputType.LIGHTNING_ADDRESS", (InputType.LIGHTNING_ADDRESS, InputType,), {}) # type: ignore
3407
- InputType.LNURL_PAY = type("InputType.LNURL_PAY", (InputType.LNURL_PAY, InputType,), {}) # type: ignore
3408
- InputType.SILENT_PAYMENT_ADDRESS = type("InputType.SILENT_PAYMENT_ADDRESS", (InputType.SILENT_PAYMENT_ADDRESS, InputType,), {}) # type: ignore
3409
- InputType.LNURL_AUTH = type("InputType.LNURL_AUTH", (InputType.LNURL_AUTH, InputType,), {}) # type: ignore
3410
- InputType.URL = type("InputType.URL", (InputType.URL, InputType,), {}) # type: ignore
3411
- InputType.BIP21 = type("InputType.BIP21", (InputType.BIP21, InputType,), {}) # type: ignore
3412
- InputType.BOLT12_INVOICE_REQUEST = type("InputType.BOLT12_INVOICE_REQUEST", (InputType.BOLT12_INVOICE_REQUEST, InputType,), {}) # type: ignore
3413
- InputType.LNURL_WITHDRAW = type("InputType.LNURL_WITHDRAW", (InputType.LNURL_WITHDRAW, InputType,), {}) # type: ignore
3414
-
3415
-
3416
-
3417
-
3418
- class _UniffiConverterTypeInputType(_UniffiConverterRustBuffer):
3419
- @staticmethod
3420
- def read(buf):
3421
- variant = buf.read_i32()
3422
- if variant == 1:
3423
- return InputType.BITCOIN_ADDRESS(
3424
- _UniffiConverterTypeBitcoinAddressDetails.read(buf),
3425
- )
3426
- if variant == 2:
3427
- return InputType.BOLT11_INVOICE(
3428
- _UniffiConverterTypeBolt11InvoiceDetails.read(buf),
3429
- )
3430
- if variant == 3:
3431
- return InputType.BOLT12_INVOICE(
3432
- _UniffiConverterTypeBolt12InvoiceDetails.read(buf),
3433
- )
3434
- if variant == 4:
3435
- return InputType.BOLT12_OFFER(
3436
- _UniffiConverterTypeBolt12OfferDetails.read(buf),
3437
- )
3438
- if variant == 5:
3439
- return InputType.LIGHTNING_ADDRESS(
3440
- _UniffiConverterTypeLightningAddressDetails.read(buf),
3441
- )
3442
- if variant == 6:
3443
- return InputType.LNURL_PAY(
3444
- _UniffiConverterTypeLnurlPayRequestDetails.read(buf),
3445
- )
3446
- if variant == 7:
3447
- return InputType.SILENT_PAYMENT_ADDRESS(
3448
- _UniffiConverterTypeSilentPaymentAddressDetails.read(buf),
3449
- )
3450
- if variant == 8:
3451
- return InputType.LNURL_AUTH(
3452
- _UniffiConverterTypeLnurlAuthRequestDetails.read(buf),
3453
- )
3454
- if variant == 9:
3455
- return InputType.URL(
3456
- _UniffiConverterString.read(buf),
3457
- )
3458
- if variant == 10:
3459
- return InputType.BIP21(
3460
- _UniffiConverterTypeBip21Details.read(buf),
3461
- )
3462
- if variant == 11:
3463
- return InputType.BOLT12_INVOICE_REQUEST(
3464
- _UniffiConverterTypeBolt12InvoiceRequestDetails.read(buf),
3465
- )
3466
- if variant == 12:
3467
- return InputType.LNURL_WITHDRAW(
3468
- _UniffiConverterTypeLnurlWithdrawRequestDetails.read(buf),
3469
- )
3470
- raise InternalError("Raw enum value doesn't match any cases")
3471
-
3472
- @staticmethod
3473
- def check_lower(value):
3474
- if value.is_bitcoin_address():
3475
- _UniffiConverterTypeBitcoinAddressDetails.check_lower(value._values[0])
3476
- return
3477
- if value.is_bolt11_invoice():
3478
- _UniffiConverterTypeBolt11InvoiceDetails.check_lower(value._values[0])
3479
- return
3480
- if value.is_bolt12_invoice():
3481
- _UniffiConverterTypeBolt12InvoiceDetails.check_lower(value._values[0])
3482
- return
3483
- if value.is_bolt12_offer():
3484
- _UniffiConverterTypeBolt12OfferDetails.check_lower(value._values[0])
3485
- return
3486
- if value.is_lightning_address():
3487
- _UniffiConverterTypeLightningAddressDetails.check_lower(value._values[0])
3488
- return
3489
- if value.is_lnurl_pay():
3490
- _UniffiConverterTypeLnurlPayRequestDetails.check_lower(value._values[0])
3491
- return
3492
- if value.is_silent_payment_address():
3493
- _UniffiConverterTypeSilentPaymentAddressDetails.check_lower(value._values[0])
3494
- return
3495
- if value.is_lnurl_auth():
3496
- _UniffiConverterTypeLnurlAuthRequestDetails.check_lower(value._values[0])
3497
- return
3498
- if value.is_url():
3499
- _UniffiConverterString.check_lower(value._values[0])
3500
- return
3501
- if value.is_bip21():
3502
- _UniffiConverterTypeBip21Details.check_lower(value._values[0])
3503
- return
3504
- if value.is_bolt12_invoice_request():
3505
- _UniffiConverterTypeBolt12InvoiceRequestDetails.check_lower(value._values[0])
3506
- return
3507
- if value.is_lnurl_withdraw():
3508
- _UniffiConverterTypeLnurlWithdrawRequestDetails.check_lower(value._values[0])
3509
- return
3510
- raise ValueError(value)
3511
-
3512
- @staticmethod
3513
- def write(value, buf):
3514
- if value.is_bitcoin_address():
3515
- buf.write_i32(1)
3516
- _UniffiConverterTypeBitcoinAddressDetails.write(value._values[0], buf)
3517
- if value.is_bolt11_invoice():
3518
- buf.write_i32(2)
3519
- _UniffiConverterTypeBolt11InvoiceDetails.write(value._values[0], buf)
3520
- if value.is_bolt12_invoice():
3521
- buf.write_i32(3)
3522
- _UniffiConverterTypeBolt12InvoiceDetails.write(value._values[0], buf)
3523
- if value.is_bolt12_offer():
3524
- buf.write_i32(4)
3525
- _UniffiConverterTypeBolt12OfferDetails.write(value._values[0], buf)
3526
- if value.is_lightning_address():
3527
- buf.write_i32(5)
3528
- _UniffiConverterTypeLightningAddressDetails.write(value._values[0], buf)
3529
- if value.is_lnurl_pay():
3530
- buf.write_i32(6)
3531
- _UniffiConverterTypeLnurlPayRequestDetails.write(value._values[0], buf)
3532
- if value.is_silent_payment_address():
3533
- buf.write_i32(7)
3534
- _UniffiConverterTypeSilentPaymentAddressDetails.write(value._values[0], buf)
3535
- if value.is_lnurl_auth():
3536
- buf.write_i32(8)
3537
- _UniffiConverterTypeLnurlAuthRequestDetails.write(value._values[0], buf)
3538
- if value.is_url():
3539
- buf.write_i32(9)
3540
- _UniffiConverterString.write(value._values[0], buf)
3541
- if value.is_bip21():
3542
- buf.write_i32(10)
3543
- _UniffiConverterTypeBip21Details.write(value._values[0], buf)
3544
- if value.is_bolt12_invoice_request():
3545
- buf.write_i32(11)
3546
- _UniffiConverterTypeBolt12InvoiceRequestDetails.write(value._values[0], buf)
3547
- if value.is_lnurl_withdraw():
3548
- buf.write_i32(12)
3549
- _UniffiConverterTypeLnurlWithdrawRequestDetails.write(value._values[0], buf)
3550
-
3551
-
3552
-
3553
-
3554
-
3555
-
3556
-
3557
- class LnurlCallbackStatus:
3558
- """
3559
- Contains the result of the entire LNURL interaction, as reported by the LNURL endpoint.
3560
-
3561
- * `Ok` indicates the interaction with the endpoint was valid, and the endpoint
3562
- - started to pay the invoice asynchronously in the case of LNURL-withdraw,
3563
- - verified the client signature in the case of LNURL-auth
3564
- * `Error` indicates a generic issue the LNURL endpoint encountered, including a freetext
3565
- description of the reason.
3566
-
3567
- Both cases are described in LUD-03 <https://github.com/lnurl/luds/blob/luds/03.md> & LUD-04: <https://github.com/lnurl/luds/blob/luds/04.md>
3568
- """
3569
-
3570
- def __init__(self):
3571
- raise RuntimeError("LnurlCallbackStatus cannot be instantiated directly")
3572
-
3573
- # Each enum variant is a nested class of the enum itself.
3574
- class OK:
3575
- """
3576
- On-wire format is: `{"status": "OK"}`
3577
- """
3578
-
3579
-
3580
- def __init__(self,):
3581
- pass
3582
-
3583
- def __str__(self):
3584
- return "LnurlCallbackStatus.OK()".format()
3585
-
3586
- def __eq__(self, other):
3587
- if not other.is_ok():
3588
- return False
3589
- return True
3590
-
3591
- class ERROR_STATUS:
3592
- """
3593
- On-wire format is: `{"status": "ERROR", "reason": "error details..."}`
3594
- """
3595
-
3596
- error_details: "LnurlErrorDetails"
3597
-
3598
- def __init__(self,error_details: "LnurlErrorDetails"):
3599
- self.error_details = error_details
3600
-
3601
- def __str__(self):
3602
- return "LnurlCallbackStatus.ERROR_STATUS(error_details={})".format(self.error_details)
3603
-
3604
- def __eq__(self, other):
3605
- if not other.is_error_status():
3606
- return False
3607
- if self.error_details != other.error_details:
3608
- return False
3609
- return True
3610
-
3611
-
3612
-
3613
- # For each variant, we have an `is_NAME` method for easily checking
3614
- # whether an instance is that variant.
3615
- def is_ok(self) -> bool:
3616
- return isinstance(self, LnurlCallbackStatus.OK)
3617
- def is_error_status(self) -> bool:
3618
- return isinstance(self, LnurlCallbackStatus.ERROR_STATUS)
3619
-
3620
-
3621
- # Now, a little trick - we make each nested variant class be a subclass of the main
3622
- # enum class, so that method calls and instance checks etc will work intuitively.
3623
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
3624
- LnurlCallbackStatus.OK = type("LnurlCallbackStatus.OK", (LnurlCallbackStatus.OK, LnurlCallbackStatus,), {}) # type: ignore
3625
- LnurlCallbackStatus.ERROR_STATUS = type("LnurlCallbackStatus.ERROR_STATUS", (LnurlCallbackStatus.ERROR_STATUS, LnurlCallbackStatus,), {}) # type: ignore
3626
-
3627
-
3628
-
3629
-
3630
- class _UniffiConverterTypeLnurlCallbackStatus(_UniffiConverterRustBuffer):
3631
- @staticmethod
3632
- def read(buf):
3633
- variant = buf.read_i32()
3634
- if variant == 1:
3635
- return LnurlCallbackStatus.OK(
3636
- )
3637
- if variant == 2:
3638
- return LnurlCallbackStatus.ERROR_STATUS(
3639
- _UniffiConverterTypeLnurlErrorDetails.read(buf),
3640
- )
3641
- raise InternalError("Raw enum value doesn't match any cases")
3642
-
3643
- @staticmethod
3644
- def check_lower(value):
3645
- if value.is_ok():
3646
- return
3647
- if value.is_error_status():
3648
- _UniffiConverterTypeLnurlErrorDetails.check_lower(value.error_details)
3649
- return
3650
- raise ValueError(value)
3651
-
3652
- @staticmethod
3653
- def write(value, buf):
3654
- if value.is_ok():
3655
- buf.write_i32(1)
3656
- if value.is_error_status():
3657
- buf.write_i32(2)
3658
- _UniffiConverterTypeLnurlErrorDetails.write(value.error_details, buf)
3659
-
3660
-
3661
-
3662
-
3663
- # ServiceConnectivityError
3664
- # We want to define each variant as a nested class that's also a subclass,
3665
- # which is tricky in Python. To accomplish this we're going to create each
3666
- # class separately, then manually add the child classes to the base class's
3667
- # __dict__. All of this happens in dummy class to avoid polluting the module
3668
- # namespace.
3669
- class ServiceConnectivityError(Exception):
3670
- pass
3671
-
3672
- _UniffiTempServiceConnectivityError = ServiceConnectivityError
3673
-
3674
- class ServiceConnectivityError: # type: ignore
3675
- class Builder(_UniffiTempServiceConnectivityError):
3676
- def __init__(self, *values):
3677
- if len(values) != 1:
3678
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3679
- if not isinstance(values[0], str):
3680
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3681
- super().__init__(", ".join(map(repr, values)))
3682
- self._values = values
3683
-
3684
- def __getitem__(self, index):
3685
- return self._values[index]
3686
-
3687
- def __repr__(self):
3688
- return "ServiceConnectivityError.Builder({})".format(str(self))
3689
- _UniffiTempServiceConnectivityError.Builder = Builder # type: ignore
3690
- class Redirect(_UniffiTempServiceConnectivityError):
3691
- def __init__(self, *values):
3692
- if len(values) != 1:
3693
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3694
- if not isinstance(values[0], str):
3695
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3696
- super().__init__(", ".join(map(repr, values)))
3697
- self._values = values
3698
-
3699
- def __getitem__(self, index):
3700
- return self._values[index]
3701
-
3702
- def __repr__(self):
3703
- return "ServiceConnectivityError.Redirect({})".format(str(self))
3704
- _UniffiTempServiceConnectivityError.Redirect = Redirect # type: ignore
3705
- class Status(_UniffiTempServiceConnectivityError):
3706
- def __init__(self, status, body):
3707
- super().__init__(", ".join([
3708
- "status={!r}".format(status),
3709
- "body={!r}".format(body),
3710
- ]))
3711
- self.status = status
3712
- self.body = body
3713
-
3714
- def __repr__(self):
3715
- return "ServiceConnectivityError.Status({})".format(str(self))
3716
- _UniffiTempServiceConnectivityError.Status = Status # type: ignore
3717
- class Timeout(_UniffiTempServiceConnectivityError):
3718
- def __init__(self, *values):
3719
- if len(values) != 1:
3720
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3721
- if not isinstance(values[0], str):
3722
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3723
- super().__init__(", ".join(map(repr, values)))
3724
- self._values = values
3725
-
3726
- def __getitem__(self, index):
3727
- return self._values[index]
3728
-
3729
- def __repr__(self):
3730
- return "ServiceConnectivityError.Timeout({})".format(str(self))
3731
- _UniffiTempServiceConnectivityError.Timeout = Timeout # type: ignore
3732
- class Request(_UniffiTempServiceConnectivityError):
3733
- def __init__(self, *values):
3734
- if len(values) != 1:
3735
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3736
- if not isinstance(values[0], str):
3737
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3738
- super().__init__(", ".join(map(repr, values)))
3739
- self._values = values
3740
-
3741
- def __getitem__(self, index):
3742
- return self._values[index]
3743
-
3744
- def __repr__(self):
3745
- return "ServiceConnectivityError.Request({})".format(str(self))
3746
- _UniffiTempServiceConnectivityError.Request = Request # type: ignore
3747
- class Connect(_UniffiTempServiceConnectivityError):
3748
- def __init__(self, *values):
3749
- if len(values) != 1:
3750
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3751
- if not isinstance(values[0], str):
3752
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3753
- super().__init__(", ".join(map(repr, values)))
3754
- self._values = values
3755
-
3756
- def __getitem__(self, index):
3757
- return self._values[index]
3758
-
3759
- def __repr__(self):
3760
- return "ServiceConnectivityError.Connect({})".format(str(self))
3761
- _UniffiTempServiceConnectivityError.Connect = Connect # type: ignore
3762
- class Body(_UniffiTempServiceConnectivityError):
3763
- def __init__(self, *values):
3764
- if len(values) != 1:
3765
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3766
- if not isinstance(values[0], str):
3767
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3768
- super().__init__(", ".join(map(repr, values)))
3769
- self._values = values
3770
-
3771
- def __getitem__(self, index):
3772
- return self._values[index]
3773
-
3774
- def __repr__(self):
3775
- return "ServiceConnectivityError.Body({})".format(str(self))
3776
- _UniffiTempServiceConnectivityError.Body = Body # type: ignore
3777
- class Decode(_UniffiTempServiceConnectivityError):
3778
- def __init__(self, *values):
3779
- if len(values) != 1:
3780
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3781
- if not isinstance(values[0], str):
3782
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3783
- super().__init__(", ".join(map(repr, values)))
3784
- self._values = values
3785
-
3786
- def __getitem__(self, index):
3787
- return self._values[index]
3788
-
3789
- def __repr__(self):
3790
- return "ServiceConnectivityError.Decode({})".format(str(self))
3791
- _UniffiTempServiceConnectivityError.Decode = Decode # type: ignore
3792
- class Json(_UniffiTempServiceConnectivityError):
3793
- def __init__(self, *values):
3794
- if len(values) != 1:
3795
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3796
- if not isinstance(values[0], str):
3797
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3798
- super().__init__(", ".join(map(repr, values)))
3799
- self._values = values
3800
-
3801
- def __getitem__(self, index):
3802
- return self._values[index]
3803
-
3804
- def __repr__(self):
3805
- return "ServiceConnectivityError.Json({})".format(str(self))
3806
- _UniffiTempServiceConnectivityError.Json = Json # type: ignore
3807
- class Other(_UniffiTempServiceConnectivityError):
3808
- def __init__(self, *values):
3809
- if len(values) != 1:
3810
- raise TypeError(f"Expected 1 arguments, found {len(values)}")
3811
- if not isinstance(values[0], str):
3812
- raise TypeError(f"unexpected type for tuple element 0 - expected 'str', got '{type(values[0])}'")
3813
- super().__init__(", ".join(map(repr, values)))
3814
- self._values = values
3815
-
3816
- def __getitem__(self, index):
3817
- return self._values[index]
3818
-
3819
- def __repr__(self):
3820
- return "ServiceConnectivityError.Other({})".format(str(self))
3821
- _UniffiTempServiceConnectivityError.Other = Other # type: ignore
3822
-
3823
- ServiceConnectivityError = _UniffiTempServiceConnectivityError # type: ignore
3824
- del _UniffiTempServiceConnectivityError
3825
-
3826
-
3827
- class _UniffiConverterTypeServiceConnectivityError(_UniffiConverterRustBuffer):
3828
- @staticmethod
3829
- def read(buf):
3830
- variant = buf.read_i32()
3831
- if variant == 1:
3832
- return ServiceConnectivityError.Builder(
3833
- _UniffiConverterString.read(buf),
3834
- )
3835
- if variant == 2:
3836
- return ServiceConnectivityError.Redirect(
3837
- _UniffiConverterString.read(buf),
3838
- )
3839
- if variant == 3:
3840
- return ServiceConnectivityError.Status(
3841
- _UniffiConverterUInt16.read(buf),
3842
- _UniffiConverterString.read(buf),
3843
- )
3844
- if variant == 4:
3845
- return ServiceConnectivityError.Timeout(
3846
- _UniffiConverterString.read(buf),
3847
- )
3848
- if variant == 5:
3849
- return ServiceConnectivityError.Request(
3850
- _UniffiConverterString.read(buf),
3851
- )
3852
- if variant == 6:
3853
- return ServiceConnectivityError.Connect(
3854
- _UniffiConverterString.read(buf),
3855
- )
3856
- if variant == 7:
3857
- return ServiceConnectivityError.Body(
3858
- _UniffiConverterString.read(buf),
3859
- )
3860
- if variant == 8:
3861
- return ServiceConnectivityError.Decode(
3862
- _UniffiConverterString.read(buf),
3863
- )
3864
- if variant == 9:
3865
- return ServiceConnectivityError.Json(
3866
- _UniffiConverterString.read(buf),
3867
- )
3868
- if variant == 10:
3869
- return ServiceConnectivityError.Other(
3870
- _UniffiConverterString.read(buf),
3871
- )
3872
- raise InternalError("Raw enum value doesn't match any cases")
3873
-
3874
- @staticmethod
3875
- def check_lower(value):
3876
- if isinstance(value, ServiceConnectivityError.Builder):
3877
- _UniffiConverterString.check_lower(value._values[0])
3878
- return
3879
- if isinstance(value, ServiceConnectivityError.Redirect):
3880
- _UniffiConverterString.check_lower(value._values[0])
3881
- return
3882
- if isinstance(value, ServiceConnectivityError.Status):
3883
- _UniffiConverterUInt16.check_lower(value.status)
3884
- _UniffiConverterString.check_lower(value.body)
3885
- return
3886
- if isinstance(value, ServiceConnectivityError.Timeout):
3887
- _UniffiConverterString.check_lower(value._values[0])
3888
- return
3889
- if isinstance(value, ServiceConnectivityError.Request):
3890
- _UniffiConverterString.check_lower(value._values[0])
3891
- return
3892
- if isinstance(value, ServiceConnectivityError.Connect):
3893
- _UniffiConverterString.check_lower(value._values[0])
3894
- return
3895
- if isinstance(value, ServiceConnectivityError.Body):
3896
- _UniffiConverterString.check_lower(value._values[0])
3897
- return
3898
- if isinstance(value, ServiceConnectivityError.Decode):
3899
- _UniffiConverterString.check_lower(value._values[0])
3900
- return
3901
- if isinstance(value, ServiceConnectivityError.Json):
3902
- _UniffiConverterString.check_lower(value._values[0])
3903
- return
3904
- if isinstance(value, ServiceConnectivityError.Other):
3905
- _UniffiConverterString.check_lower(value._values[0])
3906
- return
3907
-
3908
- @staticmethod
3909
- def write(value, buf):
3910
- if isinstance(value, ServiceConnectivityError.Builder):
3911
- buf.write_i32(1)
3912
- _UniffiConverterString.write(value._values[0], buf)
3913
- if isinstance(value, ServiceConnectivityError.Redirect):
3914
- buf.write_i32(2)
3915
- _UniffiConverterString.write(value._values[0], buf)
3916
- if isinstance(value, ServiceConnectivityError.Status):
3917
- buf.write_i32(3)
3918
- _UniffiConverterUInt16.write(value.status, buf)
3919
- _UniffiConverterString.write(value.body, buf)
3920
- if isinstance(value, ServiceConnectivityError.Timeout):
3921
- buf.write_i32(4)
3922
- _UniffiConverterString.write(value._values[0], buf)
3923
- if isinstance(value, ServiceConnectivityError.Request):
3924
- buf.write_i32(5)
3925
- _UniffiConverterString.write(value._values[0], buf)
3926
- if isinstance(value, ServiceConnectivityError.Connect):
3927
- buf.write_i32(6)
3928
- _UniffiConverterString.write(value._values[0], buf)
3929
- if isinstance(value, ServiceConnectivityError.Body):
3930
- buf.write_i32(7)
3931
- _UniffiConverterString.write(value._values[0], buf)
3932
- if isinstance(value, ServiceConnectivityError.Decode):
3933
- buf.write_i32(8)
3934
- _UniffiConverterString.write(value._values[0], buf)
3935
- if isinstance(value, ServiceConnectivityError.Json):
3936
- buf.write_i32(9)
3937
- _UniffiConverterString.write(value._values[0], buf)
3938
- if isinstance(value, ServiceConnectivityError.Other):
3939
- buf.write_i32(10)
3940
- _UniffiConverterString.write(value._values[0], buf)
3941
-
3942
-
3943
-
3944
-
3945
-
3946
- class SuccessAction:
3947
- """
3948
- Supported success action types
3949
-
3950
- Receiving any other (unsupported) success action type will result in a failed parsing,
3951
- which will abort the LNURL-pay workflow, as per LUD-09.
3952
- """
3953
-
3954
- def __init__(self):
3955
- raise RuntimeError("SuccessAction cannot be instantiated directly")
3956
-
3957
- # Each enum variant is a nested class of the enum itself.
3958
- class AES:
3959
- """
3960
- AES type, described in LUD-10
3961
- """
3962
-
3963
- data: "AesSuccessActionData"
3964
-
3965
- def __init__(self,data: "AesSuccessActionData"):
3966
- self.data = data
3967
-
3968
- def __str__(self):
3969
- return "SuccessAction.AES(data={})".format(self.data)
3970
-
3971
- def __eq__(self, other):
3972
- if not other.is_aes():
3973
- return False
3974
- if self.data != other.data:
3975
- return False
3976
- return True
3977
-
3978
- class MESSAGE:
3979
- """
3980
- Message type, described in LUD-09
3981
- """
3982
-
3983
- data: "MessageSuccessActionData"
3984
-
3985
- def __init__(self,data: "MessageSuccessActionData"):
3986
- self.data = data
3987
-
3988
- def __str__(self):
3989
- return "SuccessAction.MESSAGE(data={})".format(self.data)
3990
-
3991
- def __eq__(self, other):
3992
- if not other.is_message():
3993
- return False
3994
- if self.data != other.data:
3995
- return False
3996
- return True
3997
-
3998
- class URL:
3999
- """
4000
- URL type, described in LUD-09
4001
- """
4002
-
4003
- data: "UrlSuccessActionData"
4004
-
4005
- def __init__(self,data: "UrlSuccessActionData"):
4006
- self.data = data
4007
-
4008
- def __str__(self):
4009
- return "SuccessAction.URL(data={})".format(self.data)
4010
-
4011
- def __eq__(self, other):
4012
- if not other.is_url():
4013
- return False
4014
- if self.data != other.data:
4015
- return False
4016
- return True
4017
-
4018
-
4019
-
4020
- # For each variant, we have an `is_NAME` method for easily checking
4021
- # whether an instance is that variant.
4022
- def is_aes(self) -> bool:
4023
- return isinstance(self, SuccessAction.AES)
4024
- def is_message(self) -> bool:
4025
- return isinstance(self, SuccessAction.MESSAGE)
4026
- def is_url(self) -> bool:
4027
- return isinstance(self, SuccessAction.URL)
4028
-
4029
-
4030
- # Now, a little trick - we make each nested variant class be a subclass of the main
4031
- # enum class, so that method calls and instance checks etc will work intuitively.
4032
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
4033
- SuccessAction.AES = type("SuccessAction.AES", (SuccessAction.AES, SuccessAction,), {}) # type: ignore
4034
- SuccessAction.MESSAGE = type("SuccessAction.MESSAGE", (SuccessAction.MESSAGE, SuccessAction,), {}) # type: ignore
4035
- SuccessAction.URL = type("SuccessAction.URL", (SuccessAction.URL, SuccessAction,), {}) # type: ignore
4036
-
4037
-
4038
-
4039
-
4040
- class _UniffiConverterTypeSuccessAction(_UniffiConverterRustBuffer):
4041
- @staticmethod
4042
- def read(buf):
4043
- variant = buf.read_i32()
4044
- if variant == 1:
4045
- return SuccessAction.AES(
4046
- _UniffiConverterTypeAesSuccessActionData.read(buf),
4047
- )
4048
- if variant == 2:
4049
- return SuccessAction.MESSAGE(
4050
- _UniffiConverterTypeMessageSuccessActionData.read(buf),
4051
- )
4052
- if variant == 3:
4053
- return SuccessAction.URL(
4054
- _UniffiConverterTypeUrlSuccessActionData.read(buf),
4055
- )
4056
- raise InternalError("Raw enum value doesn't match any cases")
4057
-
4058
- @staticmethod
4059
- def check_lower(value):
4060
- if value.is_aes():
4061
- _UniffiConverterTypeAesSuccessActionData.check_lower(value.data)
4062
- return
4063
- if value.is_message():
4064
- _UniffiConverterTypeMessageSuccessActionData.check_lower(value.data)
4065
- return
4066
- if value.is_url():
4067
- _UniffiConverterTypeUrlSuccessActionData.check_lower(value.data)
4068
- return
4069
- raise ValueError(value)
4070
-
4071
- @staticmethod
4072
- def write(value, buf):
4073
- if value.is_aes():
4074
- buf.write_i32(1)
4075
- _UniffiConverterTypeAesSuccessActionData.write(value.data, buf)
4076
- if value.is_message():
4077
- buf.write_i32(2)
4078
- _UniffiConverterTypeMessageSuccessActionData.write(value.data, buf)
4079
- if value.is_url():
4080
- buf.write_i32(3)
4081
- _UniffiConverterTypeUrlSuccessActionData.write(value.data, buf)
4082
-
4083
-
4084
-
4085
-
4086
-
4087
-
4088
-
4089
- class SuccessActionProcessed:
4090
- """
4091
- [`SuccessAction`] where contents are ready to be consumed by the caller
4092
-
4093
- Contents are identical to [`SuccessAction`], except for AES where the ciphertext is decrypted.
4094
- """
4095
-
4096
- def __init__(self):
4097
- raise RuntimeError("SuccessActionProcessed cannot be instantiated directly")
4098
-
4099
- # Each enum variant is a nested class of the enum itself.
4100
- class AES:
4101
- """
4102
- See [`SuccessAction::Aes`] for received payload
4103
-
4104
- See [`AesSuccessActionDataDecrypted`] for decrypted payload
4105
- """
4106
-
4107
- result: "AesSuccessActionDataResult"
4108
-
4109
- def __init__(self,result: "AesSuccessActionDataResult"):
4110
- self.result = result
4111
-
4112
- def __str__(self):
4113
- return "SuccessActionProcessed.AES(result={})".format(self.result)
4114
-
4115
- def __eq__(self, other):
4116
- if not other.is_aes():
4117
- return False
4118
- if self.result != other.result:
4119
- return False
4120
- return True
4121
-
4122
- class MESSAGE:
4123
- """
4124
- See [`SuccessAction::Message`]
4125
- """
4126
-
4127
- data: "MessageSuccessActionData"
4128
-
4129
- def __init__(self,data: "MessageSuccessActionData"):
4130
- self.data = data
4131
-
4132
- def __str__(self):
4133
- return "SuccessActionProcessed.MESSAGE(data={})".format(self.data)
4134
-
4135
- def __eq__(self, other):
4136
- if not other.is_message():
4137
- return False
4138
- if self.data != other.data:
4139
- return False
4140
- return True
4141
-
4142
- class URL:
4143
- """
4144
- See [`SuccessAction::Url`]
4145
- """
4146
-
4147
- data: "UrlSuccessActionData"
4148
-
4149
- def __init__(self,data: "UrlSuccessActionData"):
4150
- self.data = data
4151
-
4152
- def __str__(self):
4153
- return "SuccessActionProcessed.URL(data={})".format(self.data)
4154
-
4155
- def __eq__(self, other):
4156
- if not other.is_url():
4157
- return False
4158
- if self.data != other.data:
4159
- return False
4160
- return True
4161
-
4162
-
4163
-
4164
- # For each variant, we have an `is_NAME` method for easily checking
4165
- # whether an instance is that variant.
4166
- def is_aes(self) -> bool:
4167
- return isinstance(self, SuccessActionProcessed.AES)
4168
- def is_message(self) -> bool:
4169
- return isinstance(self, SuccessActionProcessed.MESSAGE)
4170
- def is_url(self) -> bool:
4171
- return isinstance(self, SuccessActionProcessed.URL)
4172
-
4173
-
4174
- # Now, a little trick - we make each nested variant class be a subclass of the main
4175
- # enum class, so that method calls and instance checks etc will work intuitively.
4176
- # We might be able to do this a little more neatly with a metaclass, but this'll do.
4177
- SuccessActionProcessed.AES = type("SuccessActionProcessed.AES", (SuccessActionProcessed.AES, SuccessActionProcessed,), {}) # type: ignore
4178
- SuccessActionProcessed.MESSAGE = type("SuccessActionProcessed.MESSAGE", (SuccessActionProcessed.MESSAGE, SuccessActionProcessed,), {}) # type: ignore
4179
- SuccessActionProcessed.URL = type("SuccessActionProcessed.URL", (SuccessActionProcessed.URL, SuccessActionProcessed,), {}) # type: ignore
4180
-
4181
-
4182
-
4183
-
4184
- class _UniffiConverterTypeSuccessActionProcessed(_UniffiConverterRustBuffer):
4185
- @staticmethod
4186
- def read(buf):
4187
- variant = buf.read_i32()
4188
- if variant == 1:
4189
- return SuccessActionProcessed.AES(
4190
- _UniffiConverterTypeAesSuccessActionDataResult.read(buf),
4191
- )
4192
- if variant == 2:
4193
- return SuccessActionProcessed.MESSAGE(
4194
- _UniffiConverterTypeMessageSuccessActionData.read(buf),
4195
- )
4196
- if variant == 3:
4197
- return SuccessActionProcessed.URL(
4198
- _UniffiConverterTypeUrlSuccessActionData.read(buf),
4199
- )
4200
- raise InternalError("Raw enum value doesn't match any cases")
4201
-
4202
- @staticmethod
4203
- def check_lower(value):
4204
- if value.is_aes():
4205
- _UniffiConverterTypeAesSuccessActionDataResult.check_lower(value.result)
4206
- return
4207
- if value.is_message():
4208
- _UniffiConverterTypeMessageSuccessActionData.check_lower(value.data)
4209
- return
4210
- if value.is_url():
4211
- _UniffiConverterTypeUrlSuccessActionData.check_lower(value.data)
4212
- return
4213
- raise ValueError(value)
4214
-
4215
- @staticmethod
4216
- def write(value, buf):
4217
- if value.is_aes():
4218
- buf.write_i32(1)
4219
- _UniffiConverterTypeAesSuccessActionDataResult.write(value.result, buf)
4220
- if value.is_message():
4221
- buf.write_i32(2)
4222
- _UniffiConverterTypeMessageSuccessActionData.write(value.data, buf)
4223
- if value.is_url():
4224
- buf.write_i32(3)
4225
- _UniffiConverterTypeUrlSuccessActionData.write(value.data, buf)
4226
-
4227
-
4228
-
4229
-
4230
-
4231
- class _UniffiConverterOptionalUInt32(_UniffiConverterRustBuffer):
4232
- @classmethod
4233
- def check_lower(cls, value):
4234
- if value is not None:
4235
- _UniffiConverterUInt32.check_lower(value)
4236
-
4237
- @classmethod
4238
- def write(cls, value, buf):
4239
- if value is None:
4240
- buf.write_u8(0)
4241
- return
4242
-
4243
- buf.write_u8(1)
4244
- _UniffiConverterUInt32.write(value, buf)
4245
-
4246
- @classmethod
4247
- def read(cls, buf):
4248
- flag = buf.read_u8()
4249
- if flag == 0:
4250
- return None
4251
- elif flag == 1:
4252
- return _UniffiConverterUInt32.read(buf)
4253
- else:
4254
- raise InternalError("Unexpected flag byte for optional type")
4255
-
4256
-
4257
-
4258
- class _UniffiConverterOptionalUInt64(_UniffiConverterRustBuffer):
4259
- @classmethod
4260
- def check_lower(cls, value):
4261
- if value is not None:
4262
- _UniffiConverterUInt64.check_lower(value)
4263
-
4264
- @classmethod
4265
- def write(cls, value, buf):
4266
- if value is None:
4267
- buf.write_u8(0)
4268
- return
4269
-
4270
- buf.write_u8(1)
4271
- _UniffiConverterUInt64.write(value, buf)
4272
-
4273
- @classmethod
4274
- def read(cls, buf):
4275
- flag = buf.read_u8()
4276
- if flag == 0:
4277
- return None
4278
- elif flag == 1:
4279
- return _UniffiConverterUInt64.read(buf)
4280
- else:
4281
- raise InternalError("Unexpected flag byte for optional type")
4282
-
4283
-
4284
-
4285
- class _UniffiConverterOptionalBool(_UniffiConverterRustBuffer):
4286
- @classmethod
4287
- def check_lower(cls, value):
4288
- if value is not None:
4289
- _UniffiConverterBool.check_lower(value)
4290
-
4291
- @classmethod
4292
- def write(cls, value, buf):
4293
- if value is None:
4294
- buf.write_u8(0)
4295
- return
4296
-
4297
- buf.write_u8(1)
4298
- _UniffiConverterBool.write(value, buf)
4299
-
4300
- @classmethod
4301
- def read(cls, buf):
4302
- flag = buf.read_u8()
4303
- if flag == 0:
4304
- return None
4305
- elif flag == 1:
4306
- return _UniffiConverterBool.read(buf)
4307
- else:
4308
- raise InternalError("Unexpected flag byte for optional type")
4309
-
4310
-
4311
-
4312
- class _UniffiConverterOptionalString(_UniffiConverterRustBuffer):
4313
- @classmethod
4314
- def check_lower(cls, value):
4315
- if value is not None:
4316
- _UniffiConverterString.check_lower(value)
4317
-
4318
- @classmethod
4319
- def write(cls, value, buf):
4320
- if value is None:
4321
- buf.write_u8(0)
4322
- return
4323
-
4324
- buf.write_u8(1)
4325
- _UniffiConverterString.write(value, buf)
4326
-
4327
- @classmethod
4328
- def read(cls, buf):
4329
- flag = buf.read_u8()
4330
- if flag == 0:
4331
- return None
4332
- elif flag == 1:
4333
- return _UniffiConverterString.read(buf)
4334
- else:
4335
- raise InternalError("Unexpected flag byte for optional type")
4336
-
4337
-
4338
-
4339
- class _UniffiConverterOptionalTypeSymbol(_UniffiConverterRustBuffer):
4340
- @classmethod
4341
- def check_lower(cls, value):
4342
- if value is not None:
4343
- _UniffiConverterTypeSymbol.check_lower(value)
4344
-
4345
- @classmethod
4346
- def write(cls, value, buf):
4347
- if value is None:
4348
- buf.write_u8(0)
4349
- return
4350
-
4351
- buf.write_u8(1)
4352
- _UniffiConverterTypeSymbol.write(value, buf)
4353
-
4354
- @classmethod
4355
- def read(cls, buf):
4356
- flag = buf.read_u8()
4357
- if flag == 0:
4358
- return None
4359
- elif flag == 1:
4360
- return _UniffiConverterTypeSymbol.read(buf)
4361
- else:
4362
- raise InternalError("Unexpected flag byte for optional type")
4363
-
4364
-
4365
-
4366
- class _UniffiConverterOptionalTypeAmount(_UniffiConverterRustBuffer):
4367
- @classmethod
4368
- def check_lower(cls, value):
4369
- if value is not None:
4370
- _UniffiConverterTypeAmount.check_lower(value)
4371
-
4372
- @classmethod
4373
- def write(cls, value, buf):
4374
- if value is None:
4375
- buf.write_u8(0)
4376
- return
4377
-
4378
- buf.write_u8(1)
4379
- _UniffiConverterTypeAmount.write(value, buf)
4380
-
4381
- @classmethod
4382
- def read(cls, buf):
4383
- flag = buf.read_u8()
4384
- if flag == 0:
4385
- return None
4386
- elif flag == 1:
4387
- return _UniffiConverterTypeAmount.read(buf)
4388
- else:
4389
- raise InternalError("Unexpected flag byte for optional type")
4390
-
4391
-
4392
-
4393
- class _UniffiConverterOptionalMapStringString(_UniffiConverterRustBuffer):
4394
- @classmethod
4395
- def check_lower(cls, value):
4396
- if value is not None:
4397
- _UniffiConverterMapStringString.check_lower(value)
4398
-
4399
- @classmethod
4400
- def write(cls, value, buf):
4401
- if value is None:
4402
- buf.write_u8(0)
4403
- return
4404
-
4405
- buf.write_u8(1)
4406
- _UniffiConverterMapStringString.write(value, buf)
4407
-
4408
- @classmethod
4409
- def read(cls, buf):
4410
- flag = buf.read_u8()
4411
- if flag == 0:
4412
- return None
4413
- elif flag == 1:
4414
- return _UniffiConverterMapStringString.read(buf)
4415
- else:
4416
- raise InternalError("Unexpected flag byte for optional type")
4417
-
4418
-
4419
-
4420
- class _UniffiConverterSequenceString(_UniffiConverterRustBuffer):
4421
- @classmethod
4422
- def check_lower(cls, value):
4423
- for item in value:
4424
- _UniffiConverterString.check_lower(item)
4425
-
4426
- @classmethod
4427
- def write(cls, value, buf):
4428
- items = len(value)
4429
- buf.write_i32(items)
4430
- for item in value:
4431
- _UniffiConverterString.write(item, buf)
4432
-
4433
- @classmethod
4434
- def read(cls, buf):
4435
- count = buf.read_i32()
4436
- if count < 0:
4437
- raise InternalError("Unexpected negative sequence length")
4438
-
4439
- return [
4440
- _UniffiConverterString.read(buf) for i in range(count)
4441
- ]
4442
-
4443
-
4444
-
4445
- class _UniffiConverterSequenceTypeBip21Extra(_UniffiConverterRustBuffer):
4446
- @classmethod
4447
- def check_lower(cls, value):
4448
- for item in value:
4449
- _UniffiConverterTypeBip21Extra.check_lower(item)
4450
-
4451
- @classmethod
4452
- def write(cls, value, buf):
4453
- items = len(value)
4454
- buf.write_i32(items)
4455
- for item in value:
4456
- _UniffiConverterTypeBip21Extra.write(item, buf)
4457
-
4458
- @classmethod
4459
- def read(cls, buf):
4460
- count = buf.read_i32()
4461
- if count < 0:
4462
- raise InternalError("Unexpected negative sequence length")
4463
-
4464
- return [
4465
- _UniffiConverterTypeBip21Extra.read(buf) for i in range(count)
4466
- ]
4467
-
4468
-
4469
-
4470
- class _UniffiConverterSequenceTypeBolt11RouteHint(_UniffiConverterRustBuffer):
4471
- @classmethod
4472
- def check_lower(cls, value):
4473
- for item in value:
4474
- _UniffiConverterTypeBolt11RouteHint.check_lower(item)
4475
-
4476
- @classmethod
4477
- def write(cls, value, buf):
4478
- items = len(value)
4479
- buf.write_i32(items)
4480
- for item in value:
4481
- _UniffiConverterTypeBolt11RouteHint.write(item, buf)
4482
-
4483
- @classmethod
4484
- def read(cls, buf):
4485
- count = buf.read_i32()
4486
- if count < 0:
4487
- raise InternalError("Unexpected negative sequence length")
4488
-
4489
- return [
4490
- _UniffiConverterTypeBolt11RouteHint.read(buf) for i in range(count)
4491
- ]
4492
-
4493
-
4494
-
4495
- class _UniffiConverterSequenceTypeBolt11RouteHintHop(_UniffiConverterRustBuffer):
4496
- @classmethod
4497
- def check_lower(cls, value):
4498
- for item in value:
4499
- _UniffiConverterTypeBolt11RouteHintHop.check_lower(item)
4500
-
4501
- @classmethod
4502
- def write(cls, value, buf):
4503
- items = len(value)
4504
- buf.write_i32(items)
4505
- for item in value:
4506
- _UniffiConverterTypeBolt11RouteHintHop.write(item, buf)
4507
-
4508
- @classmethod
4509
- def read(cls, buf):
4510
- count = buf.read_i32()
4511
- if count < 0:
4512
- raise InternalError("Unexpected negative sequence length")
4513
-
4514
- return [
4515
- _UniffiConverterTypeBolt11RouteHintHop.read(buf) for i in range(count)
4516
- ]
4517
-
4518
-
4519
-
4520
- class _UniffiConverterSequenceTypeBolt12OfferBlindedPath(_UniffiConverterRustBuffer):
4521
- @classmethod
4522
- def check_lower(cls, value):
4523
- for item in value:
4524
- _UniffiConverterTypeBolt12OfferBlindedPath.check_lower(item)
4525
-
4526
- @classmethod
4527
- def write(cls, value, buf):
4528
- items = len(value)
4529
- buf.write_i32(items)
4530
- for item in value:
4531
- _UniffiConverterTypeBolt12OfferBlindedPath.write(item, buf)
4532
-
4533
- @classmethod
4534
- def read(cls, buf):
4535
- count = buf.read_i32()
4536
- if count < 0:
4537
- raise InternalError("Unexpected negative sequence length")
4538
-
4539
- return [
4540
- _UniffiConverterTypeBolt12OfferBlindedPath.read(buf) for i in range(count)
4541
- ]
4542
-
4543
-
4544
-
4545
- class _UniffiConverterSequenceTypeLocaleOverrides(_UniffiConverterRustBuffer):
4546
- @classmethod
4547
- def check_lower(cls, value):
4548
- for item in value:
4549
- _UniffiConverterTypeLocaleOverrides.check_lower(item)
4550
-
4551
- @classmethod
4552
- def write(cls, value, buf):
4553
- items = len(value)
4554
- buf.write_i32(items)
4555
- for item in value:
4556
- _UniffiConverterTypeLocaleOverrides.write(item, buf)
4557
-
4558
- @classmethod
4559
- def read(cls, buf):
4560
- count = buf.read_i32()
4561
- if count < 0:
4562
- raise InternalError("Unexpected negative sequence length")
4563
-
4564
- return [
4565
- _UniffiConverterTypeLocaleOverrides.read(buf) for i in range(count)
4566
- ]
4567
-
4568
-
4569
-
4570
- class _UniffiConverterSequenceTypeLocalizedName(_UniffiConverterRustBuffer):
4571
- @classmethod
4572
- def check_lower(cls, value):
4573
- for item in value:
4574
- _UniffiConverterTypeLocalizedName.check_lower(item)
4575
-
4576
- @classmethod
4577
- def write(cls, value, buf):
4578
- items = len(value)
4579
- buf.write_i32(items)
4580
- for item in value:
4581
- _UniffiConverterTypeLocalizedName.write(item, buf)
4582
-
4583
- @classmethod
4584
- def read(cls, buf):
4585
- count = buf.read_i32()
4586
- if count < 0:
4587
- raise InternalError("Unexpected negative sequence length")
4588
-
4589
- return [
4590
- _UniffiConverterTypeLocalizedName.read(buf) for i in range(count)
4591
- ]
4592
-
4593
-
4594
-
4595
- class _UniffiConverterSequenceTypeInputType(_UniffiConverterRustBuffer):
4596
- @classmethod
4597
- def check_lower(cls, value):
4598
- for item in value:
4599
- _UniffiConverterTypeInputType.check_lower(item)
4600
-
4601
- @classmethod
4602
- def write(cls, value, buf):
4603
- items = len(value)
4604
- buf.write_i32(items)
4605
- for item in value:
4606
- _UniffiConverterTypeInputType.write(item, buf)
4607
-
4608
- @classmethod
4609
- def read(cls, buf):
4610
- count = buf.read_i32()
4611
- if count < 0:
4612
- raise InternalError("Unexpected negative sequence length")
4613
-
4614
- return [
4615
- _UniffiConverterTypeInputType.read(buf) for i in range(count)
4616
- ]
4617
-
4618
-
4619
-
4620
- class _UniffiConverterMapStringString(_UniffiConverterRustBuffer):
4621
- @classmethod
4622
- def check_lower(cls, items):
4623
- for (key, value) in items.items():
4624
- _UniffiConverterString.check_lower(key)
4625
- _UniffiConverterString.check_lower(value)
4626
-
4627
- @classmethod
4628
- def write(cls, items, buf):
4629
- buf.write_i32(len(items))
4630
- for (key, value) in items.items():
4631
- _UniffiConverterString.write(key, buf)
4632
- _UniffiConverterString.write(value, buf)
4633
-
4634
- @classmethod
4635
- def read(cls, buf):
4636
- count = buf.read_i32()
4637
- if count < 0:
4638
- raise InternalError("Unexpected negative map size")
4639
-
4640
- # It would be nice to use a dict comprehension,
4641
- # but in Python 3.7 and before the evaluation order is not according to spec,
4642
- # so we we're reading the value before the key.
4643
- # This loop makes the order explicit: first reading the key, then the value.
4644
- d = {}
4645
- for i in range(count):
4646
- key = _UniffiConverterString.read(buf)
4647
- val = _UniffiConverterString.read(buf)
4648
- d[key] = val
4649
- return d
4650
-
4651
- # Async support# RustFuturePoll values
4652
- _UNIFFI_RUST_FUTURE_POLL_READY = 0
4653
- _UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1
4654
-
4655
- # Stores futures for _uniffi_continuation_callback
4656
- _UniffiContinuationHandleMap = _UniffiHandleMap()
4657
-
4658
- _UNIFFI_GLOBAL_EVENT_LOOP = None
4659
-
4660
- """
4661
- Set the event loop to use for async functions
4662
-
4663
- This is needed if some async functions run outside of the eventloop, for example:
4664
- - A non-eventloop thread is spawned, maybe from `EventLoop.run_in_executor` or maybe from the
4665
- Rust code spawning its own thread.
4666
- - The Rust code calls an async callback method from a sync callback function, using something
4667
- like `pollster` to block on the async call.
4668
-
4669
- In this case, we need an event loop to run the Python async function, but there's no eventloop set
4670
- for the thread. Use `uniffi_set_event_loop` to force an eventloop to be used in this case.
4671
- """
4672
- def uniffi_set_event_loop(eventloop: asyncio.BaseEventLoop):
4673
- global _UNIFFI_GLOBAL_EVENT_LOOP
4674
- _UNIFFI_GLOBAL_EVENT_LOOP = eventloop
4675
-
4676
- def _uniffi_get_event_loop():
4677
- if _UNIFFI_GLOBAL_EVENT_LOOP is not None:
4678
- return _UNIFFI_GLOBAL_EVENT_LOOP
4679
- else:
4680
- return asyncio.get_running_loop()
4681
-
4682
- # Continuation callback for async functions
4683
- # lift the return value or error and resolve the future, causing the async function to resume.
4684
- @_UNIFFI_RUST_FUTURE_CONTINUATION_CALLBACK
4685
- def _uniffi_continuation_callback(future_ptr, poll_code):
4686
- (eventloop, future) = _UniffiContinuationHandleMap.remove(future_ptr)
4687
- eventloop.call_soon_threadsafe(_uniffi_set_future_result, future, poll_code)
4688
-
4689
- def _uniffi_set_future_result(future, poll_code):
4690
- if not future.cancelled():
4691
- future.set_result(poll_code)
4692
-
4693
- async def _uniffi_rust_call_async(rust_future, ffi_poll, ffi_complete, ffi_free, lift_func, error_ffi_converter):
4694
- try:
4695
- eventloop = _uniffi_get_event_loop()
4696
-
4697
- # Loop and poll until we see a _UNIFFI_RUST_FUTURE_POLL_READY value
4698
- while True:
4699
- future = eventloop.create_future()
4700
- ffi_poll(
4701
- rust_future,
4702
- _uniffi_continuation_callback,
4703
- _UniffiContinuationHandleMap.insert((eventloop, future)),
4704
- )
4705
- poll_code = await future
4706
- if poll_code == _UNIFFI_RUST_FUTURE_POLL_READY:
4707
- break
4708
-
4709
- return lift_func(
4710
- _uniffi_rust_call_with_error(error_ffi_converter, ffi_complete, rust_future)
4711
- )
4712
- finally:
4713
- ffi_free(rust_future)
4714
- def _uniffi_trait_interface_call_async(make_call, handle_success, handle_error):
4715
- async def make_call_and_call_callback():
4716
- try:
4717
- handle_success(await make_call())
4718
- except Exception as e:
4719
- print("UniFFI: Unhandled exception in trait interface call", file=sys.stderr)
4720
- traceback.print_exc(file=sys.stderr)
4721
- handle_error(
4722
- _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR,
4723
- _UniffiConverterString.lower(repr(e)),
4724
- )
4725
- eventloop = _uniffi_get_event_loop()
4726
- task = asyncio.run_coroutine_threadsafe(make_call_and_call_callback(), eventloop)
4727
- handle = _UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert((eventloop, task))
4728
- return _UniffiForeignFuture(handle, _uniffi_foreign_future_free)
4729
-
4730
- def _uniffi_trait_interface_call_async_with_error(make_call, handle_success, handle_error, error_type, lower_error):
4731
- async def make_call_and_call_callback():
4732
- try:
4733
- try:
4734
- handle_success(await make_call())
4735
- except error_type as e:
4736
- handle_error(
4737
- _UniffiRustCallStatus.CALL_ERROR,
4738
- lower_error(e),
4739
- )
4740
- except Exception as e:
4741
- print("UniFFI: Unhandled exception in trait interface call", file=sys.stderr)
4742
- traceback.print_exc(file=sys.stderr)
4743
- handle_error(
4744
- _UniffiRustCallStatus.CALL_UNEXPECTED_ERROR,
4745
- _UniffiConverterString.lower(repr(e)),
4746
- )
4747
- eventloop = _uniffi_get_event_loop()
4748
- task = asyncio.run_coroutine_threadsafe(make_call_and_call_callback(), eventloop)
4749
- handle = _UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.insert((eventloop, task))
4750
- return _UniffiForeignFuture(handle, _uniffi_foreign_future_free)
4751
-
4752
- _UNIFFI_FOREIGN_FUTURE_HANDLE_MAP = _UniffiHandleMap()
4753
-
4754
- @_UNIFFI_FOREIGN_FUTURE_FREE
4755
- def _uniffi_foreign_future_free(handle):
4756
- (eventloop, task) = _UNIFFI_FOREIGN_FUTURE_HANDLE_MAP.remove(handle)
4757
- eventloop.call_soon(_uniffi_foreign_future_do_free, task)
4758
-
4759
- def _uniffi_foreign_future_do_free(task):
4760
- if not task.done():
4761
- task.cancel()
4762
-
4763
- __all__ = [
4764
- "InternalError",
4765
- "AesSuccessActionDataResult",
4766
- "Amount",
4767
- "BitcoinNetwork",
4768
- "InputType",
4769
- "LnurlCallbackStatus",
4770
- "ServiceConnectivityError",
4771
- "SuccessAction",
4772
- "SuccessActionProcessed",
4773
- "AesSuccessActionData",
4774
- "AesSuccessActionDataDecrypted",
4775
- "Bip21Details",
4776
- "Bip21Extra",
4777
- "BitcoinAddressDetails",
4778
- "Bolt11Invoice",
4779
- "Bolt11InvoiceDetails",
4780
- "Bolt11RouteHint",
4781
- "Bolt11RouteHintHop",
4782
- "Bolt12Invoice",
4783
- "Bolt12InvoiceDetails",
4784
- "Bolt12InvoiceRequestDetails",
4785
- "Bolt12Offer",
4786
- "Bolt12OfferBlindedPath",
4787
- "Bolt12OfferDetails",
4788
- "CurrencyInfo",
4789
- "FiatCurrency",
4790
- "LightningAddressDetails",
4791
- "LnurlAuthRequestDetails",
4792
- "LnurlErrorDetails",
4793
- "LnurlPayRequestDetails",
4794
- "LnurlWithdrawRequestDetails",
4795
- "LocaleOverrides",
4796
- "LocalizedName",
4797
- "MessageSuccessActionData",
4798
- "PaymentRequestSource",
4799
- "Rate",
4800
- "RestResponse",
4801
- "SilentPaymentAddressDetails",
4802
- "Symbol",
4803
- "UrlSuccessActionData",
4804
- "RestClient",
4805
- ]
4806
-