@arkade-os/sdk 0.4.25 → 0.4.27
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/README.md +5 -25
- package/dist/cjs/contracts/contractManager.js +31 -11
- package/dist/cjs/contracts/contractWatcher.js +2 -2
- package/dist/cjs/identity/hdCapableIdentity.js +18 -0
- package/dist/cjs/identity/index.js +3 -1
- package/dist/cjs/identity/seedIdentity.js +16 -0
- package/dist/cjs/index.js +4 -2
- package/dist/cjs/script/address.js +2 -2
- package/dist/cjs/wallet/delegator.js +10 -4
- package/dist/cjs/wallet/hdDescriptorProvider.js +29 -0
- package/dist/cjs/wallet/inputSignerRouter.js +98 -0
- package/dist/cjs/wallet/serviceWorker/wallet.js +1 -0
- package/dist/cjs/wallet/signingErrors.js +32 -0
- package/dist/cjs/wallet/unroll.js +5 -1
- package/dist/cjs/wallet/wallet.js +232 -86
- package/dist/cjs/wallet/walletReceiveRotator.js +547 -0
- package/dist/cjs/worker/messageBus.js +1 -0
- package/dist/esm/adapters/asyncStorage.js +1 -1
- package/dist/esm/adapters/expo.js +2 -2
- package/dist/esm/adapters/fileSystem.js +1 -1
- package/dist/esm/adapters/indexedDB.js +1 -1
- package/dist/esm/adapters/localStorage.js +1 -1
- package/dist/esm/arkfee/index.js +1 -1
- package/dist/esm/arknote/index.js +1 -1
- package/dist/esm/bip322/index.js +2 -2
- package/dist/esm/contracts/arkcontract.js +2 -2
- package/dist/esm/contracts/contractManager.js +36 -16
- package/dist/esm/contracts/contractWatcher.js +5 -5
- package/dist/esm/contracts/handlers/default.js +4 -4
- package/dist/esm/contracts/handlers/delegate.js +4 -4
- package/dist/esm/contracts/handlers/helpers.js +2 -2
- package/dist/esm/contracts/handlers/index.js +8 -8
- package/dist/esm/contracts/handlers/vhtlc.js +3 -3
- package/dist/esm/contracts/index.js +8 -8
- package/dist/esm/extension/asset/assetGroup.js +7 -7
- package/dist/esm/extension/asset/assetId.js +2 -2
- package/dist/esm/extension/asset/assetInput.js +2 -2
- package/dist/esm/extension/asset/assetOutput.js +1 -1
- package/dist/esm/extension/asset/assetRef.js +3 -3
- package/dist/esm/extension/asset/index.js +8 -8
- package/dist/esm/extension/asset/metadata.js +1 -1
- package/dist/esm/extension/asset/packet.js +3 -3
- package/dist/esm/extension/index.js +4 -4
- package/dist/esm/forfeit.js +2 -2
- package/dist/esm/identity/hdCapableIdentity.js +17 -1
- package/dist/esm/identity/index.js +6 -5
- package/dist/esm/identity/seedIdentity.js +18 -2
- package/dist/esm/identity/serialize.js +2 -2
- package/dist/esm/identity/singleKey.js +1 -1
- package/dist/esm/identity/staticDescriptorProvider.js +2 -2
- package/dist/esm/index.js +48 -48
- package/dist/esm/intent/index.js +3 -3
- package/dist/esm/musig2/index.js +3 -3
- package/dist/esm/musig2/sign.js +1 -1
- package/dist/esm/providers/ark.js +3 -3
- package/dist/esm/providers/delegator.js +1 -1
- package/dist/esm/providers/electrum.js +2 -2
- package/dist/esm/providers/expoArk.js +2 -2
- package/dist/esm/providers/expoIndexer.js +3 -3
- package/dist/esm/providers/indexer.js +3 -3
- package/dist/esm/repositories/inMemory/walletRepository.js +1 -1
- package/dist/esm/repositories/index.js +9 -9
- package/dist/esm/repositories/indexedDB/contractRepository.js +4 -4
- package/dist/esm/repositories/indexedDB/db.js +2 -2
- package/dist/esm/repositories/indexedDB/schema.js +1 -1
- package/dist/esm/repositories/indexedDB/walletRepository.js +6 -6
- package/dist/esm/repositories/migrations/fromStorageAdapter.js +1 -1
- package/dist/esm/repositories/migrations/walletRepositoryImpl.js +1 -1
- package/dist/esm/repositories/realm/index.js +3 -3
- package/dist/esm/repositories/realm/schemas.js +1 -1
- package/dist/esm/repositories/realm/walletRepository.js +3 -3
- package/dist/esm/repositories/scriptFromAddress.js +1 -1
- package/dist/esm/repositories/sqlite/index.js +2 -2
- package/dist/esm/repositories/sqlite/walletRepository.js +3 -3
- package/dist/esm/script/address.js +3 -3
- package/dist/esm/script/base.js +3 -3
- package/dist/esm/script/default.js +2 -2
- package/dist/esm/script/delegate.js +3 -3
- package/dist/esm/script/tapscript.js +1 -1
- package/dist/esm/script/vhtlc.js +2 -2
- package/dist/esm/storage/indexedDB.js +1 -1
- package/dist/esm/tree/signingSession.js +2 -2
- package/dist/esm/tree/validation.js +2 -2
- package/dist/esm/utils/arkTransaction.js +7 -7
- package/dist/esm/utils/transactionHistory.js +1 -1
- package/dist/esm/utils/unknownFields.js +1 -1
- package/dist/esm/wallet/asset-manager.js +5 -5
- package/dist/esm/wallet/asset.js +1 -1
- package/dist/esm/wallet/batch.js +2 -2
- package/dist/esm/wallet/delegator.js +16 -10
- package/dist/esm/wallet/expo/background.js +5 -5
- package/dist/esm/wallet/expo/index.js +2 -2
- package/dist/esm/wallet/expo/wallet.js +8 -8
- package/dist/esm/wallet/hdDescriptorProvider.js +31 -2
- package/dist/esm/wallet/inputSignerRouter.js +94 -0
- package/dist/esm/wallet/onchain.js +7 -7
- package/dist/esm/wallet/ramps.js +3 -3
- package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +6 -6
- package/dist/esm/wallet/serviceWorker/wallet.js +8 -7
- package/dist/esm/wallet/signingErrors.js +27 -0
- package/dist/esm/wallet/unroll.js +12 -8
- package/dist/esm/wallet/utils.js +2 -2
- package/dist/esm/wallet/validation.js +2 -2
- package/dist/esm/wallet/vtxo-manager.js +9 -9
- package/dist/esm/wallet/wallet.js +262 -117
- package/dist/esm/wallet/walletReceiveRotator.js +540 -0
- package/dist/esm/worker/expo/index.js +4 -4
- package/dist/esm/worker/expo/processors/contractPollProcessor.js +1 -1
- package/dist/esm/worker/expo/processors/index.js +1 -1
- package/dist/esm/worker/expo/taskRunner.js +1 -1
- package/dist/esm/worker/messageBus.js +7 -6
- package/dist/types/adapters/asyncStorage.d.ts +2 -2
- package/dist/types/adapters/expo.d.ts +4 -4
- package/dist/types/adapters/fileSystem.d.ts +2 -2
- package/dist/types/adapters/indexedDB.d.ts +2 -2
- package/dist/types/adapters/localStorage.d.ts +2 -2
- package/dist/types/arkfee/index.d.ts +2 -2
- package/dist/types/arknote/index.d.ts +2 -2
- package/dist/types/bip322/index.d.ts +1 -1
- package/dist/types/contracts/arkcontract.d.ts +1 -1
- package/dist/types/contracts/contractManager.d.ts +39 -9
- package/dist/types/contracts/contractWatcher.d.ts +3 -3
- package/dist/types/contracts/handlers/default.d.ts +3 -3
- package/dist/types/contracts/handlers/delegate.d.ts +3 -3
- package/dist/types/contracts/handlers/helpers.d.ts +1 -1
- package/dist/types/contracts/handlers/index.d.ts +7 -7
- package/dist/types/contracts/handlers/registry.d.ts +1 -1
- package/dist/types/contracts/handlers/vhtlc.d.ts +3 -3
- package/dist/types/contracts/index.d.ts +14 -14
- package/dist/types/contracts/types.d.ts +21 -4
- package/dist/types/contracts/vtxoOwnership.d.ts +3 -3
- package/dist/types/extension/asset/assetGroup.d.ts +6 -6
- package/dist/types/extension/asset/assetId.d.ts +1 -1
- package/dist/types/extension/asset/assetInput.d.ts +2 -2
- package/dist/types/extension/asset/assetOutput.d.ts +1 -1
- package/dist/types/extension/asset/assetRef.d.ts +3 -3
- package/dist/types/extension/asset/index.d.ts +8 -8
- package/dist/types/extension/asset/metadata.d.ts +1 -1
- package/dist/types/extension/asset/packet.d.ts +2 -2
- package/dist/types/extension/index.d.ts +6 -6
- package/dist/types/forfeit.d.ts +1 -1
- package/dist/types/identity/descriptorProvider.d.ts +8 -1
- package/dist/types/identity/hdCapableIdentity.d.ts +33 -6
- package/dist/types/identity/index.d.ts +12 -11
- package/dist/types/identity/seedIdentity.d.ts +21 -5
- package/dist/types/identity/serialize.d.ts +1 -1
- package/dist/types/identity/singleKey.d.ts +3 -3
- package/dist/types/identity/staticDescriptorProvider.d.ts +3 -3
- package/dist/types/index.d.ts +59 -59
- package/dist/types/intent/index.d.ts +2 -2
- package/dist/types/musig2/index.d.ts +4 -4
- package/dist/types/providers/ark.d.ts +5 -5
- package/dist/types/providers/delegator.d.ts +2 -2
- package/dist/types/providers/electrum.d.ts +5 -5
- package/dist/types/providers/expoArk.d.ts +1 -1
- package/dist/types/providers/expoIndexer.d.ts +1 -1
- package/dist/types/providers/indexer.d.ts +1 -1
- package/dist/types/providers/onchain.d.ts +2 -2
- package/dist/types/repositories/contractRepository.d.ts +1 -1
- package/dist/types/repositories/inMemory/contractRepository.d.ts +2 -2
- package/dist/types/repositories/inMemory/walletRepository.d.ts +2 -2
- package/dist/types/repositories/index.d.ts +9 -9
- package/dist/types/repositories/indexedDB/contractRepository.d.ts +2 -2
- package/dist/types/repositories/indexedDB/db.d.ts +3 -3
- package/dist/types/repositories/indexedDB/walletRepository.d.ts +2 -2
- package/dist/types/repositories/migrations/contractRepositoryImpl.d.ts +3 -3
- package/dist/types/repositories/migrations/fromStorageAdapter.d.ts +2 -2
- package/dist/types/repositories/migrations/walletRepositoryImpl.d.ts +3 -3
- package/dist/types/repositories/realm/contractRepository.d.ts +3 -3
- package/dist/types/repositories/realm/index.d.ts +4 -4
- package/dist/types/repositories/realm/walletRepository.d.ts +3 -3
- package/dist/types/repositories/serialization.d.ts +11 -11
- package/dist/types/repositories/sqlite/contractRepository.d.ts +3 -3
- package/dist/types/repositories/sqlite/index.d.ts +3 -3
- package/dist/types/repositories/sqlite/walletRepository.d.ts +3 -3
- package/dist/types/repositories/walletRepository.d.ts +1 -1
- package/dist/types/script/address.d.ts +2 -2
- package/dist/types/script/base.d.ts +2 -2
- package/dist/types/script/default.d.ts +2 -2
- package/dist/types/script/delegate.d.ts +3 -3
- package/dist/types/script/vhtlc.d.ts +2 -2
- package/dist/types/storage/asyncStorage.d.ts +1 -1
- package/dist/types/storage/fileSystem.d.ts +1 -1
- package/dist/types/storage/inMemory.d.ts +1 -1
- package/dist/types/storage/indexedDB.d.ts +1 -1
- package/dist/types/storage/localStorage.d.ts +1 -1
- package/dist/types/tree/signingSession.d.ts +2 -2
- package/dist/types/tree/validation.d.ts +1 -1
- package/dist/types/utils/arkTransaction.d.ts +5 -5
- package/dist/types/utils/syncCursors.d.ts +1 -1
- package/dist/types/utils/timelock.d.ts +1 -1
- package/dist/types/utils/transaction.d.ts +2 -2
- package/dist/types/utils/transactionHistory.d.ts +1 -1
- package/dist/types/utils/txSizeEstimator.d.ts +1 -1
- package/dist/types/wallet/asset-manager.d.ts +3 -3
- package/dist/types/wallet/asset.d.ts +2 -2
- package/dist/types/wallet/batch.d.ts +2 -2
- package/dist/types/wallet/delegator.d.ts +5 -5
- package/dist/types/wallet/expo/background.d.ts +4 -4
- package/dist/types/wallet/expo/index.d.ts +4 -4
- package/dist/types/wallet/expo/wallet.d.ts +8 -8
- package/dist/types/wallet/hdDescriptorProvider.d.ts +26 -5
- package/dist/types/wallet/index.d.ts +63 -26
- package/dist/types/wallet/inputSignerRouter.d.ts +35 -0
- package/dist/types/wallet/onchain.d.ts +6 -6
- package/dist/types/wallet/ramps.d.ts +2 -2
- package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +7 -7
- package/dist/types/wallet/serviceWorker/wallet.d.ts +20 -10
- package/dist/types/wallet/signingErrors.d.ts +19 -0
- package/dist/types/wallet/unroll.d.ts +6 -6
- package/dist/types/wallet/utils.d.ts +5 -5
- package/dist/types/wallet/validation.d.ts +3 -3
- package/dist/types/wallet/vtxo-manager.d.ts +2 -2
- package/dist/types/wallet/wallet.d.ts +71 -22
- package/dist/types/wallet/walletReceiveRotator.d.ts +306 -0
- package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
- package/dist/types/worker/expo/index.d.ts +7 -7
- package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
- package/dist/types/worker/expo/processors/index.d.ts +1 -1
- package/dist/types/worker/expo/taskRunner.d.ts +7 -7
- package/dist/types/worker/messageBus.d.ts +7 -6
- package/package.json +2 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { hex } from "@scure/base";
|
|
2
|
+
import { DescriptorSigningProviderMissingError, MissingSigningDescriptorError, } from "./signingErrors.js";
|
|
3
|
+
const DESCRIPTOR_CAPABLE_CONTRACT_TYPES = new Set(["default", "delegate"]);
|
|
4
|
+
/**
|
|
5
|
+
* Routes PSBT inputs to the correct signer based on the owning contract.
|
|
6
|
+
* Inputs whose script matches a `default`/`delegate` contract with a
|
|
7
|
+
* non-baseline owner are sent to {@link DescriptorProvider}; everything
|
|
8
|
+
* else (baseline-owned contracts, non-default/non-delegate contracts,
|
|
9
|
+
* and the boarding script) is sent to {@link Identity}. Inputs with no
|
|
10
|
+
* matching contract and no boarding match are silently skipped, matching
|
|
11
|
+
* how the wallet historically handled cosigner/connector inputs.
|
|
12
|
+
*/
|
|
13
|
+
export class InputSignerRouter {
|
|
14
|
+
constructor(deps) {
|
|
15
|
+
this.deps = deps;
|
|
16
|
+
}
|
|
17
|
+
async sign(tx, jobs) {
|
|
18
|
+
if (jobs.length === 0)
|
|
19
|
+
return tx;
|
|
20
|
+
const distinctScripts = Array.from(new Set(jobs.map((j) => hex.encode(j.lookupScript))));
|
|
21
|
+
const contracts = await this.deps.contractRepository.getContracts({
|
|
22
|
+
script: distinctScripts,
|
|
23
|
+
});
|
|
24
|
+
// Repo may yield duplicates if seeded oddly; keep the first one
|
|
25
|
+
// for each script to match the wallet's historical behaviour.
|
|
26
|
+
const scriptToContract = new Map();
|
|
27
|
+
for (const contract of contracts) {
|
|
28
|
+
if (!scriptToContract.has(contract.script)) {
|
|
29
|
+
scriptToContract.set(contract.script, contract);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const baselinePubKeyHex = hex.encode(await this.deps.identity.xOnlyPublicKey());
|
|
33
|
+
const boardingScriptHex = hex.encode(this.deps.boardingPkScript);
|
|
34
|
+
const identityIndexes = [];
|
|
35
|
+
const descriptorGroups = new Map();
|
|
36
|
+
for (const job of jobs) {
|
|
37
|
+
const scriptHex = hex.encode(job.lookupScript);
|
|
38
|
+
const contract = scriptToContract.get(scriptHex);
|
|
39
|
+
if (!contract) {
|
|
40
|
+
if (scriptHex === boardingScriptHex) {
|
|
41
|
+
identityIndexes.push(job.index);
|
|
42
|
+
}
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!DESCRIPTOR_CAPABLE_CONTRACT_TYPES.has(contract.type)) {
|
|
46
|
+
identityIndexes.push(job.index);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
// `baselinePubKeyHex` is freshly produced by `hex.encode`,
|
|
50
|
+
// so it is already lowercase. `contract.params.pubKey` is
|
|
51
|
+
// persisted data: a migration or custom repository adapter
|
|
52
|
+
// could legitimately store it uppercase, so canonicalize
|
|
53
|
+
// before comparing to match the legacy router behaviour.
|
|
54
|
+
const ownerPubKeyHex = contract.params.pubKey?.toLowerCase();
|
|
55
|
+
if (ownerPubKeyHex && ownerPubKeyHex === baselinePubKeyHex) {
|
|
56
|
+
identityIndexes.push(job.index);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const descriptor = contract.metadata?.signingDescriptor;
|
|
60
|
+
if (typeof descriptor !== "string" || descriptor.length === 0) {
|
|
61
|
+
throw new MissingSigningDescriptorError(contract.script, contract.type);
|
|
62
|
+
}
|
|
63
|
+
const bucket = descriptorGroups.get(descriptor);
|
|
64
|
+
if (bucket) {
|
|
65
|
+
bucket.push(job.index);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
descriptorGroups.set(descriptor, [job.index]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
let signed = tx;
|
|
72
|
+
if (identityIndexes.length > 0) {
|
|
73
|
+
signed = await this.deps.identity.sign(signed, identityIndexes);
|
|
74
|
+
}
|
|
75
|
+
if (descriptorGroups.size > 0) {
|
|
76
|
+
if (!this.deps.descriptorProvider) {
|
|
77
|
+
throw new DescriptorSigningProviderMissingError();
|
|
78
|
+
}
|
|
79
|
+
const sortedDescriptors = Array.from(descriptorGroups.keys()).sort();
|
|
80
|
+
for (const descriptor of sortedDescriptors) {
|
|
81
|
+
const indexes = descriptorGroups.get(descriptor);
|
|
82
|
+
const [next] = await this.deps.descriptorProvider.signWithDescriptor([
|
|
83
|
+
{
|
|
84
|
+
tx: signed,
|
|
85
|
+
descriptor,
|
|
86
|
+
inputIndexes: indexes,
|
|
87
|
+
},
|
|
88
|
+
]);
|
|
89
|
+
signed = next;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return signed;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { p2tr } from "@scure/btc-signer";
|
|
2
|
-
import { DEFAULT_NETWORK_NAME } from
|
|
3
|
-
import { getNetwork } from
|
|
4
|
-
import { ESPLORA_URL, EsploraProvider, } from
|
|
5
|
-
import { findP2AOutput, P2A } from
|
|
6
|
-
import { TxWeightEstimator } from
|
|
7
|
-
import { Transaction } from
|
|
8
|
-
import { DUST_AMOUNT } from
|
|
2
|
+
import { DEFAULT_NETWORK_NAME } from "./index.js";
|
|
3
|
+
import { getNetwork } from "../networks.js";
|
|
4
|
+
import { ESPLORA_URL, EsploraProvider, } from "../providers/onchain.js";
|
|
5
|
+
import { findP2AOutput, P2A } from "../utils/anchor.js";
|
|
6
|
+
import { TxWeightEstimator } from "../utils/txSizeEstimator.js";
|
|
7
|
+
import { Transaction } from "../utils/transaction.js";
|
|
8
|
+
import { DUST_AMOUNT } from "./utils.js";
|
|
9
9
|
/**
|
|
10
10
|
* Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
|
|
11
11
|
*
|
package/dist/esm/wallet/ramps.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Estimator } from
|
|
1
|
+
import { Estimator } from "../arkfee/index.js";
|
|
2
2
|
import { Address, OutScript } from "@scure/btc-signer";
|
|
3
3
|
import { hex } from "@scure/base";
|
|
4
|
-
import { networks } from
|
|
5
|
-
import { ArkAddress } from
|
|
4
|
+
import { networks } from "../networks.js";
|
|
5
|
+
import { ArkAddress } from "../script/address.js";
|
|
6
6
|
/**
|
|
7
7
|
* Ramps is a class wrapping `settle` method to provide a more convenient interface for onboarding and offboarding operations.
|
|
8
8
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RestIndexerProvider } from
|
|
2
|
-
import { isExpired, isRecoverable, isSpendable, isSubdust, } from
|
|
3
|
-
import { extendCoin } from
|
|
4
|
-
import { buildTransactionHistory } from
|
|
5
|
-
import { filterVtxosForScript, getVtxosForContract, saveVtxosForContract, warnAndFilterVtxosForScript, } from
|
|
6
|
-
import { scriptFromArkAddress } from
|
|
1
|
+
import { RestIndexerProvider } from "../../providers/indexer.js";
|
|
2
|
+
import { isExpired, isRecoverable, isSpendable, isSubdust, } from "../index.js";
|
|
3
|
+
import { extendCoin } from "../utils.js";
|
|
4
|
+
import { buildTransactionHistory } from "../../utils/transactionHistory.js";
|
|
5
|
+
import { filterVtxosForScript, getVtxosForContract, saveVtxosForContract, warnAndFilterVtxosForScript, } from "../../contracts/vtxoOwnership.js";
|
|
6
|
+
import { scriptFromArkAddress } from "../../repositories/scriptFromAddress.js";
|
|
7
7
|
export class WalletNotInitializedError extends Error {
|
|
8
8
|
constructor() {
|
|
9
9
|
super("Wallet handler not initialized");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { hex } from "@scure/base";
|
|
2
|
-
import { serializeReadonlyIdentity, serializeSigningIdentity, } from
|
|
3
|
-
import { setupServiceWorker } from
|
|
4
|
-
import { IndexedDBContractRepository, IndexedDBWalletRepository, } from
|
|
5
|
-
import { DEFAULT_MESSAGE_TAG, } from
|
|
6
|
-
import { getRandomId } from
|
|
7
|
-
import { MESSAGE_BUS_NOT_INITIALIZED, ServiceWorkerTimeoutError, } from
|
|
8
|
-
import { getArkadeServerUrl } from
|
|
2
|
+
import { serializeReadonlyIdentity, serializeSigningIdentity, } from "../../identity/index.js";
|
|
3
|
+
import { setupServiceWorker } from "../../worker/browser/utils.js";
|
|
4
|
+
import { IndexedDBContractRepository, IndexedDBWalletRepository, } from "../../repositories/index.js";
|
|
5
|
+
import { DEFAULT_MESSAGE_TAG, } from "./wallet-message-handler.js";
|
|
6
|
+
import { getRandomId } from "../utils.js";
|
|
7
|
+
import { MESSAGE_BUS_NOT_INITIALIZED, ServiceWorkerTimeoutError, } from "../../worker/errors.js";
|
|
8
|
+
import { getArkadeServerUrl } from "../wallet.js";
|
|
9
9
|
// Check by error message content instead of instanceof because postMessage uses the
|
|
10
10
|
// structured clone algorithm which strips the prototype chain — the page
|
|
11
11
|
// receives a plain Error, not the original MessageBusNotInitializedError.
|
|
@@ -917,6 +917,7 @@ export class ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
|
917
917
|
indexerUrl: options.indexerUrl,
|
|
918
918
|
esploraUrl: options.esploraUrl,
|
|
919
919
|
settlementConfig: options.settlementConfig,
|
|
920
|
+
walletMode: options.walletMode,
|
|
920
921
|
watcherConfig: options.watcherConfig,
|
|
921
922
|
messageTimeouts,
|
|
922
923
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when a rotated contract (default or delegate) is missing the
|
|
3
|
+
* metadata.signingDescriptor required to route it to a descriptor-aware
|
|
4
|
+
* signer.
|
|
5
|
+
*/
|
|
6
|
+
export class MissingSigningDescriptorError extends Error {
|
|
7
|
+
constructor(contractScript, contractType) {
|
|
8
|
+
super(`Cannot sign input for ${contractType} contract ${contractScript}: ` +
|
|
9
|
+
`metadata.signingDescriptor is missing. This wallet was rotated ` +
|
|
10
|
+
`on an earlier build that did not persist signing descriptors. ` +
|
|
11
|
+
`Manually set metadata.signingDescriptor on the contract record, ` +
|
|
12
|
+
`or restore from a pre-rotation snapshot.`);
|
|
13
|
+
this.contractScript = contractScript;
|
|
14
|
+
this.contractType = contractType;
|
|
15
|
+
this.name = "MissingSigningDescriptorError";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Thrown when an input needs descriptor-aware signing but no
|
|
20
|
+
* DescriptorProvider was wired into the wallet.
|
|
21
|
+
*/
|
|
22
|
+
export class DescriptorSigningProviderMissingError extends Error {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("Descriptor signing requested but no DescriptorProvider was wired into this wallet");
|
|
25
|
+
this.name = "DescriptorSigningProviderMissingError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { base64, hex } from "@scure/base";
|
|
2
2
|
import { SigHash, TaprootControlBlock } from "@scure/btc-signer";
|
|
3
|
-
import { timelockToSequence } from
|
|
4
|
-
import { ChainTxType } from
|
|
5
|
-
import { VtxoScript } from
|
|
6
|
-
import { TxWeightEstimator } from
|
|
7
|
-
import { Wallet } from
|
|
8
|
-
import { Transaction } from
|
|
9
|
-
import { DUST_AMOUNT } from
|
|
3
|
+
import { timelockToSequence } from "../utils/timelock.js";
|
|
4
|
+
import { ChainTxType } from "../providers/indexer.js";
|
|
5
|
+
import { VtxoScript } from "../script/base.js";
|
|
6
|
+
import { TxWeightEstimator } from "../utils/txSizeEstimator.js";
|
|
7
|
+
import { Wallet } from "./wallet.js";
|
|
8
|
+
import { Transaction } from "../utils/transaction.js";
|
|
9
|
+
import { DUST_AMOUNT } from "./utils.js";
|
|
10
10
|
export var Unroll;
|
|
11
11
|
(function (Unroll) {
|
|
12
12
|
let StepType;
|
|
@@ -227,7 +227,11 @@ export async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress)
|
|
|
227
227
|
if (!feeRate || feeRate < Wallet.MIN_FEE_RATE) {
|
|
228
228
|
feeRate = Wallet.MIN_FEE_RATE;
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
// Esplora returns a `number` and bitcoind regtest sometimes reports
|
|
231
|
+
// fractional sat/vB (e.g. 1.006). `BigInt(1.006)` throws RangeError
|
|
232
|
+
// — round up so we always pay AT LEAST the advertised rate and
|
|
233
|
+
// satisfy BigInt's integer requirement.
|
|
234
|
+
const feeAmount = txWeightEstimator.vsize().fee(BigInt(Math.ceil(feeRate)));
|
|
231
235
|
if (feeAmount > totalAmount) {
|
|
232
236
|
throw new Error("fee amount is greater than the total amount");
|
|
233
237
|
}
|
package/dist/esm/wallet/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArkAddress, } from
|
|
2
|
-
import { contractHandlers } from
|
|
1
|
+
import { ArkAddress, } from "../index.js";
|
|
2
|
+
import { contractHandlers } from "../contracts/handlers/index.js";
|
|
3
3
|
import { hex } from "@scure/base";
|
|
4
4
|
export const DUST_AMOUNT = 546; // sats
|
|
5
5
|
export function extendCoin(wallet, utxo) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { equalBytes } from "@scure/btc-signer/utils.js";
|
|
2
|
-
import { ArkAddress } from
|
|
3
|
-
import { Extension } from
|
|
2
|
+
import { ArkAddress } from "../script/address.js";
|
|
3
|
+
import { Extension } from "../extension/index.js";
|
|
4
4
|
import { Address, OutScript } from "@scure/btc-signer";
|
|
5
5
|
export const ErrOffchainOutputNotFound = (address) => new Error(`offchain send output not found: ${address}`);
|
|
6
6
|
export const ErrInvalidAssetOutputAmount = (got, want, assetId) => new Error(`invalid asset output amount for ${assetId}: got ${got}, want ${want}`);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isExpired, isRecoverable, isSpendable, isSubdust, } from
|
|
2
|
-
import { maybeArkError } from
|
|
3
|
-
import { hasBoardingTxExpired } from
|
|
4
|
-
import { CSVMultisigTapscript } from
|
|
1
|
+
import { isExpired, isRecoverable, isSpendable, isSubdust, } from "./index.js";
|
|
2
|
+
import { maybeArkError } from "../providers/errors.js";
|
|
3
|
+
import { hasBoardingTxExpired } from "../utils/arkTransaction.js";
|
|
4
|
+
import { CSVMultisigTapscript } from "../script/tapscript.js";
|
|
5
5
|
import { hex } from "@scure/base";
|
|
6
|
-
import { getSequence } from
|
|
7
|
-
import { Transaction } from
|
|
8
|
-
import { TxWeightEstimator } from
|
|
9
|
-
import { Estimator } from
|
|
10
|
-
import { ArkAddress } from
|
|
6
|
+
import { getSequence } from "../script/base.js";
|
|
7
|
+
import { Transaction } from "../utils/transaction.js";
|
|
8
|
+
import { TxWeightEstimator } from "../utils/txSizeEstimator.js";
|
|
9
|
+
import { Estimator } from "../arkfee/index.js";
|
|
10
|
+
import { ArkAddress } from "../script/address.js";
|
|
11
11
|
/**
|
|
12
12
|
* Return whether a wallet exposes the properties required for boarding input sweep operations.
|
|
13
13
|
*
|