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

[Split] partially colored #161

Merged
merged 28 commits into from
May 16, 2024
Merged

Conversation

shadowv0vshadow
Copy link
Collaborator

@shadowv0vshadow shadowv0vshadow commented Apr 1, 2024

Here are some examples for partially colored:

1. Fulled colored -> Partially colored example:
Vin[0]: 1000 Satoshis (colored with 1000 Atoms)
Vin[1]: 99999999999900 Satoshis

Vout[0]: 900 Satoshis (colored with 900 Atoms)
Vout[1]: 100000000000000 Satoshis (colored with 100 Atoms)
2. Partially colored ->  Fulled colored example:
Vin[0]: 1000 Satoshis (colored with 100 Atoms)
Vin[1]: 1000 Satoshis (colored with 900 Atoms)

Vout[0]: 1000 Satoshis (colored with 1000 Atoms)
Vout[1]: 1000 Satoshis (colored with 0 Atoms)
3. Split 1 token example:
Vin[0]: 1000 Satoshis (colored with 1000 Atoms)
Vin[1]:  546 Satoshis

Vout[0]: 999 Satoshis (colored with 999 Atoms)
Vout[1]: 547 Satoshis (colored with 1 Atoms)
4. Multiple Partially colored example:
Vin[0]: 1000 Satoshis (colored with 1000 Atoms and 1000 quarks)
Vin[1]: 900 Satoshis

Vout[0]: 900 Satoshis (colored with 900 Atoms and 900 quarks)
Vout[1]: 1000 Satoshis (colored with 100 Atoms and 100 quarks)

@shadowv0vshadow shadowv0vshadow changed the title Split utxo [Split] Partially colored Apr 1, 2024
@shadowv0vshadow shadowv0vshadow marked this pull request as ready for review April 1, 2024 18:12
@shadowv0vshadow
Copy link
Collaborator Author

This PR will activate on a specific height for the partial coloring feature, which allows the minimum coloring to be 1. This split does't involve fractional splitting. By using partial coloring, tokens can be split into a minimum of 1. This is sufficient for current needs. For partially colored UTXOs, merging will be attempted during transfer, using a FIFO for colored UTXOs. It only applies to Fungible Tokens (FTs) and doesn't apply to Non-Fungible Tokens (NFTs).

@hotbroker
Copy link

hotbroker commented Apr 6, 2024

image
typo?

@shadowv0vshadow shadowv0vshadow changed the title [Split] Partially colored [Split] partially colored Apr 6, 2024
@shadowv0vshadow
Copy link
Collaborator Author

Migration guide

1. API change

blockchain.scripthash.listunspent

FROM:

{
  "txid": "1f5db4cb0c72546cea7a027c403adda96767f0d6e45e75c237fc085a56eb29d7",
  "tx_hash": "1f5db4cb0c72546cea7a027c403adda96767f0d6e45e75c237fc085a56eb29d7",
  "index": 0,
  "tx_pos": 0,
  "vout": 0,
  "height": 2541154,
  "value": 1000,
  "atomicals": ["45515640773c53609a92a1023359bf9a0f864f8f8454c62f58682b3145a9a043i0"]
}

TO

{
  "txid": "1f5db4cb0c72546cea7a027c403adda96767f0d6e45e75c237fc085a56eb29d7",
  "tx_hash": "1f5db4cb0c72546cea7a027c403adda96767f0d6e45e75c237fc085a56eb29d7",
  "index": 0,
  "tx_pos": 0,
  "vout": 0,
  "height": 2541154,
  "value": 1000,
  "satvalue": 1000,
  "atomicals": {
      "45515640773c53609a92a1023359bf9a0f864f8f8454c62f58682b3145a9a043i0": 1000
  }
}

We must use the value in atomicals, It represents the actual value of this FT, and in some partially colored cases, the value of this FT may differ from the satoshi value of this UTXO.

We have retained the 'value' field for transitional adjustments. We will remove the 'value' field in subsequent updates to avoid unnecessary confusion.

blockchain.atomicals.listscripthash

The modifications are the same as those for blockchain.scripthash.listunspent, both targeting the atomicals field.

blockchain.scripthash.listunspent

The return content remains the same, it is important to note that the confirmed value now also represents the actual partially colored value.

blockchain.atomicals.get_ft_balances_scripthash

The return content remains the same, it is important to note that the confirmed value now also represents the actual partially colored value.

For example:

{
  "success": true,
  "response": {
    "balances": {"595522d778ec1f40e3068553ef5aef0ccb52c502786496c0882bb79818fa6db2i0": {
        "id": "595522d778ec1f40e3068553ef5aef0ccb52c502786496c0882bb79818fa6db2i0",
        "ticker": "amt",
        "confirmed": 1
      }
    }
  }
}

2. The partial coloring feature requires reindexing.

3. We have removed the validation check for 'cleanly_assigned' from blockchain.atomicals.validate and blockchain.transaction.broadcast. This is done to allow the partial coloring code to run more smoothly.

@atomicals
Copy link
Owner

This is very well done and thought out, thank you!

@hotbroker
Copy link

交易所和钱包的balance都沟通同步支持了吧?

@shadowv0vshadow shadowv0vshadow changed the base branch from master to develop April 11, 2024 07:31
@AlexV525 AlexV525 merged commit c17511f into atomicals:develop May 16, 2024
1 check passed
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.

4 participants