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

13.0.0 #697

Merged
merged 19 commits into from
Oct 9, 2024
Merged

13.0.0 #697

merged 19 commits into from
Oct 9, 2024

Conversation

lisicky
Copy link
Contributor

@lisicky lisicky commented Oct 9, 2024

13.0.0

Serialization Changes:

  • Set Type Serialization: All set types are now serialized with a tag "258", which will become mandatory after the next hard fork (HF). There is no way to force serialization without the tag. The period between the current and the next era serves as a transition between the old CBOR format and the new CBOR format for sets.

  • Preservation of Original Transaction Bytes: Only the FixedTransaction type can preserve original transaction bytes. This is crucial when signing a transaction from a third party, as there is no guarantee that all CBOR types will be in a specific format.

  • Redeemers Collection Serialization: The redeemers collection is now serialized as a map by default. After the next HF, redeemers will only be allowed as a map.

API Changes:

  • New Function has_transaction_set_tag: We've added the has_transaction_set_tag function to help you check if all sets in a transaction have the tag. It returns TransactionSetsState based on the transaction's content. This is useful for determining whether a transaction can be signed by a hardware wallet. In the case of MixedSets, it might be impossible to sign a transaction with a hardware wallet. Once the tag "258" becomes mandatory, we will remove the has_transaction_set_tag function.

    enum TransactionSetsState {
        AllSetsHaveTag = 0,
        AllSetsHaveNoTag = 1,
        MixedSets = 2,
    }
  • Removal of hash_transaction: The hash_transaction function has been removed because it cannot guarantee the correctness of a transaction hash for a transaction from a third-party tool. Instead, you should use the FixedTransaction type.

    WARNING: If you need to sign a transaction from a third party, use the FixedTransaction type. Do not use the Transaction type, as it is not serialization round-trip safe and the transaction hash might be incorrect.

Examples:

  • Getting a Transaction Hash from a Third-Party Transaction:

    let transaction = FixedTransaction::from_hex("tx_hex")?; // Or use from_bytes if you have a byte array.
    let tx_hash = transaction.transaction_hash();
  • Getting a Transaction Hash from a Transaction from a Transaction Builder:

    let tx = tx_builder.build_tx()?;
    let transaction = FixedTransaction::from_bytes(tx.to_bytes())?; 
    let tx_hash = transaction.transaction_hash();
  • Getting a Transaction Hash from a Transaction Body from a Transaction Builder:

    let tx_body = tx_builder.build()?;
    let transaction = FixedTransaction::new_from_body_bytes(tx_body.to_bytes())?;
    let tx_hash = transaction.transaction_hash();
  • Signing a Transaction or Adding a Signature:

    let mut transaction = FixedTransaction::new_from(tx_body.to_bytes())?;
    transaction.add_vkey_witness(get_vkey_witness()); // To add an existing signature.
    transaction.sign_and_add_vkey_signature(get_private_key()); // To sign and add a signature with a private key.
    // You can also use:
    // .add_bootstrap_witness
    // .sign_and_add_icarus_bootstrap_signature
    // .sign_and_add_daedalus_bootstrap_signature

@lisicky lisicky requested a review from vsubhuman October 9, 2024 09:02
@vsubhuman vsubhuman added this to the 13.0.0 milestone Oct 9, 2024
Copy link
Contributor Author

@lisicky lisicky left a comment

Choose a reason for hiding this comment

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

/check

@lisicky lisicky merged commit 5fbfe14 into master Oct 9, 2024
5 checks passed
@lisicky lisicky deleted the evgenii/sets_and_tags branch October 9, 2024 09:40
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