Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CIP 68 #47

Open
ripoff2 opened this issue Mar 18, 2023 · 3 comments
Open

Add support for CIP 68 #47

ripoff2 opened this issue Mar 18, 2023 · 3 comments

Comments

@ripoff2
Copy link

ripoff2 commented Mar 18, 2023

Hey, I got an error when trying to unmarshal cbor string to tx

Error: cannot unmarshal map into Go struct field cardano.rawTx.Body of type cardano.TxOutput (cannot decode CBOR map to struct with toarray option)

Here is cbor string: 84a50082825820b3578db07b274dd8d81012a16abe67f55f7d1698f1485623f5a5f46e3a93d40b018258202e01017ba4b9423f4bf55bc9ffbba26f1a5169e1fbef762ea923e730da4b037b000185a300583911d3f00c944c02e92d01373ba8401a0845ad9b2b98df54ad826c5858a25ea481523030b23a495286ca1a18bd141a493e9b5a19d889953f6cdb01821a002e0928a1581cfca746f58adf9f3da13b7227e5e2c6052f376447473f4d49f8004195a151000643b0436974697a656e20233834353401028201d81859019dd87983a7446e616d654d436974697a656e202338343534446f70656e4566616c73654566696c657382a3437372635835697066733a2f2f516d5842755158696a4450776a626853486d5a57454659534231576f46563171706e634d4d634170544553703148446e616d654d436974697a656e202338343534496d656469615479706549696d6167652f676966a3437372635835697066733a2f2f516d614843753641696f73484734697674456a665a6378684b7062464b7833384c64784758366750794d7477486b446e616d654850617373706f7274496d656469615479706549766964656f2f6d703445696d6167655835697066733a2f2f516d5842755158696a4450776a626853486d5a57454659534231576f46563171706e634d4d63417054455370314846476f6c64656e4566616c7365467374616d7073427b7d496d656469615479706549696d6167652f67696601d879860181581ce36f43a40751c35295b19a218301cc7be019d016e8927c0321fd28c7d87a80581cfca746f58adf9f3da13b7227e5e2c6052f376447473f4d49f8004195d87a80d87a80825839019f2c5d54d9cf8466e0109aec09ea58a5060fd75fcaf463cde64d08cd9e81f619476906491b519e3805c0e67e6ccaa6516052b7842d9081f21a11f4b5d082583901dfcb5f6c42f7529f31be82e0e68a75c2db94e425409770341011ef805ea481523030b23a495286ca1a18bd141a493e9b5a19d889953f6cdb1a008583b082583901dfd0594ef1f0f093e16a1c63f7cf76aeab68728b037d6a0945ff5fad2f4ad699c92ce6d1991dd05b64b6275dc3b714641db2b09cffefc830821a0012378ea1581cfca746f58adf9f3da13b7227e5e2c6052f376447473f4d49f8004195a151000de140436974697a656e2023383435340182583901dfd0594ef1f0f093e16a1c63f7cf76aeab68728b037d6a0945ff5fad2f4ad699c92ce6d1991dd05b64b6275dc3b714641db2b09cffefc8301a04caebbc021a00034201031a0536522109a1581cfca746f58adf9f3da13b7227e5e2c6052f376447473f4d49f8004195a251000643b0436974697a656e2023383435340151000de140436974697a656e20233834353401a0f5f6

@safanaj
Copy link

safanaj commented Apr 17, 2023

Hey @ripoff2 , looking at the cbor looks like it is a babbage tx with post alonzo body:

$ cardano-cli text-view decode-cbor --in-file x.json

