0

I have just migrated to AndroidX (which may or may not be related to this issue). However, Network.usePublicNetwork(); is now showing a syntax error:

enter image description here

Below are my imports:

import org.stellar.sdk.AssetTypeNative;
import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Memo;
import org.stellar.sdk.Network;
import org.stellar.sdk.PaymentOperation;
import org.stellar.sdk.Server;
import org.stellar.sdk.responses.AccountResponse;
import org.stellar.sdk.responses.SubmitTransactionResponse;
2

I've tracked down the reason for this. The following is taken from the description for the 0.8.0 SDK release:

"Configure network at the transaction and server level rather than using a singleton to determine which network to use globally."

For server level, we already have this in place:

Server server = new Server("https://horizon.stellar.org");

At the transaction level there is now an additional argument passed, in this case Network.PUBLIC

Transaction.Builder(sourceAccount, Network.PUBLIC)

You can delete Network.usePublicNetwork();

NOTE:

When building your transaction, the followng may help:

publicKeyForSourceAccount is the public key string for the source account, and publicKeyForDestinationAccount is the public key string for the destination account.

AccountResponse sourceAccount = server.accounts().account(publicKeyForSourceAccount);

org.stellar.sdk.Transaction payment = new org.stellar.sdk.Transaction.Builder(sourceAccount, Network.PUBLIC)  //Have to use fully qualified name for Transaction as Firebase already has a Transaction import.
                        .addOperation(new PaymentOperation.Builder(publicKeyForDestinationAccount, new AssetTypeNative(), amount).build())
                        .addMemo(Memo.text("Create Room"))
                        .setTimeout(TIMEOUT_INFINITE)
                        .build();
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.