Skip to content
This repository was archived by the owner on Jul 17, 2023. It is now read-only.

Add signPsetV2 and blindPsetV2 to identities - #140

Open
altafan wants to merge 11 commits into
vulpemventures:masterfrom
altafan:psetv2
Open

altafan wants to merge 11 commits into
vulpemventures:masterfrom
altafan:psetv2

Conversation

@altafan

@altafan altafan commented Sep 2, 2022

Copy link
Copy Markdown
Contributor

This adds 2 new methods to identities signPsetV2 and blindPsetV2 to manage transactions with the new psetv2 format.

The base Identity type has a new function blindPsetV2WithSource that basically takes care of creating the xkp blinding generator either from a list of unblinded inputs, a master blinding key or a list of blinding private keys by giving priority in this exact order in case more than one source is defined.

NOTE: The method blindPsetV2 accepts an optional list of unblinded inputs that the user can pass in case he already unblinded them all. Otherwise the master key/list of blinding keys of the identity will be used to unblind the tx inputs if needed.

Closes #125.

Please @tiero @louisinger review.

@altafan
altafan requested a review from louisinger September 2, 2022 10:48
Comment thread src/identity/mnemonic.ts Outdated
Comment thread src/identity/identity.ts
Comment thread src/identity/mnemonic.ts Outdated
Comment thread src/identity/multisig.ts Outdated
@altafan

altafan commented Sep 20, 2022

Copy link
Copy Markdown
Contributor Author

@louisinger I merged new commits of master to this PR but now CI always fails with this min-relay-fee-not-met error in a test that I didn't touch at all. Can you check if I've messed up with something with my merge?

@altafan

altafan commented Sep 21, 2022 •

Copy link
Copy Markdown
Contributor Author

@tiero @louisinger I fixed the issues with tx estimation by making a little refactor of the core logic.

Note that at the moment the estimation assumes all inputs are of type p2wpkh | p2sh(p2wpkh), therefore I left a TODO with a brief description of what to do to be more generic and make an accurate estimation with all kind of (non-taproot) inputs.

Comment thread src/transaction.ts
Comment thread src/identity/mnemonic.ts
const signingKeyPair = ECPairFactory(this.ecclib).fromPrivateKey(
privateKeyBuffer
);
const preimage = pset.getInputPreimage(i, sighashType);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe here we should decode the script type? if is segwit v1 we should branch out, and at least if is a key-path spend try to make the schnorr signature necessary?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If not in this PR, at least let's throw an error that is not implemented in the case is a taproot output and/or input.tapLeafScript is present, so user knows can only signs segwit v0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Identity] Support psetv2

3 participants