@meshconnect/uwc-bitcoin 0.4.3-snapshot.c8ab084 → 0.5.0
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.
- package/dist/bitcoin-namespace.d.ts +11 -4
- package/dist/bitcoin-namespace.d.ts.map +1 -1
- package/dist/bitcoin-namespace.js +18 -4
- package/dist/bitcoin-namespace.js.map +1 -1
- package/dist/broadcast.d.ts +24 -0
- package/dist/broadcast.d.ts.map +1 -0
- package/dist/broadcast.js +68 -0
- package/dist/broadcast.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/psbt.d.ts +31 -0
- package/dist/psbt.d.ts.map +1 -0
- package/dist/psbt.js +299 -0
- package/dist/psbt.js.map +1 -0
- package/package.json +3 -3
- package/src/bitcoin-namespace.test.ts +65 -1
- package/src/bitcoin-namespace.ts +22 -4
- package/src/broadcast.test.ts +137 -0
- package/src/broadcast.ts +75 -0
- package/src/index.ts +11 -1
- package/src/psbt.test.ts +113 -0
- package/src/psbt.ts +373 -0
|
@@ -24,10 +24,11 @@ export declare function assertBitcoinNetwork(network: Network, method: string):
|
|
|
24
24
|
* was constructed with — the transport builds that adapter bound to the live
|
|
25
25
|
* session.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* Sending is Mesh-broadcast: the wallet only signs a Mesh-built PSBT, and this
|
|
28
|
+
* module finalizes and broadcasts it ({@link signAndSendPsbt}). Wallet-side
|
|
29
|
+
* broadcast can't be the primary path — framed Link's bridge relays only
|
|
30
|
+
* `bitcoin:signTransaction`, and some wallets (Bitget) expose no working
|
|
31
|
+
* broadcast at all.
|
|
31
32
|
*
|
|
32
33
|
* Phased build plan:
|
|
33
34
|
* https://app.notion.com/p/3a5f862e950a8187b3d3f0e255d13f45
|
|
@@ -49,6 +50,12 @@ export declare class BitcoinNamespace {
|
|
|
49
50
|
* does not support PSBT signing.
|
|
50
51
|
*/
|
|
51
52
|
signPsbt(request: BitcoinPsbtSignRequest): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Sign a PSBT with the wallet, finalize it, and broadcast the result through
|
|
55
|
+
* the Esplora API at `broadcastUrl` (mempool.space when omitted). Returns the
|
|
56
|
+
* txid — the same shape every other namespace returns from a send.
|
|
57
|
+
*/
|
|
58
|
+
signAndSendPsbt(request: BitcoinPsbtSignRequest, broadcastUrl?: string): Promise<TransactionResult>;
|
|
52
59
|
/**
|
|
53
60
|
* High-level transfer (Path A): the wallet signs and broadcasts, returning a
|
|
54
61
|
* txid. Rejects if the active adapter's transport does not offer it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin-namespace.d.ts","sourceRoot":"","sources":["../src/bitcoin-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,SAAS,EACT,OAAO,EACP,aAAa,EACb,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"bitcoin-namespace.d.ts","sourceRoot":"","sources":["../src/bitcoin-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC1B,wBAAwB,EACxB,SAAS,EACT,OAAO,EACP,aAAa,EACb,iBAAiB,EAClB,MAAM,wBAAwB,CAAA;AAG/B,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAKxD,2CAA2C;AAC3C,eAAO,MAAM,iBAAiB,EAAE,SAAoB,CAAA;AAEpD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAa3E;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,gBAAgB;IAIf,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,2CAA2C;IAC3C,QAAQ,CAAC,SAAS,YAAoB;IAEtC,YAA6B,OAAO,EAAE,uBAAuB,EAAI;IAEjE,mDAAmD;IACnD,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAE7C;IAED,8DAA8D;IAC9D,WAAW,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAEvC;IAED,6CAA6C;IAC7C,WAAW,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,aAAa,CAAC,CAEpE;IAED;;;;OAIG;IACG,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,CAG/D;IAED;;;;OAIG;IACG,eAAe,CACnB,OAAO,EAAE,sBAAsB,EAC/B,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAI5B;IAED;;;OAGG;IACG,YAAY,CAChB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAG5B;IAED,uDAAuD;IACvD;;;;;;;;;OASG;IACG,UAAU,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAGhD;IAED,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { bitcoinNetwork } from '@meshconnect/uwc-constants';
|
|
2
2
|
import { WalletConnectorError } from '@meshconnect/uwc-types';
|
|
3
|
+
import { broadcastTransaction } from './broadcast';
|
|
4
|
+
import { base64ToBytes } from './encoding';
|
|
5
|
+
import { finalizePsbt } from './psbt';
|
|
3
6
|
/** CAIP-2 namespace this module serves. */
|
|
4
7
|
export const BITCOIN_NAMESPACE = 'bip122';
|
|
5
8
|
/**
|
|
@@ -37,10 +40,11 @@ export function assertBitcoinNetwork(network, method) {
|
|
|
37
40
|
* was constructed with — the transport builds that adapter bound to the live
|
|
38
41
|
* session.
|
|
39
42
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* Sending is Mesh-broadcast: the wallet only signs a Mesh-built PSBT, and this
|
|
44
|
+
* module finalizes and broadcasts it ({@link signAndSendPsbt}). Wallet-side
|
|
45
|
+
* broadcast can't be the primary path — framed Link's bridge relays only
|
|
46
|
+
* `bitcoin:signTransaction`, and some wallets (Bitget) expose no working
|
|
47
|
+
* broadcast at all.
|
|
44
48
|
*
|
|
45
49
|
* Phased build plan:
|
|
46
50
|
* https://app.notion.com/p/3a5f862e950a8187b3d3f0e255d13f45
|
|
@@ -74,6 +78,16 @@ export class BitcoinNamespace {
|
|
|
74
78
|
throw this.unsupported('signPsbt');
|
|
75
79
|
return this.adapter.signPsbt(request);
|
|
76
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Sign a PSBT with the wallet, finalize it, and broadcast the result through
|
|
83
|
+
* the Esplora API at `broadcastUrl` (mempool.space when omitted). Returns the
|
|
84
|
+
* txid — the same shape every other namespace returns from a send.
|
|
85
|
+
*/
|
|
86
|
+
async signAndSendPsbt(request, broadcastUrl) {
|
|
87
|
+
const signed = await this.signPsbt(request);
|
|
88
|
+
const rawTx = finalizePsbt(base64ToBytes(signed));
|
|
89
|
+
return broadcastTransaction(rawTx, broadcastUrl);
|
|
90
|
+
}
|
|
77
91
|
/**
|
|
78
92
|
* High-level transfer (Path A): the wallet signs and broadcasts, returning a
|
|
79
93
|
* txid. Rejects if the active adapter's transport does not offer it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin-namespace.js","sourceRoot":"","sources":["../src/bitcoin-namespace.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+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,OAAO,EAAE,oBAAoB,MAAM,0CAA0C;SAC9E,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** mempool.space's Esplora API for Bitcoin mainnet. */
|
|
2
|
+
export declare const DEFAULT_BITCOIN_BROADCAST_URL = "https://mempool.space/api";
|
|
3
|
+
/**
|
|
4
|
+
* Broadcast a raw transaction through an Esplora-compatible REST API
|
|
5
|
+
* (`POST {baseUrl}/tx`, raw hex body, txid as the plain-text response) and
|
|
6
|
+
* return the txid.
|
|
7
|
+
*
|
|
8
|
+
* `baseUrl` is any Esplora host — mempool.space by default, or a proxy with
|
|
9
|
+
* the same contract — so moving broadcast behind a Mesh endpoint is a config
|
|
10
|
+
* change, not a code change.
|
|
11
|
+
*
|
|
12
|
+
* The txid is computed locally first, because a thrown broadcast is not proof
|
|
13
|
+
* the payment failed:
|
|
14
|
+
* - "already known" means an earlier attempt landed, so it resolves with the
|
|
15
|
+
* txid instead of reporting a payment that went through as failed;
|
|
16
|
+
* - a lost response or timeout leaves the outcome unknown, so the error names
|
|
17
|
+
* the txid for the caller to reconcile against the chain;
|
|
18
|
+
* - a response that isn't this txid throws rather than being recorded as one.
|
|
19
|
+
*
|
|
20
|
+
* Any other non-2xx throws with the API's own message (e.g. `min relay fee not
|
|
21
|
+
* met`): the payment did not happen, and the reason is what makes it actionable.
|
|
22
|
+
*/
|
|
23
|
+
export declare function broadcastTransaction(rawTxHex: string, baseUrl?: string): Promise<string>;
|
|
24
|
+
//# sourceMappingURL=broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAGA,uDAAuD;AACvD,eAAO,MAAM,6BAA6B,8BAA8B,CAAA;AAaxE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAsC,GAC9C,OAAO,CAAC,MAAM,CAAC,CAkCjB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { WalletConnectorError } from '@meshconnect/uwc-types';
|
|
2
|
+
import { computeTxid } from './psbt';
|
|
3
|
+
/** mempool.space's Esplora API for Bitcoin mainnet. */
|
|
4
|
+
export const DEFAULT_BITCOIN_BROADCAST_URL = 'https://mempool.space/api';
|
|
5
|
+
const BROADCAST_TIMEOUT_MS = 30_000;
|
|
6
|
+
/**
|
|
7
|
+
* Bitcoin Core rejection reasons meaning the network already has this exact
|
|
8
|
+
* transaction — e.g. a retry after a lost response. Same txid, so it succeeded.
|
|
9
|
+
* A confirmed tx reads "already in block chain" before Core 24 and "outputs
|
|
10
|
+
* already in utxo set" from 24 on; nodes behind an Esplora host vary.
|
|
11
|
+
*/
|
|
12
|
+
const ALREADY_BROADCAST = /txn-already-known|txn-already-in-mempool|already in block ?chain|outputs already in utxo set/i;
|
|
13
|
+
/**
|
|
14
|
+
* Broadcast a raw transaction through an Esplora-compatible REST API
|
|
15
|
+
* (`POST {baseUrl}/tx`, raw hex body, txid as the plain-text response) and
|
|
16
|
+
* return the txid.
|
|
17
|
+
*
|
|
18
|
+
* `baseUrl` is any Esplora host — mempool.space by default, or a proxy with
|
|
19
|
+
* the same contract — so moving broadcast behind a Mesh endpoint is a config
|
|
20
|
+
* change, not a code change.
|
|
21
|
+
*
|
|
22
|
+
* The txid is computed locally first, because a thrown broadcast is not proof
|
|
23
|
+
* the payment failed:
|
|
24
|
+
* - "already known" means an earlier attempt landed, so it resolves with the
|
|
25
|
+
* txid instead of reporting a payment that went through as failed;
|
|
26
|
+
* - a lost response or timeout leaves the outcome unknown, so the error names
|
|
27
|
+
* the txid for the caller to reconcile against the chain;
|
|
28
|
+
* - a response that isn't this txid throws rather than being recorded as one.
|
|
29
|
+
*
|
|
30
|
+
* Any other non-2xx throws with the API's own message (e.g. `min relay fee not
|
|
31
|
+
* met`): the payment did not happen, and the reason is what makes it actionable.
|
|
32
|
+
*/
|
|
33
|
+
export async function broadcastTransaction(rawTxHex, baseUrl = DEFAULT_BITCOIN_BROADCAST_URL) {
|
|
34
|
+
const txid = await computeTxid(rawTxHex);
|
|
35
|
+
let response;
|
|
36
|
+
let body;
|
|
37
|
+
try {
|
|
38
|
+
response = await fetch(`${baseUrl.replace(/\/+$/, '')}/tx`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: { 'Content-Type': 'text/plain' },
|
|
41
|
+
body: rawTxHex,
|
|
42
|
+
signal: AbortSignal.timeout(BROADCAST_TIMEOUT_MS)
|
|
43
|
+
});
|
|
44
|
+
body = (await response.text()).trim();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
throw new WalletConnectorError({
|
|
48
|
+
type: 'unknown',
|
|
49
|
+
message: `Bitcoin broadcast outcome unknown for txid ${txid}: ${error instanceof Error ? error.message : String(error)}`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
if (ALREADY_BROADCAST.test(body))
|
|
54
|
+
return txid;
|
|
55
|
+
throw new WalletConnectorError({
|
|
56
|
+
type: 'unknown',
|
|
57
|
+
message: `Bitcoin broadcast failed (${response.status}): ${body || response.statusText}`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (body.toLowerCase() !== txid) {
|
|
61
|
+
throw new WalletConnectorError({
|
|
62
|
+
type: 'unknown',
|
|
63
|
+
message: `Bitcoin broadcast returned ${body.slice(0, 200) || 'an empty response'}, expected txid ${txid}`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return txid;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,WAAW,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E,SAAS;YACf,OAAO,EAAE,6BAA6B,QAAQ,CAAC,MAAM,MAAM,IAAI,IAAI,QAAQ,CAAC,UAAU,EAAE;SACzF,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,oBAAoB,CAAC;YAC7B,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,8BAA8B,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,mBAAmB,mBAAmB,IAAI,EAAE;SAC1G,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export { WalletStandardBitcoinAdapter } from './adapters/wallet-standard';
|
|
|
4
4
|
export type { WalletStandardBitcoinWallet, WalletStandardBitcoinAccount } from './adapters/wallet-standard';
|
|
5
5
|
export { OkxBitcoinAdapter } from './adapters/okx';
|
|
6
6
|
export type { OkxBitcoinProvider } from './adapters/okx';
|
|
7
|
-
export { bytesToHex, hexToBytes } from './encoding';
|
|
7
|
+
export { bytesToHex, hexToBytes, base64ToBytes, bytesToBase64 } from './encoding';
|
|
8
|
+
export { finalizePsbt, computeTxid } from './psbt';
|
|
9
|
+
export { broadcastTransaction, DEFAULT_BITCOIN_BROADCAST_URL } from './broadcast';
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;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,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,
|
|
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,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { BitcoinNamespace, assertBitcoinNetwork, BITCOIN_NAMESPACE } from './bitcoin-namespace';
|
|
2
2
|
export { WalletStandardBitcoinAdapter } from './adapters/wallet-standard';
|
|
3
3
|
export { OkxBitcoinAdapter } from './adapters/okx';
|
|
4
|
-
export { bytesToHex, hexToBytes } from './encoding';
|
|
4
|
+
export { bytesToHex, hexToBytes, base64ToBytes, bytesToBase64 } from './encoding';
|
|
5
|
+
export { finalizePsbt, computeTxid } from './psbt';
|
|
6
|
+
export { broadcastTransaction, DEFAULT_BITCOIN_BROADCAST_URL } from './broadcast';
|
|
5
7
|
//# 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;AAE5B,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAKzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,
|
|
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,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EACL,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAClD,OAAO,EACL,oBAAoB,EACpB,6BAA6B,EAC9B,MAAM,aAAa,CAAA"}
|
package/dist/psbt.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finalize a wallet-signed PSBT (BIP-174 v0) and extract the network-ready
|
|
3
|
+
* raw transaction as hex.
|
|
4
|
+
*
|
|
5
|
+
* Hand-rolled rather than pulling in a Bitcoin library so `uwc-bitcoin` stays
|
|
6
|
+
* dependency-free. That is only safe because the scope is deliberately narrow:
|
|
7
|
+
* single-key spends, where finalizing is pure re-arrangement of what the wallet
|
|
8
|
+
* already produced — no script interpretation, no signature checks. Anything
|
|
9
|
+
* else (multisig, Taproot script-path, bare scripts) throws instead of guessing.
|
|
10
|
+
*
|
|
11
|
+
* Per input, in order:
|
|
12
|
+
* - Already final (`final_scriptsig` / `final_scriptwitness` present) → used
|
|
13
|
+
* as-is. Required, not optional: OKX finalizes every input it signs even when
|
|
14
|
+
* asked not to (`autoFinalized: false`), so a finalizer that only accepted
|
|
15
|
+
* partial signatures would reject every OKX transaction.
|
|
16
|
+
* - P2WPKH, P2TR key-path, P2PKH, P2SH-P2WPKH → finalized from the partial
|
|
17
|
+
* signature (or `tap_key_sig`).
|
|
18
|
+
*
|
|
19
|
+
* The caller owns the trust decision about the PSBT's contents — this never
|
|
20
|
+
* inspects outputs or amounts.
|
|
21
|
+
*/
|
|
22
|
+
export declare function finalizePsbt(signedPsbt: Uint8Array): string;
|
|
23
|
+
/**
|
|
24
|
+
* The txid of a raw transaction (hex, legacy or segwit serialization): the
|
|
25
|
+
* double SHA-256 of its witness-stripped serialization, byte-reversed.
|
|
26
|
+
*
|
|
27
|
+
* Lets a broadcaster know the txid before the network answers, so a lost
|
|
28
|
+
* response or an "already known" rejection can still be tied to the payment.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeTxid(rawTxHex: string): Promise<string>;
|
|
31
|
+
//# sourceMappingURL=psbt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psbt.d.ts","sourceRoot":"","sources":["../src/psbt.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAM3D;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASnE"}
|
package/dist/psbt.js
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { WalletConnectorError } from '@meshconnect/uwc-types';
|
|
2
|
+
import { bytesToHex, hexToBytes } from './encoding';
|
|
3
|
+
/**
|
|
4
|
+
* Finalize a wallet-signed PSBT (BIP-174 v0) and extract the network-ready
|
|
5
|
+
* raw transaction as hex.
|
|
6
|
+
*
|
|
7
|
+
* Hand-rolled rather than pulling in a Bitcoin library so `uwc-bitcoin` stays
|
|
8
|
+
* dependency-free. That is only safe because the scope is deliberately narrow:
|
|
9
|
+
* single-key spends, where finalizing is pure re-arrangement of what the wallet
|
|
10
|
+
* already produced — no script interpretation, no signature checks. Anything
|
|
11
|
+
* else (multisig, Taproot script-path, bare scripts) throws instead of guessing.
|
|
12
|
+
*
|
|
13
|
+
* Per input, in order:
|
|
14
|
+
* - Already final (`final_scriptsig` / `final_scriptwitness` present) → used
|
|
15
|
+
* as-is. Required, not optional: OKX finalizes every input it signs even when
|
|
16
|
+
* asked not to (`autoFinalized: false`), so a finalizer that only accepted
|
|
17
|
+
* partial signatures would reject every OKX transaction.
|
|
18
|
+
* - P2WPKH, P2TR key-path, P2PKH, P2SH-P2WPKH → finalized from the partial
|
|
19
|
+
* signature (or `tap_key_sig`).
|
|
20
|
+
*
|
|
21
|
+
* The caller owns the trust decision about the PSBT's contents — this never
|
|
22
|
+
* inspects outputs or amounts.
|
|
23
|
+
*/
|
|
24
|
+
export function finalizePsbt(signedPsbt) {
|
|
25
|
+
const psbt = parsePsbt(signedPsbt);
|
|
26
|
+
const finals = psbt.inputs.map((input, index) => finalizeInput(input, index, psbt.tx.inputs[index].prevIndex));
|
|
27
|
+
return bytesToHex(serializeTransaction(psbt.tx, finals));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The txid of a raw transaction (hex, legacy or segwit serialization): the
|
|
31
|
+
* double SHA-256 of its witness-stripped serialization, byte-reversed.
|
|
32
|
+
*
|
|
33
|
+
* Lets a broadcaster know the txid before the network answers, so a lost
|
|
34
|
+
* response or an "already known" rejection can still be tied to the payment.
|
|
35
|
+
*/
|
|
36
|
+
export async function computeTxid(rawTxHex) {
|
|
37
|
+
const tx = parseTransaction(hexToBytes(rawTxHex));
|
|
38
|
+
const stripped = serializeTransaction(tx, tx.inputs.map(input => ({ scriptSig: input.scriptSig, witness: [] })));
|
|
39
|
+
const once = await crypto.subtle.digest('SHA-256', stripped);
|
|
40
|
+
const twice = new Uint8Array(await crypto.subtle.digest('SHA-256', once));
|
|
41
|
+
return bytesToHex(twice.reverse());
|
|
42
|
+
}
|
|
43
|
+
// BIP-174 key types used here.
|
|
44
|
+
const GLOBAL_UNSIGNED_TX = 0x00;
|
|
45
|
+
const GLOBAL_VERSION = 0xfb;
|
|
46
|
+
const IN_NON_WITNESS_UTXO = 0x00;
|
|
47
|
+
const IN_WITNESS_UTXO = 0x01;
|
|
48
|
+
const IN_PARTIAL_SIG = 0x02;
|
|
49
|
+
const IN_REDEEM_SCRIPT = 0x04;
|
|
50
|
+
const IN_FINAL_SCRIPTSIG = 0x07;
|
|
51
|
+
const IN_FINAL_SCRIPTWITNESS = 0x08;
|
|
52
|
+
const IN_TAP_KEY_SIG = 0x13;
|
|
53
|
+
const PSBT_MAGIC = [0x70, 0x73, 0x62, 0x74, 0xff];
|
|
54
|
+
function fail(message) {
|
|
55
|
+
throw new WalletConnectorError({
|
|
56
|
+
type: 'unknown',
|
|
57
|
+
message: `finalizePsbt: ${message}`
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
class Reader {
|
|
61
|
+
bytes;
|
|
62
|
+
offset = 0;
|
|
63
|
+
constructor(bytes) {
|
|
64
|
+
this.bytes = bytes;
|
|
65
|
+
}
|
|
66
|
+
take(length) {
|
|
67
|
+
if (this.offset + length > this.bytes.length)
|
|
68
|
+
fail('truncated data');
|
|
69
|
+
const slice = this.bytes.subarray(this.offset, this.offset + length);
|
|
70
|
+
this.offset += length;
|
|
71
|
+
return slice;
|
|
72
|
+
}
|
|
73
|
+
byte() {
|
|
74
|
+
return this.take(1)[0];
|
|
75
|
+
}
|
|
76
|
+
uint32() {
|
|
77
|
+
const b = this.take(4);
|
|
78
|
+
return (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0;
|
|
79
|
+
}
|
|
80
|
+
compactSize() {
|
|
81
|
+
const first = this.byte();
|
|
82
|
+
if (first < 0xfd)
|
|
83
|
+
return first;
|
|
84
|
+
if (first === 0xfd) {
|
|
85
|
+
const b = this.take(2);
|
|
86
|
+
return b[0] | (b[1] << 8);
|
|
87
|
+
}
|
|
88
|
+
if (first === 0xfe)
|
|
89
|
+
return this.uint32();
|
|
90
|
+
const low = this.uint32();
|
|
91
|
+
const high = this.uint32();
|
|
92
|
+
// No PSBT field legitimately approaches 2^53; anything that large is corrupt.
|
|
93
|
+
if (high > 0x1fffff)
|
|
94
|
+
fail('length out of range');
|
|
95
|
+
return high * 0x100000000 + low;
|
|
96
|
+
}
|
|
97
|
+
varBytes() {
|
|
98
|
+
return this.take(this.compactSize());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function parsePsbt(bytes) {
|
|
102
|
+
const reader = new Reader(bytes);
|
|
103
|
+
if (!PSBT_MAGIC.every(b => reader.byte() === b))
|
|
104
|
+
fail('not a PSBT');
|
|
105
|
+
const global = readMap(reader);
|
|
106
|
+
const version = global.find(kv => kv.type === GLOBAL_VERSION);
|
|
107
|
+
if (version && new Reader(version.value).uint32() !== 0) {
|
|
108
|
+
fail('only PSBT version 0 is supported');
|
|
109
|
+
}
|
|
110
|
+
const unsignedTx = global.find(kv => kv.type === GLOBAL_UNSIGNED_TX);
|
|
111
|
+
if (!unsignedTx)
|
|
112
|
+
fail('missing unsigned transaction');
|
|
113
|
+
const tx = parseTransaction(unsignedTx.value);
|
|
114
|
+
const inputs = tx.inputs.map(() => readMap(reader));
|
|
115
|
+
// Output maps carry nothing extraction needs, but must be present — a PSBT
|
|
116
|
+
// cut short there is malformed and should not be trusted.
|
|
117
|
+
for (let i = 0; i < tx.outputs.length; i++)
|
|
118
|
+
readMap(reader);
|
|
119
|
+
return { tx, inputs };
|
|
120
|
+
}
|
|
121
|
+
function readMap(reader) {
|
|
122
|
+
const map = [];
|
|
123
|
+
for (;;) {
|
|
124
|
+
const key = reader.varBytes();
|
|
125
|
+
if (key.length === 0)
|
|
126
|
+
return map;
|
|
127
|
+
map.push({
|
|
128
|
+
type: key[0],
|
|
129
|
+
keyData: key.subarray(1),
|
|
130
|
+
value: reader.varBytes()
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Parse a transaction in either legacy or segwit serialization. */
|
|
135
|
+
function parseTransaction(bytes) {
|
|
136
|
+
const reader = new Reader(bytes);
|
|
137
|
+
const version = reader.take(4);
|
|
138
|
+
let inputCount = reader.compactSize();
|
|
139
|
+
const segwit = inputCount === 0;
|
|
140
|
+
if (segwit) {
|
|
141
|
+
if (reader.byte() !== 0x01)
|
|
142
|
+
fail('invalid segwit flag');
|
|
143
|
+
inputCount = reader.compactSize();
|
|
144
|
+
}
|
|
145
|
+
const inputs = [];
|
|
146
|
+
for (let i = 0; i < inputCount; i++) {
|
|
147
|
+
const outpoint = reader.take(36);
|
|
148
|
+
inputs.push({
|
|
149
|
+
outpoint,
|
|
150
|
+
prevIndex: new Reader(outpoint.subarray(32)).uint32(),
|
|
151
|
+
scriptSig: reader.varBytes(),
|
|
152
|
+
sequence: reader.take(4)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const outputCount = reader.compactSize();
|
|
156
|
+
const outputs = [];
|
|
157
|
+
for (let i = 0; i < outputCount; i++) {
|
|
158
|
+
const value = reader.take(8);
|
|
159
|
+
const script = reader.varBytes();
|
|
160
|
+
outputs.push(concat([value, compactSize(script.length), script]));
|
|
161
|
+
}
|
|
162
|
+
if (segwit) {
|
|
163
|
+
for (let i = 0; i < inputCount; i++) {
|
|
164
|
+
const items = reader.compactSize();
|
|
165
|
+
for (let j = 0; j < items; j++)
|
|
166
|
+
reader.varBytes();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return { version, inputs, outputs, locktime: reader.take(4) };
|
|
170
|
+
}
|
|
171
|
+
function finalizeInput(input, index, prevIndex) {
|
|
172
|
+
const get = (type) => input.find(kv => kv.type === type)?.value;
|
|
173
|
+
const finalScriptSig = get(IN_FINAL_SCRIPTSIG);
|
|
174
|
+
const finalWitness = get(IN_FINAL_SCRIPTWITNESS);
|
|
175
|
+
if (finalScriptSig || finalWitness) {
|
|
176
|
+
return {
|
|
177
|
+
scriptSig: finalScriptSig ?? new Uint8Array(),
|
|
178
|
+
witness: finalWitness ? parseWitness(finalWitness) : []
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const script = prevoutScript(input, index, prevIndex);
|
|
182
|
+
const partialSigs = input.filter(kv => kv.type === IN_PARTIAL_SIG);
|
|
183
|
+
const singleSig = () => {
|
|
184
|
+
if (partialSigs.length === 0)
|
|
185
|
+
fail(`input ${index} is not signed`);
|
|
186
|
+
if (partialSigs.length > 1) {
|
|
187
|
+
fail(`input ${index} has ${partialSigs.length} signatures; only single-key spends are supported`);
|
|
188
|
+
}
|
|
189
|
+
const { value: signature, keyData: pubkey } = partialSigs[0];
|
|
190
|
+
return [signature, pubkey];
|
|
191
|
+
};
|
|
192
|
+
if (isP2wpkh(script)) {
|
|
193
|
+
return { scriptSig: new Uint8Array(), witness: singleSig() };
|
|
194
|
+
}
|
|
195
|
+
if (isP2tr(script)) {
|
|
196
|
+
const tapKeySig = get(IN_TAP_KEY_SIG);
|
|
197
|
+
if (!tapKeySig) {
|
|
198
|
+
fail(`input ${index} has no Taproot key-path signature; script-path spends are not supported`);
|
|
199
|
+
}
|
|
200
|
+
return { scriptSig: new Uint8Array(), witness: [tapKeySig] };
|
|
201
|
+
}
|
|
202
|
+
if (isP2pkh(script)) {
|
|
203
|
+
const [signature, pubkey] = singleSig();
|
|
204
|
+
return {
|
|
205
|
+
scriptSig: concat([pushData(signature), pushData(pubkey)]),
|
|
206
|
+
witness: []
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (isP2sh(script)) {
|
|
210
|
+
const redeemScript = get(IN_REDEEM_SCRIPT);
|
|
211
|
+
if (!redeemScript || !isP2wpkh(redeemScript)) {
|
|
212
|
+
fail(`input ${index} is P2SH but not P2SH-P2WPKH; unsupported`);
|
|
213
|
+
}
|
|
214
|
+
return { scriptSig: pushData(redeemScript), witness: singleSig() };
|
|
215
|
+
}
|
|
216
|
+
fail(`input ${index} has an unsupported script type`);
|
|
217
|
+
}
|
|
218
|
+
/** The scriptPubKey this input spends, from whichever UTXO field is present. */
|
|
219
|
+
function prevoutScript(input, index, prevIndex) {
|
|
220
|
+
const witnessUtxo = input.find(kv => kv.type === IN_WITNESS_UTXO)?.value;
|
|
221
|
+
if (witnessUtxo) {
|
|
222
|
+
const reader = new Reader(witnessUtxo);
|
|
223
|
+
reader.take(8); // amount
|
|
224
|
+
return reader.varBytes();
|
|
225
|
+
}
|
|
226
|
+
const nonWitnessUtxo = input.find(kv => kv.type === IN_NON_WITNESS_UTXO)?.value;
|
|
227
|
+
if (nonWitnessUtxo) {
|
|
228
|
+
const output = parseTransaction(nonWitnessUtxo).outputs[prevIndex];
|
|
229
|
+
if (!output)
|
|
230
|
+
fail(`input ${index} spends an output its UTXO does not have`);
|
|
231
|
+
const reader = new Reader(output);
|
|
232
|
+
reader.take(8);
|
|
233
|
+
return reader.varBytes();
|
|
234
|
+
}
|
|
235
|
+
fail(`input ${index} has no UTXO information`);
|
|
236
|
+
}
|
|
237
|
+
function parseWitness(bytes) {
|
|
238
|
+
const reader = new Reader(bytes);
|
|
239
|
+
const items = [];
|
|
240
|
+
const count = reader.compactSize();
|
|
241
|
+
for (let i = 0; i < count; i++)
|
|
242
|
+
items.push(reader.varBytes());
|
|
243
|
+
return items;
|
|
244
|
+
}
|
|
245
|
+
const isP2wpkh = (s) => s.length === 22 && s[0] === 0x00 && s[1] === 0x14;
|
|
246
|
+
const isP2tr = (s) => s.length === 34 && s[0] === 0x51 && s[1] === 0x20;
|
|
247
|
+
const isP2pkh = (s) => s.length === 25 &&
|
|
248
|
+
s[0] === 0x76 &&
|
|
249
|
+
s[1] === 0xa9 &&
|
|
250
|
+
s[2] === 0x14 &&
|
|
251
|
+
s[23] === 0x88 &&
|
|
252
|
+
s[24] === 0xac;
|
|
253
|
+
const isP2sh = (s) => s.length === 23 && s[0] === 0xa9 && s[1] === 0x14 && s[22] === 0x87;
|
|
254
|
+
function serializeTransaction(tx, finals) {
|
|
255
|
+
const segwit = finals.some(f => f.witness.length > 0);
|
|
256
|
+
const parts = [tx.version];
|
|
257
|
+
if (segwit)
|
|
258
|
+
parts.push(Uint8Array.of(0x00, 0x01));
|
|
259
|
+
parts.push(compactSize(tx.inputs.length));
|
|
260
|
+
tx.inputs.forEach((input, i) => {
|
|
261
|
+
const { scriptSig } = finals[i];
|
|
262
|
+
parts.push(input.outpoint, compactSize(scriptSig.length), scriptSig, input.sequence);
|
|
263
|
+
});
|
|
264
|
+
parts.push(compactSize(tx.outputs.length), ...tx.outputs);
|
|
265
|
+
if (segwit) {
|
|
266
|
+
for (const { witness } of finals) {
|
|
267
|
+
parts.push(compactSize(witness.length));
|
|
268
|
+
for (const item of witness)
|
|
269
|
+
parts.push(compactSize(item.length), item);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
parts.push(tx.locktime);
|
|
273
|
+
return concat(parts);
|
|
274
|
+
}
|
|
275
|
+
/** Minimal script push for data up to 255 bytes (signatures, keys, redeem scripts). */
|
|
276
|
+
function pushData(data) {
|
|
277
|
+
if (data.length <= 75)
|
|
278
|
+
return concat([Uint8Array.of(data.length), data]);
|
|
279
|
+
if (data.length <= 0xff)
|
|
280
|
+
return concat([Uint8Array.of(0x4c, data.length), data]);
|
|
281
|
+
fail('script push too large');
|
|
282
|
+
}
|
|
283
|
+
function compactSize(n) {
|
|
284
|
+
if (n < 0xfd)
|
|
285
|
+
return Uint8Array.of(n);
|
|
286
|
+
if (n <= 0xffff)
|
|
287
|
+
return Uint8Array.of(0xfd, n & 0xff, n >> 8);
|
|
288
|
+
return Uint8Array.of(0xfe, n & 0xff, (n >> 8) & 0xff, (n >> 16) & 0xff, n >>> 24);
|
|
289
|
+
}
|
|
290
|
+
function concat(parts) {
|
|
291
|
+
const out = new Uint8Array(parts.reduce((sum, p) => sum + p.length, 0));
|
|
292
|
+
let offset = 0;
|
|
293
|
+
for (const part of parts) {
|
|
294
|
+
out.set(part, offset);
|
|
295
|
+
offset += part.length;
|
|
296
|
+
}
|
|
297
|
+
return out;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=psbt.js.map
|
package/dist/psbt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psbt.js","sourceRoot":"","sources":["../src/psbt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,YAAY,CAAC,UAAsB;IACjD,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC9C,aAAa,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,SAAS,CAAC,CAC9D,CAAA;IACD,OAAO,UAAU,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAgB;IAChD,MAAM,EAAE,GAAG,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;IACjD,MAAM,QAAQ,GAAG,oBAAoB,CACnC,EAAE,EACF,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CACtE,CAAA;IACD,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CAAC,IAAI,CAAC,CAAC,CAAA;IAC7D,OAAO,UAAU,CAAC,EAAE,CAClB,IAAI,EACJ,CAAC,GAAG,IAAI,EACR,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,EACf,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAChB,CAAC,KAAK,EAAE,CACT,CAAA;AACH,CAAC;AAED,SAAS,MAAM,CAAC,KAAmB;IACjC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;IACvE,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACrB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAA;IACvB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshconnect/uwc-bitcoin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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,8 +16,8 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@meshconnect/uwc-
|
|
20
|
-
"@meshconnect/uwc-
|
|
19
|
+
"@meshconnect/uwc-constants": "0.7.12",
|
|
20
|
+
"@meshconnect/uwc-types": "0.28.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^7.0.2"
|