@meshconnect/uwc-bitcoin 0.2.2 → 0.2.4-snapshot.d9f6da2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import type { BitcoinAccount, BitcoinPsbtSignRequest, BitcoinSendTransferRequest, BitcoinSignMessageParams, SignatureType, TransactionResult } from '@meshconnect/uwc-types';
2
+ /**
3
+ * The seam between the Bitcoin namespace module and a single transport.
4
+ *
5
+ * A concrete adapter is constructed by its transport bound to an
6
+ * already-connected provider/session — Wallet Standard `bitcoin:*` for the
7
+ * injected transport, WalletConnect bip122 for the WalletConnect transport —
8
+ * so the port carries no `connect`/provider argument: connecting is the
9
+ * transport's job. Each adapter converts between these transport-agnostic
10
+ * domain shapes and its wallet's native interface (e.g. hex/base64 strings ↔
11
+ * `Uint8Array`).
12
+ *
13
+ * `getAccounts` + `signMessage` are the always-present verify-flow methods.
14
+ * `signPsbt` and `sendTransfer` are optional because they map to distinct wallet
15
+ * paths — a Wallet Standard wallet signs a PSBT (Path B); a WalletConnect wallet
16
+ * does a high-level `sendTransfer` (Path A) — and not every adapter offers both.
17
+ */
18
+ export interface BitcoinTransportAdapter {
19
+ /** Enumerate the bip122 accounts available on the connected session. */
20
+ getAccounts(): Promise<BitcoinAccount[]>;
21
+ /** Sign a message with the given account. */
22
+ signMessage(params: BitcoinSignMessageParams): Promise<SignatureType>;
23
+ /**
24
+ * Sign a PSBT (Path B). Returns the wallet-signed PSBT, base64-encoded — the
25
+ * wallet does NOT broadcast; finalizing + broadcasting is a separate step.
26
+ * Optional: only adapters whose wallet exposes PSBT signing implement it.
27
+ */
28
+ signPsbt?(request: BitcoinPsbtSignRequest): Promise<string>;
29
+ /**
30
+ * High-level transfer (Path A): the wallet does coin selection, fee, signing,
31
+ * and broadcast, returning a txid. Optional: only adapters whose transport
32
+ * offers it (e.g. WalletConnect `sendTransfer`) implement it.
33
+ */
34
+ sendTransfer?(request: BitcoinSendTransferRequest): Promise<TransactionResult>;
35
+ /** Release any session resources the adapter holds. Optional. */
36
+ disconnect?(): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAA;IAExC,6CAA6C;IAC7C,WAAW,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAErE;;;;OAIG;IACH,QAAQ,CAAC,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE3D;;;;OAIG;IACH,YAAY,CAAC,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE9E,iEAAiE;IACjE,UAAU,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ import type { BitcoinAccount, BitcoinPsbtSignRequest, BitcoinSignMessageParams, SignatureType } from '@meshconnect/uwc-types';
2
+ import type { BitcoinTransportAdapter } from '../adapter';
3
+ /**
4
+ * The subset of the Wallet Standard `bitcoin:*` interface this adapter drives.
5
+ * Structural (no `@wallet-standard/*` dependency); grounded on the community
6
+ * bitcoin-wallet-standard interface that MetaMask exposes. (OKX signs BTC too,
7
+ * but via a legacy injected provider, not Wallet Standard — it needs a separate
8
+ * adapter, not this one.)
9
+ * @see https://github.com/ExodusMovement/bitcoin-wallet-standard
10
+ */
11
+ export interface WalletStandardBitcoinAccount {
12
+ address: string;
13
+ publicKey: Uint8Array;
14
+ purpose?: 'payment' | 'ordinals';
15
+ }
16
+ interface BitcoinConnectFeature {
17
+ connect(input: {
18
+ purposes: ('payment' | 'ordinals')[];
19
+ }): Promise<{
20
+ accounts: WalletStandardBitcoinAccount[];
21
+ }>;
22
+ }
23
+ interface BitcoinSignMessageFeature {
24
+ signMessage(input: {
25
+ account: WalletStandardBitcoinAccount;
26
+ message: Uint8Array;
27
+ protocol?: 'ecdsa' | 'bip322';
28
+ }): Promise<{
29
+ signature: Uint8Array;
30
+ signedMessage: Uint8Array;
31
+ }[]>;
32
+ }
33
+ interface BitcoinSignTransactionFeature {
34
+ signTransaction(input: {
35
+ account: WalletStandardBitcoinAccount;
36
+ psbt: Uint8Array;
37
+ inputsToSign?: {
38
+ account: WalletStandardBitcoinAccount;
39
+ signingIndexes: number[];
40
+ sigHash?: string;
41
+ }[];
42
+ }): Promise<{
43
+ psbt: Uint8Array;
44
+ }[]>;
45
+ }
46
+ /** The handle the injected transport passes in (a discovered `bitcoin:*` wallet). */
47
+ export interface WalletStandardBitcoinWallet {
48
+ name: string;
49
+ accounts: readonly WalletStandardBitcoinAccount[];
50
+ features: Record<string, unknown> & {
51
+ 'bitcoin:connect'?: BitcoinConnectFeature;
52
+ 'bitcoin:signMessage'?: BitcoinSignMessageFeature;
53
+ 'bitcoin:signTransaction'?: BitcoinSignTransactionFeature;
54
+ };
55
+ }
56
+ /**
57
+ * Wallet Standard (`bitcoin:*`) transport adapter — the injected path for
58
+ * wallets that speak Wallet Standard (verified: MetaMask). The injected
59
+ * transport discovers the wallet and hands it here; this adapter performs the
60
+ * bip122-specific operations against it, converting hex/base64 ↔ `Uint8Array`
61
+ * at the boundary.
62
+ *
63
+ * `sendTransfer` is intentionally not implemented — Wallet Standard has no
64
+ * high-level transfer; that is the WalletConnect adapter's path.
65
+ */
66
+ export declare class WalletStandardBitcoinAdapter implements BitcoinTransportAdapter {
67
+ private readonly wallet;
68
+ private accounts;
69
+ constructor(wallet: WalletStandardBitcoinWallet);
70
+ getAccounts(): Promise<BitcoinAccount[]>;
71
+ signMessage(params: BitcoinSignMessageParams): Promise<SignatureType>;
72
+ signPsbt(request: BitcoinPsbtSignRequest): Promise<string>;
73
+ disconnect(): Promise<void>;
74
+ /** Look up the wallet-native account for an address, connecting first if needed. */
75
+ private requireAccount;
76
+ private unsupported;
77
+ }
78
+ export {};
79
+ //# sourceMappingURL=wallet-standard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-standard.d.ts","sourceRoot":"","sources":["../../src/adapters/wallet-standard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACd,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAQzD;;;;;;;GAOG;AACH,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,UAAU,CAAA;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;CACjC;AAED,UAAU,qBAAqB;IAC7B,OAAO,CAAC,KAAK,EAAE;QACb,QAAQ,EAAE,CAAC,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;KACrC,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,4BAA4B,EAAE,CAAA;KAAE,CAAC,CAAA;CAC1D;AAED,UAAU,yBAAyB;IACjC,WAAW,CAAC,KAAK,EAAE;QACjB,OAAO,EAAE,4BAA4B,CAAA;QACrC,OAAO,EAAE,UAAU,CAAA;QACnB,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;KAC9B,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,U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uwc-types';
2
+ import { base64ToBytes, bytesToBase64, bytesToHex, utf8ToBytes } from '../encoding';
3
+ /**
4
+ * Wallet Standard (`bitcoin:*`) transport adapter — the injected path for
5
+ * wallets that speak Wallet Standard (verified: MetaMask). The injected
6
+ * transport discovers the wallet and hands it here; this adapter performs the
7
+ * bip122-specific operations against it, converting hex/base64 ↔ `Uint8Array`
8
+ * at the boundary.
9
+ *
10
+ * `sendTransfer` is intentionally not implemented — Wallet Standard has no
11
+ * high-level transfer; that is the WalletConnect adapter's path.
12
+ */
13
+ export class WalletStandardBitcoinAdapter {
14
+ wallet;
15
+ accounts = null;
16
+ constructor(wallet) {
17
+ this.wallet = wallet;
18
+ }
19
+ async getAccounts() {
20
+ const connect = this.wallet.features['bitcoin:connect'];
21
+ // The wallet exposes accounts only after `bitcoin:connect`; fall back to any
22
+ // it already lists (a wallet without the connect feature).
23
+ this.accounts = connect
24
+ ? (await connect.connect({ purposes: ['payment'] })).accounts
25
+ : this.wallet.accounts;
26
+ return this.accounts.map(account => ({
27
+ address: account.address,
28
+ publicKey: bytesToHex(account.publicKey),
29
+ ...(account.purpose ? { purpose: account.purpose } : {})
30
+ }));
31
+ }
32
+ async signMessage(params) {
33
+ const feature = this.wallet.features['bitcoin:signMessage'];
34
+ if (!feature) {
35
+ throw this.unsupported('signMessage');
36
+ }
37
+ const account = await this.requireAccount(params.account.address);
38
+ const [result] = await feature.signMessage({
39
+ account,
40
+ message: utf8ToBytes(params.message),
41
+ ...(params.protocol ? { protocol: params.protocol } : {})
42
+ });
43
+ if (!result) {
44
+ throw new WalletConnectorError({
45
+ type: 'unknown',
46
+ message: 'wallet-standard bitcoin: signMessage returned no signature'
47
+ });
48
+ }
49
+ return { type: 'standard', signature: bytesToBase64(result.signature) };
50
+ }
51
+ async signPsbt(request) {
52
+ const feature = this.wallet.features['bitcoin:signTransaction'];
53
+ if (!feature) {
54
+ throw this.unsupported('signPsbt');
55
+ }
56
+ const account = await this.requireAccount(request.from);
57
+ const inputsToSign = request.inputsToSign
58
+ ? await Promise.all(request.inputsToSign.map(async (input) => ({
59
+ account: await this.requireAccount(input.address),
60
+ signingIndexes: input.signingIndexes,
61
+ ...(input.sigHash ? { sigHash: input.sigHash } : {})
62
+ })))
63
+ : undefined;
64
+ const [result] = await feature.signTransaction({
65
+ account,
66
+ psbt: base64ToBytes(request.psbt),
67
+ ...(inputsToSign ? { inputsToSign } : {})
68
+ });
69
+ if (!result) {
70
+ throw new WalletConnectorError({
71
+ type: 'unknown',
72
+ message: 'wallet-standard bitcoin: signTransaction returned no PSBT'
73
+ });
74
+ }
75
+ return bytesToBase64(result.psbt);
76
+ }
77
+ disconnect() {
78
+ this.accounts = null;
79
+ return Promise.resolve();
80
+ }
81
+ /** Look up the wallet-native account for an address, connecting first if needed. */
82
+ async requireAccount(address) {
83
+ if (!this.accounts)
84
+ await this.getAccounts();
85
+ const account = this.accounts?.find(a => a.address === address);
86
+ if (!account) {
87
+ throw new WalletConnectorError({
88
+ type: 'unknown',
89
+ message: `wallet-standard bitcoin: no connected account for "${address}"`
90
+ });
91
+ }
92
+ return account;
93
+ }
94
+ unsupported(method) {
95
+ return new WalletConnectorError({
96
+ type: 'unknown',
97
+ message: `wallet-standard bitcoin: this wallet does not support ${method}`
98
+ });
99
+ }
100
+ }
101
+ //# sourceMappingURL=wallet-standard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet-standard.js","sourceRoot":"","sources":["../../src/adapters/wallet-standard.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EACL,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACZ,MAAM,aAAa,CAAA;AAqDpB;;;;;;;;;GASG;AACH,MAAM,OAAO,4BAA4B;IAGV;IAFrB,QAAQ,GAAmD,IAAI,CAAA;IAEvE,YAA6B,MAAmC;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE,KAAK,CAAC,W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E,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC1C,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,oBAAoB,CAAC;gBAC7B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,2DAA2D;aACrE,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED,UAAU;QACR,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;IAC1B,CAAC;IAED,oFAAoF;IAC5E,KAAK,CAAC,cAAc,CAC1B,OAAe;QAEf,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;QAC5C,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,CAAC,CAAA;QAC/D,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,oBAAoB,CAAC;gBAC7B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,sDAAsD,OAAO,GAAG;aAC1E,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAEO,WAAW,CAAC,MAAc;QAChC,OAAO,IAAI,oBAAoB,CAAC;YAC9B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,yDAAyD,MAAM,EAAE;SAC3E,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import type { BitcoinAccount, BitcoinPsbtSignRequest, BitcoinSendTransferRequest, BitcoinSignMessageParams, SignatureType, TransactionResult } from '@meshconnect/uwc-types';
2
+ import type { BitcoinTransportAdapter } from '../adapter';
3
+ /**
4
+ * Issues a WalletConnect JSON-RPC request for a bip122 method. The WalletConnect
5
+ * transport binds this to its live `SignClient` + session topic + chainId, e.g.
6
+ * `(method, params) => signClient.request({ topic, chainId, request: { method, params } })`.
7
+ * Kept as a plain function so `uwc-bitcoin` needs no `@walletconnect/*` dependency.
8
+ */
9
+ export type BitcoinWalletConnectRequest = (method: string, params: Record<string, unknown>) => Promise<unknown>;
10
+ /**
11
+ * WalletConnect (bip122) transport adapter — the Path A / mobile path (Trust
12
+ * Wallet, …). The WalletConnect transport pairs the session and constructs this
13
+ * adapter bound to the connected account's first external address plus a
14
+ * `request` function; this adapter maps our domain shapes onto the Reown/CAIP-2
15
+ * bip122 JSON-RPC methods (`getAccountAddresses`, `signMessage`, `signPsbt`,
16
+ * `sendTransfer`).
17
+ *
18
+ * Wire format follows the Reown Bitcoin RPC reference (what wallets implement
19
+ * over WalletConnect) — all-JSON strings, `account` on every request. NOTE:
20
+ * untested end-to-end; grounded on the spec, not a live wallet.
21
+ */
22
+ export declare class WalletConnectBitcoinAdapter implements BitcoinTransportAdapter {
23
+ private readonly account;
24
+ private readonly request;
25
+ /**
26
+ * @param account The connected account's first external address — the
27
+ * `account` parameter every bip122 method requires.
28
+ * @param request Issues the bound WalletConnect JSON-RPC request.
29
+ */
30
+ constructor(account: string, request: BitcoinWalletConnectRequest);
31
+ getAccounts(): Promise<BitcoinAccount[]>;
32
+ signMessage(params: BitcoinSignMessageParams): Promise<SignatureType>;
33
+ signPsbt(request: BitcoinPsbtSignRequest): Promise<string>;
34
+ sendTransfer(request: BitcoinSendTransferRequest): Promise<TransactionResult>;
35
+ }
36
+ //# sourceMappingURL=walletconnect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletconnect.d.ts","sourceRoot":"","sources":["../../src/adapters/walletconnect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAE1B,wBAAwB,EACxB,aAAa,EACb,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAE/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,OAAO,CAAC,CAAA;AAmBrB;;;;;;;;;;;GAWG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IAOvE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B;;;;OAIG;gBAEgB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,2BAA2B;IAGjD,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAgBxC,WAAW,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC;IAUrE,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IA0B1D,YAAY,CAChB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC;CAQ9B"}
@@ -0,0 +1,90 @@
1
+ import { WalletConnectorError } from '@meshconnect/uwc-types';
2
+ /** Maps a SIGHASH flag to its numeric value (Bitcoin Core encoding). */
3
+ const SIGHASH_VALUES = {
4
+ ALL: 0x01,
5
+ NONE: 0x02,
6
+ SINGLE: 0x03,
7
+ 'ALL|ANYONECANPAY': 0x81,
8
+ 'NONE|ANYONECANPAY': 0x82,
9
+ 'SINGLE|ANYONECANPAY': 0x83
10
+ };
11
+ /**
12
+ * WalletConnect (bip122) transport adapter — the Path A / mobile path (Trust
13
+ * Wallet, …). The WalletConnect transport pairs the session and constructs this
14
+ * adapter bound to the connected account's first external address plus a
15
+ * `request` function; this adapter maps our domain shapes onto the Reown/CAIP-2
16
+ * bip122 JSON-RPC methods (`getAccountAddresses`, `signMessage`, `signPsbt`,
17
+ * `sendTransfer`).
18
+ *
19
+ * Wire format follows the Reown Bitcoin RPC reference (what wallets implement
20
+ * over WalletConnect) — all-JSON strings, `account` on every request. NOTE:
21
+ * untested end-to-end; grounded on the spec, not a live wallet.
22
+ */
23
+ export class WalletConnectBitcoinAdapter {
24
+ account;
25
+ request;
26
+ /**
27
+ * @param account The connected account's first external address — the
28
+ * `account` parameter every bip122 method requires.
29
+ * @param request Issues the bound WalletConnect JSON-RPC request.
30
+ */
31
+ constructor(account, request) {
32
+ this.account = account;
33
+ this.request = request;
34
+ }
35
+ async getAccounts() {
36
+ const result = (await this.request('getAccountAddresses', {
37
+ account: this.account
38
+ }));
39
+ return result.map(entry => ({
40
+ address: entry.address,
41
+ // WalletConnect wallets MAY omit the public key; empty when absent.
42
+ publicKey: entry.publicKey ?? '',
43
+ ...(entry.intention === 'ordinal'
44
+ ? { purpose: 'ordinals' }
45
+ : entry.intention === 'payment'
46
+ ? { purpose: 'payment' }
47
+ : {})
48
+ }));
49
+ }
50
+ async signMessage(params) {
51
+ const result = (await this.request('signMessage', {
52
+ account: this.account,
53
+ message: params.message,
54
+ address: params.account.address,
55
+ ...(params.protocol ? { protocol: params.protocol } : {})
56
+ }));
57
+ return { type: 'standard', signature: result.signature };
58
+ }
59
+ async signPsbt(request) {
60
+ if (!request.inputsToSign?.length) {
61
+ throw new WalletConnectorError({
62
+ type: 'unknown',
63
+ message: 'walletconnect bitcoin: signPsbt requires inputsToSign (the WC signPsbt method has no "sign all" mode)'
64
+ });
65
+ }
66
+ const signInputs = request.inputsToSign.flatMap(input => input.signingIndexes.map(index => ({
67
+ address: input.address,
68
+ index,
69
+ ...(input.sigHash
70
+ ? { sighashTypes: [SIGHASH_VALUES[input.sigHash]] }
71
+ : {})
72
+ })));
73
+ const result = (await this.request('signPsbt', {
74
+ account: this.account,
75
+ psbt: request.psbt,
76
+ signInputs,
77
+ broadcast: false
78
+ }));
79
+ return result.psbt;
80
+ }
81
+ async sendTransfer(request) {
82
+ const result = (await this.request('sendTransfer', {
83
+ account: this.account,
84
+ recipientAddress: request.to,
85
+ amount: request.amount.toString()
86
+ }));
87
+ return result.txid;
88
+ }
89
+ }
90
+ //# sourceMappingURL=walletconnect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletconnect.js","sourceRoot":"","sources":["../../src/adapters/walletconnect.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAc7D,wEAAwE;AACxE,MAAM,cAAc,GAAmC;IACrD,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,IAAI;CAC5B,CAAA;AASD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,2BAA2B;IAOnB;IACA;IAPnB;;;;OAIG;IACH,YACmB,OAAe,EACf,OAAoC;QADpC,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAA6B;IACpD,CAAC;IAEJ,KAAK,CAAC,WAAW;QACf,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE;YACxD,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC,CAAuB,CAAA;QACzB,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,oEAAoE;YACpE,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,EAAE;YAChC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS;gBAC/B,CAAC,CAAC,EAAE,OAAO,EAAE,UAAmB,EAAE;gBAClC,CAAC,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS;oBAC7B,CAAC,CAAC,EAAE,OAAO,EAAE,SAAkB,EAAE;oBACjC,CAAC,CAAC,EAAE,CAAC;SACV,CAAC,CAAC,CAAA;IACL,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAgC;QAChD,MAA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B,CAAA;QACvB,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,OAAmC;QAEnC,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YACjD,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,gBAAgB,EAAE,OAAO,CAAC,EAAE;YAC5B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE;SAClC,CAAC,CAAqB,CAAA;QACvB,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF"}
@@ -1,4 +1,5 @@
1
- import type { Namespace, Network } from '@meshconnect/uwc-types';
1
+ import type { BitcoinAccount, BitcoinPsbtSignRequest, BitcoinSendTransferRequest, BitcoinSignMessageParams, Namespace, Network, SignatureType, TransactionResult } from '@meshconnect/uwc-types';
2
+ import type { BitcoinTransportAdapter } from './adapter';
2
3
  /** CAIP-2 namespace this module serves. */
3
4
  export declare const BITCOIN_NAMESPACE: Namespace;
4
5
  /**
@@ -14,23 +15,42 @@ export declare function assertBitcoinNetwork(network: Network, method: string):
14
15
  * (`injected-connector`, `wallet-connect-connector`) own wallet discovery,
15
16
  * pairing, and the provider/session lifecycle. This module owns only
16
17
  * Bitcoin-specific operations performed against a transport-supplied
17
- * provider/session — enumerating bip122 accounts, signing messages,
18
- * building/signing/finalizing PSBTs, and broadcasting. Both transports
19
- * dispatch their `bip122` branch into the matching adapter here.
18
+ * provider/session, delegating each to the {@link BitcoinTransportAdapter} it
19
+ * was constructed with — the transport builds that adapter bound to the live
20
+ * session.
20
21
  *
21
- * Those operations, and the provider/session types they take, land on the
22
- * `BitcoinTransportAdapter` port in Phase 2 — deferred here so the scaffold
23
- * doesn't pre-commit signatures before those types exist.
24
- *
25
- * Phase 1 (scaffold): namespace identity + the shared network guard only.
22
+ * Phase 2 exposes the grounded verify-flow operations (account enumeration and
23
+ * message signing). PSBT signing (Path B) plus finalize/broadcast, and the
24
+ * high-level `sendTransfer` (Path A), land in Phase 3 alongside their concrete
25
+ * adapters.
26
26
  *
27
27
  * Phased build plan:
28
28
  * https://app.notion.com/p/3a5f862e950a8187b3d3f0e255d13f45
29
29
  */
30
30
  export declare class BitcoinNamespace {
31
+ private readonly adapter;
31
32
  /** CAIP-2 namespace this module serves. */
32
33
  readonly namespace: Namespace;
34
+ constructor(adapter: BitcoinTransportAdapter);
33
35
  /** Throws unless `network` is a bip122 network. */
34
36
  assertSupportedNetwork(network: Network): void;
37
+ /** Enumerate the bip122 accounts on the connected session. */
38
+ getAccounts(): Promise<BitcoinAccount[]>;
39
+ /** Sign a message with the given account. */
40
+ signMessage(params: BitcoinSignMessageParams): Promise<SignatureType>;
41
+ /**
42
+ * Sign a PSBT (Path B). Returns the wallet-signed PSBT (base64); finalizing +
43
+ * broadcasting is a separate step. Rejects if the active adapter's wallet
44
+ * does not support PSBT signing.
45
+ */
46
+ signPsbt(request: BitcoinPsbtSignRequest): Promise<string>;
47
+ /**
48
+ * High-level transfer (Path A): the wallet signs and broadcasts, returning a
49
+ * txid. Rejects if the active adapter's transport does not offer it.
50
+ */
51
+ sendTransfer(request: BitcoinSendTransferRequest): Promise<TransactionResult>;
52
+ /** Release any session resources the adapter holds. */
53
+ disconnect(): Promise<void>;
54
+ private unsupported;
35
55
  }
36
56
  //# sourceMappingURL=bitcoin-namespace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bitcoin-namespace.d.ts","sourceRoot":"","sources":["../src/bitcoin-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGhE,2CAA2C;AAC3C,eAAO,MAAM,iBAAiB,EAAE,SAAoB,CAAA;AAEpD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAO3E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH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;CAMpB"}
@@ -21,25 +21,65 @@ export function assertBitcoinNetwork(network, method) {
21
21
  * (`injected-connector`, `wallet-connect-connector`) own wallet discovery,
22
22
  * pairing, and the provider/session lifecycle. This module owns only
23
23
  * Bitcoin-specific operations performed against a transport-supplied
24
- * provider/session — enumerating bip122 accounts, signing messages,
25
- * building/signing/finalizing PSBTs, and broadcasting. Both transports
26
- * dispatch their `bip122` branch into the matching adapter here.
24
+ * provider/session, delegating each to the {@link BitcoinTransportAdapter} it
25
+ * was constructed with — the transport builds that adapter bound to the live
26
+ * session.
27
27
  *
28
- * Those operations, and the provider/session types they take, land on the
29
- * `BitcoinTransportAdapter` port in Phase 2 — deferred here so the scaffold
30
- * doesn't pre-commit signatures before those types exist.
31
- *
32
- * Phase 1 (scaffold): namespace identity + the shared network guard only.
28
+ * Phase 2 exposes the grounded verify-flow operations (account enumeration and
29
+ * message signing). PSBT signing (Path B) plus finalize/broadcast, and the
30
+ * high-level `sendTransfer` (Path A), land in Phase 3 alongside their concrete
31
+ * adapters.
33
32
  *
34
33
  * Phased build plan:
35
34
  * https://app.notion.com/p/3a5f862e950a8187b3d3f0e255d13f45
36
35
  */
37
36
  export class BitcoinNamespace {
37
+ adapter;
38
38
  /** CAIP-2 namespace this module serves. */
39
39
  namespace = BITCOIN_NAMESPACE;
40
+ constructor(adapter) {
41
+ this.adapter = adapter;
42
+ }
40
43
  /** Throws unless `network` is a bip122 network. */
41
44
  assertSupportedNetwork(network) {
42
45
  assertBitcoinNetwork(network, 'BitcoinNamespace.assertSupportedNetwork');
43
46
  }
47
+ /** Enumerate the bip122 accounts on the connected session. */
48
+ getAccounts() {
49
+ return this.adapter.getAccounts();
50
+ }
51
+ /** Sign a message with the given account. */
52
+ signMessage(params) {
53
+ return this.adapter.signMessage(params);
54
+ }
55
+ /**
56
+ * Sign a PSBT (Path B). Returns the wallet-signed PSBT (base64); finalizing +
57
+ * broadcasting is a separate step. Rejects if the active adapter's wallet
58
+ * does not support PSBT signing.
59
+ */
60
+ async signPsbt(request) {
61
+ if (!this.adapter.signPsbt)
62
+ throw this.unsupported('signPsbt');
63
+ return this.adapter.signPsbt(request);
64
+ }
65
+ /**
66
+ * High-level transfer (Path A): the wallet signs and broadcasts, returning a
67
+ * txid. Rejects if the active adapter's transport does not offer it.
68
+ */
69
+ async sendTransfer(request) {
70
+ if (!this.adapter.sendTransfer)
71
+ throw this.unsupported('sendTransfer');
72
+ return this.adapter.sendTransfer(request);
73
+ }
74
+ /** Release any session resources the adapter holds. */
75
+ async disconnect() {
76
+ await this.adapter.disconnect?.();
77
+ }
78
+ unsupported(method) {
79
+ return new WalletConnectorError({
80
+ type: 'unknown',
81
+ message: `BitcoinNamespace.${method}: the active adapter does not support it`
82
+ });
83
+ }
44
84
  }
45
85
  //# sourceMappingURL=bitcoin-namespace.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bitcoin-namespace.js","sourceRoot":"","sources":["../src/bitcoin-namespace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,2CAA2C;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAc,QAAQ,CAAA;AAEpD;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,MAAc;IACnE,IAAI,OAAO,CAAC,SAAS,KAAK,iBAAiB,EAAE,CAAC;QAC5C,MAAM,IAAI,oBAAoB,CAAC;YAC7B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,GAAG,MAAM,wCAAwC,OAAO,CAAC,EAAE,GAAG;SACxE,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,gBAAgB;IAC3B,2CAA2C;IAClC,SAAS,GAAG,iBAAiB,CAAA;IAEtC,mDAAmD;IACnD,sBAAsB,CAAC,OAAgB;QACrC,oBAAoB,CAAC,OAAO,EAAE,yCAAyC,CAAC,CAAA;IAC1E,CAAC;CACF"}
1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G;IACH,KAAK,CAAC,YAAY,CAChB,OAAmC;QAEnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY;YAAE,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAA;QACtE,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAA;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QAChC,OAAO,IAAI,oBAAoB,CAAC;YAC9B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,oBAAoB,MAAM,0CAA0C;SAC9E,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Minimal encoding helpers for the boundary between our transport-agnostic
3
+ * domain shapes (hex/base64 strings, JSON-safe) and the Wallet Standard
4
+ * `bitcoin:*` interface (raw `Uint8Array`). Uses only Web-standard APIs
5
+ * (`TextEncoder`, `atob`/`btoa`) so `uwc-bitcoin` stays dependency-free.
6
+ */
7
+ export declare function utf8ToBytes(text: string): Uint8Array;
8
+ export declare function bytesToHex(bytes: Uint8Array): string;
9
+ export declare function bytesToBase64(bytes: Uint8Array): string;
10
+ export declare function base64ToBytes(base64: string): Uint8Array;
11
+ //# sourceMappingURL=encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAEpD;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIpD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIvD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAKxD"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Minimal encoding helpers for the boundary between our transport-agnostic
3
+ * domain shapes (hex/base64 strings, JSON-safe) and the Wallet Standard
4
+ * `bitcoin:*` interface (raw `Uint8Array`). Uses only Web-standard APIs
5
+ * (`TextEncoder`, `atob`/`btoa`) so `uwc-bitcoin` stays dependency-free.
6
+ */
7
+ export function utf8ToBytes(text) {
8
+ return new TextEncoder().encode(text);
9
+ }
10
+ export function bytesToHex(bytes) {
11
+ let hex = '';
12
+ for (const byte of bytes)
13
+ hex += byte.toString(16).padStart(2, '0');
14
+ return hex;
15
+ }
16
+ export function bytesToBase64(bytes) {
17
+ let binary = '';
18
+ for (const byte of bytes)
19
+ binary += String.fromCharCode(byte);
20
+ return btoa(binary);
21
+ }
22
+ export function base64ToBytes(base64) {
23
+ const binary = atob(base64);
24
+ const bytes = new Uint8Array(binary.length);
25
+ for (let i = 0; i < binary.length; i++)
26
+ bytes[i] = binary.charCodeAt(i);
27
+ return bytes;
28
+ }
29
+ //# sourceMappingURL=encoding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.js","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IACnE,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACvE,OAAO,KAAK,CAAA;AACd,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
1
  export { BitcoinNamespace, assertBitcoinNetwork, BITCOIN_NAMESPACE } from './bitcoin-namespace';
2
+ export type { BitcoinTransportAdapter } from './adapter';
3
+ export { WalletStandardBitcoinAdapter } from './adapters/wallet-standard';
4
+ export type { WalletStandardBitcoinWallet, WalletStandardBitcoinAccount } from './adapters/wallet-standard';
5
+ export { WalletConnectBitcoinAdapter } from './adapters/walletconnect';
6
+ export type { BitcoinWalletConnectRequest } from './adapters/walletconnect';
2
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AACzE,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AACtE,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA"}
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export { BitcoinNamespace, assertBitcoinNetwork, BITCOIN_NAMESPACE } from './bitcoin-namespace';
2
+ export { WalletStandardBitcoinAdapter } from './adapters/wallet-standard';
3
+ export { WalletConnectBitcoinAdapter } from './adapters/walletconnect';
2
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/uwc-bitcoin",
3
- "version": "0.2.2",
3
+ "version": "0.2.4-snapshot.d9f6da2",
4
4
  "description": "Mesh-owned Bitcoin (bip122) namespace module for Universal Wallet Connector — network-specific logic (PSBT, address/network handling, mempool broadcast) with pluggable transport adapters (Wallet Standard bitcoin:* and WalletConnect bip122), consumed by the injected and walletConnect transport connectors",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "src"
17
17
  ],
18
18
  "dependencies": {
19
- "@meshconnect/uwc-types": "0.25.0"
19
+ "@meshconnect/uwc-types": "0.26.1-snapshot.d9f6da2"
20
20
  },
21
21
  "devDependencies": {
22
22
  "typescript": "^5.9.3"