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 descriptor support to createmultisig rpc #1171

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Vasu-08
Copy link
Contributor

@Vasu-08 Vasu-08 commented Aug 16, 2023

This pr adds descriptor support to createmultisig rpc.

@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.09% 🎉

Comparison is base (0c18028) 70.41% compared to head (77be48b) 70.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1171      +/-   ##
==========================================
+ Coverage   70.41%   70.51%   +0.09%     
==========================================
  Files         174      174              
  Lines       27515    27535      +20     
==========================================
+ Hits        19376    19416      +40     
+ Misses       8139     8119      -20     
Files Changed Coverage Δ
lib/descriptor/abstractdescriptor.js 92.68% <ø> (ø)
lib/descriptor/common.js 100.00% <100.00%> (ø)
lib/node/rpc.js 45.47% <100.00%> (+1.98%) ⬆️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Vasu-08 Vasu-08 changed the title Createmultisig rpc Add descriptor support to createmultisig rpc Aug 16, 2023
@Vasu-08 Vasu-08 force-pushed the createmultisig_rpc branch 3 times, most recently from d26e7c6 to 3599c13 Compare August 17, 2023 08:55
Copy link
Collaborator

@theanmolsharma theanmolsharma left a comment

Choose a reason for hiding this comment

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

Instead of creating a descriptor string and then parsing it and then generating address, do this.

  • Use the redeem script generated previously to generate address (based on outputType passed as arg).
  • Generated final descriptor string to be returned using string interpolation

Rationale: We are already generating the redeem script. Creating a descriptor just performs the same checks as Script.fromMultisig() which is unnecessary.

Comment on lines +2065 to +2069
let outputType = valid.str(2);

if (outputType === null) {
outputType = outputTypes.LEGACY;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let outputType = valid.str(2);
if (outputType === null) {
outputType = outputTypes.LEGACY;
}
const outputType = valid.str(2) ?? outputTypes.LEGACY;

'Redeem script exceeds size limit.');
}
const isWitness = outputType !== outputTypes.LEGACY;
const script = Script.fromMultisig(m, n, keys, false, isWitness);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const script = Script.fromMultisig(m, n, keys, false, isWitness);
const redeemScript = Script.fromMultisig(m, n, keys, false, isWitness);

Comment on lines +2106 to +2108
const subdesc = MultisigDescriptor.fromString(
`multi(${m},${keyString})`, this.network, context
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like this, but can't think of a better alternative atm

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.

None yet

2 participants