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

fix: override the original witnesses when sign transactions #107

Merged

Conversation

yangby-cryptape
Copy link
Contributor

@yangby-cryptape yangby-cryptape commented Mar 18, 2024

Issue

I'm working on a new type script, which requires its own witness.

But when I build a transaction with ckb_sdk::XxxUnlocker, the witness will be overridden.

  • When sign transactions, the method to handle witnesses are correct.

    // Put signature into witness
    let witness_data = witnesses[witness_idx].raw_data();
    let mut current_witness: WitnessArgs = if witness_data.is_empty() {
    WitnessArgs::default()
    } else {
    WitnessArgs::from_slice(witness_data.as_ref())?
    };
    current_witness = current_witness
    .as_builder()
    .lock(Some(signature).pack())
    .build();

  • But, when call the following code to prepare for sign transactions:

    if handler.build_transaction(&mut tx, script_group, context.as_ref())? {

    The original witnesses will be overridden.

I tested this patch with my project, it works!

@quake quake merged commit d68be13 into nervosnetwork:master Mar 18, 2024
10 checks passed
@yangby-cryptape yangby-cryptape deleted the bugfix/override-witnesses branch March 18, 2024 07:37
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