-
Notifications
You must be signed in to change notification settings - Fork 2
/
models.py
104 lines (77 loc) · 1.96 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from sqlite3 import Row
from typing import Optional
from fastapi import Query
from pydantic import BaseModel
class CreateWallet(BaseModel):
masterpub: str = Query("")
title: str = Query("")
network: str = "Mainnet"
meta: str = "{}"
class WalletAccount(BaseModel):
id: str
masterpub: str
fingerprint: str
title: str
address_no: int
balance: int
type: Optional[str] = ""
network: str = "Mainnet"
meta: str = "{}"
@classmethod
def from_row(cls, row: Row) -> "WalletAccount":
return cls(**dict(row))
class Address(BaseModel):
id: str
address: str
wallet: str
amount: int = 0
branch_index: int = 0
address_index: int
note: Optional[str] = None
has_activity: bool = False
@classmethod
def from_row(cls, row: Row) -> "Address":
return cls(**dict(row))
class TransactionInput(BaseModel):
tx_id: str
vout: int
amount: int
address: str
branch_index: int
address_index: int
wallet: str
tx_hex: str
class TransactionOutput(BaseModel):
amount: int
address: str
branch_index: Optional[int] = None
address_index: Optional[int] = None
wallet: Optional[str] = None
class MasterPublicKey(BaseModel):
id: str
public_key: str
fingerprint: str
class CreatePsbt(BaseModel):
masterpubs: list[MasterPublicKey]
inputs: list[TransactionInput]
outputs: list[TransactionOutput]
fee_rate: int
tx_size: int
class SerializedTransaction(BaseModel):
tx_hex: str
class ExtractPsbt(BaseModel):
psbt_base64 = ""
inputs: list[SerializedTransaction]
network = "Mainnet"
class ExtractTx(BaseModel):
tx_hex = ""
network = "Mainnet"
class SignedTransaction(BaseModel):
tx_hex: Optional[str]
tx_json: Optional[str]
class Config(BaseModel):
mempool_endpoint = "https://mempool.space"
receive_gap_limit = 20
change_gap_limit = 5
sats_denominated = True
network = "Mainnet"