The fiat currency to use.
changeFiatCurrency("usd");
Method to check if a proposal's PSBTs can be finalized.
This method retrieves all approvals for a given proposal ID, filters out the approvals that are expired, and checks if the PSBTs for the active approvals can be finalized.
The ID of the proposal to check.
A Promise that resolves to a boolean indicating whether the PSBTs for the given proposal can be finalized.
Asynchronously deletes approvals with the given IDs.
Single or multiple approval IDs to be deleted.
void
when the operation is successful.await deleteApprovals('some-approval-id');
Asynchronously deletes completed proposals with the given IDs.
Single or multiple completed proposal IDs to be deleted.
void
when the operation is successful.await deleteCompletedProposals('some-completed-proposal-id');
Asynchronously deletes policies with the given IDs.
Single or multiple policy IDs to be deleted.
void
when the operation is successful.await deletePolicies('some-policy-id');
Asynchronously deletes proposals with the given IDs.
Single or multiple proposal IDs to be deleted.
void
when the operation is successful.await deleteProposals('some-proposal-id');
Asynchronously deletes signers with the given IDs.
Single or multiple signer IDs to be deleted.
void
when the operation is successful.await deleteSigners('some-signer-id');
Method to finalize a spending proposal.
This method finalizes a spending proposal by doing the following:
The ID of the spending proposal to finalize.
A Promise that resolves to a CompletedPublishedProposal
object representing the finalized proposal.
An error if the proposal or policy cannot be found, if there are no approvals for the proposal, if the PSBTs cannot be finalized, or if the proposal cannot be broadcast.
Returns the active fiat currency
const currency = getActiveFiatCurrency();
Asynchronously fetches approvals associated with given proposal IDs.
Optional
proposal_ids: string | string[]Optional proposal IDs to filter the approvals by.
- A Promise that resolves to a Map. Each key in the map is a proposal ID, and the corresponding value is an array of approved proposals associated with that proposal ID.
const approvalsMap = await getApprovals(['proposal1', 'proposal2']);
const allApprovalsMap = await getApprovals();
Asynchronously fetches approved proposals by their associated policy IDs.
A single policy ID or an array of policy IDs for which to fetch approved proposals. If this is not specified, the function fetches approvals for all available policy IDs.
// Fetch approvals for a single policy ID
const approvals = await getApprovalsByPolicyId('some-policy-id');
// Fetch approvals for multiple policy IDs
const approvals = await getApprovalsByPolicyId(['policy-id-1', 'policy-id-2']);
SmartVaultsTypes.PublishedApprovedProposal - For the structure of a PublishedApprovedProposal object.
Retrieves a completed proposal based on the provided transaction details.
Object containing the transaction details.
A Promise that resolves with the completed proposal, if found, or null.
getCompletedProposalByTx
getCompletedProposalByTx({txid: '1234', confirmation_time: {confirmedAt: new Date()}, net: -1})
Asynchronously fetches all completed proposals, optionally with pagination.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options to control the returned data.
// Fetch completed proposals with default settings
const proposals = await getCompletedProposals();
// Fetch completed proposals with pagination
const proposals = await getCompletedProposals({ limit: 5 });
SmartVaultsTypes.CompletedPublishedProposal - For the structure of a CompletedPublishedProposal object.
Asynchronously fetches completed proposals by their IDs.
The IDs of the completed proposals to fetch.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options to limit the number of returned proposals or to fetch from a specific offset.
// Fetch a single proposal by ID
const proposals = await getCompletedProposalsById("some-proposal-id");
// Fetch multiple proposals by IDs with pagination
const proposals = await getCompletedProposalsById(["id1", "id2"], { since: new Date() });
SmartVaultsTypes.CompletedPublishedProposal - For the structure of a CompletedPublishedProposal object.
Asynchronously fetches completed proposals by their associated policy IDs.
The policy IDs corresponding to the completed proposals to fetch.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options to limit the number of returned proposals or to fetch from a specific offset.
// Fetch a single proposal by policy ID
const proposals = await getCompletedProposalsByPolicyId("some-policy-id");
// Fetch multiple proposals by policy IDs with pagination
const proposals = await getCompletedProposalsByPolicyId(["policy-id1", "policy-id2"], { since : new Date() });
SmartVaultsTypes.PublishedCompletedSpendingProposal - For the structure of a PublishedCompletedSpendingProposal object.
Retrieves profiles for given contacts or for all contacts if none are provided.
Optional
contacts: Contact[]Optional array of contacts.
const contactProfiles = await getContactProfiles([{ publicKey: 'key1' }, { publicKey: 'key2' }]);
Returns the number of contacts that have shared their signer.
The Nostr hex public key of user for which to fetch the number of contacts that have shared their signer.
- A promise that resolves to the number of contacts that have shared their signer.
const howManySigners = await getContactSignersCount("hexPubKey");
Optional
signerDescriptors: string[]Optional
paginationOpts: PaginationOptsOptional
conversationId: stringOptional
paginationOpts: PaginationOptsOptional
signerDescriptor: stringAsynchronously fetches signers the user has shared. If IDs are provided, the method fetches signers corresponding to those IDs. Otherwise, it fetches all shared signers based.
Optional
id: string | string[]Optional ID(s) of the signers to fetch.
Will throw an error if any issue occurs during the request to the relay.
// Fetch a single shared signer by ID
const result = await getMySharedSigners("some-signer-id");
// Fetch multiple shared signers by IDs
const result = await getMySharedSigners(["id1", "id2"]);
// Fetch all shared signers
const result = await getMySharedSigners();
SmartVaultsTypes.MySharedSigner - For the structure of MySharedSigner objects.
Optional
pubkey: string | string[]Optional
signerOfferingIds: string[]Optional
signerDescriptors: string[]Optional
signerFingerprints: string[]Fetches signers owned by the user and returns them as an array of BaseOwnedSigner objects.
A promise that resolves to an array of BaseOwnedSigner objects. Each BaseOwnedSigner object represents an owned signer and contains all the properties of the base signer object, plus `ownerPubKey' and 'createdAt' properties.
Throws an error if there's an issue in fetching signer events or decrypting content.
Asynchronously retrieves policies within a specified pagination scope.
Optional
paginationOpts: PaginationOpts = {}Pagination options for fetching policies.
const paginationOpts = { limit: 10, page: 2 };
const policies = await getPolicies(paginationOpts);
Optional
paginationOpts: PaginationOptsAsynchronously retrieves policies by their IDs.
An array of policy IDs.
const ids = ['id1', 'id2'];
const policiesById = await getPoliciesById(ids);
Retrieves a profile by a given public key or uses the instance's public key if not provided.
Optional
publicKey: stringOptional public key to fetch the profile.
const profile = await getProfile('publicKey123');
Method to retrieve and decrypt not completed proposals.
This method retrieves all not completed proposals.
A Promise that resolves to an array of decrypted proposals.
Asynchronously fetches proposals by their IDs.
A single proposal ID or an array of proposal IDs to fetch.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options.
const proposalsById = await getProposalsById('some-proposal-id');
Asynchronously fetches proposals by associated policy IDs.
A single policy ID or an array of policy IDs for which to fetch proposals.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options.
const proposalsByPolicyId = await getProposalsByPolicyId('some-policy-id');
Retrieves a list of recommended contacts based on shared signers.
const recommendedContacts = await getRecommendedContacts();
Asynchronously retrieves shared keys by their IDs.
Optional
ids: string[]An array of shared key IDs.
const ids = ['id1', 'id2'];
const sharedKeysById = await getSharedKeysById(ids);
Asynchronously fetches signers shared with the user based on specified public keys. Returns them as an array of PublishedSharedSigner objects, each containing details such as owner's public key and creation time.
Optional
publicKeys: string | string[]Optional public keys to filter the fetched signers. Can be a single string or an array of strings.
// Fetch shared signers by a specific public key
const result = await getSharedSigners("some-public-key");
// Fetch shared signers by multiple public keys
const result = await getSharedSigners(["key1", "key2"]);
// Fetch all shared signers
const result = await getSharedSigners();
SmartVaultsTypes.PublishedSharedSigner - For the structure of PublishedSharedSigner objects.
Optional
publicKeys: string | string[]Optional
fromVerifiedKeyAgents: booleanOptional
paginationOpts: PaginationOptsOptional
signerOfferingIds: string[]Optional
fromVerifiedKeyAgents: booleanOptional
paginationOpts: PaginationOptsOptional
keyAgentsPubKeys: string[]Optional
fromVerifiedKeyAgents: booleanOptional
paginationOpts: PaginationOptsOptional
period: PeriodAsynchronously retrieves transactionMetadata based on the given pagination options.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options for fetching transactionMetadata.
const transactionMetadata = await getTransactionMetadata();
Asynchronously retrieves one or more transactionMetadata by their IDs.
The transactionMetadata IDs to fetch.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options.
- A promise that resolves to a map where the keys are transactionMetadata IDs and the values are the corresponding transactionMetadata.
const transactionMetadataMap = await getTransactionMetadataById(['transactionMetadata1', 'transactionMetadata2']);
Asynchronously retrieves transactionMetadata associated with one or more policy IDs.
This method first converts the input into an array of policy IDs (if not already), builds the appropriate filter with pagination options, and then fetches the transactionMetadata.
The policy IDs to filter transactionMetadata by.
Optional
paginationOpts: PaginationOpts = {}Optional pagination options.
- A promise that resolves to a map where the keys are policy IDs and the values are the associated transactionMetadata.
const transactionMetadataMap = await getTransactionMetadataByPolicyId(['policy1', 'policy2']);
Asynchronously retrieves a transactionMetadata given its transactionMetadata data.
The policy ID associaded with the transactionMetadata.
The source ID (could be an address a txid, etc).
const transactionMetadata = await getTransactionMetadataBySourceId("policyId","trxid");
Asynchronously removes contacts by publicKey and publishes a Contacts event.
publicKeys of contacts to remove.
await removeContacts('somePubKey');
await removeContacts(['somePubKey', 'otherPubKey']);
Asynchronously revokes shared signers with the given IDs.
Single or multiple shared signer IDs to be revoked ( not signer ids ).
void
when the operation is successful.await revokeMySharedSigners('some-shared-signer-id');
Asynchronously saves an owned signer by encrypting its properties, building a new event,
and publishing it via NostrClient
.
Parameters for the owned signer, including description
, descriptor
,
fingerprint
, name
, t
.
A promise that resolves to an BaseOwnedSigner object with encrypted data and includes the owner's public key and creation date.
Will throw an error if the event publishing fails.
const signer = await saveOwnedSigner({description, descriptor, fingerprint, name, t});
Asynchronously saves a new policy and associated shared keys, then publishes the policy event.
Payload containing policy details.
const payload = {
name: 'My Policy',
description: 'Description here',
miniscript: 'miniscriptString',
nostrPublicKeys: ['key1', 'key2'],
createdAt: new Date()
};
const publishedPolicy = await savePolicy(payload);
Asynchronously creates and publishes a 'SharedSigners' event.
A promise that resolves to a PublishedSharedSigner object, includes the owner's public key and shared date.
Will throw an error if the event publishing fails or if the user tries to share a signer with themselves.
const signer = await saveSharedSigner({descriptor, fingerprint}, pubkey);
Optional
confirmationComponent: (() => Promise<boolean>)Asynchronously saves a transactionMetadata associated with a given policy ID.
The method creates and publishes a TransactionMetadata event.
The ID of the policy to which the transactionMetadata is to be associated.
The transactionMetadata object containing the data to be saved.
const publishedTransactionMetadata = await saveTransactionMetadata('some-policy-id', { data: { 'Address': 'some-address' }, text: 'some-transactionMetadata-text' });
Sets the profile metadata and publishes a Metadata event.
Metadata for the profile.
await setProfile({ name: 'Alice', about: 'Learning about Smart Vaults' });
Asynchronously initiates a spending proposal.
Payload for the spending proposal.
const payload = {
policy,
to_address: "abc123",
description: "A spending proposal",
amountDescriptor: 10,
feeRatePriority: 'high',
policyPath: new Map([['nodeId',[0,1,2]]]),
utxos: ["utxo1", "utxo2"],
useFrozenUtxos: false
};
const spendingProposal = await spend(payload);
Subscribes to specified kinds of events and handles them using a provided callback function.
The event kinds to subscribe to. This can either be an array or a single value.
The callback function to handle incoming events. It receives the kind of event and the associated payload.
const kindsToSubscribe = [SmartVaultsKind.Policy, SmartVaultsKind.Proposal];
const myCallback = (kind, payload) => {
console.log(`Received event of kind ${kind} with payload:`, payload);
};
const mySubscription = subscribe(kindsToSubscribe, myCallback);
// To unsubscribe
mySubscription.disconnect();
Asynchronously upserts contacts and publishes a Contacts event.
const contact = new Contact({ publicKey: 'somePubKey', relay: 'some.relay.com' });
await upsertContacts(contact);
Generated using TypeDoc
Changes the fiat currency used to fetch the Bitcoin exchange rate.