diff --git a/packages/sdk/src/browser-wallets/unisat/index.ts b/packages/sdk/src/browser-wallets/unisat/index.ts index 7044e662..86c35af1 100644 --- a/packages/sdk/src/browser-wallets/unisat/index.ts +++ b/packages/sdk/src/browser-wallets/unisat/index.ts @@ -1,3 +1,4 @@ -export * from "./addresses"; -export * from "./signatures"; -export * from "./utils"; +export * from "./addresses" +export * from "./signatures" +export * from "./types" +export * from "./utils" diff --git a/packages/sdk/src/browser-wallets/unisat/signatures.ts b/packages/sdk/src/browser-wallets/unisat/signatures.ts index 16d86d11..88634ea6 100644 --- a/packages/sdk/src/browser-wallets/unisat/signatures.ts +++ b/packages/sdk/src/browser-wallets/unisat/signatures.ts @@ -2,14 +2,14 @@ import { Psbt } from "bitcoinjs-lib"; import { isUnisatInstalled } from "./utils"; -export async function signPsbt(psbt: Psbt) { +export async function signPsbt(psbt: Psbt, { finalize = true }: UnisatSignPSBTOptions = {}) { if (!isUnisatInstalled()) { throw new Error("Unisat not installed."); } const psbtHex = psbt.toHex(); - const signedPsbtHex = await window.unisat.signPsbt(psbtHex); + const signedPsbtHex = await window.unisat.signPsbt(psbtHex, { autoFinalized: finalize }) if (!signedPsbtHex) { throw new Error("Failed to sign psbt hex using Unisat."); diff --git a/packages/sdk/src/browser-wallets/unisat/types.ts b/packages/sdk/src/browser-wallets/unisat/types.ts new file mode 100644 index 00000000..75e82759 --- /dev/null +++ b/packages/sdk/src/browser-wallets/unisat/types.ts @@ -0,0 +1,3 @@ +export interface UnisatSignPSBTOptions { + finalize?: boolean +} diff --git a/packages/sdk/src/types.d.ts b/packages/sdk/src/types.d.ts index ff658f32..d55f8a8b 100644 --- a/packages/sdk/src/types.d.ts +++ b/packages/sdk/src/types.d.ts @@ -1,19 +1,19 @@ declare interface Window { - unisat: Unisat; - satsConnect: any; - ethereum: MetaMask; + unisat: Unisat + satsConnect: any + ethereum: MetaMask } type Unisat = { - getNetwork: () => Promise; - switchNetwork: (targetNetwork: UnisatNetwork) => Promise; - requestAccounts: () => Promise; - getPublicKey: () => Promise; - signPsbt: (hex: string) => Promise; - signMessage: (message: string) => Promise; -}; + getNetwork: () => Promise + switchNetwork: (targetNetwork: UnisatNetwork) => Promise + requestAccounts: () => Promise + getPublicKey: () => Promise + signPsbt: (hex: string, { autoFinalized }: Record) => Promise + signMessage: (message: string) => Promise +} type MetaMask = { - isMetaMask: boolean; - request: (options: { method: string; params?: any }) => Promise; -}; + isMetaMask: boolean + request: (options: { method: string; params?: any }) => Promise +}