in resdb_driver/transaction.py [0:0]
def create(cls, tx_signers, recipients, metadata=None, asset=None):
"""! A simple way to generate a `CREATE` transaction.
Note:
This method currently supports the following Cryptoconditions
use cases:
- Ed25519
- ThresholdSha256
Additionally, it provides support for the following Resdb
use cases:
- Multiple inputs and outputs.
@param tx_signers (:obj:`list` of :obj:`str`): A list of keys that
represent the signers of the CREATE Transaction.
@param recipients (:obj:`list` of :obj:`tuple`): A list of
([keys],amount) that represent the recipients of this
Transaction.
@param metadata (dict): The metadata to be stored along with the
Transaction.
@param asset (dict): The metadata associated with the asset that will
be created in this Transaction.
@return :class:`~resdb.transaction.Transaction`
"""
if not isinstance(tx_signers, list):
raise TypeError("`tx_signers` must be a list instance")
if not isinstance(recipients, list):
raise TypeError("`recipients` must be a list instance")
if len(tx_signers) == 0:
raise ValueError("`tx_signers` list cannot be empty")
if len(recipients) == 0:
raise ValueError("`recipients` list cannot be empty")
if not (asset is None or isinstance(asset, dict)):
raise TypeError("`asset` must be a dict or None")
inputs = []
outputs = []
# generate_outputs
for recipient in recipients:
if not isinstance(recipient, tuple) or len(recipient) != 2:
raise ValueError(
(
"Each `recipient` in the list must be a"
" tuple of `([<list of public keys>],"
" <amount>)`"
)
)
pub_keys, amount = recipient
outputs.append(Output.generate(pub_keys, amount))
# generate inputs
inputs.append(Input.generate(tx_signers))
return cls(cls.CREATE, {"data": asset}, inputs, outputs, metadata)