From c3fff7bc580ba3cb526a1de1fae4ec3085912abc Mon Sep 17 00:00:00 2001 From: Josh Scanlan Date: Wed, 22 Jul 2026 12:56:58 -0700 Subject: [PATCH 1/2] adds tee support --- packages/@magic-ext/bitcoin/src/index.ts | 25 ++++++++++++++++++++---- packages/@magic-ext/bitcoin/src/types.ts | 25 ++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/packages/@magic-ext/bitcoin/src/index.ts b/packages/@magic-ext/bitcoin/src/index.ts index 0f7360c31..cd5735539 100644 --- a/packages/@magic-ext/bitcoin/src/index.ts +++ b/packages/@magic-ext/bitcoin/src/index.ts @@ -1,5 +1,13 @@ import { MultichainExtension } from '@magic-sdk/provider'; -import { BitcoinConfig, BitcoinPayloadMethod } from './types'; +import { + BitcoinConfig, + BitcoinPayloadMethod, + BitcoinSignedTransaction, + BitcoinTransactionInput, + BitcoinTransactionOutput, +} from './types'; + +export * from './types'; export class BitcoinExtension extends MultichainExtension<'bitcoin'> { name = 'bitcoin' as const; @@ -14,9 +22,18 @@ export class BitcoinExtension extends MultichainExtension<'bitcoin'> { }); } - public async signTransaction(txn: string, inputIndex: number) { - return this.request( - this.utils.createJsonRpcRequestPayload(BitcoinPayloadMethod.BitcoinSignTransaction, [txn, inputIndex]), + /** + * Signs a Bitcoin transaction in the TEE. The caller supplies fully-formed + * inputs (the UTXOs to spend, each with its value) and outputs; coin selection, + * fee, and change are the caller's responsibility. Resolves with the + * broadcast-ready signed transaction. + */ + public async signTransaction( + inputs: BitcoinTransactionInput[], + outputs: BitcoinTransactionOutput[], + ): Promise { + return this.request( + this.utils.createJsonRpcRequestPayload(BitcoinPayloadMethod.BitcoinSignTransaction, [{ inputs, outputs }]), ); } } diff --git a/packages/@magic-ext/bitcoin/src/types.ts b/packages/@magic-ext/bitcoin/src/types.ts index ff4426d93..3186d23c2 100644 --- a/packages/@magic-ext/bitcoin/src/types.ts +++ b/packages/@magic-ext/bitcoin/src/types.ts @@ -6,3 +6,28 @@ export interface BitcoinConfig { export enum BitcoinPayloadMethod { BitcoinSignTransaction = 'btc_signTransaction', } + +/** + * A UTXO to spend. `value` is in BTC (not satoshis) and is required: the enclave + * needs each input's value to compute its segwit (BIP143) sighash. `tx_num` is + * the output index (vout) of the UTXO within its source transaction. + */ +export interface BitcoinTransactionInput { + txid: string; + tx_num: number; + value: number; + address?: string; +} + +/** A transaction output. `value` is in BTC (not satoshis). */ +export interface BitcoinTransactionOutput { + address: string; + value: number; +} + +export interface BitcoinSignedTransaction { + /** The broadcast-ready, fully-signed transaction as hex. */ + signedTransaction: string; + /** The transaction hash (txid). */ + transactionHash: string; +} From e1143c5f992b88f43ad70b4d60c6fd70cf6ea640 Mon Sep 17 00:00:00 2001 From: Josh Scanlan Date: Wed, 22 Jul 2026 13:21:37 -0700 Subject: [PATCH 2/2] run yarn --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7d9587d6d..c7a7fde30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3324,7 +3324,7 @@ __metadata: version: 0.0.0-use.local resolution: "@magic-ext/react-native-bare-oauth@workspace:packages/@magic-ext/react-native-bare-oauth" dependencies: - "@magic-sdk/react-native-bare": ^34.8.0 + "@magic-sdk/react-native-bare": ^34.8.1 "@magic-sdk/types": ^27.9.0 "@types/crypto-js": 4.2.0 crypto-js: ^4.2.0 @@ -3339,7 +3339,7 @@ __metadata: version: 0.0.0-use.local resolution: "@magic-ext/react-native-expo-oauth@workspace:packages/@magic-ext/react-native-expo-oauth" dependencies: - "@magic-sdk/react-native-expo": ^34.8.0 + "@magic-sdk/react-native-expo": ^34.8.1 "@magic-sdk/types": ^27.9.0 "@react-native-async-storage/async-storage": ^2.1.2 "@types/crypto-js": ~4.2.0 @@ -3481,7 +3481,7 @@ __metadata: languageName: unknown linkType: soft -"@magic-sdk/react-native-bare@^34.8.0, @magic-sdk/react-native-bare@workspace:packages/@magic-sdk/react-native-bare": +"@magic-sdk/react-native-bare@^34.8.1, @magic-sdk/react-native-bare@workspace:packages/@magic-sdk/react-native-bare": version: 0.0.0-use.local resolution: "@magic-sdk/react-native-bare@workspace:packages/@magic-sdk/react-native-bare" dependencies: @@ -3522,7 +3522,7 @@ __metadata: languageName: unknown linkType: soft -"@magic-sdk/react-native-expo@^34.8.0, @magic-sdk/react-native-expo@workspace:packages/@magic-sdk/react-native-expo": +"@magic-sdk/react-native-expo@^34.8.1, @magic-sdk/react-native-expo@workspace:packages/@magic-sdk/react-native-expo": version: 0.0.0-use.local resolution: "@magic-sdk/react-native-expo@workspace:packages/@magic-sdk/react-native-expo" dependencies: