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

Enable taproot address #408

Merged
merged 27 commits into from
Nov 20, 2024
Merged

Enable taproot address #408

merged 27 commits into from
Nov 20, 2024

Conversation

slavastartsev
Copy link
Contributor

No description provided.

Copy link

changeset-bot bot commented Nov 7, 2024

⚠️ No Changeset found

Latest commit: 4ba6d93

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bob ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 19, 2024 1:55pm

sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@gregdhill gregdhill left a comment

Choose a reason for hiding this comment

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

Some test cases would be good please :)

sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
sdk/src/wallet/utxo.ts Show resolved Hide resolved
sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
@slavastartsev
Copy link
Contributor Author

slavastartsev commented Nov 7, 2024

Some test cases would be good please :)

Tests will be added updated

sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
sdk/src/wallet/utxo.ts Show resolved Hide resolved
sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
sdk/src/wallet/utxo.ts Outdated Show resolved Hide resolved
Comment on lines +9 to +16
vi.mock(import('@scure/btc-signer'), async (importOriginal) => {
const actual = await importOriginal();

return {
...actual,
selectUTXO: vi.fn(actual.selectUTXO),
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of this?

Copy link
Contributor Author

@slavastartsev slavastartsev Nov 19, 2024

Choose a reason for hiding this comment

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

it allows us to check what arguments it was called with.

  • vi.fn - mock/spy function
  • actual.selectUTXO - original function implementation

so when it will be called it will run the same code + we can spy on arguments/errors/return values

const maxSpendableBalance = cardinalOutputs.reduce((acc, output) => acc + output.value, 0);

// spend 90% of max spendable amount
await createBitcoinPsbt(paymentAddress, paymentAddress, Math.floor(maxSpendableBalance * 0.9), pubkey);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should check this fails, check the balance of the address including ordinals, try to create the UTXO and check it throws an error that the account has insufficient balance. I think this test is not really doing anything useful right now since we're checking only the cardinal balance.

Copy link
Contributor Author

@slavastartsev slavastartsev Nov 19, 2024

Choose a reason for hiding this comment

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

This test is checking that when we create psbt none of the possible inputs contains inscriptions -- @sander2 wanted that to be tested.

I've added a test that checks if it throws an error if we try to spend max balance including ordinals. I think this new test is more general and works (throws) with all types of addresses, not just p2tr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm actually yeah you are right that this test is still valid

@gregdhill gregdhill merged commit 97b4080 into master Nov 20, 2024
5 checks passed
@gregdhill gregdhill deleted the feat/taproot-address branch November 20, 2024 09:51
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.

4 participants