Skip to content

Commit

Permalink
Merge pull request #10 from andreasgriffin/added_classmethods
Browse files Browse the repository at this point in the history
Added more from_  class_methods
  • Loading branch information
andreasgriffin authored Jul 22, 2024
2 parents cb9c538 + 8ec5a02 commit 053134d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions bitcoin_qr_tools/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,26 @@ def from_binary(cls, raw: bytes, network) -> "Data":

raise DecodingException(f"{raw} Could not be decoded with from_binary") # type: ignore

@classmethod
def from_tx(cls, tx: bdk.Transaction) -> "Data":
assert isinstance(tx, bdk.Transaction)
return Data(tx, DataType.Tx)

@classmethod
def from_psbt(cls, psbt: bdk.PartiallySignedTransaction) -> "Data":
assert isinstance(psbt, bdk.PartiallySignedTransaction)
return Data(psbt, DataType.PSBT)

@classmethod
def from_descriptor(cls, descriptor: bdk.Descriptor) -> "Data":
assert isinstance(descriptor, bdk.Descriptor)
return Data(descriptor, DataType.Descriptor)

@classmethod
def from_multipath_descriptor(cls, multipath_descriptor: MultipathDescriptor) -> "Data":
assert isinstance(multipath_descriptor, MultipathDescriptor)
return Data(multipath_descriptor, DataType.MultiPathDescriptor)

@classmethod
def from_str(cls, s: str, network) -> "Data":
s = s.strip()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ disable_error_code = "assignment"

[tool.poetry]
name = "bitcoin-qr-tools"
version = "0.10.7"
version = "0.10.8"
authors = ["andreasgriffin <[email protected]>"]
license = "GPL-3.0"
readme = "README.md"
Expand Down

0 comments on commit 053134d

Please sign in to comment.