tfchain/TFChainWallet.py
def coins_send(self, recipient, amount, source=None, refund=None, lock=None, data=None):
        """
        Send the specified amount of coins to the given recipient,
        optionally locked. Arbitrary data can be attached as well if desired.

        If the given recipient is a valid ERC20 address, than this will send
        the specified amount to that ERC20 address and no lock or data is allowed to be defined.

        The recipient is one of:
            - None: recipient is the Free-For-All wallet
            - str (or unlockhash): recipient is a personal wallet
            - list: recipient is a MultiSig wallet where all owners (specified as a list of addresses) have to sign
            - tuple (addresses, sigcount): recipient is a sigcount-of-addresscount MultiSig wallet
            - an ERC20 address (str/ERC20Address), amount will be send to this ERC20 address

        The amount can be a str or an int:
            - when it is an int, you are defining the amount in the smallest unit (that is 1 == 0.000000001 TFT)
            - when defining as a str you can use the following space-stripped and case-insentive formats:
                - '123456789': same as when defining the amount as an int
                - '123.456': define the amount in TFT (that is '123.456' == 123.456 TFT == 123456000000)
                - '123456 TFT': define the amount in TFT (that is '123456 TFT' == 123456 TFT == 123456000000000)
                - '123.456 TFT': define the amount in TFT (that is '123.456 TFT' == 123.456 TFT == 123456000000)

        The lock can be a str, or int:
            - when it is an int it represents either a block height or an epoch timestamp (in seconds)
            - when a str it can be a Jumpscale Datetime (e.g. '12:00:10', '31/10/2012 12:30', ...) or a Jumpscale Duration (e.g. '+ 2h', '+7d12h', ...)

        Returns a TransactionSendResult.

        @param recipient: see explanation above
        @param amount: int or str that defines the amount of TFT to set, see explanation above
        @param source: one or multiple addresses/unlockhashes from which to fund this coin send transaction, by default all personal wallet addresses are used, only known addresses can be used
        @param refund: optional refund address, by default is uses the source if it specifies a single address otherwise it uses the default wallet address (recipient type, with None being the exception in its interpretation)
        @param lock: optional lock that can be used to lock the sent amount to a specific time or block height, see explation above
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        """
        if ERC20Address.is_valid_value(recipient):
            if lock is not None:
                raise ValueError("a lock cannot be applied when sending coins to an ERC20 Address")
            if data is not None:
                raise ValueError("data cannot be added to the transaction when sending coins to an ERC20 Address")
            # all good, try to send to the ERC20 address
            return self.erc20.coins_send(address=recipient, amount=amount, source=source, refund=refund)

        amount = Currency(value=amount)
        if amount <= 0:
            raise ValueError("no amount is defined to be sent")

        # define recipient
        recipient = ConditionTypes.from_recipient(recipient, lock=lock)

        # fund amount
        balance = self.balance
        miner_fee = self.client.minimum_miner_fee
        inputs, remainder, suggested_refund = balance.fund(amount+miner_fee, source=source)

        # define the refund condition
        if refund is None: # automatically choose a refund condition if none is given
            if suggested_refund is None:
                refund = ConditionTypes.unlockhash_new(unlockhash=self.address)
            else:
                refund = suggested_refund
        else:
            # use the given refund condition (defined as a recipient)
            refund = ConditionTypes.from_recipient(refund)

        # create transaction
        txn = tftransactions.new()
        # add main coin output
        txn.coin_output_add(value=amount, condition=recipient)
        # add refund coin output if needed
        if remainder > 0:
            txn.coin_output_add(value=remainder, condition=refund)
        # add the miner fee
        txn.miner_fee_add(miner_fee)

        # add the coin inputs
        txn.coin_inputs = inputs

        # if there is data to be added, add it as well
        if data:
            txn.data = data

        # generate the signature requests
        sig_requests = txn.signature_requests_new()
        if len(sig_requests) == 0:
            raise Exception("BUG: sig requests should not be empty at this point, please fix or report as an issue")

        # fulfill the signature requests that we can fulfill
        for request in sig_requests:
            try:
                key_pair = self.key_pair_get(request.wallet_address)
                input_hash = request.input_hash_new(public_key=key_pair.public_key)
                signature = key_pair.sign(input_hash)
                request.signature_fulfill(public_key=key_pair.public_key, signature=signature)
            except KeyError:
                pass # this is acceptable due to how we directly try the key_pair_get method

        # txn should be fulfilled now
        submit = txn.is_fulfilled()
        if submit:
            # submit the transaction
            txn.id = self._transaction_put(transaction=txn)

            # update balance
            for ci in txn.coin_inputs:
                balance.output_add(ci.parent_output, confirmed=False, spent=True)
            addresses = self.addresses + balance.addresses_multisig
            for idx, co in enumerate(txn.coin_outputs):
                if str(co.condition.unlockhash) in addresses:
                    # add the id to the coin_output, so we can track it has been spent
                    co.id = txn.coin_outputid_new(idx)
                    balance.output_add(co, confirmed=False, spent=False)
            # and return the created/submitted transaction for optional user consumption

        return TransactionSendResult(txn, submit)

        Send the specified amount of coins to the given recipient,
        optionally locked. Arbitrary data can be attached as well if desired.

        If the given recipient is a valid ERC20 address, than this will send
        the specified amount to that ERC20 address and no lock or data is allowed to be defined.

        The recipient is one of:
            - None: recipient is the Free-For-All wallet
            - str (or unlockhash): recipient is a personal wallet
            - list: recipient is a MultiSig wallet where all owners (specified as a list of addresses) have to sign
            - tuple (addresses, sigcount): recipient is a sigcount-of-addresscount MultiSig wallet
            - an ERC20 address (str/ERC20Address), amount will be send to this ERC20 address

        The amount can be a str or an int:
            - when it is an int, you are defining the amount in the smallest unit (that is 1 == 0.000000001 TFT)
            - when defining as a str you can use the following space-stripped and case-insentive formats:
                - '123456789': same as when defining the amount as an int
                - '123.456': define the amount in TFT (that is '123.456' == 123.456 TFT == 123456000000)
                - '123456 TFT': define the amount in TFT (that is '123456 TFT' == 123456 TFT == 123456000000000)
                - '123.456 TFT': define the amount in TFT (that is '123.456 TFT' == 123.456 TFT == 123456000000)

        The lock can be a str, or int:
            - when it is an int it represents either a block height or an epoch timestamp (in seconds)
            - when a str it can be a Jumpscale Datetime (e.g. '12:00:10', '31/10/2012 12:30', ...) or a Jumpscale Duration (e.g. '+ 2h', '+7d12h', ...)

        Returns a TransactionSendResult.

        @param recipient: see explanation above
        @param amount: int or str that defines the amount of TFT to set, see explanation above
        @param source: one or multiple addresses/unlockhashes from which to fund this coin send transaction, by default all personal wallet addresses are used, only known addresses can be used
        @param refund: optional refund address, by default is uses the source if it specifies a single address otherwise it uses the default wallet address (recipient type, with None being the exception in its interpretation)
        @param lock: optional lock that can be used to lock the sent amount to a specific time or block height, see explation above
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        
Send the specified amount of coins to the given recipient,
optionally locked. Arbitrary data can be attached as well if desired.

