diff --git a/defichain/transactions/builder/modules/utxo.py b/defichain/transactions/builder/modules/utxo.py index bd4c62bf..4ba1ae3a 100644 --- a/defichain/transactions/builder/modules/utxo.py +++ b/defichain/transactions/builder/modules/utxo.py @@ -5,30 +5,44 @@ class UTXO: + """ + **The methods of this module are responsible for sending UTXO to different addresses.** + + You can do that three on different ways: + + 1. send: send just one specified amount from the builder address to another address + + 2. sendall: send all utxo from the builder address to another address + + 3. sendmany: send specified amounts from the builder address to multiple different addresses. + """ def __init__(self, builder): self._builder: RawTransactionBuilder = builder - def send(self, value: "float | int", addressTo: str, changeAddress: str = None, inputs=[]) -> Transaction: + def send(self, amount: "float | int", addressTo: str, changeAddress: str = None, inputs=[]) -> Transaction: """ - Sends the specified amount of UTXO to the specified address. Returns the remaining UTXO from the input to the - sender address if not changed. + Sends the specified amount of UTXO to the specified address. - :param value: (required) amount of UTXO to send - :type value: float | int + Returns the remaining UTXO from the input to the sender address if not changed. + + >>> builder.utxo.send(1, "df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e") # sends one UTXO DFI to the specified address + + :param amount: (required) amount of UTXO to send + :type amount: float | int :param addressTo: (required) address to send the UTXO to :type addressTo: str :param changeAddress: (optional) address to which the remaining UTXO should be sent :type changeAddress: str :param inputs: (optional) Inputs - :type inputs: TxInputs + :type inputs: TxInput :return: Transaction """ if changeAddress is None: changeAddress = self._builder.get_address() # Convert Float to Integer - value = Converter.float_to_int(value) + value = Converter.float_to_int(amount) # If to_address is the same as account address if addressTo == self._builder.get_address() or addressTo == changeAddress: @@ -59,6 +73,8 @@ def sendall(self, addressTo: str, inputs=[]) -> Transaction: """ Sends all UTXO to the specified address + >>> builder.utxo.sendall("df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e") # sends all UTXO DFI to the specified address + :param addressTo: (required) address to send the UTXO to :type addressTo: str :param inputs: (optional) Inputs @@ -87,8 +103,10 @@ def sendmany(self, addressAmountTo: {}, changeAddress=None, inputs=[]) -> Transa Sends the specified amount of UTXO to the specified addresses. Returns the remaining UTXO from the input to the sender address if not changed. - :param addressAmountTo: (required) AddressAmount - :type addressAmountTo: json string + >>> builder.utxo.sendmany({"df1qw8c57c3c4u7k2h4gv2d5x4jr4qgq6cugg33g6e": "1@DFI", "df1qzfwy63ggj5jfpul7r04kn2ss8kjz2sda57fa4m": "1@DFI"}) # sends each address one UTXO DFI + + :param addressAmountTo: (required) json with specified address and amount to send + :type addressAmountTo: :ref:`Transactions AddressAmount` :param changeAddress: (required) address to which the remaining UTXO should be sent :type changeAddress: str :param inputs: (optional) Inputs diff --git a/defichain/transactions/builder/txbuilder.py b/defichain/transactions/builder/txbuilder.py index 015a2ff4..7dae4c4f 100644 --- a/defichain/transactions/builder/txbuilder.py +++ b/defichain/transactions/builder/txbuilder.py @@ -2,7 +2,6 @@ from defichain.exceptions.transactions import TxBuilderError -from defichain.transactions.remotedata.remotedata import RemoteData from defichain.transactions.remotedata import RemoteDataOcean, RemoteDataNode from .rawtransactionbuilder import RawTransactionBuilder diff --git a/docs/source/sdk/transactions/index.rst b/docs/source/sdk/transactions/index.rst index be8c4160..085046a5 100644 --- a/docs/source/sdk/transactions/index.rst +++ b/docs/source/sdk/transactions/index.rst @@ -13,4 +13,9 @@ Transactions :maxdepth: 1 :hidden: - exceptions \ No newline at end of file + exceptions + +.. _Transactions AddressAmount: + +AddressAmount +-------------