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

Change transaction struct [Change inputs output to list] #151

Merged

Conversation

shadowv0vshadow
Copy link
Collaborator

And add is_cleanly_assigned into res struct

@atomicals
Copy link
Owner

Can you please paste a before and after sample in the comment above please?

@atomicals
Copy link
Owner

If something has is_cleanly_assigned=false and it's NOT burned. because they just got merged, then will is_burned be correctly still set to false?

@shadowv0vshadow
Copy link
Collaborator Author

shadowv0vshadow commented Mar 22, 2024

I found a bug in #150

Before this, I had been using a dictionary in the code for transaction detail to return the index of a certain input or output. However, I overlooked one thing, which is that NFTs/FTs can actually be merged in the same single UTXO. So, there is a need to modify the structure to make a single UTXO contain multiple atomicals of assets. Therefore, the structure of the interface's return is modified to a list.
And here are some examples, after code fix, struct change:

Merge FTs, txid: dbe6c961e1182fd0f6704ad1d592952db77b841e64c788662f25b7d57882cc3e

{
  "success": true,
  "response": {
    "op": "transfer",
    "txid": "dbe6c961e1182fd0f6704ad1d592952db77b841e64c788662f25b7d57882cc3e",
    "height": 824642,
    "tx_num": 948609236,
    "info": {},
    "transfers": {
      "inputs": {
        "4": [
          {
            "address": "bc1q0c5aru88dtcq86ahnv09k392wnkdawkmzkxnav",
            "atomical_id": "9ba68637ba32edb6370bebceaac3df4341180cbf7bac210741b12a679692d716i0",
            "type": "FT",
            "index": 4,
            "value": 600
          },
          {
            "address": "bc1q0c5aru88dtcq86ahnv09k392wnkdawkmzkxnav",
            "atomical_id": "56a8702bab3d2405eb9a356fd0725ca112a93a8efd1ecca06c6085e7278f0341i0",
            "type": "FT",
            "index": 4,
            "value": 600
          }
        ]
      },
      "outputs": {
        "0": [
          {
            "address": "bc1q0c5aru88dtcq86ahnv09k392wnkdawkmzkxnav",
            "atomical_id": "9ba68637ba32edb6370bebceaac3df4341180cbf7bac210741b12a679692d716i0",
            "type": "FT",
            "index": 0,
            "value": 600
          },
          {
            "address": "bc1q0c5aru88dtcq86ahnv09k392wnkdawkmzkxnav",
            "atomical_id": "56a8702bab3d2405eb9a356fd0725ca112a93a8efd1ecca06c6085e7278f0341i0",
            "type": "FT",
            "index": 0,
            "value": 600
          }
        ]
      },
      "is_burned": false,
      "burned_fts": {},
      "is_cleanly_assigned": true
    }
  }
}

Merge NFTs: a10aa0f95d5ead4ad96b8060b91e5105fb5ebed89222b15ae7bca04546f606b2
It would be return like this:

{
  "success": true,
  "response": {
    "op": "transfer",
    "txid": "a10aa0f95d5ead4ad96b8060b91e5105fb5ebed89222b15ae7bca04546f606b2",
    "height": 822867,
    "tx_num": 942235266,
    "info": {},
    "transfers": {
      "inputs": {
        "0": [
          {
            "address": "bc1pnef29aqvc4tv4sxyed4ae6n7ej0f3s8arx3z337980a7yxzvf8tsd4g0fg",
            "atomical_id": "b1d0b1058b99346226b72bdae4366704ccd98b3fd3d6c023461dad3e0df88000i0",
            "type": "NFT",
            "index": 0,
            "value": 29000
          },
          {
            "address": "bc1pnef29aqvc4tv4sxyed4ae6n7ej0f3s8arx3z337980a7yxzvf8tsd4g0fg",
            "atomical_id": "b1d0cfb9c9dfdc6663589da87efe3e96458236be5521cc4bdbbefaa8384dc500i0",
            "type": "NFT",
            "index": 0,
            "value": 29000
          },
          {
            "address": "bc1pnef29aqvc4tv4sxyed4ae6n7ej0f3s8arx3z337980a7yxzvf8tsd4g0fg",
            "atomical_id": "b1d06870fd0d2801c98a49bdfd44098255fca0f3653248416df3e6eecb2e5b05i0",
            "type": "NFT",
            "index": 0,
            "value": 29000
          },
      ...
      },
      "is_burned": true,
      "burned_fts": {
        "9125f03bcf9325f6071762b9aee00b461a0b43ed157c336e2e89e07f47ea6f66i0": 20000.0,
        "d4c48c4db504282e987776cba26f78fbc1573460a02c45d9e5de37c5b13ef751i0": 5000.0
      },
      "is_cleanly_assigned": false
    }
  }
}

Copy link
Owner

@atomicals atomicals left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, ready to merge.

@atomicals atomicals merged commit fc4a41e into atomicals:master Mar 23, 2024
1 check failed
@shadowv0vshadow shadowv0vshadow deleted the change-transaction-struct branch March 23, 2024 00:56
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