> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/bsv-code-academy/bsv-simple/simple-sdk/wallet-core.md).

# API Reference

`WalletCore` is the abstract base class that both `BrowserWallet` and `ServerWallet` extend. It provides wallet info, key derivation, payments, multi-output sends, and server wallet funding.

**Source:** `src/core/WalletCore.ts`

## Constructor

```typescript
constructor(identityKey: string, defaults?: Partial<WalletDefaults>)
```

| Parameter     | Type                      | Description                          |
| ------------- | ------------------------- | ------------------------------------ |
| `identityKey` | `string`                  | Compressed public key hex (66 chars) |
| `defaults`    | `Partial<WalletDefaults>` | Override default configuration       |

## Abstract Methods

### getClient()

```typescript
abstract getClient(): WalletInterface
```

Returns the underlying BSV SDK wallet client. Implemented by `BrowserWallet` (returns `WalletClient`) and `ServerWallet` (returns `ToolboxWallet`).

## Wallet Info

### getIdentityKey()

```typescript
getIdentityKey(): string
```

Returns the wallet's compressed public key hex string (66 characters).

### getAddress()

```typescript
getAddress(): string
```

Returns the P2PKH address derived from the identity key.

### getStatus()

```typescript
getStatus(): WalletStatus
```

**Returns:**

```typescript
{
  isConnected: boolean
  identityKey: string | null
  network: string
}
```

### getWalletInfo()

```typescript
getWalletInfo(): WalletInfo
```

**Returns:**

```typescript
{
  identityKey: string
  address: string
  network: string
  isConnected: boolean
}
```

## Key Derivation

### derivePublicKey()

```typescript
async derivePublicKey(
  protocolID: [SecurityLevel, string],
  keyID: string,
  counterparty?: string,
  forSelf?: boolean
): Promise<string>
```

Derive a public key for any protocol.

| Parameter      | Type                      | Default    | Description                                       |
| -------------- | ------------------------- | ---------- | ------------------------------------------------- |
| `protocolID`   | `[SecurityLevel, string]` | *required* | Protocol identifier (e.g., `[2, '3241645161d8']`) |
| `keyID`        | `string`                  | *required* | Key identifier (e.g., `'invoice-001'`)            |
| `counterparty` | `string`                  | `'anyone'` | Counterparty identity key                         |
| `forSelf`      | `boolean`                 | `false`    | Derive for self instead of counterparty           |

**Returns:** Compressed public key hex string.

### derivePaymentKey()

```typescript
async derivePaymentKey(counterparty: string, invoiceNumber?: string): Promise<string>
```

Derive a BRC-29 payment key. Uses protocol ID `[2, '3241645161d8']`.

| Parameter       | Type     | Default    | Description              |
| --------------- | -------- | ---------- | ------------------------ |
| `counterparty`  | `string` | *required* | Recipient's identity key |
| `invoiceNumber` | `string` | random     | Invoice/key identifier   |

**Returns:** Compressed public key hex string.

## Payments

### pay()

```typescript
async pay(options: PaymentOptions): Promise<TransactionResult>
```

Send a BRC-29 payment to a counterparty via `PeerPayClient.sendPayment()`. The payment is constructed and delivered to the recipient in a single call.

| Parameter             | Type     | Required | Description              |
| --------------------- | -------- | -------- | ------------------------ |
| `options.to`          | `string` | Yes      | Recipient's identity key |
| `options.satoshis`    | `number` | Yes      | Amount to send           |
| `options.memo`        | `string` | No       | Optional memo            |
| `options.description` | `string` | No       | Transaction description  |

**Returns:** [`TransactionResult`](/bsv-code-academy/bsv-simple/simple-sdk/wallet-core/types.md#transactionresult)

### send()

```typescript
async send(options: SendOptions): Promise<SendResult>
```

Create a transaction with multiple outputs of different types in a single transaction.

| Parameter             | Type               | Required | Description                    |
| --------------------- | ------------------ | -------- | ------------------------------ |
| `options.outputs`     | `SendOutputSpec[]` | Yes      | Array of output specifications |
| `options.description` | `string`           | No       | Transaction description        |

**Returns:** [`SendResult`](/bsv-code-academy/bsv-simple/simple-sdk/wallet-core/types.md#sendresult) (extends `TransactionResult` with `outputDetails`)

**Output routing rules:**

| `to` | `data` | Result                                                |
| ---- | ------ | ----------------------------------------------------- |
| Yes  | No     | **P2PKH** — Simple payment (`satoshis` required, > 0) |
| No   | Yes    | **OP\_RETURN** — Data inscription (`satoshis` = 0)    |
| Yes  | Yes    | **PushDrop** — Encrypted token (`satoshis` >= 1)      |
| No   | No     | Error                                                 |

**`SendOutputSpec` fields:**

| Field         | Type                                | Description                                                           |
| ------------- | ----------------------------------- | --------------------------------------------------------------------- |
| `to`          | `string?`                           | Recipient public key                                                  |
| `satoshis`    | `number?`                           | Amount (required for P2PKH, default 1 for PushDrop, 0 for OP\_RETURN) |
| `data`        | `(string \| object \| number[])[]?` | Data fields                                                           |
| `description` | `string?`                           | Output description                                                    |
| `basket`      | `string?`                           | Track in a basket                                                     |
| `protocolID`  | `[number, string]?`                 | PushDrop protocol ID                                                  |
| `keyID`       | `string?`                           | PushDrop key ID                                                       |

### fundServerWallet()

```typescript
async fundServerWallet(
  request: PaymentRequest,
  basket?: string
): Promise<TransactionResult>
```

Fund a `ServerWallet` using a BRC-29 derived payment.

| Parameter | Type             | Required | Description                                                |
| --------- | ---------------- | -------- | ---------------------------------------------------------- |
| `request` | `PaymentRequest` | Yes      | Payment request from `ServerWallet.createPaymentRequest()` |
| `basket`  | `string`         | No       | Track the funding output in a basket                       |

**Returns:** [`TransactionResult`](/bsv-code-academy/bsv-simple/simple-sdk/wallet-core/types.md#transactionresult)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hub.bsvblockchain.org/bsv-code-academy/bsv-simple/simple-sdk/wallet-core.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