84  # list(4)
   a5  # map(5)
       # key
      00  # int(0)
       # value
      82  # list(2)
         82  # list(2)
            58 20 b3 57 8d b0 7b 27 4d d8 d8 10 12 a1 6a be
            67 f5 5f 7d 16 98 f1 48 56 23 f5 a5 f4 6e 3a 93
            d4 0b  # bytes(32)
            01  # int(1)
         82  # list(2)
            58 20 2e 01 01 7b a4 b9 42 3f 4b f5 5b c9 ff bb
            a2 6f 1a 51 69 e1 fb ef 76 2e a9 23 e7 30 da 4b
            03 7b  # bytes(32)
            00  # int(0)
       # key
      01  # int(1)
       # value
      85  # list(5)
         a3  # map(3)
             # key
            00  # int(0)
             # value
            58 39 11 d3 f0 0c 94 4c 02 e9 2d 01 37 3b a8 40
            1a 08 45 ad 9b 2b 98 df 54 ad 82 6c 58 58 a2 5e
            a4 81 52 30 30 b2 3a 49 52 86 ca 1a 18 bd 14 1a
            49 3e 9b 5a 19 d8 89 95 3f 6c db  # bytes(57)
             # key
            01  # int(1)
             # value
            82  # list(2)
               1a 00 2e 09 28  # int(3017000)
               a1  # map(1)
                   # key
                  58 1c fc a7 46 f5 8a df 9f 3d a1 3b 72 27 e5 e2
                  c6 05 2f 37 64 47 47 3f 4d 49 f8 00 41 95  # bytes(28)
                   # value
                  a1  # map(1)
                      # key
                     51 00 06 43 b0 43 69 74 69 7a 65 6e 20 23 38 34
                     35 34  # bytes(17)
                      # value
                     01  # int(1)
             # key
            02  # int(2)
             # value
            82  # list(2)
               01  # int(1)
               d8 18  # tag(24)
                  59 01 9d d8 79 83 a7 44 6e 61 6d 65 4d 43 69 74
                  69 7a 65 6e 20 23 38 34 35 34 44 6f 70 65 6e 45
                  66 61 6c 73 65 45 66 69 6c 65 73 82 a3 43 73 72
                  63 58 35 69 70 66 73 3a 2f 2f 51 6d 58 42 75 51
                  58 69 6a 44 50 77 6a 62 68 53 48 6d 5a 57 45 46
                  59 53 42 31 57 6f 46 56 31 71 70 6e 63 4d 4d 63
                  41 70 54 45 53 70 31 48 44 6e 61 6d 65 4d 43 69
                  74 69 7a 65 6e 20 23 38 34 35 34 49 6d 65 64 69
                  61 54 79 70 65 49 69 6d 61 67 65 2f 67 69 66 a3
                  43 73 72 63 58 35 69 70 66 73 3a 2f 2f 51 6d 61
                  48 43 75 36 41 69 6f 73 48 47 34 69 76 74 45 6a
                  66 5a 63 78 68 4b 70 62 46 4b 78 33 38 4c 64 78
                  47 58 36 67 50 79 4d 74 77 48 6b 44 6e 61 6d 65
                  48 50 61 73 73 70 6f 72 74 49 6d 65 64 69 61 54
                  79 70 65 49 76 69 64 65 6f 2f 6d 70 34 45 69 6d
                  61 67 65 58 35 69 70 66 73 3a 2f 2f 51 6d 58 42
                  75 51 58 69 6a 44 50 77 6a 62 68 53 48 6d 5a 57
                  45 46 59 53 42 31 57 6f 46 56 31 71 70 6e 63 4d
                  4d 63 41 70 54 45 53 70 31 48 46 47 6f 6c 64 65
                  6e 45 66 61 6c 73 65 46 73 74 61 6d 70 73 42 7b
                  7d 49 6d 65 64 69 61 54 79 70 65 49 69 6d 61 67
                  65 2f 67 69 66 01 d8 79 86 01 81 58 1c e3 6f 43
                  a4 07 51 c3 52 95 b1 9a 21 83 01 cc 7b e0 19 d0
                  16 e8 92 7c 03 21 fd 28 c7 d8 7a 80 58 1c fc a7
                  46 f5 8a df 9f 3d a1 3b 72 27 e5 e2 c6 05 2f 37
                  64 47 47 3f 4d 49 f8 00 41 95 d8 7a 80 d8 7a 80  # bytes(413)
         82  # list(2)
            58 39 01 9f 2c 5d 54 d9 cf 84 66 e0 10 9a ec 09
            ea 58 a5 06 0f d7 5f ca f4 63 cd e6 4d 08 cd 9e
            81 f6 19 47 69 06 49 1b 51 9e 38 05 c0 e6 7e 6c
            ca a6 51 60 52 b7 84 2d 90 81 f2  # bytes(57)
            1a 11 f4 b5 d0  # int(301250000)
         82  # list(2)
            58 39 01 df cb 5f 6c 42 f7 52 9f 31 be 82 e0 e6
            8a 75 c2 db 94 e4 25 40 97 70 34 10 11 ef 80 5e
            a4 81 52 30 30 b2 3a 49 52 86 ca 1a 18 bd 14 1a
            49 3e 9b 5a 19 d8 89 95 3f 6c db  # bytes(57)
            1a 00 85 83 b0  # int(8750000)
         82  # list(2)
            58 39 01 df d0 59 4e f1 f0 f0 93 e1 6a 1c 63 f7
            cf 76 ae ab 68 72 8b 03 7d 6a 09 45 ff 5f ad 2f
            4a d6 99 c9 2c e6 d1 99 1d d0 5b 64 b6 27 5d c3
            b7 14 64 1d b2 b0 9c ff ef c8 30  # bytes(57)
            82  # list(2)
               1a 00 12 37 8e  # int(1193870)
               a1  # map(1)
                   # key
                  58 1c fc a7 46 f5 8a df 9f 3d a1 3b 72 27 e5 e2
                  c6 05 2f 37 64 47 47 3f 4d 49 f8 00 41 95  # bytes(28)
                   # value
                  a1  # map(1)
                      # key
                     51 00 0d e1 40 43 69 74 69 7a 65 6e 20 23 38 34
                     35 34  # bytes(17)
                      # value
                     01  # int(1)
         82  # list(2)
            58 39 01 df d0 59 4e f1 f0 f0 93 e1 6a 1c 63 f7
            cf 76 ae ab 68 72 8b 03 7d 6a 09 45 ff 5f ad 2f
            4a d6 99 c9 2c e6 d1 99 1d d0 5b 64 b6 27 5d c3
            b7 14 64 1d b2 b0 9c ff ef c8 30  # bytes(57)
            1a 04 ca eb bc  # int(80407484)
       # key
      02  # int(2)
       # value
      1a 00 03 42 01  # int(213505)
       # key
      03  # int(3)
       # value
      1a 05 36 52 21  # int(87446049)
       # key
      09  # int(9)
       # value
      a1  # map(1)
          # key
         58 1c fc a7 46 f5 8a df 9f 3d a1 3b 72 27 e5 e2
         c6 05 2f 37 64 47 47 3f 4d 49 f8 00 41 95  # bytes(28)
          # value
         a2  # map(2)
             # key
            51 00 06 43 b0 43 69 74 69 7a 65 6e 20 23 38 34
            35 34  # bytes(17)
             # value
            01  # int(1)
             # key
            51 00 0d e1 40 43 69 74 69 7a 65 6e 20 23 38 34
            35 34  # bytes(17)
             # value
            01  # int(1)
   a0  # map(0)
   f5  # bool(true)
   f6  # null

Notice the:

       # key
      01  # int(1)
       # value
      85  # list(5)
         a3  # map(3)

as per the CDDL here: https://github.com/input-output-hk/cardano-ledger/blob/master/eras/babbage/test-suite/cddl-files/babbage.cddl#L79
the TxOutput is in the post_alonzo_transaction_output format (a map) that is not supported in this library.
Just FYI I forked this project and will copy this issue in my repo to work on it. ( safanaj#1 )

@safanaj
Copy link

safanaj commented Apr 20, 2023

@ripoff2 just to let you know, using this https://github.com/safanaj/cardano-go/releases/tag/v0.1.18 the above transaction will be decoded, still that the CIP 68 is not fully managed as it is just proposed and I am not sure how to deal with hs details yet, but the TxOutput will contain the DatumOption with the inline datum as it is in the transaction.

@ripoff2
Copy link
Author

ripoff2 commented Apr 21, 2023

@safanaj thanks!

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

No branches or pull requests

2 participants