If the given recipient is a valid ERC20 address, than this will send
the specified amount to that ERC20 address and no lock or data is allowed to be defined.





The lock can be a str, or int:
when it is an int it represents either a block height or an epoch timestamp (in seconds)
when a str it can be a Jumpscale Datetime  or a Jumpscale Duration


Send the specified amount of coins to the given recipient optionally locked . Arbitrary data can be attached as well if desired . If the given recipient is a valid ERC20 address than this will send the specified amount to that ERC20 address and no lock or data is allowed to be defined . The lock can be a str or int : when it is an int it represents either a block height or an epoch timestamp ( in seconds ) when a str it can be a Jumpscale Datetime or a Jumpscale Duration
def coins_send(self, recipient, amount, source=None, refund=None, lock=None, data=None):
        if ERC20Address.is_valid_value(recipient):
            if lock is not None:
                raise ValueError("a lock cannot be applied when sending coins to an ERC20 Address")
            if data is not None:
                raise ValueError("data cannot be added to the transaction when sending coins to an ERC20 Address")
            return self.erc20.coins_send(address=recipient, amount=amount, source=source, refund=refund)
        amount = Currency(value=amount)
        if amount <= 0:
            raise ValueError("no amount is defined to be sent")
        recipient = ConditionTypes.from_recipient(recipient, lock=lock)
        balance = self.balance
        miner_fee = self.client.minimum_miner_fee
        inputs, remainder, suggested_refund = balance.fund(amount+miner_fee, source=source)
        if refund is None: 
            if suggested_refund is None:
                refund = ConditionTypes.unlockhash_new(unlockhash=self.address)
            else:
                refund = suggested_refund
        else:
            refund = ConditionTypes.from_recipient(refund)
        txn = tftransactions.new()
        txn.coin_output_add(value=amount, condition=recipient)
        if remainder > 0:
            txn.coin_output_add(value=remainder, condition=refund)
        txn.miner_fee_add(miner_fee)
        txn.coin_inputs = inputs
        if data:
            txn.data = data
        sig_requests = txn.signature_requests_new()
        if len(sig_requests) == 0:
            raise Exception("BUG: sig requests should not be empty at this point, please fix or report as an issue")
        for request in sig_requests:
            try:
                key_pair = self.key_pair_get(request.wallet_address)
                input_hash = request.input_hash_new(public_key=key_pair.public_key)
                signature = key_pair.sign(input_hash)
                request.signature_fulfill(public_key=key_pair.public_key, signature=signature)
            except KeyError:
                pass 
        submit = txn.is_fulfilled()
        if submit:
            txn.id = self._transaction_put(transaction=txn)
            for ci in txn.coin_inputs:
                balance.output_add(ci.parent_output, confirmed=False, spent=True)
            addresses = self.addresses + balance.addresses_multisig
            for idx, co in enumerate(txn.coin_outputs):
                if str(co.condition.unlockhash) in addresses:
                    co.id = txn.coin_outputid_new(idx)
                    balance.output_add(co, confirmed=False, spent=False)
        return TransactionSendResult(txn, submit)
