Hi,
In my app, I need to create a "voucher" transaction that can be redeemed (published to the network) any time, in any order.
I know that it can be achieved by channels. The distributor creates a channel account for each "voucher" transaction. This channel account is then the source of the transaction for redeeming "voucher", and the voucher is valid as long as no one uses the same channel to publish transactions (bumping seq number).
In my case, there is one more limitation.
The distributor must not know the channel secret key. Therefore he can not create such channels upfront.
The channel secret key must be private to the user who is going to publish the transaction to the network. That way, he is sure that his "voucher" is always valid (no one can bump the seq number).
Everything would be great if not the fact, that channel is a stellar account, which must be funded by 1 XLM. Therefore two transactions must be submitted to the network. Which is unacceptable in my case. Everything must be contained in one "voucher" transaction. Here is an example:
const channelKeypair = StellarSdk.Keypair.random()
const channelPublicKey = sourceKeypair.publicKey();
const channelAccount = await server.loadAccount(sourcePublicKey);
const transaction = new StellarSdk.TransactionBuilder(channelAccount, {
fee,
networkPassphrase: StellarSdk.Networks.TESTNET
})
.addOperation(
StellarSdk.Operation.createAccount({
source: distributorPublicKey,
destination: channelPublicKey,
startingBalance: "1.00003"
})
)
.addOperation(
StellarSdk.Operation.payment({
source: distributorPublicKey,
destination: doesntReallyMatter,
asset: voucherToken,
amount: "1"
})
)
.addOperation(
StellarSdk.Operation.accountMerge({
destination: distributorPublicKey,
})
)
.build();
transaction.sign(channelKeypair);
requestDistributorSign(transaction);
// wait some time ...
server.submitTransaction(transaction)
Right now it won't work, since channelAccount is not created yet, even the fact that its creation op is contained in such transaction.
Is there any workaround? Or is it possible to see this functionality in the stellar-core update? Should I create issue in stellar-core repo ? I might not be the only one, who would make use of such feature.