Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Prepare transaction offline with seed, send prepared tx to node without needing to invoke seed #228

Open
jo7399 opened this issue Aug 23, 2019 · 2 comments
Assignees
Labels

Comments

@jo7399
Copy link

jo7399 commented Aug 23, 2019

Currently working on a demo where i have a buyer and seller side. They communicate with http requests and whilst the buyer transfers to the sender the thought is that the buyer shouldn't need to make use of API calls whilst holding the seed for the funds he whishes to transfer. In Pyota I thought of creating a transaction with prepare_transfer on the buyer side, which is sent to the seller who then invokes send_trytes. But I have encountered the following issues:

  1. The buyer needs to invoke an API to prepare_transfer which I want to avoid.
  2. The seller needs to buyer's seed to attach the transaction to the tangle (i.e. to send_trytes, because for a value transaction the api needs the seed as an input) which is obvisouly undesireable. I guess one faces the same problem when using different functions/combinations of different functions.

Ideally I would like the buyer to propose/prepare a transfer with his/her seed and then the transfer is sent to the seller who sends the transaction to a node without requiring access to the buyers seed. From what I understand this would be possible in js: https://docs.iota.org/docs/getting-started/0.1/tutorials/send-iota-tokens

Any ideas how I can do this in python?

Thanks for anyone's help in advance. I'm very new to IOTA so I may well have overlooked something very basic

@todofixthis todofixthis self-assigned this Aug 23, 2019
@todofixthis
Copy link
Contributor

Hi @jo7399 I apologise that it has taken me so long to address this.

Unfortunately, PyOTA currently requires a connection to a node to complete the PoW process. #139 proposes to address this, but it has not been implemented yet.

Other than that, however, your thinking is correct — the buyer can prepare_transfer offline (a local IRI node is required, but it doesn't actually have to be connected to the Tangle; see docs for more info), and the seller can then use send_trytes to broadcast the signed transactions to the Tangle.

@lzpap
Copy link
Member

lzpap commented Oct 22, 2019

Hey @jo7399 , the PoW process can be done locally starting with PyOTA 2.1.0.

The buyer needs to invoke an API to prepare_transfer which I want to avoid.

prepare_transfer extended api command in PyOTA does call some API to ensure the prepared bundle is okay. Inside the command:

  • get_inputs is called if no inputs is provided to prepare_transfer
  • get_balance is called to check if the provided inputs have sufficient balance
  • get_new_addresses is called if you haven't provided change_address, that is the address where to send the remaining funds. (inputs - transferred amount = remaining funds)

The seller needs to buyer's seed to attach the transaction to the tangle (i.e. to send_trytes, because for a value transaction the api needs the seed as an input) which is obvisouly undesireable. I guess one faces the same problem when using different functions/combinations of different functions.

prepare_transfer does sign the inputs, the output of the call is a finalized bundle that is ready to be sent to send_trytes. During send_trytes, the following happens:

  • calling get_transactions_to_approve to get 2 tip transactions from an IOTA node.
  • calling attach_to_tangle to do proof of work. This can be done without a connection to a node, all you need to do is install PyOTA-PoW and specify local_pow argument see here.
  • calling broadcast_and_store to send the final trytes to the network.

I hope this clarifies the inner workings of the python lib and helps you to develop your prototype. Ping me if you need further help! :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants