Skip to content

Commit

Permalink
Merge pull request #125 from bob-collective/feat/taproot-address
Browse files Browse the repository at this point in the history
Enable tweak signer for taproot address
  • Loading branch information
gregdhill authored Nov 26, 2024
2 parents 5699223 + 1a819bc commit 756bfe8
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-lobsters-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gobob/sats-wagmi": patch
---

Enable tweak signer for taproot address
2 changes: 1 addition & 1 deletion packages/sats-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3",
"@gobob/bob-sdk": "^3.0.3",
"@gobob/bob-sdk": "^3.1.0",
"@metamask/providers": "^12.0.0",
"@scure/base": "^1.1.6",
"@scure/btc-signer": "^1.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/sats-wagmi/src/connectors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ abstract class SatsConnector {
return this.ordinalsAddress;
}

/** Convience wrapper around the getAddressInfo function
/** Convenience wrapper around the getAddressInfo function
* @param address - The address to get the type of.
* @returns The address type of the address.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/sats-wagmi/src/connectors/okx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from 'bitcoin-address-validation';
import { AddressType, Network } from 'bitcoin-address-validation';

import { okxLogo } from '../assets/okx';

Expand Down Expand Up @@ -157,7 +157,7 @@ class OKXConnector extends SatsConnector {
return {
index,
publicKey,
disableTweakSigner: true
disableTweakSigner: this.getAddressType(this.paymentAddress!) !== AddressType.p2tr
};
});

Expand Down
9 changes: 7 additions & 2 deletions packages/sats-wagmi/src/connectors/unisat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from 'bitcoin-address-validation';
import { AddressType, Network } from 'bitcoin-address-validation';

import { bitgetLogo } from '../assets/bitget';

Expand Down Expand Up @@ -200,11 +200,16 @@ class UnisatConnector extends SatsConnector {
inputs.push(index);
}
}

if (!this.paymentAddress) {
throw new Error('No payment address specified');
}

const toSignInputs = inputs.map((index) => {
return {
index,
publicKey: this.publicKey,
disableTweakSigner: true
disableTweakSigner: this.getAddressType(this.paymentAddress!) !== AddressType.p2tr
};
});

Expand Down
14 changes: 2 additions & 12 deletions packages/sats-wagmi/src/hooks/useBalance.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { UseQueryOptions, useQuery } from '@tanstack/react-query';
import { EsploraClient } from '@gobob/bob-sdk';
import { getBalance } from '@gobob/bob-sdk';

import { useSatsWagmi } from '../provider';
import { INTERVAL } from '../utils';
Expand All @@ -23,17 +23,7 @@ const useBalance = (props: UseBalanceProps = {}) => {
enabled: Boolean(address),
queryKey: ['sats-balance', network, address],
refetchInterval: INTERVAL.SECONDS_30,
queryFn: async () => {
if (!address) {
return { confirmed: BigInt(0), unconfirmed: BigInt(0), total: BigInt(0) };
}

const esploraClient = new EsploraClient(network);

const { confirmed, unconfirmed, total } = await esploraClient.getBalance(address);

return { confirmed: BigInt(confirmed), unconfirmed: BigInt(unconfirmed), total: BigInt(total) };
},
queryFn: () => getBalance(address),
...props
});
};
Expand Down
50 changes: 25 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 756bfe8

Please sign in to comment.