-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ASSET-34] Add bitcoin network info (#39)
* ASSET-34 Update bitcoin address type Signed-off-by: jormal <jormal@naver.com> * ASSET-34 Add bitcoin network info Signed-off-by: jormal <jormal@naver.com> * ASSET-34 Update bitcoin asset info Signed-off-by: jormal <jormal@naver.com> * ASSET-34 Update version Signed-off-by: jormal <jormal@naver.com> --------- Signed-off-by: jormal <jormal@naver.com>
- Loading branch information
Showing
28 changed files
with
242 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.0.7 | ||
2.0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"contracts": [], | ||
"id": "unknown-bitcoin", | ||
"images": { | ||
"png128": true, | ||
"png256": true, | ||
"png32": true, | ||
"png64": true, | ||
"svg": true | ||
}, | ||
"name": "Unknown Bitcoin Asset", | ||
"references": [], | ||
"tags": [ | ||
"bitcoin" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Self | ||
|
||
from bitcoinlib.encoding import EncodingError | ||
from bitcoinlib.keys import deserialize_address | ||
|
||
from libraries.models.templates.str_model import StrModel | ||
|
||
|
||
class AddressBitcoin(StrModel): | ||
"""A constrained `str` for the Bitcoin address.""" | ||
|
||
@property | ||
def __deserialized_result(self) -> dict: | ||
"""The result from the deserialization the Bitcoin address.""" | ||
return deserialize_address(self.root) | ||
|
||
@property | ||
def public_key_hash(self) -> str: | ||
"""The public key hash of the Bitcoin address.""" | ||
return self.__deserialized_result.get("public_key_hash") | ||
|
||
@property | ||
def encoding_type(self) -> str: | ||
"""The encoding type of the Bitcoin address.""" | ||
return self.__deserialized_result.get("encoding") | ||
|
||
@property | ||
def script_type(self) -> str: | ||
"""The script type of the Bitcoin address.""" | ||
return self.__deserialized_result.get("script_type") | ||
|
||
def __eq__(self, other: Self | str) -> bool: | ||
match other: | ||
case AddressBitcoin(): | ||
return self.root.lower() == other.root.lower() | ||
case str(): | ||
return self.root.lower() == other.lower() | ||
case _: | ||
raise ValueError(f"Cannot compare {self} with {other}") | ||
|
||
def __lt__(self, other: Self) -> bool: | ||
return self.public_key_hash < other.public_key_hash | ||
|
||
def __hash__(self) -> int: | ||
return hash(self.public_key_hash) | ||
|
||
def validate_str(self) -> Self: | ||
try: | ||
return deserialize_address(self.root).get("address") | ||
except EncodingError: | ||
raise ValueError(f"Invalid Bitcoin address: {self.root}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"currency": { | ||
"address": "1111111111111111111114oLvT2", | ||
"decimals": 8, | ||
"id": "btc-0", | ||
"name": "Bitcoin", | ||
"symbol": "BTC" | ||
}, | ||
"engine": "bitcoin", | ||
"explorers": [], | ||
"id": "bitcoin-1", | ||
"images": { | ||
"png128": true, | ||
"png256": true, | ||
"png32": true, | ||
"png64": true, | ||
"svg": true | ||
}, | ||
"name": "Bitcoin Mainnet", | ||
"network": "mainnet", | ||
"tags": [ | ||
"bitcoin" | ||
], | ||
"unknownAssetId": "unknown-bitcoin" | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"currency": { | ||
"address": "1111111111111111111114oLvT2", | ||
"decimals": 8, | ||
"id": "btc-0", | ||
"name": "Bitcoin", | ||
"symbol": "BTC" | ||
}, | ||
"engine": "bitcoin", | ||
"explorers": [], | ||
"id": "bitcoin-2", | ||
"images": { | ||
"png128": true, | ||
"png256": true, | ||
"png32": true, | ||
"png64": true, | ||
"svg": true | ||
}, | ||
"name": "Bitcoin Testnet", | ||
"network": "testnet", | ||
"tags": [ | ||
"bitcoin" | ||
], | ||
"unknownAssetId": "unknown-bitcoin" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Specifies the essential requirements of the project. | ||
bitcoinlib>=0.6.15 | ||
build>=1.2.1 | ||
hexbytes>=0.3.1 | ||
pydantic>=2.5.3 | ||
web3>=6.14.0 | ||
build>=1.2.1 |