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

refactor(signing): support non-index zero input signing #4646

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

kyranjamie
Copy link
Collaborator

@kyranjamie kyranjamie commented Dec 5, 2023

Try out this version of Leather — download extension builds.

Closes #4620

Leather currently operates in a mode where addresses are reused. Users only have a single native segwit/taproot address per account. For a short while we were generating new addresses, per bitcoin privacy best practice, and built the signing logic it in a way to support this in future.

In refactoring the signing to work with Ledger via a unified API, I assumed the zero address index which broke this. This PR aims to fix this problem, by introducing a signing configuration, consisting of a derivation path and an input index. When creating the inscription transfer, we create this accompanying config, BitcoinSigningConfig[]. From this, we can then tell the signing function with which address index we need to sign the tx.

In order to not have to make changes in parts of the code where we do know transactions only need to be signed with the 0th index, I've written a function to make the config that assumes this.

Open to other ideas how we can do this. It's a shame in a way to have to have this accompanying metadata, but I can't think of any way we could otherwise know how to sign the tx at a later point in the tx signing flow.

@fbwoolf
Copy link
Contributor

fbwoolf commented Dec 6, 2023

Related to this issue? #4645

@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch 3 times, most recently from ff69170 to aa34d14 Compare December 6, 2023 16:39
@fbwoolf
Copy link
Contributor

fbwoolf commented Dec 7, 2023

@kyranjamie I tested your branch. I still get the error and see the wrong address in their app, maybe it is on their end so will comment on the issue.

@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch 2 times, most recently from b318f68 to bf9c35f Compare December 7, 2023 12:31
@kyranjamie kyranjamie marked this pull request as ready for review December 7, 2023 12:43
@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch from bf9c35f to fd5be9b Compare December 7, 2023 13:09
const signedOnlyIndexZeroPsbt =
'70736274ff01007b02000000020c9199d8079e6fe8a6c78ac9c4e0311c97c9fcdc8b5586c56d191b6d98c0035e0000000000ffffffff087168f5b929b37a27704d338aa9d0d3508a819f879c244ba12128f04a5b37ef0000000000ffffffff01c800000000000000160014a8113965cee4d5ffa2d9996a204866a58200131d000000000001011f6400000000000000160014a8113965cee4d5ffa2d9996a204866a58200131d220203fe21e3444109e30ff7d19da0f530c344cad2e35fbee89afb2413858e4a9d7aa5483045022100ea4c2a68f1032102ad2c73504096f5dbd63d242ccce8000aa9db1a0ce4c4c59402204269fdd3536697329ed9bffcf67e3584d2d3426f84bb004fe467286abe7b02d8010001011f6400000000000000160014a8113965cee4d5ffa2d9996a204866a58200131d0000';

test.describe('Sign PSBT', () => {
test.beforeEach(async ({ extensionId, globalPage, onboardingPage, page }) => {
await globalPage.setupAndUseApiCalls(extensionId);
await onboardingPage.signInWithTestAccount(extensionId);
await page.goto('https://leather.io');
await page.goto('localhost:3000');
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking this is intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, cc @fbwoolf

We just need a page to trigger the request from, better the local app than leather.io

Copy link
Contributor

Choose a reason for hiding this comment

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

I took from other rpc signing tests, so best to change there too?

Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

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

Code LGTM - didn't fully test the flow

Copy link
Contributor

@fbwoolf fbwoolf left a comment

Choose a reason for hiding this comment

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

Nice refactor. 👍

@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch 2 times, most recently from 6b892d7 to 420fb4f Compare December 8, 2023 08:28
@kyranjamie
Copy link
Collaborator Author

@314159265359879 any chance you can QA pre-merge?

@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch from 420fb4f to 18c9dc0 Compare December 8, 2023 09:39
@kyranjamie kyranjamie force-pushed the refactor/non-zero-signing-config branch 15 times, most recently from f0f3636 to 18c9dc0 Compare December 8, 2023 12:07
@kyranjamie kyranjamie added this pull request to the merge queue Dec 8, 2023
Merged via the queue into dev with commit d2edb18 Dec 8, 2023
52 checks passed
@kyranjamie kyranjamie deleted the refactor/non-zero-signing-config branch December 8, 2023 15:05
@markmhendrickson markmhendrickson linked an issue Dec 11, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants