Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@overcat
Copy link
Member

@overcat overcat commented Jul 18, 2025

Transaction class.

package org.stellar.sdk;

import static java.nio.charset.StandardCharsets.UTF_8;

import java.util.Collections;
import org.stellar.sdk.operations.ManageDataOperation;
import org.stellar.sdk.responses.TransactionResponse;

public class Demo {
  public static void main(String[] args) {
    try (Server server = new Server("https://horizon-testnet.stellar.org")) {
      KeyPair masterKp =
          KeyPair.fromSecretSeed("SCZV7YTZVJY5GMUHBGSP6AHJMBHUH6SLANWIFQ7JUN6BYGK4YOLP3DIW");
      KeyPair extraSigner =
          KeyPair.fromSecretSeed("SBGQBSZDLS6QP23CC6CQXTRIIUOBSI6T6X6LHLRVUC7GDQMEIRPHG32H");
      TransactionBuilderAccount source = server.loadAccount(masterKp.getAccountId());

      TransactionPreconditions preconditions =
          TransactionPreconditions.builder()
              .extraSigners(
                  Collections.singletonList(
                      SignerKey.fromEd25519SignedPayload(
                          extraSigner.getAccountId(), "Hello, World!".getBytes(UTF_8))))
              .build();
      Transaction tx =
          new TransactionBuilder(source, Network.TESTNET)
              .setBaseFee(100)
              .setTimeout(300)
              .addPreconditions(preconditions)
              .addOperation(
                  ManageDataOperation.builder()
                      .name("hello")
                      .value("world".getBytes(UTF_8))
                      .build())
              .build();

      tx.sign(masterKp);
      tx.signExtraSignersPayload(extraSigner); // Sign the extra signers payload
      try {
        TransactionResponse response = server.submitTransaction(tx);
        System.out.println("Transaction successful: " + response.getHash());
      } catch (Exception e) {
        System.err.println("Transaction failed: " + e.getMessage());
      }
    }
  }
}

@codecov
Copy link

codecov bot commented Jul 18, 2025

Codecov Report

Attention: Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.76%. Comparing base (2c3b28e) to head (c02bff2).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/main/java/org/stellar/sdk/Transaction.java 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #713      +/-   ##
============================================
+ Coverage     80.74%   80.76%   +0.02%     
- Complexity     1294     1300       +6     
============================================
  Files           214      214              
  Lines          5052     5065      +13     
  Branches        425      429       +4     
============================================
+ Hits           4079     4091      +12     
  Misses          715      715              
- Partials        258      259       +1     
Files with missing lines Coverage Δ
src/main/java/org/stellar/sdk/Transaction.java 93.75% <92.30%> (-0.13%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@overcat overcat enabled auto-merge (squash) July 19, 2025 01:18
@overcat overcat merged commit 7137834 into master Jul 19, 2025
9 checks passed
@overcat overcat deleted the feat/sign-signed-payload branch July 19, 2025 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants