# IBTCWalletSwap

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:30](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L30)

Interface for swaps requiring Bitcoin wallet interaction

## Methods

### estimateBitcoinFee()

```
estimateBitcoinFee(wallet, feeRate?): Promise<TokenAmount<BtcToken<false>>>;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:60](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L60)

Estimates a bitcoin on-chain fee paid for the bitcoin swap transaction

#### Parameters

| Parameter  | Type                                                                                                                                                                                                                                                                | Description                                      |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `wallet`   | \| [`IBitcoinWallet`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/interfaces/IBitcoinWallet.md) \| [`MinimalBitcoinWalletInterface`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/MinimalBitcoinWalletInterface.md) | Sender's bitcoin wallet                          |
| `feeRate?` | `number`                                                                                                                                                                                                                                                            | Optional fee rate in sats/vB for the transaction |

#### Returns

`Promise`<[`TokenAmount`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/TokenAmount.md)<[`BtcToken`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/BtcToken.md)<`false`>>>

***

### getFundedPsbt()

```
getFundedPsbt(

   _bitcoinWallet, 

   feeRate?, 

   additionalOutputs?): Promise<{

  psbt: Transaction;

  psbtBase64: string;

  psbtHex: string;

  signInputs: number[];

}>;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:41](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L41)

Returns the PSBT that is already funded with wallet's UTXOs (runs a coin-selection algorithm to choose UTXOs to use), also returns inputs indices that need to be signed by the wallet before submitting the PSBT back to the SDK with [submitPsbt](#submitpsbt)

#### Parameters

| Parameter            | Type                                                                                                                                                                                                                                                                | Description                                                                    |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| `_bitcoinWallet`     | \| [`IBitcoinWallet`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/interfaces/IBitcoinWallet.md) \| [`MinimalBitcoinWalletInterface`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/MinimalBitcoinWalletInterface.md) | Sender's bitcoin wallet                                                        |
| `feeRate?`           | `number`                                                                                                                                                                                                                                                            | Optional fee rate in sats/vB for the transaction                               |
| `additionalOutputs?` | ( \| { `amount`: `bigint`; `outputScript`: `Uint8Array`; } \| { `address`: `string`; `amount`: `bigint`; })\[]                                                                                                                                                      | additional outputs to add to the PSBT - can be used to collect fees from users |

#### Returns

`Promise`<{ `psbt`: `Transaction`; `psbtBase64`: `string`; `psbtHex`: `string`; `signInputs`: `number`\[]; }>

***

### getRequiredConfirmationsCount()

```
getRequiredConfirmationsCount(): number;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:91](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L91)

Returns the number of confirmations required for the bitcoin transaction for this swap to complete and settle

#### Returns

`number`

***

### sendBitcoinTransaction()

```
sendBitcoinTransaction(wallet, feeRate?): Promise<string>;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:68](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L68)

Sends a swap bitcoin transaction via the passed bitcoin wallet

#### Parameters

| Parameter  | Type                                                                                                                                                                                                                                                                                    | Description                                      |
| ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| `wallet`   | \| [`IBitcoinWallet`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/interfaces/IBitcoinWallet.md) \| [`MinimalBitcoinWalletInterfaceWithSigner`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/MinimalBitcoinWalletInterfaceWithSigner.md) | Sender's bitcoin wallet                          |
| `feeRate?` | `number`                                                                                                                                                                                                                                                                                | Optional fee rate in sats/vB for the transaction |

#### Returns

`Promise`<`string`>

***

### submitPsbt()

```
submitPsbt(psbt): Promise<string>;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:52](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L52)

Submits a PSBT signed by the wallet back to the SDK

#### Parameters

| Parameter | Type  | Description                                                                |
| --------- | ----- | -------------------------------------------------------------------------- |
| `psbt`    | `any` | A PSBT, either a Transaction object or a hex or base64 encoded PSBT string |

#### Returns

`Promise`<`string`>

***

### waitForBitcoinTransaction()

```
waitForBitcoinTransaction(

   updateCallback?, 

   checkIntervalSeconds?, 

abortSignal?): Promise<string>;
```

Defined in: [atomiq-sdk/src/swaps/IBTCWalletSwap.ts:81](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/swaps/IBTCWalletSwap.ts#L81)

Waits till the bitcoin transaction gets the required number of confirmations

#### Parameters

| Parameter               | Type                                                                      | Description                                                                       |
| ----------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `updateCallback?`       | (`txId?`, `confirmations?`, `targetConfirmations?`, `txEtaMs?`) => `void` | Callback called when txId is found, and also called with subsequent confirmations |
| `checkIntervalSeconds?` | `number`                                                                  | How often to check the bitcoin transaction                                        |
| `abortSignal?`          | `AbortSignal`                                                             | Abort signal                                                                      |

#### Returns

`Promise`<`string`>

#### Throws

if in invalid state
