XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.21k stars 512 forks source link

atomical multiple transaction support? #839

Closed kws4679 closed 6 years ago

kws4679 commented 6 years ago

Hello!!

Is there any way to run multiple transactions atomically? For example, when payer send some XRP to the payee, at the same time payer should send XRP to other payee like fee. Those two transactions should be run atomically. It seems that there is a function name "combine" but for different purpose.

Thanks!!

MarkusTeufelberger commented 6 years ago

You might be able to simulate such a behaviour by creating multiple Escrow objects with the same preimage-SHA256 and releasing them once they are all on the ledger. Even if one EscrowRelease transaction fails, it would be easily possible for anyone on the network to eventually release the funds.

Sounds like a lot of work, fees and ledger spam to me though, depends on the use case of course.

intelliot commented 6 years ago

Hello @kws4679

For XRP specifically - no. You would need to do two separate transactions to send XRP to two different addresses. Of course, you could achieve this with an off-ledger system. For example, if you hosted your user's wallet, then you could deduct the fee from their balance on your own internal ledger/database.

@MarkusTeufelberger 's idea would work as well, depending on what you're trying to accomplish.

If your users are sending an issued asset (not XRP) on the ledger, then you can consider using Transfer Fees.

Hope that helps! Let us know if you have further questions.