Code Monkey home page Code Monkey logo

Comments (4)

catch-21 avatar catch-21 commented on September 26, 2024

Hi @somereason thanks for raising. Is this reproducible? It would be useful to have the steps you took to construct the transaction.

from cardano-rosetta.

 avatar commented on September 26, 2024
   //cardano client lib
    @Test
    void calcTxHash() throws Exception {
        BigInteger fee = BigInteger.valueOf(200000);
        BigInteger inputAmount = BigInteger.valueOf(99600000);
        var bodyBuilder = new TransactionBody.TransactionBodyBuilder()
                .ttl(66000000)
                .inputs(List.of(new TransactionInput.TransactionInputBuilder()
                        .transactionId("607452ed1beaafd69df00cb3667dd393cea655a58686442c2d74914066486a20")
                        .index(0)
                        .build()))
                .outputs(List.of(new TransactionOutput.TransactionOutputBuilder()
                        .address(address)
                        .value(Value.builder()
                                .coin(inputAmount.subtract(fee))
                                .build())
                        .build()))
                .fee(fee);
        Transaction tx = Transaction.builder()
                .body(bodyBuilder.build())
                .auxiliaryData(AuxiliaryData.builder()
                        .metadata(new CBORMetadata().put(BigInteger.valueOf(1924), "hello world"))
                        .build())
                .build();
        tx = account.sign(tx);
        System.out.println(tx.getBody().getHash());
        Assertions.assertTrue(tx.getBody().getHash().equals("ed274c6e445d3b173956d788bd33acfe1fcafa18d7a2b9c0d89c2ffd465888b6"));
        System.out.println(HexUtil.encodeHexString(getRosettaBytes(tx.serializeToHex())));
    }

    public static byte[] getRosettaBytes(String signedTxn) throws CborException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        new CborEncoder(baos).encode(new CborBuilder()
                .addArray()
                .add(signedTxn)
                .addMap()
                .addKey("operation")
                .value("")
                .end()
                .end()
                .build());
        return baos.toByteArray();
    }

note: getRosettaBytes works fine under cardano-clinet-lib version 0.1.5 and cardano-rosetta 1.5.0, but now I'm using cardano-clinet-lib version 0.2.0-beta2 and cardano-roestta 1.7.0

from cardano-rosetta.

catch-21 avatar catch-21 commented on September 26, 2024

I couldn't say exactly the cause here because Rosetta is intended to be used with the construction workflow, see Flow of Operations. Perhaps this issue is related to deserialising a transaction with custom metadata.

from cardano-rosetta.

 avatar commented on September 26, 2024

I couldn't say exactly the cause here because Rosetta is intended to be used with the construction workflow, see Flow of Operations. Perhaps this issue is related to deserialising a transaction with custom metadata.

but this transaction has broadcasted. so it seems the hex is legal.

from cardano-rosetta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.