def coins_send ( self , recipient , amount , source = None , refund = None , lock = None , data = None ) : if ERC20Address . is_valid_value ( recipient ) : if lock is not None : raise ValueError ( "a lock cannot be applied when sending coins to an ERC20 Address" ) if data is not None : raise ValueError ( "data cannot be added to the transaction when sending coins to an ERC20 Address" ) return self . erc20 . coins_send ( address = recipient , amount = amount , source = source , refund = refund ) amount = Currency ( value = amount ) if amount <= 0 : raise ValueError ( "no amount is defined to be sent" ) recipient = ConditionTypes . from_recipient ( recipient , lock = lock ) balance = self . balance miner_fee = self . client . minimum_miner_fee inputs , remainder , suggested_refund = balance . fund ( amount + miner_fee , source = source ) if refund is None : if suggested_refund is None : refund = ConditionTypes . unlockhash_new ( unlockhash = self . address ) else : refund = suggested_refund else : refund = ConditionTypes . from_recipient ( refund ) txn = tftransactions . new ( ) txn . coin_output_add ( value = amount , condition = recipient ) if remainder > 0 : txn . coin_output_add ( value = remainder , condition = refund ) txn . miner_fee_add ( miner_fee ) txn . coin_inputs = inputs if data : txn . data = data sig_requests = txn . signature_requests_new ( ) if len ( sig_requests ) == 0 : raise Exception ( "BUG: sig requests should not be empty at this point, please fix or report as an issue" ) for request in sig_requests : try : key_pair = self . key_pair_get ( request . wallet_address ) input_hash = request . input_hash_new ( public_key = key_pair . public_key ) signature = key_pair . sign ( input_hash ) request . signature_fulfill ( public_key = key_pair . public_key , signature = signature ) except KeyError : pass submit = txn . is_fulfilled ( ) if submit : txn . id = self . _transaction_put ( transaction = txn ) for ci in txn . coin_inputs : balance . output_add ( ci . parent_output , confirmed = False , spent = True ) addresses = self . addresses + balance . addresses_multisig for idx , co in enumerate ( txn . coin_outputs ) : if str ( co . condition . unlockhash ) in addresses : co . id = txn . coin_outputid_new ( idx ) balance . output_add ( co , confirmed = False , spent = False ) return TransactionSendResult ( txn , submit )
Send the specified amount of coins to the given recipient,
optionally locked.
Send the specified amount of coins to the given recipient optionally locked .
"""
        Send the specified amount of coins to the given recipient,
        optionally locked. Arbitrary data can be attached as well if desired.

        If the given recipient is a valid ERC20 address, than this will send
        the specified amount to that ERC20 address and no lock or data is allowed to be defined.

        The recipient is one of:
            - None: recipient is the Free-For-All wallet
            - str (or unlockhash): recipient is a personal wallet
            - list: recipient is a MultiSig wallet where all owners (specified as a list of addresses) have to sign
            - tuple (addresses, sigcount): recipient is a sigcount-of-addresscount MultiSig wallet
            - an ERC20 address (str/ERC20Address), amount will be send to this ERC20 address

        The amount can be a str or an int:
            - when it is an int, you are defining the amount in the smallest unit (that is 1 == 0.000000001 TFT)
            - when defining as a str you can use the following space-stripped and case-insentive formats:
                - '123456789': same as when defining the amount as an int
                - '123.456': define the amount in TFT (that is '123.456' == 123.456 TFT == 123456000000)
                - '123456 TFT': define the amount in TFT (that is '123456 TFT' == 123456 TFT == 123456000000000)
                - '123.456 TFT': define the amount in TFT (that is '123.456 TFT' == 123.456 TFT == 123456000000)

        The lock can be a str, or int:
            - when it is an int it represents either a block height or an epoch timestamp (in seconds)
            - when a str it can be a Jumpscale Datetime (e.g. '12:00:10', '31/10/2012 12:30', ...) or a Jumpscale Duration (e.g. '+ 2h', '+7d12h', ...)

        Returns a TransactionSendResult.

        @param recipient: see explanation above
        @param amount: int or str that defines the amount of TFT to set, see explanation above
        @param source: one or multiple addresses/unlockhashes from which to fund this coin send transaction, by default all personal wallet addresses are used, only known addresses can be used
        @param refund: optional refund address, by default is uses the source if it specifies a single address otherwise it uses the default wallet address (recipient type, with None being the exception in its interpretation)
        @param lock: optional lock that can be used to lock the sent amount to a specific time or block height, see explation above
        @param data: optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
        """ # all good, try to send to the ERC20 address # define recipient # fund amount # define the refund condition # automatically choose a refund condition if none is given # use the given refund condition (defined as a recipient) # create transaction # add main coin output # add refund coin output if needed # add the miner fee # add the coin inputs # if there is data to be added, add it as well # generate the signature requests # fulfill the signature requests that we can fulfill # this is acceptable due to how we directly try the key_pair_get method # txn should be fulfilled now # submit the transaction # update balance # add the id to the coin_output, so we can track it has been spent # and return the created/submitted transaction for optional user consumption
self
recipient
see explanation above
see explanation above
amount
int or str that defines the amount of TFT to set, see explanation above
int or str that defines the amount of TFT to set see explanation above
source
one or multiple addresses/unlockhashes from which to fund this coin send transaction, by default all personal wallet addresses are used, only known addresses can be used
one or multiple addresses / unlockhashes from which to fund this coin send transaction by default all personal wallet addresses are used only known addresses can be used
refund
optional refund address, by default is uses the source if it specifies a single address otherwise it uses the default wallet address (recipient type, with None being the exception in its interpretation)
optional refund address by default is uses the source if it specifies a single address otherwise it uses the default wallet address ( recipient type with None being the exception in its interpretation )
lock
optional lock that can be used to lock the sent amount to a specific time or block height, see explation above
optional lock that can be used to lock the sent amount to a specific time or block height see explation above
data
optional data that can be attached ot the sent transaction (str or bytes), with a max length of 83
optional data that can be attached ot the sent transaction ( str or bytes ) with a max length of 83