Build Babbage apps in TypeScript
npm i @babbage/sdk
There are a few example projects you can check out which implement the Babbage SDK:
- 🎵Tempo: A platform for creating and sharing music, and empowering artists with micropayments
- ✅Simple ToDo List: An app that demonstrates the basics of Bitcoin tokenization and identity
📒 The JavaScript API is documented below the examples, in the API section
The 📚Babbage Learn website hosts the concepts, guides and reference materials that show you how the SDK works.
import { encrypt, decrypt } from '@babbage/sdk-ts'
// Encrypt and decrypt data using the Babbage SDK
const encryptedData = await encrypt({
plaintext: Buffer.from('some data'),
protocolID: [0, 'Hello World'],
keyID: '1'
})
// The same protocol and key ID is needed for decryption
const decryptedData = await decrypt({
ciphertext: encryptedData,
protocolID: [0, 'Hello World'],
keyID: '1',
returnType: 'string'
})
This example also uses PushDrop
import { createAction } from '@babbage/sdk-ts'
import { create, redeem } from 'pushdrop'
const bitcoinOutputScript = await create({
fields: [ // The "fields" are the data payload to attach to the token.
Buffer.from('My First Token'),
Buffer.from('My name is Ty') // Tokens can represent anything!
],
// The "first token" protocol and key ID can be used to sign and
// lock this new Bitcoin PushDrop token.
protocolID: 'first token',
keyID: '1'
})
const newToken = await createAction({
// The Bitcoin transaction ("Action" with a capital A) has an output,
// because it has led to the creation of a new Bitcoin token.
outputs: [{
// The output amount is how much Bitcoin (measured in "satoshis")
// this token is worth. Let's use 1000 satoshis.
satoshis: 1000,
// The output script for this token was created by the PushDrop library,
// which you can see above.
script: bitcoinOutputScript
}],
// Finally, we'll describe the Action for the user
description: 'Create my first token'
})
// Here, we're using the PushDrop library to unlcok / redeem the PushDrop
// token that was previously created. By providing this information,
// PushDrop can "unlock" and spend the token. When the token gets spent,
// the user gets their 1000 satoshis back.
const unlockingScript = await pushdrop.redeem({
// To unlock the token, we need to use the same "first token" protocol
// and key ID as when we created the token before. Otherwise, the
// key won't fit the lock and the Bitcoins won't come out.
protocolID: 'first token',
keyID: '1',
// We're telling PushDrop which previous transaction and output we want to
// unlock, so that the correct unlocking puzzle can be prepared.
prevTxId: newToken.txid,
outputIndex: 0, // The first output from the transaction
// We also give PushDrop a copy of the locking puzzle ("script") that
// we want to open, which is helpful in preparing to unlock it.
lockingScript: bitcoinOutputScript,
// Finally, the number of satoshis we are expecting to unlock when the
// puzzle gets solved.
outputAmount: 1000
})
// Now, we're going to use the unlocking puzle that PushDrop has prepared for us,
// so that the user can get their Bitcoins back. This is another "Action", which
// is just a Bitcoin transaction.
// The amount the user gets back will be slightly less, because of transaction fees.
await createAction({
inputs: { // These are inputs, which unlock Bitcoin tokens.
// The input comes from the token which we're completing
[newToken.txid]: {
...newToken,
// The output we want to redeem is specified here, and we also give
// the unlocking puzzle ("script") from PushDrop.
outputsToRedeem: [{
index: 0, // The first output of the transaction
unlockingScript
}]
}
},
// Let the user know why they're getting some Bitcoins back
description: 'Redeem my first token'
})
🏆 After reading the above two examples, could you implement a token with encrypted data? 🏆
Links: API, Interfaces, Classes, Functions, Types, Variables
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AbortActionArgs {
reference: Base64String;
}
See also: Base64String
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AbortActionResult {
referenceNumber: string;
log?: string;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AbortActionResult {
aborted: boolean;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AcquireCertificateArgs {
type: Base64String;
certifier: PubKeyHex;
acquisitionProtocol: AcquisitionProtocol;
fields: Record<CertificateFieldNameUnder50Bytes, string>;
serialNumber?: Base64String;
revocationOutpoint?: OutpointString;
signature?: HexString;
certifierUrl?: string;
keyringRevealer?: KeyringRevealer;
keyringForSubject?: Record<CertificateFieldNameUnder50Bytes, Base64String>;
privileged?: BooleanDefaultFalse;
privilegedReason?: DescriptionString5to50Bytes;
}
See also: AcquisitionProtocol, Base64String, BooleanDefaultFalse, CertificateFieldNameUnder50Bytes, DescriptionString5to50Bytes, HexString, KeyringRevealer, OutpointString, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AcquireCertificateResult extends WalletCertificate {
}
See also: WalletCertificate
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface AuthenticatedResult {
authenticated: boolean;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface BasketInsertion {
basket: BasketStringUnder300Bytes;
customInstructions?: string;
tags?: OutputTagStringUnder300Bytes[];
}
See also: BasketStringUnder300Bytes, OutputTagStringUnder300Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CertificateApi {
type: string;
subject: string;
validationKey: string;
serialNumber: string;
certifier: string;
revocationOutpoint: string;
signature: string;
fields?: Record<string, string>;
}
Interface CertificateApi Details
max length of 255
certifier: string
Certificate fields object where keys are field names and values are field value.
fields?: Record<string, string>
max length of 255
revocationOutpoint: string
max length of 255
serialNumber: string
max length of 255
signature: string
max length of 255
subject: string
max length of 255
type: string
max length of 255
validationKey: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CounterpartyKeyLinkageResult {
type: "counterparty-revelation";
prover: string;
verifier: string;
counterparty: string;
revelationTime: string;
encryptedLinkage: string;
}
Interface CounterpartyKeyLinkageResult Details
ISO date string
revelationTime: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionArgs {
description: DescriptionString5to50Bytes;
inputBEEF?: BEEF;
inputs?: CreateActionInput[];
outputs?: CreateActionOutput[];
lockTime?: PositiveIntegerOrZero;
version?: PositiveIntegerOrZero;
labels?: LabelStringUnder300Bytes[];
options?: CreateActionOptions;
}
See also: BEEF, CreateActionInput, CreateActionOptions, CreateActionOutput, DescriptionString5to50Bytes, LabelStringUnder300Bytes, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionInput extends OptionalEnvelopeEvidenceApi {
outputsToRedeem: CreateActionOutputToRedeem[];
}
See also: CreateActionOutputToRedeem, OptionalEnvelopeEvidenceApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionInput {
outpoint: OutpointString;
inputDescription: DescriptionString5to50Bytes;
unlockingScript?: HexString;
unlockingScriptLength?: PositiveInteger;
sequenceNumber?: PositiveIntegerOrZero;
}
See also: DescriptionString5to50Bytes, HexString, OutpointString, PositiveInteger, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionOptions {
acceptDelayedBroadcast?: boolean;
trustSelf?: TrustSelf;
knownTxids?: string[];
resultFormat?: "beef" | "none";
noSend?: boolean;
noSendChange?: OutPoint[];
sendWith?: string[];
randomizeOutputs?: boolean;
}
Interface CreateActionOptions Details
true if local validation and self-signed mapi response is sufficient.
Upon return, transaction will have sending
status. Watchman will proceed to send the transaction asynchronously.
false if a valid mapi response from the bitcoin transaction processing network is required.
Upon return, transaction will have unproven
status. Watchman will proceed to prove transaction.
default true
acceptDelayedBroadcast?: boolean
If the caller already has envelopes or BUMPS for certain txids, pass them in this array and they will be assumed to be valid and not returned again in the results.
knownTxids?: string[]
If true, successfully created transactions remain in the nosend
state.
A proof will be sought but it will not be considered an error if the txid remains unknown.
Supports testing, user control over broadcasting of transactions, and batching.
noSend?: boolean
Available transaction fee payment output(s) belonging to the user.
Only change outputs previously created by a noSend transaction.
Supports chained noSend transactions by minimizing the consumption and non-replenishment of change outputs.
noSendChange?: OutPoint[]
See also: OutPoint
optional. When set to false, the wallet will avoid randomizing the order of outputs within the transaction.
randomizeOutputs?: boolean
If 'beef', the results will format new transaction and supporting input proofs in BEEF format.
If 'none', the results will include only the txid of the new transaction.
Otherwise, the results will use EnvelopeEvidenceApi
format.
resultFormat?: "beef" | "none"
Setting sendWith
to an array of txid
values for previously created noSend
transactions
causes all of them to be sent to the bitcoin network as a single batch of transactions.
When using sendWith
, createAction
can be called without inputs or outputs,
in which case previously created noSend
transactions will be sent
without creating a new transaction.
sendWith?: string[]
If undefined, normal case, all inputs must be provably valid by chain of rawTx and merkle proof values, and results will include new rawTx and proof chains for new outputs.
If 'known', any input txid corresponding to a previously processed transaction may ommit its rawTx and proofs, and results will exclude new rawTx and proof chains for new outputs.
trustSelf?: TrustSelf
See also: TrustSelf
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionOptions {
signAndProcess?: BooleanDefaultTrue;
acceptDelayedBroadcast?: BooleanDefaultTrue;
trustSelf?: TrustSelf;
knownTxids?: TXIDHexString[];
returnTXIDOnly?: BooleanDefaultFalse;
noSend?: BooleanDefaultFalse;
noSendChange?: OutpointString[];
sendWith?: TXIDHexString[];
randomizeOutputs?: BooleanDefaultTrue;
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, OutpointString, TXIDHexString, TrustSelf
Links: API, Interfaces, Classes, Functions, Types, Variables
A specific output to be created as part of a new transactions. These outputs can contain custom scripts as specified by recipients.
export interface CreateActionOutput {
script: string;
satoshis: number;
description?: string;
basket?: string;
customInstructions?: string;
tags?: string[];
}
Interface CreateActionOutput Details
Destination output basket name for the new UTXO
basket?: string
Custom spending instructions (metadata, string, optional)
customInstructions?: string
Human-readable output line-item description
description?: string
The amount of the output in satoshis
satoshis: number
The output script that will be included, hex encoded
script: string
Optional array of output tags to assign to this output.
tags?: string[]
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionOutput {
lockingScript: HexString;
satoshis: SatoshiValue;
outputDescription: DescriptionString5to50Bytes;
basket?: BasketStringUnder300Bytes;
customInstructions?: string;
tags?: OutputTagStringUnder300Bytes[];
}
See also: BasketStringUnder300Bytes, DescriptionString5to50Bytes, HexString, OutputTagStringUnder300Bytes, SatoshiValue
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionOutputToRedeem {
index: number;
unlockingScript: string | number;
spendingDescription?: string;
sequenceNumber?: number;
}
Interface CreateActionOutputToRedeem Details
Zero based output index within its transaction to spend, vout.
index: number
Sequence number to use when spending
sequenceNumber?: number
Hex scriptcode that unlocks the satoshis or the maximum script length (in bytes) if using signAction
.
Note that you should create any signatures with SIGHASH_NONE | ANYONECANPAY
or similar
so that the additional Dojo outputs can be added afterward without invalidating your signature.
unlockingScript: string | number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionParams {
description: string;
inputs?: Record<string, CreateActionInput>;
beef?: Beef | number[];
outputs?: CreateActionOutput[];
lockTime?: number;
version?: number;
labels?: string[];
originator?: string;
options?: CreateActionOptions;
acceptDelayedBroadcast?: boolean;
log?: string;
}
See also: CreateActionInput, CreateActionOptions, CreateActionOutput
Interface CreateActionParams Details
true if local validation and self-signed mapi response is sufficient.
Upon return, transaction will have sending
status. Watchman will proceed to send the transaction asynchronously.
false if a valid mapi response from the bitcoin transaction processing network is required.
Upon return, transaction will have unproven
status. Watchman will proceed to prove transaction.
default true
DEPRECATED: Use options.acceptDelayedBroadcast instead.
acceptDelayedBroadcast?: boolean
Optional. Alternate source of validity proof data for inputs
.
If number[]
it must be serialized Beef
.
beef?: Beef | number[]
Human readable string giving the purpose of this transaction. Value will be encrypted prior to leaving this device. Encrypted length limit is 500 characters.
description: string
If an input is self-provided (known to user's Dojo), or if beef is used, envelope evidence can be ommitted, reducing data size and processing time.
each input's outputsToRedeem:
- satoshis must be greater than zero, must match output's value.
- spendingDescription length limit is 50, values are encrypted before leaving this device
- unlockingScript is max byte length for
signActionRequired
mode, otherwise hex string.
inputs?: Record<string, CreateActionInput>
See also: CreateActionInput
transaction labels to apply to this transaction default []
labels?: string[]
Optional. Default is zero. When the transaction can be processed into a block:
= 500,000,000 values are interpreted as minimum required unix time stamps in seconds < 500,000,000 values are interpreted as minimum required block height
lockTime?: number
Processing options.
options?: CreateActionOptions
See also: CreateActionOptions
Reserved Admin originators 'projectbabbage.com' 'staging-satoshiframe.babbage.systems' 'satoshiframe.babbage.systems'
originator?: string
each output:
- description length limit is 50, values are encrypted before leaving this device
outputs?: CreateActionOutput[]
See also: CreateActionOutput
Optional. Transaction version number, default is current standard transaction version value.
version?: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionResult {
signActionRequired?: boolean;
createResult?: DojoCreateTransactionResultApi;
txid?: string;
rawTx?: string;
inputs?: Record<string, OptionalEnvelopeEvidenceApi>;
beef?: number[];
noSendChange?: OutPoint[];
mapiResponses?: MapiResponseApi[];
sendWithResults?: DojoSendWithResultsApi[];
options?: CreateActionOptions;
log?: string;
}
See also: CreateActionOptions, DojoCreateTransactionResultApi, DojoSendWithResultsApi, MapiResponseApi, OptionalEnvelopeEvidenceApi, OutPoint
Interface CreateActionResult Details
Valid for options.resultFormat 'beef',
in which case rawTx
and inputs
will be undefined.
Change output(s) that may be forwarded to chained noSend transactions.
beef?: number[]
if signActionRequired, the dojo createTransaction results to be forwarded to signAction
createResult?: DojoCreateTransactionResultApi
See also: DojoCreateTransactionResultApi
This is the fully-formed inputs
field of this transaction, as per the SPV Envelope specification.
inputs?: Record<string, OptionalEnvelopeEvidenceApi>
See also: OptionalEnvelopeEvidenceApi
operational and performance logging if enabled.
log?: string
If not signActionRequired
, at least one valid mapi response.
may be a self-signed response if acceptDelayedBroadcast
is true.
If signActionRequired
, empty array.
mapiResponses?: MapiResponseApi[]
See also: MapiResponseApi
Valid for options.noSend true.
Change output(s) that may be forwarded to chained noSend transactions.
noSendChange?: OutPoint[]
See also: OutPoint
Processing options.
options?: CreateActionOptions
See also: CreateActionOptions
if not signActionRequired, fully signed transaction as LE hex string
if signActionRequired:
- All length specified unlocking scripts are zero bytes
- All SABPPP template unlocking scripts have zero byte signatures
- All custom provided unlocking scripts fully copied.
rawTx?: string
true if at least one input's outputsToRedeem uses numeric max script byte length for unlockingScript
If true, in-process transaction will have status unsigned
. An unsigned
transaction must be completed
by signing all remaining unsigned inputs and calling signAction
. Failure to complete the process in
a timely manner will cause the transaction to transition to failed
.
If false or undefined, completed transaction will have status of sending
, nosend
or unproven
,
depending on acceptDelayedBroadcast
and noSend
.
signActionRequired?: boolean
if not signActionRequired, signed transaction hash (double SHA256 BE hex string)
txid?: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateActionResult {
txid?: TXIDHexString;
tx?: AtomicBEEF;
noSendChange?: OutpointString[];
sendWithResults?: SendWithResult[];
signableTransaction?: SignableTransaction;
}
See also: AtomicBEEF, OutpointString, SendWithResult, SignableTransaction, TXIDHexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateCertificateResult extends CertificateApi {
type: string;
subject: string;
validationKey: string;
serialNumber: string;
certifier: string;
revocationOutpoint: string;
signature: string;
fields?: Record<string, string>;
masterKeyring?: Record<string, string>;
}
See also: CertificateApi
Interface CreateCertificateResult Details
max length of 255
certifier: string
Certificate fields object where keys are field names and values are field value.
fields?: Record<string, string>
Certificate masterKeyring object where keys are field names and values are field masterKey value.
masterKeyring?: Record<string, string>
max length of 255
revocationOutpoint: string
max length of 255
serialNumber: string
max length of 255
signature: string
max length of 255
subject: string
max length of 255
type: string
max length of 255
validationKey: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateHmacArgs extends WalletEncryptionArgs {
data: Byte[];
}
See also: Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateHmacResult {
hmac: Byte[];
}
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateSignatureArgs extends WalletEncryptionArgs {
data?: Byte[];
hashToDirectlySign?: Byte[];
}
See also: Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface CreateSignatureResult {
signature: Byte[];
}
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DiscoverByAttributesArgs {
attributes: Record<CertificateFieldNameUnder50Bytes, string>;
limit?: PositiveIntegerDefault10Max10000;
offset?: PositiveIntegerOrZero;
seekPermission?: BooleanDefaultTrue;
}
See also: BooleanDefaultTrue, CertificateFieldNameUnder50Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DiscoverByIdentityKeyArgs {
identityKey: PubKeyHex;
limit?: PositiveIntegerDefault10Max10000;
offset?: PositiveIntegerOrZero;
seekPermission?: BooleanDefaultTrue;
}
See also: BooleanDefaultTrue, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DiscoverCertificatesResult {
totalCertificates: PositiveIntegerOrZero;
certificates: IdentityCertificate[];
}
See also: IdentityCertificate, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoCreateTransactionResultApi {
inputs: Record<string, DojoCreatingTxInputsApi>;
outputs: DojoCreateTxResultOutputApi[];
derivationPrefix: string;
version: number;
lockTime: number;
referenceNumber: string;
paymailHandle: string;
note?: string;
log?: string;
}
See also: DojoCreateTxResultOutputApi, DojoCreatingTxInputsApi
Links: API, Interfaces, Classes, Functions, Types, Variables
A specific output to be created as part of a new transactions. These outputs can contain custom scripts as specified by recipients.
export interface DojoCreateTxOutputApi {
script: string;
satoshis: number;
description?: string;
basket?: string;
customInstructions?: string;
tags?: string[];
}
Interface DojoCreateTxOutputApi Details
Destination output basket name for the new UTXO
basket?: string
Custom spending instructions (metadata, string, optional)
customInstructions?: string
Human-readable output line-item description
description?: string
The amount of the output in satoshis
satoshis: number
The output script that will be included, hex encoded
script: string
Optional array of output tags to assign to this output.
tags?: string[]
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoCreateTxResultInstructionsApi {
type: string;
derivationPrefix?: string;
derivationSuffix?: string;
senderIdentityKey?: string;
paymailHandle?: string;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoCreateTxResultOutputApi extends DojoCreateTxOutputApi {
providedBy: DojoProvidedByApi;
purpose?: string;
destinationBasket?: string;
derivationSuffix?: string;
keyOffset?: string;
}
See also: DojoCreateTxOutputApi, DojoProvidedByApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoCreatingTxInputsApi extends EnvelopeEvidenceApi {
outputsToRedeem: DojoOutputToRedeemApi[];
providedBy: DojoProvidedByApi;
instructions: Record<number, DojoCreateTxResultInstructionsApi>;
}
See also: DojoCreateTxResultInstructionsApi, DojoOutputToRedeemApi, DojoProvidedByApi, EnvelopeEvidenceApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoOutputToRedeemApi {
index: number;
unlockingScriptLength: number;
spendingDescription?: string;
}
Interface DojoOutputToRedeemApi Details
Zero based output index within its transaction to spend.
index: number
byte length of unlocking script
Note: To protect client keys and utxo control, unlocking scripts are never shared with Dojo.
unlockingScriptLength: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface DojoSendWithResultsApi {
txid: string;
transactionId: number;
reference: string;
status: "unproven" | "failed" | "sending";
}
Links: API, Interfaces, Classes, Functions, Types, Variables
Simplest case of an envelope is a rawTx
and merkle proof
that ties the transaction to a known block header.
This will be the case for any sufficiently old transaction.
If the transaction has been mined but for some reason the block headers may not be known, an array of headers
linking
known headers to the one needed by the proof
may be provided. They must be in height order and need to overlap
a known header.
If the transaction has not been minded yet but it has been submitted to one or more miners then the mapi responses received, proving that specific miners have received the transaction for processing, are included in the mapiResponses array. Note that the miner reputations must be checked to give weight to these responses.
Additionally, when the transaction hasn't been mined or a proof
is unavailable and mapi responses proving miner
acceptance are unavailable, then all the transactions providing inputs can be submitted in an inputs object.
The keys of the inputs object are the transaction hashes (txids) of each of the input transactions. The value of each inputs object property is another envelope object.
References: Section 2 of https://projectbabbage.com/assets/simplified-payments.pdf https://gist.github.com/ty-everett/44b6a0e7f3d6c48439f9ff26068f8d8b
export interface EnvelopeApi extends EnvelopeEvidenceApi {
headers?: string[];
reference?: string;
}
See also: EnvelopeEvidenceApi
Interface EnvelopeApi Details
For root nodes only. Array of 80 byte block headers encoded as 160 character hex strings Include headers the envelope creator is aware of but which the resipient may not have.
headers?: string[]
Arbitrary reference string associated with the envelope, typically root node only.
reference?: string
Links: API, Interfaces, Classes, Functions, Types, Variables
Either inputs or proof are required.
export interface EnvelopeEvidenceApi {
rawTx: string;
proof?: TscMerkleProofApi | Buffer;
inputs?: Record<string, EnvelopeEvidenceApi>;
txid?: string;
mapiResponses?: MapiResponseApi[];
depth?: number;
}
See also: MapiResponseApi, TscMerkleProofApi
Interface EnvelopeEvidenceApi Details
count of maximum number of chained unproven transactions before a proven leaf node proof nodes have depth zero.
depth?: number
Only one of proof or inputs must be valid. Branching nodes have inputs with a sub envelope (values) for every input transaction txid (keys)
inputs?: Record<string, EnvelopeEvidenceApi>
See also: EnvelopeEvidenceApi
Array of mapi transaction status update responses Only the payload, signature, and publicKey properties are relevant.
Branching inputs nodes only. Array of mapi transaction status update responses confirming unproven transctions have at least been submitted for processing.
mapiResponses?: MapiResponseApi[]
See also: MapiResponseApi
Either proof, or inputs, must have a value. Leaf nodes have proofs.
If value is a Buffer, content is binary encoded serialized proof see: chaintracks-spv.utils.serializeTscMerkleProof
proof?: TscMerkleProofApi | Buffer
See also: TscMerkleProofApi
A valid bitcoin transaction encoded as a hex string.
rawTx: string
double SHA256 hash of serialized rawTx. Optional.
txid?: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetHeaderArgs {
height: PositiveInteger;
}
See also: PositiveInteger
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetHeaderResult {
header: HexString;
}
See also: HexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetHeightResult {
height: PositiveInteger;
}
See also: PositiveInteger
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetInfoParams {
description?: string;
}
Interface GetInfoParams Details
Describe the high-level operation being performed, so that the user can make an informed decision if permission is needed.
description?: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetInfoResult {
metanetClientVersion: string;
chain: Chain;
height: number;
userId: number;
userIdentityKey: string;
dojoIdentityKey: string;
dojoIdentityName?: string;
perferredCurrency: string;
}
See also: Chain
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetNetworkResult {
network: WalletNetwork;
}
See also: WalletNetwork
Links: API, Interfaces, Classes, Functions, Types, Variables
When identityKey
is true, WalletEncryptionArgs
are not used.
When identityKey
is undefined, WalletEncryptionArgs
are required.
export interface GetPublicKeyArgs extends Partial<WalletEncryptionArgs> {
identityKey?: true;
forSelf?: BooleanDefaultFalse;
}
See also: BooleanDefaultFalse, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetPublicKeyResult {
publicKey: PubKeyHex;
}
See also: PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetTransactionOutputResult {
txid: string;
vout: number;
amount: number;
outputScript: string;
type: string;
spendable: boolean;
envelope?: EnvelopeApi;
customInstructions?: string;
basket?: string;
tags?: string[];
}
See also: EnvelopeApi
Interface GetTransactionOutputResult Details
Number of satoshis in the output
amount: number
If includeBasket
option is true, name of basket to which this output belongs.
basket?: string
When envelope requested, any custom instructions associated with this output.
customInstructions?: string
When requested and available, output validity support envelope.
envelope?: EnvelopeApi
See also: EnvelopeApi
Hex representation of output locking script
outputScript: string
Whether this output is free to be spent
spendable: boolean
If includeTags
option is true, tags assigned to this output.
tags?: string[]
Transaction ID of transaction that created the output
txid: string
The type of output, for example "P2PKH" or "P2RPH"
type: string
Index in the transaction of the output
vout: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface GetVersionResult {
version: VersionString7To30Bytes;
}
See also: VersionString7To30Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface IdentityCertificate extends WalletCertificate {
certifierInfo: IdentityCertifier;
publiclyRevealedKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>;
decryptedFields: Record<CertificateFieldNameUnder50Bytes, string>;
}
See also: Base64String, CertificateFieldNameUnder50Bytes, IdentityCertifier, WalletCertificate
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface IdentityCertifier {
name: EntityNameStringMax100Bytes;
iconUrl: EntityIconURLStringMax500Bytes;
description: DescriptionString5to50Bytes;
trust: PositiveIntegerMax10;
}
See also: DescriptionString5to50Bytes, EntityIconURLStringMax500Bytes, EntityNameStringMax100Bytes, PositiveIntegerMax10
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface InternalizeActionArgs {
tx: AtomicBEEF;
outputs: InternalizeOutput[];
description: DescriptionString5to50Bytes;
labels?: LabelStringUnder300Bytes[];
seekPermission?: BooleanDefaultTrue;
}
See also: AtomicBEEF, BooleanDefaultTrue, DescriptionString5to50Bytes, InternalizeOutput, LabelStringUnder300Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface InternalizeActionResult {
accepted: true;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface InternalizeOutput {
outputIndex: PositiveIntegerOrZero;
protocol: "wallet payment" | "basket insertion";
paymentRemittance?: WalletPayment;
insertionRemittance?: BasketInsertion;
}
See also: BasketInsertion, PositiveIntegerOrZero, WalletPayment
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface KeyDeriverApi {
rootKey: PrivateKey;
identityKey: string;
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf?: boolean): PublicKey;
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey;
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey;
revealCounterpartySecret(counterparty: Counterparty): number[];
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[];
}
See also: Counterparty, WalletProtocol
Interface KeyDeriverApi Details
The identity of this key deriver which is normally the public key associated with the rootKey
identityKey: string
The root key from which all other keys are derived.
rootKey: PrivateKey
Derives a private key based on protocol ID, key ID, and counterparty.
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey
See also: Counterparty, WalletProtocol
Returns
- The derived private key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Derives a public key based on protocol ID, key ID, and counterparty.
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf?: boolean): PublicKey
See also: Counterparty, WalletProtocol
Returns
- The derived public key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
forSelf
- Optional. false if undefined. Whether deriving for self.
Derives a symmetric key based on protocol ID, key ID, and counterparty. Note: Symmetric keys should not be derivable by everyone due to security risks.
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey
See also: Counterparty, WalletProtocol
Returns
- The derived symmetric key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to derive a symmetric key for 'anyone'.
Reveals the shared secret between the root key and the counterparty. Note: This should not be used for 'self'.
revealCounterpartySecret(counterparty: Counterparty): number[]
See also: Counterparty
Returns
- The shared secret as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to reveal a shared secret for 'self'.
Reveals the specific key association for a given protocol ID, key ID, and counterparty.
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[]
See also: Counterparty, WalletProtocol
Returns
- The specific key association as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface KeyLinkageResult {
encryptedLinkage: Byte[];
encryptedLinkageProof: Byte[];
prover: PubKeyHex;
verifier: PubKeyHex;
counterparty: PubKeyHex;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsArgs {
labels: LabelStringUnder300Bytes[];
labelQueryMode?: "any" | "all";
includeLabels?: BooleanDefaultFalse;
includeInputs?: BooleanDefaultFalse;
includeInputSourceLockingScripts?: BooleanDefaultFalse;
includeInputUnlockingScripts?: BooleanDefaultFalse;
includeOutputs?: BooleanDefaultFalse;
includeOutputLockingScripts?: BooleanDefaultFalse;
limit?: PositiveIntegerDefault10Max10000;
offset?: PositiveIntegerOrZero;
seekPermission?: BooleanDefaultTrue;
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, LabelStringUnder300Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsResult {
totalTransactions: number;
transactions: ListActionsTransaction[];
}
See also: ListActionsTransaction
Interface ListActionsResult Details
The number of transactions in the complete set
totalTransactions: number
The specific transactions from the set that were requested, based on limit
and offset
transactions: ListActionsTransaction[]
See also: ListActionsTransaction
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsResult {
totalActions: PositiveIntegerOrZero;
actions: WalletAction[];
}
See also: PositiveIntegerOrZero, WalletAction
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsTransaction {
txid: string;
amount: number;
status: TransactionStatusApi;
senderPaymail: string;
recipientPaymail: string;
isOutgoing: boolean;
note: string;
created_at: string;
referenceNumber: string;
labels: string[];
inputs?: ListActionsTransactionInput[];
outputs?: ListActionsTransactionOutput[];
}
See also: ListActionsTransactionInput, ListActionsTransactionOutput, TransactionStatusApi
Interface ListActionsTransaction Details
The number of satoshis added or removed from Dojo by this transaction
amount: number
The time the transaction was registered with the Dojo
created_at: string
Whether or not the transaction was created with createTransaction
isOutgoing: boolean
A set of all the labels affixed to the transaction
labels: string[]
The human-readable tag for the transaction, provided by the person who initiated it
note: string
The Paymail handle of the person who received the transaction
recipientPaymail: string
The Dojo reference number for the transaction
referenceNumber: string
The Paymail handle of the person who sent the transaction
senderPaymail: string
The current state of the transaction. Common statuses are completed
and unproven
.
status: TransactionStatusApi
See also: TransactionStatusApi
The transaction ID
txid: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsTransactionInput {
txid: string;
vout: number;
amount: number;
outputScript: string;
type: string;
spendable: boolean;
spendingDescription?: string;
basket?: string;
tags?: string[];
}
Interface ListActionsTransactionInput Details
Number of satoshis in the output
amount: number
Optionally included basket assignment.
basket?: string
Hex representation of output locking script
outputScript: string
Whether this output is free to be spent
spendable: boolean
Spending description for this transaction input
spendingDescription?: string
Optionally included tag assignments.
tags?: string[]
Transaction ID of transaction that created the output
txid: string
The type of output, for example "P2PKH" or "P2RPH"
type: string
Index in the transaction of the output
vout: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListActionsTransactionOutput {
txid: string;
vout: number;
amount: number;
outputScript: string;
type: string;
spendable: boolean;
description?: string;
basket?: string;
tags?: string[];
}
Interface ListActionsTransactionOutput Details
Number of satoshis in the output
amount: number
Optionally included basket assignment.
basket?: string
Output description
description?: string
Hex representation of output locking script
outputScript: string
Whether this output is free to be spent
spendable: boolean
Optionally included tag assignments.
tags?: string[]
Transaction ID of transaction that created the output
txid: string
The type of output, for example "P2PKH" or "P2RPH"
type: string
Index in the transaction of the output
vout: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListCertificatesArgs {
certifiers: PubKeyHex[];
types: Base64String[];
limit?: PositiveIntegerDefault10Max10000;
offset?: PositiveIntegerOrZero;
privileged?: BooleanDefaultFalse;
privilegedReason?: DescriptionString5to50Bytes;
}
See also: Base64String, BooleanDefaultFalse, DescriptionString5to50Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListCertificatesResult {
totalCertificates: PositiveIntegerOrZero;
certificates: WalletCertificate[];
}
See also: PositiveIntegerOrZero, WalletCertificate
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListOutputsArgs {
basket: BasketStringUnder300Bytes;
tags?: OutputTagStringUnder300Bytes[];
tagQueryMode?: "all" | "any";
include?: "locking scripts" | "entire transactions";
includeCustomInstructions?: BooleanDefaultFalse;
includeTags?: BooleanDefaultFalse;
includeLabels?: BooleanDefaultFalse;
limit?: PositiveIntegerDefault10Max10000;
offset?: PositiveIntegerOrZero;
seekPermission?: BooleanDefaultTrue;
}
See also: BasketStringUnder300Bytes, BooleanDefaultFalse, BooleanDefaultTrue, OutputTagStringUnder300Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ListOutputsResult {
totalOutputs: PositiveIntegerOrZero;
BEEF?: BEEF;
outputs: WalletOutput[];
}
See also: BEEF, PositiveIntegerOrZero, WalletOutput
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface MapiResponseApi {
payload: string;
signature: string;
publicKey: string;
encoding?: string;
mimetype?: string;
}
Interface MapiResponseApi Details
encoding of the payload data
encoding?: string
mime type of the payload data
mimetype?: string
Contents of the envelope. Validate using signature and publicKey. encoding and mimetype may assist with decoding validated payload.
payload: string
public key to use to verify signature of payload data
publicKey: string
signature producted by correpsonding private key on payload data
signature: string
Links: API, Interfaces, Classes, Functions, Types, Variables
Either rawTx or txid are required. If txid, then it must be a known transaction.
If not a known trxid, either inputs or proof are required.
export interface OptionalEnvelopeEvidenceApi {
rawTx?: string;
proof?: TscMerkleProofApi | Buffer;
inputs?: Record<string, OptionalEnvelopeEvidenceApi>;
txid?: string;
mapiResponses?: MapiResponseApi[];
depth?: number;
}
See also: MapiResponseApi, TscMerkleProofApi
Interface OptionalEnvelopeEvidenceApi Details
count of maximum number of chained unproven transactions before a proven leaf node proof nodes have depth zero.
depth?: number
Only one of proof or inputs must be valid. Branching nodes have inputs with a sub envelope (values) for every input transaction txid (keys)
inputs?: Record<string, OptionalEnvelopeEvidenceApi>
See also: OptionalEnvelopeEvidenceApi
Array of mapi transaction status update responses Only the payload, signature, and publicKey properties are relevant.
Branching inputs nodes only. Array of mapi transaction status update responses confirming unproven transctions have at least been submitted for processing.
mapiResponses?: MapiResponseApi[]
See also: MapiResponseApi
Either proof, or inputs, must have a value. Leaf nodes have proofs.
If value is a Buffer, content is binary encoded serialized proof see: chaintracks-spv.utils.serializeTscMerkleProof
proof?: TscMerkleProofApi | Buffer
See also: TscMerkleProofApi
A valid bitcoin transaction encoded as a hex string.
rawTx?: string
double SHA256 hash of serialized rawTx. Optional.
txid?: string
Links: API, Interfaces, Classes, Functions, Types, Variables
Identifies a unique transaction output by its txid
and index vout
export interface OutPoint {
txid: string;
vout: number;
}
Interface OutPoint Details
Transaction double sha256 hash as big endian hex string
txid: string
zero based output index within the transaction
vout: number
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ProveCertificateArgs {
certificate: WalletCertificate;
fieldsToReveal: CertificateFieldNameUnder50Bytes[];
verifier: PubKeyHex;
privileged?: BooleanDefaultFalse;
privilegedReason?: DescriptionString5to50Bytes;
}
See also: BooleanDefaultFalse, CertificateFieldNameUnder50Bytes, DescriptionString5to50Bytes, PubKeyHex, WalletCertificate
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ProveCertificateResult extends CertificateApi {
type: string;
subject: string;
validationKey: string;
serialNumber: string;
certifier: string;
revocationOutpoint: string;
signature: string;
fields?: Record<string, string>;
keyring: Record<string, string>;
}
See also: CertificateApi
Interface ProveCertificateResult Details
max length of 255
certifier: string
Plaintext field names and values of only those fields requested in fieldsToReveal
fields?: Record<string, string>
field revelation keyring for the given verifier
keyring: Record<string, string>
max length of 255
revocationOutpoint: string
max length of 255
serialNumber: string
max length of 255
signature: string
max length of 255
subject: string
max length of 255
type: string
max length of 255
validationKey: string
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ProveCertificateResult {
keyringForVerifier: Record<CertificateFieldNameUnder50Bytes, Base64String>;
}
See also: Base64String, CertificateFieldNameUnder50Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RelinquishCertificateArgs {
type: Base64String;
serialNumber: Base64String;
certifier: PubKeyHex;
}
See also: Base64String, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RelinquishCertificateResult {
relinquished: boolean;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RelinquishOutputArgs {
basket: BasketStringUnder300Bytes;
output: OutpointString;
}
See also: BasketStringUnder300Bytes, OutpointString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RelinquishOutputResult {
relinquished: true;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RevealCounterpartyKeyLinkageArgs {
counterparty: PubKeyHex;
verifier: PubKeyHex;
privileged?: BooleanDefaultFalse;
privilegedReason?: DescriptionString5to50Bytes;
}
See also: BooleanDefaultFalse, DescriptionString5to50Bytes, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RevealCounterpartyKeyLinkageResult extends KeyLinkageResult {
revelationTime: ISOTimestampString;
}
See also: ISOTimestampString, KeyLinkageResult
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RevealSpecificKeyLinkageArgs {
counterparty: WalletCounterparty;
verifier: PubKeyHex;
protocolID: WalletProtocol;
keyID: KeyIDStringUnder800Bytes;
privilegedReason?: DescriptionString5to50Bytes;
privileged?: BooleanDefaultFalse;
}
See also: BooleanDefaultFalse, DescriptionString5to50Bytes, KeyIDStringUnder800Bytes, PubKeyHex, WalletCounterparty, WalletProtocol
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface RevealSpecificKeyLinkageResult extends KeyLinkageResult {
protocolID: WalletProtocol;
keyID: KeyIDStringUnder800Bytes;
proofType: Byte;
}
See also: Byte, KeyIDStringUnder800Bytes, KeyLinkageResult, WalletProtocol
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SendWithResult {
txid: TXIDHexString;
status: SendWithResultStatus;
}
See also: SendWithResultStatus, TXIDHexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignActionArgs {
spends: Record<PositiveIntegerOrZero, SignActionSpend>;
reference: Base64String;
options?: SignActionOptions;
}
See also: Base64String, PositiveIntegerOrZero, SignActionOptions, SignActionSpend
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignActionOptions {
acceptDelayedBroadcast?: BooleanDefaultTrue;
returnTXIDOnly?: BooleanDefaultFalse;
noSend?: BooleanDefaultFalse;
sendWith?: TXIDHexString[];
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, TXIDHexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignActionResult {
rawTx: string;
inputs: Record<string, EnvelopeEvidenceApi>;
mapiResponses: MapiResponseApi[];
txid: string;
log?: string;
}
See also: EnvelopeEvidenceApi, MapiResponseApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignActionResult {
txid?: TXIDHexString;
tx?: AtomicBEEF;
sendWithResults?: SendWithResult[];
}
See also: AtomicBEEF, SendWithResult, TXIDHexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignActionSpend {
unlockingScript: HexString;
sequenceNumber?: PositiveIntegerOrZero;
}
See also: HexString, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SignableTransaction {
tx: AtomicBEEF;
reference: Base64String;
}
See also: AtomicBEEF, Base64String
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SpecificKeyLinkageResult {
type: "specific-revelation";
prover: string;
verifier: string;
counterparty: string;
protocolID: ProtocolID;
encryptedLinkage: string;
}
See also: ProtocolID
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SubmitDirectTransaction {
rawTx: string;
txid?: string;
inputs?: Record<string, OptionalEnvelopeEvidenceApi>;
mapiResponses?: MapiResponseApi[];
proof?: TscMerkleProofApi;
outputs: SubmitDirectTransactionOutput[];
referenceNumber?: string;
}
See also: MapiResponseApi, OptionalEnvelopeEvidenceApi, SubmitDirectTransactionOutput, TscMerkleProofApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SubmitDirectTransactionOutput {
vout: number;
satoshis: number;
basket?: string;
derivationPrefix?: string;
derivationSuffix?: string;
customInstructions?: string;
senderIdentityKey?: string;
tags?: string[];
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface SubmitDirectTransactionResult {
transactionId: number;
referenceNumber: string;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
As defined in https://github.com/bitcoin-sv-specs/brfc-merchantapi/blob/master/README.md
export interface TscMerkleProofApi {
height?: number;
index: number;
txOrId: string | Buffer;
target: string | Buffer;
nodes: string[] | Buffer;
targetType?: "hash" | "header" | "merkleRoot" | "height";
proofType?: "branch" | "tree";
composite?: boolean;
}
Interface TscMerkleProofApi Details
The most efficient way of confirming a proof should also be the most common, when the containing block's height is known.
height?: number
Index of transaction in its block. First transaction is index zero.
index: number
Merkle tree sibling hash values required to compute root from txid. Duplicates (sibling hash === computed hash) are indicated by "*" or type byte === 1. type byte === 2... Strings are encoded as hex.
nodes: string[] | Buffer
Merkle root (length === 32) or serialized block header containing it (length === 80). If string, encoding is hex.
target: string | Buffer
Full transaction (length > 32 bytes) or just its double SHA256 hash (length === 32 bytes). If string, encoding is hex.
txOrId: string | Buffer
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidAbortActionArgs {
reference: sdk.Base64String;
log?: string;
}
See also: Base64String
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidAcquireCertificateArgs {
type: sdk.Base64String;
certifier: sdk.PubKeyHex;
acquisitionProtocol: sdk.AcquisitionProtocol;
fields: Record<sdk.CertificateFieldNameUnder50Bytes, string>;
serialNumber?: sdk.Base64String;
revocationOutpoint?: sdk.OutpointString;
signature?: sdk.HexString;
certifierUrl?: string;
keyringRevealer?: sdk.KeyringRevealer;
keyringForSubject?: Record<sdk.CertificateFieldNameUnder50Bytes, sdk.Base64String>;
privileged?: sdk.BooleanDefaultFalse;
privilegedReason?: sdk.DescriptionString5to50Bytes;
log?: string;
}
See also: AcquisitionProtocol, Base64String, BooleanDefaultFalse, CertificateFieldNameUnder50Bytes, DescriptionString5to50Bytes, HexString, KeyringRevealer, OutpointString, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidBasketInsertion {
basket: sdk.BasketStringUnder300Bytes;
customInstructions?: string;
tags: sdk.OutputTagStringUnder300Bytes[];
}
See also: BasketStringUnder300Bytes, OutputTagStringUnder300Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidCreateActionArgs extends ValidProcessActionArgs {
description: sdk.DescriptionString5to50Bytes;
inputBEEF?: sdk.BEEF;
inputs: sdk.ValidCreateActionInput[];
outputs: sdk.ValidCreateActionOutput[];
lockTime: number;
version: number;
labels: string[];
options: ValidCreateActionOptions;
isSignAction: boolean;
}
See also: BEEF, DescriptionString5to50Bytes, ValidCreateActionInput, ValidCreateActionOptions, ValidCreateActionOutput, ValidProcessActionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidCreateActionInput {
outpoint: OutPoint;
inputDescription: sdk.DescriptionString5to50Bytes;
sequenceNumber: sdk.PositiveIntegerOrZero;
unlockingScript?: sdk.HexString;
unlockingScriptLength: sdk.PositiveInteger;
}
See also: DescriptionString5to50Bytes, HexString, OutPoint, PositiveInteger, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidCreateActionOptions extends ValidProcessActionOptions {
signAndProcess: boolean;
trustSelf?: TrustSelf;
knownTxids: sdk.TXIDHexString[];
noSendChange: OutPoint[];
randomizeOutputs: boolean;
}
See also: OutPoint, TXIDHexString, TrustSelf, ValidProcessActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidCreateActionOutput {
lockingScript: sdk.HexString;
satoshis: sdk.SatoshiValue;
outputDescription: sdk.DescriptionString5to50Bytes;
basket?: sdk.BasketStringUnder300Bytes;
customInstructions?: string;
tags: sdk.OutputTagStringUnder300Bytes[];
}
See also: BasketStringUnder300Bytes, DescriptionString5to50Bytes, HexString, OutputTagStringUnder300Bytes, SatoshiValue
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidInternalizeActionArgs {
tx: sdk.AtomicBEEF;
outputs: sdk.InternalizeOutput[];
description: sdk.DescriptionString5to50Bytes;
labels: sdk.LabelStringUnder300Bytes[];
seekPermission: sdk.BooleanDefaultTrue;
log?: string;
}
See also: AtomicBEEF, BooleanDefaultTrue, DescriptionString5to50Bytes, InternalizeOutput, LabelStringUnder300Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidInternalizeOutput {
outputIndex: sdk.PositiveIntegerOrZero;
protocol: "wallet payment" | "basket insertion";
paymentRemittance?: ValidWalletPayment;
insertionRemittance?: ValidBasketInsertion;
}
See also: PositiveIntegerOrZero, ValidBasketInsertion, ValidWalletPayment
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidListActionsArgs {
labels: sdk.LabelStringUnder300Bytes[];
labelQueryMode: "any" | "all";
includeLabels: sdk.BooleanDefaultFalse;
includeInputs: sdk.BooleanDefaultFalse;
includeInputSourceLockingScripts: sdk.BooleanDefaultFalse;
includeInputUnlockingScripts: sdk.BooleanDefaultFalse;
includeOutputs: sdk.BooleanDefaultFalse;
includeOutputLockingScripts: sdk.BooleanDefaultFalse;
limit: sdk.PositiveIntegerDefault10Max10000;
offset: sdk.PositiveIntegerOrZero;
seekPermission: sdk.BooleanDefaultTrue;
log?: string;
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, LabelStringUnder300Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidListCertificatesArgs {
certifiers: sdk.PubKeyHex[];
types: sdk.Base64String[];
limit: sdk.PositiveIntegerDefault10Max10000;
offset: sdk.PositiveIntegerOrZero;
privileged: sdk.BooleanDefaultFalse;
privilegedReason?: sdk.DescriptionString5to50Bytes;
log?: string;
}
See also: Base64String, BooleanDefaultFalse, DescriptionString5to50Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidListOutputsArgs {
basket: sdk.BasketStringUnder300Bytes;
tags: sdk.OutputTagStringUnder300Bytes[];
tagQueryMode: "all" | "any";
includeLockingScripts: boolean;
includeTransactions: boolean;
includeCustomInstructions: sdk.BooleanDefaultFalse;
includeTags: sdk.BooleanDefaultFalse;
includeLabels: sdk.BooleanDefaultFalse;
limit: sdk.PositiveIntegerDefault10Max10000;
offset: sdk.PositiveIntegerOrZero;
seekPermission: sdk.BooleanDefaultTrue;
knownTxids: string[];
log?: string;
}
See also: BasketStringUnder300Bytes, BooleanDefaultFalse, BooleanDefaultTrue, OutputTagStringUnder300Bytes, PositiveIntegerDefault10Max10000, PositiveIntegerOrZero
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidProcessActionArgs {
options: sdk.ValidProcessActionOptions;
isSendWith: boolean;
isNewTx: boolean;
isNoSend: boolean;
isDelayed: boolean;
log?: string;
}
See also: ValidProcessActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidProcessActionOptions {
acceptDelayedBroadcast: sdk.BooleanDefaultTrue;
returnTXIDOnly: sdk.BooleanDefaultFalse;
noSend: sdk.BooleanDefaultFalse;
sendWith: sdk.TXIDHexString[];
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, TXIDHexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidRelinquishOutputArgs {
basket: sdk.BasketStringUnder300Bytes;
output: sdk.OutpointString;
log?: string;
}
See also: BasketStringUnder300Bytes, OutpointString
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidSignActionArgs extends ValidProcessActionArgs {
spends: Record<sdk.PositiveIntegerOrZero, sdk.SignActionSpend>;
reference: sdk.Base64String;
options: sdk.ValidSignActionOptions;
}
See also: Base64String, PositiveIntegerOrZero, SignActionSpend, ValidProcessActionArgs, ValidSignActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidSignActionOptions extends ValidProcessActionOptions {
acceptDelayedBroadcast: boolean;
returnTXIDOnly: boolean;
noSend: boolean;
sendWith: sdk.TXIDHexString[];
}
See also: TXIDHexString, ValidProcessActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface ValidWalletPayment {
derivationPrefix: sdk.Base64String;
derivationSuffix: sdk.Base64String;
senderIdentityKey: sdk.PubKeyHex;
}
See also: Base64String, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface VerifyHmacArgs extends WalletEncryptionArgs {
data: Byte[];
hmac: Byte[];
}
See also: Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface VerifyHmacResult {
valid: boolean;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface VerifySignatureArgs extends WalletEncryptionArgs {
data?: Byte[];
hashToDirectlyVerify?: Byte[];
signature: Byte[];
forSelf?: BooleanDefaultFalse;
}
See also: BooleanDefaultFalse, Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface VerifySignatureResult {
valid: true;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
The Wallet interface defines a wallet capable of various tasks including transaction creation and signing, encryption, decryption, identity certificate management, identity verification, and communication with applications as per the BRC standards. This interface allows applications to interact with the wallet for a range of functionalities aligned with the Babbage architectural principles.
Error Handling
Every method of the Wallet
interface has a return value of the form Promise<object>
.
When an error occurs, an exception object may be thrown which must conform to the WalletErrorObject
interface.
Serialization layers can rely on the isError
property being unique to error objects to
deserialize and rethrow WalletErrorObject
conforming objects.
export interface Wallet extends WalletCryptoObject {
createAction: (args: CreateActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateActionResult>;
signAction: (args: SignActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<SignActionResult>;
abortAction: (args: AbortActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AbortActionResult>;
listActions: (args: ListActionsArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListActionsResult>;
internalizeAction: (args: InternalizeActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<InternalizeActionResult>;
listOutputs: (args: ListOutputsArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListOutputsResult>;
relinquishOutput: (args: RelinquishOutputArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RelinquishOutputResult>;
acquireCertificate: (args: AcquireCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AcquireCertificateResult>;
listCertificates: (args: ListCertificatesArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListCertificatesResult>;
proveCertificate: (args: ProveCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ProveCertificateResult>;
relinquishCertificate: (args: RelinquishCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RelinquishCertificateResult>;
discoverByIdentityKey: (args: DiscoverByIdentityKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<DiscoverCertificatesResult>;
discoverByAttributes: (args: DiscoverByAttributesArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<DiscoverCertificatesResult>;
isAuthenticated: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AuthenticatedResult>;
waitForAuthentication: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AuthenticatedResult>;
getHeight: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetHeightResult>;
getHeaderForHeight: (args: GetHeaderArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetHeaderResult>;
getNetwork: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetNetworkResult>;
getVersion: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetVersionResult>;
}
See also: AbortActionArgs, AbortActionResult, AcquireCertificateArgs, AcquireCertificateResult, AuthenticatedResult, CreateActionArgs, CreateActionResult, DiscoverByAttributesArgs, DiscoverByIdentityKeyArgs, DiscoverCertificatesResult, GetHeaderArgs, GetHeaderResult, GetHeightResult, GetNetworkResult, GetVersionResult, InternalizeActionArgs, InternalizeActionResult, ListActionsArgs, ListActionsResult, ListCertificatesArgs, ListCertificatesResult, ListOutputsArgs, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes, ProveCertificateArgs, ProveCertificateResult, RelinquishCertificateArgs, RelinquishCertificateResult, RelinquishOutputArgs, RelinquishOutputResult, SignActionArgs, SignActionResult, WalletCryptoObject, abortAction, createAction, discoverByAttributes, discoverByIdentityKey, getHeight, getNetwork, getVersion, isAuthenticated, listActions, proveCertificate, signAction, waitForAuthentication
Interface Wallet Details
Aborts a transaction that is in progress and has not yet been finalized or sent to the network.
abortAction: (args: AbortActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AbortActionResult>
See also: AbortActionArgs, AbortActionResult, OriginatorDomainNameStringUnder250Bytes
Acquires an identity certificate, whether by acquiring one from the certifier or by directly receiving it.
acquireCertificate: (args: AcquireCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AcquireCertificateResult>
See also: AcquireCertificateArgs, AcquireCertificateResult, OriginatorDomainNameStringUnder250Bytes
Creates a new Bitcoin transaction based on the provided inputs, outputs, labels, locks, and other options.
createAction: (args: CreateActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateActionResult>
See also: CreateActionArgs, CreateActionResult, OriginatorDomainNameStringUnder250Bytes
Discovers identity certificates belonging to other users, where the documents contain specific attributes, issued by a trusted entity.
discoverByAttributes: (args: DiscoverByAttributesArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<DiscoverCertificatesResult>
See also: DiscoverByAttributesArgs, DiscoverCertificatesResult, OriginatorDomainNameStringUnder250Bytes
Discovers identity certificates, issued to a given identity key by a trusted entity.
discoverByIdentityKey: (args: DiscoverByIdentityKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<DiscoverCertificatesResult>
See also: DiscoverByIdentityKeyArgs, DiscoverCertificatesResult, OriginatorDomainNameStringUnder250Bytes
Retrieves the block header of a block at a specified height.
getHeaderForHeight: (args: GetHeaderArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetHeaderResult>
See also: GetHeaderArgs, GetHeaderResult, OriginatorDomainNameStringUnder250Bytes
Retrieves the current height of the blockchain.
getHeight: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetHeightResult>
See also: GetHeightResult, OriginatorDomainNameStringUnder250Bytes
Retrieves the Bitcoin network the client is using (mainnet or testnet).
getNetwork: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetNetworkResult>
See also: GetNetworkResult, OriginatorDomainNameStringUnder250Bytes
Retrieves the current version string of the wallet.
getVersion: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetVersionResult>
See also: GetVersionResult, OriginatorDomainNameStringUnder250Bytes
Submits a transaction to be internalized and optionally labeled, outputs paid to the wallet balance, inserted into baskets, and/or tagged.
internalizeAction: (args: InternalizeActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<InternalizeActionResult>
See also: InternalizeActionArgs, InternalizeActionResult, OriginatorDomainNameStringUnder250Bytes
Checks the authentication status of the user.
isAuthenticated: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AuthenticatedResult>
See also: AuthenticatedResult, OriginatorDomainNameStringUnder250Bytes
Lists all transactions matching the specified labels.
listActions: (args: ListActionsArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListActionsResult>
See also: ListActionsArgs, ListActionsResult, OriginatorDomainNameStringUnder250Bytes
Lists identity certificates belonging to the user, filtered by certifier(s) and type(s).
listCertificates: (args: ListCertificatesArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListCertificatesResult>
See also: ListCertificatesArgs, ListCertificatesResult, OriginatorDomainNameStringUnder250Bytes
Lists the spendable outputs kept within a specific basket, optionally tagged with specific labels.
listOutputs: (args: ListOutputsArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ListOutputsResult>
See also: ListOutputsArgs, ListOutputsResult, OriginatorDomainNameStringUnder250Bytes
Proves select fields of an identity certificate, as specified, when requested by a verifier.
proveCertificate: (args: ProveCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<ProveCertificateResult>
See also: OriginatorDomainNameStringUnder250Bytes, ProveCertificateArgs, ProveCertificateResult
Relinquishes an identity certificate, removing it from the wallet regardless of whether the revocation outpoint has become spent.
relinquishCertificate: (args: RelinquishCertificateArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RelinquishCertificateResult>
See also: OriginatorDomainNameStringUnder250Bytes, RelinquishCertificateArgs, RelinquishCertificateResult
Relinquish an output out of a basket, removing it from tracking without spending it.
relinquishOutput: (args: RelinquishOutputArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RelinquishOutputResult>
See also: OriginatorDomainNameStringUnder250Bytes, RelinquishOutputArgs, RelinquishOutputResult
Signs a transaction previously created using createAction
.
signAction: (args: SignActionArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<SignActionResult>
See also: OriginatorDomainNameStringUnder250Bytes, SignActionArgs, SignActionResult
Continuously waits until the user is authenticated, returning the result once confirmed.
waitForAuthentication: (args: {}, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<AuthenticatedResult>
See also: AuthenticatedResult, OriginatorDomainNameStringUnder250Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletAction {
txid: TXIDHexString;
satoshis: SatoshiValue;
status: ActionStatus;
isOutgoing: boolean;
description: DescriptionString5to50Bytes;
labels?: LabelStringUnder300Bytes[];
version: PositiveIntegerOrZero;
lockTime: PositiveIntegerOrZero;
inputs?: WalletActionInput[];
outputs?: WalletActionOutput[];
}
See also: ActionStatus, DescriptionString5to50Bytes, LabelStringUnder300Bytes, PositiveIntegerOrZero, SatoshiValue, TXIDHexString, WalletActionInput, WalletActionOutput
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletActionInput {
sourceOutpoint: OutpointString;
sourceSatoshis: SatoshiValue;
sourceLockingScript?: HexString;
unlockingScript?: HexString;
inputDescription: DescriptionString5to50Bytes;
sequenceNumber: PositiveIntegerOrZero;
}
See also: DescriptionString5to50Bytes, HexString, OutpointString, PositiveIntegerOrZero, SatoshiValue
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletActionOutput {
satoshis: SatoshiValue;
lockingScript?: HexString;
spendable: boolean;
customInstructions?: string;
tags: OutputTagStringUnder300Bytes[];
outputIndex: PositiveIntegerOrZero;
outputDescription: DescriptionString5to50Bytes;
basket: BasketStringUnder300Bytes;
}
See also: BasketStringUnder300Bytes, DescriptionString5to50Bytes, HexString, OutputTagStringUnder300Bytes, PositiveIntegerOrZero, SatoshiValue
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletCertificate {
type: Base64String;
subject: PubKeyHex;
serialNumber: Base64String;
certifier: PubKeyHex;
revocationOutpoint: OutpointString;
signature: HexString;
fields: Record<CertificateFieldNameUnder50Bytes, string>;
}
See also: Base64String, CertificateFieldNameUnder50Bytes, HexString, OutpointString, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
The WalletCryptoObject interface defines a wallet cryptographic capabilities including: key derivation, encryption, decryption, hmac creation and verification, signature generation and verification
Error Handling
Every method of the Wallet
interface has a return value of the form Promise<object>
.
When an error occurs, an exception object may be thrown which must conform to the WalletErrorObject
interface.
Serialization layers can rely on the isError
property being unique to error objects to
deserialize and rethrow WalletErrorObject
conforming objects.
export interface WalletCryptoObject {
getPublicKey: (args: GetPublicKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetPublicKeyResult>;
revealCounterpartyKeyLinkage: (args: RevealCounterpartyKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RevealCounterpartyKeyLinkageResult>;
revealSpecificKeyLinkage: (args: RevealSpecificKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RevealSpecificKeyLinkageResult>;
encrypt: (args: WalletEncryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<WalletEncryptResult>;
decrypt: (args: WalletDecryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<WalletDecryptResult>;
createHmac: (args: CreateHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateHmacResult>;
verifyHmac: (args: VerifyHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<VerifyHmacResult>;
createSignature: (args: CreateSignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateSignatureResult>;
verifySignature: (args: VerifySignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<VerifySignatureResult>;
}
See also: CreateHmacArgs, CreateHmacResult, CreateSignatureArgs, CreateSignatureResult, GetPublicKeyArgs, GetPublicKeyResult, OriginatorDomainNameStringUnder250Bytes, RevealCounterpartyKeyLinkageArgs, RevealCounterpartyKeyLinkageResult, RevealSpecificKeyLinkageArgs, RevealSpecificKeyLinkageResult, VerifyHmacArgs, VerifyHmacResult, VerifySignatureArgs, VerifySignatureResult, WalletDecryptArgs, WalletDecryptResult, WalletEncryptArgs, WalletEncryptResult, createHmac, createSignature, decrypt, encrypt, getPublicKey, verifyHmac, verifySignature
Interface WalletCryptoObject Details
Creates an HMAC (Hash-based Message Authentication Code) based on the provided data, protocol, key ID, counterparty, and other factors.
createHmac: (args: CreateHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateHmacResult>
See also: CreateHmacArgs, CreateHmacResult, OriginatorDomainNameStringUnder250Bytes
Creates a digital signature for the provided data or hash using a specific protocol, key, and optionally considering privilege and counterparty.
createSignature: (args: CreateSignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<CreateSignatureResult>
See also: CreateSignatureArgs, CreateSignatureResult, OriginatorDomainNameStringUnder250Bytes
Decrypts the provided ciphertext using derived keys, based on the protocol ID, key ID, counterparty, and other factors.
decrypt: (args: WalletDecryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<WalletDecryptResult>
See also: OriginatorDomainNameStringUnder250Bytes, WalletDecryptArgs, WalletDecryptResult
Encrypts the provided plaintext data using derived keys, based on the protocol ID, key ID, counterparty, and other factors.
encrypt: (args: WalletEncryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<WalletEncryptResult>
See also: OriginatorDomainNameStringUnder250Bytes, WalletEncryptArgs, WalletEncryptResult
Retrieves a derived or identity public key based on the requested protocol, key ID, counterparty, and other factors.
getPublicKey: (args: GetPublicKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<GetPublicKeyResult>
See also: GetPublicKeyArgs, GetPublicKeyResult, OriginatorDomainNameStringUnder250Bytes
Reveals the key linkage between ourselves and a counterparty, to a particular verifier, across all interactions with the counterparty.
revealCounterpartyKeyLinkage: (args: RevealCounterpartyKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RevealCounterpartyKeyLinkageResult>
See also: OriginatorDomainNameStringUnder250Bytes, RevealCounterpartyKeyLinkageArgs, RevealCounterpartyKeyLinkageResult
Reveals the key linkage between ourselves and a counterparty, to a particular verifier, with respect to a specific interaction.
revealSpecificKeyLinkage: (args: RevealSpecificKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<RevealSpecificKeyLinkageResult>
See also: OriginatorDomainNameStringUnder250Bytes, RevealSpecificKeyLinkageArgs, RevealSpecificKeyLinkageResult
Verifies an HMAC (Hash-based Message Authentication Code) based on the provided data, protocol, key ID, counterparty, and other factors.
verifyHmac: (args: VerifyHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<VerifyHmacResult>
See also: OriginatorDomainNameStringUnder250Bytes, VerifyHmacArgs, VerifyHmacResult
Verifies a digital signature for the provided data or hash using a specific protocol, key, and optionally considering privilege and counterparty.
verifySignature: (args: VerifySignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes) => Promise<VerifySignatureResult>
See also: OriginatorDomainNameStringUnder250Bytes, VerifySignatureArgs, VerifySignatureResult
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletDecryptArgs extends WalletEncryptionArgs {
ciphertext: Byte[];
}
See also: Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletDecryptResult {
plaintext: Byte[];
}
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletEncryptArgs extends WalletEncryptionArgs {
plaintext: Byte[];
}
See also: Byte, WalletEncryptionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletEncryptResult {
ciphertext: Byte[];
}
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletEncryptionArgs {
protocolID: WalletProtocol;
keyID: KeyIDStringUnder800Bytes;
counterparty?: WalletCounterparty;
privileged?: BooleanDefaultFalse;
privilegedReason?: DescriptionString5to50Bytes;
seekPermission?: BooleanDefaultTrue;
}
See also: BooleanDefaultFalse, BooleanDefaultTrue, DescriptionString5to50Bytes, KeyIDStringUnder800Bytes, WalletCounterparty, WalletProtocol
Links: API, Interfaces, Classes, Functions, Types, Variables
Every method of the Wallet
interface has a return value of the form Promise<object>
.
When errors occur, an exception object may be thrown which must conform to the WalletErrorObject
interface.
Serialization layers can rely on the isError
property being unique to error objects.
Deserialization should rethrow WalletErrorObject
conforming objects.
export interface WalletErrorObject extends Error {
isError: true;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletOutput {
satoshis: SatoshiValue;
lockingScript?: HexString;
spendable: boolean;
customInstructions?: string;
tags?: OutputTagStringUnder300Bytes[];
outpoint: OutpointString;
labels?: LabelStringUnder300Bytes[];
}
See also: HexString, LabelStringUnder300Bytes, OutpointString, OutputTagStringUnder300Bytes, SatoshiValue
Links: API, Interfaces, Classes, Functions, Types, Variables
export interface WalletPayment {
derivationPrefix: Base64String;
derivationSuffix: Base64String;
senderIdentityKey: PubKeyHex;
}
See also: Base64String, PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
Links: API, Interfaces, Classes, Functions, Types, Variables
A cached version of KeyDeriver that caches the results of key derivation methods. This is useful for optimizing performance when the same keys are derived multiple times. It supports configurable cache size with sane defaults and maintains cache entries using LRU (Least Recently Used) eviction policy.
export default class CachedKeyDeriver {
constructor(rootKey: PrivateKey | "anyone", options?: {
maxCacheSize?: number;
})
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf: boolean = false): PublicKey
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey
revealCounterpartySecret(counterparty: Counterparty): number[]
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[]
}
See also: Counterparty, WalletProtocol
Class CachedKeyDeriver Details
Initializes the CachedKeyDeriver instance with a root private key and optional cache settings.
constructor(rootKey: PrivateKey | "anyone", options?: {
maxCacheSize?: number;
})
Argument Details
-
rootKey
- The root private key or the string 'anyone'.
-
options
- Optional settings for the cache.
Derives a private key based on protocol ID, key ID, and counterparty. Caches the result for future calls with the same parameters.
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey
See also: Counterparty, WalletProtocol
Returns
- The derived private key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Derives a public key based on protocol ID, key ID, and counterparty. Caches the result for future calls with the same parameters.
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf: boolean = false): PublicKey
See also: Counterparty, WalletProtocol
Returns
- The derived public key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
forSelf
- Whether deriving for self.
Derives a symmetric key based on protocol ID, key ID, and counterparty. Caches the result for future calls with the same parameters.
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey
See also: Counterparty, WalletProtocol
Returns
- The derived symmetric key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to derive a symmetric key for 'anyone'.
Reveals the shared secret between the root key and the counterparty. Caches the result for future calls with the same parameters.
revealCounterpartySecret(counterparty: Counterparty): number[]
See also: Counterparty
Returns
- The shared secret as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to reveal a shared secret for 'self'.
Reveals the specific key association for a given protocol ID, key ID, and counterparty. Caches the result for future calls with the same parameters.
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[]
See also: Counterparty, WalletProtocol
Returns
- The specific key association as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
Links: API, Interfaces, Classes, Functions, Types, Variables
export class Communicator {
static setCached(substrate: string, version: string): Communicator
static getCached(): Communicator | undefined
async dispatch<P extends object>(args: {
name: string;
params: P;
isGet?: boolean;
bodyParamKey?: string;
bodyJsonParams?: boolean;
contentType?: string;
nameHttp?: string;
isNinja?: boolean;
}): Promise<unknown>
}
Links: API, Interfaces, Classes, Functions, Types, Variables
Class responsible for deriving various types of keys using a root private key. It supports deriving public and private keys, symmetric keys, and revealing key linkages.
export class KeyDeriver implements KeyDeriverApi {
rootKey: PrivateKey;
identityKey: string;
constructor(rootKey: PrivateKey | "anyone")
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf: boolean = false): PublicKey
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey
revealCounterpartySecret(counterparty: Counterparty): number[]
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[]
}
See also: Counterparty, KeyDeriverApi, WalletProtocol
Class KeyDeriver Details
Initializes the KeyDeriver instance with a root private key.
constructor(rootKey: PrivateKey | "anyone")
Argument Details
-
rootKey
- The root private key or the string 'anyone'.
Derives a private key based on protocol ID, key ID, and counterparty.
derivePrivateKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): PrivateKey
See also: Counterparty, WalletProtocol
Returns
- The derived private key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Derives a public key based on protocol ID, key ID, and counterparty.
derivePublicKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty, forSelf: boolean = false): PublicKey
See also: Counterparty, WalletProtocol
Returns
- The derived public key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
forSelf
- Whether deriving for self.
Derives a symmetric key based on protocol ID, key ID, and counterparty. Note: Symmetric keys should not be derivable by everyone due to security risks.
deriveSymmetricKey(protocolID: WalletProtocol, keyID: string, counterparty: Counterparty): SymmetricKey
See also: Counterparty, WalletProtocol
Returns
- The derived symmetric key.
Argument Details
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to derive a symmetric key for 'anyone'.
Reveals the shared secret between the root key and the counterparty. Note: This should not be used for 'self'.
revealCounterpartySecret(counterparty: Counterparty): number[]
See also: Counterparty
Returns
- The shared secret as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
Throws
- Throws an error if attempting to reveal a shared secret for 'self'.
Reveals the specific key association for a given protocol ID, key ID, and counterparty.
revealSpecificSecret(counterparty: Counterparty, protocolID: WalletProtocol, keyID: string): number[]
See also: Counterparty, WalletProtocol
Returns
- The specific key association as a number array.
Argument Details
-
counterparty
- The counterparty's public key or a predefined value ('self' or 'anyone').
-
protocolID
- The protocol ID including a security level and protocol name.
-
keyID
- The key identifier.
Links: API, Interfaces, Classes, Functions, Types, Variables
The request is invalid.
export class WERR_BAD_REQUEST extends WalletError {
constructor(message?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
Insufficient funds in the available inputs to cover the cost of the required outputs
and the transaction fee (
export class WERR_INSUFFICIENT_FUNDS extends WalletError {
constructor(public totalSatoshisNeeded: number, public moreSatoshisNeeded: number)
}
See also: WalletError
Class WERR_INSUFFICIENT_FUNDS Details
constructor(public totalSatoshisNeeded: number, public moreSatoshisNeeded: number)
Argument Details
-
totalSatoshisNeeded
- Total satoshis required to fund transactions after net of required inputs and outputs.
-
moreSatoshisNeeded
- Shortfall on total satoshis required to fund transactions after net of required inputs and outputs.
Links: API, Interfaces, Classes, Functions, Types, Variables
An internal error has occurred.
This is an example of an error with an optional custom message
.
export class WERR_INTERNAL extends WalletError {
constructor(message?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
The ${parameter} parameter is invalid.
This is an example of an error object with a custom property parameter
and templated message
.
export class WERR_INVALID_PARAMETER extends WalletError {
constructor(public parameter: string, mustBe?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
export class WERR_INVALID_PUBLIC_KEY extends WalletError {
constructor(public key: string, network: WalletNetwork = "mainnet")
}
See also: WalletError, WalletNetwork
Class WERR_INVALID_PUBLIC_KEY Details
constructor(public key: string, network: WalletNetwork = "mainnet")
See also: WalletNetwork
Argument Details
-
key
- The invalid public key that caused the error.
-
environment
- Optional environment flag to control whether the key is included in the message.
Links: API, Interfaces, Classes, Functions, Types, Variables
The required ${parameter} parameter is missing.
This is an example of an error object with a custom property parameter
export class WERR_MISSING_PARAMETER extends WalletError {
constructor(public parameter: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
Configured network chain is invalid or does not match across services.
export class WERR_NETWORK_CHAIN extends WalletError {
constructor(message?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
Not implemented.
export class WERR_NOT_IMPLEMENTED extends WalletError {
constructor(message?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
Access is denied due to an authorization error.
export class WERR_UNAUTHORIZED extends WalletError {
constructor(message?: string)
}
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
WalletCrypto implements single-keyring wallet cryptography functions, operating without context about whether its configured keyring is privileged.
export class WalletCrypto implements WalletCryptoObject {
keyDeriver: KeyDeriverApi;
constructor(keyDeriver: KeyDeriverApi)
async getIdentityKey(originator?: OriginatorDomainNameStringUnder250Bytes): Promise<{
publicKey: PubKeyHex;
}>
async getPublicKey(args: GetPublicKeyArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<{
publicKey: PubKeyHex;
}>
async revealCounterpartyKeyLinkage(args: RevealCounterpartyKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<RevealCounterpartyKeyLinkageResult>
async revealSpecificKeyLinkage(args: RevealSpecificKeyLinkageArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<RevealSpecificKeyLinkageResult>
async encrypt(args: WalletEncryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletEncryptResult>
async decrypt(args: WalletDecryptArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<WalletDecryptResult>
async createHmac(args: CreateHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<CreateHmacResult>
async verifyHmac(args: VerifyHmacArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<VerifyHmacResult>
async createSignature(args: CreateSignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<CreateSignatureResult>
async verifySignature(args: VerifySignatureArgs, originator?: OriginatorDomainNameStringUnder250Bytes): Promise<VerifySignatureResult>
}
See also: CreateHmacArgs, CreateHmacResult, CreateSignatureArgs, CreateSignatureResult, GetPublicKeyArgs, KeyDeriverApi, OriginatorDomainNameStringUnder250Bytes, PubKeyHex, RevealCounterpartyKeyLinkageArgs, RevealCounterpartyKeyLinkageResult, RevealSpecificKeyLinkageArgs, RevealSpecificKeyLinkageResult, VerifyHmacArgs, VerifyHmacResult, VerifySignatureArgs, VerifySignatureResult, WalletCryptoObject, WalletDecryptArgs, WalletDecryptResult, WalletEncryptArgs, WalletEncryptResult, createHmac, createSignature, decrypt, encrypt, getPublicKey, verifyHmac, verifySignature
Class WalletCrypto Details
Convenience method to obtain the identityKey.
async getIdentityKey(originator?: OriginatorDomainNameStringUnder250Bytes): Promise<{
publicKey: PubKeyHex;
}>
See also: OriginatorDomainNameStringUnder250Bytes, PubKeyHex
Returns
await this.getPublicKey({ identityKey: true }, originator)
Links: API, Interfaces, Classes, Functions, Types, Variables
Derived class constructors should use the derived class name as the value for name
,
and an internationalizable constant string for message
.
If a derived class intends to wrap another WalletError, the public property should
be named walletError
and will be recovered by fromUnknown
.
Optionaly, the derived class message
can include template parameters passed in
to the constructor. See WERR_MISSING_PARAMETER for an example.
To avoid derived class name colisions, packages should include a package specific identifier after the 'WERR_' prefix. e.g. 'WERR_FOO_' as the prefix for Foo package error classes.
export class WalletError extends Error implements WalletErrorObject {
isError: true = true;
constructor(name: string, message: string, stack?: string, public details?: Record<string, string>)
get code(): sdk.ErrorCodeString10To40Bytes
set code(v: sdk.ErrorCodeString10To40Bytes)
get description(): sdk.ErrorDescriptionString20To200Bytes
set description(v: sdk.ErrorDescriptionString20To200Bytes)
static fromUnknown(err: unknown): WalletError
asStatus(): {
status: string;
code: string;
description: string;
}
}
See also: ErrorCodeString10To40Bytes, ErrorDescriptionString20To200Bytes, WalletErrorObject
Class WalletError Details
asStatus(): {
status: string;
code: string;
description: string;
}
Returns
standard HTTP error status object with status property set to 'error'.
Recovers all public fields from WalletError derived error classes and relevant Error derived errors.
Critical client data fields are preserved across HTTP DojoExpress / DojoExpressClient encoding.
static fromUnknown(err: unknown): WalletError
See also: WalletError
Links: API, Interfaces, Classes, Functions, Types, Variables
Links: API, Interfaces, Classes, Functions, Types, Variables
Aborts a previously created action which required custom input unlocking script signing.
export async function abortAction(args: {
referenceNumber: string;
log?: string;
}): Promise<AbortActionResult>
See also: AbortActionResult
Function abortAction Details
Returns
An Action object containing "txid", "rawTx" "mapiResponses" and "inputs".
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
export function asArray(val: Buffer | string | number[], encoding?: BufferEncoding): number[]
Links: API, Interfaces, Classes, Functions, Types, Variables
export function asBsvSdkScript(script: string | Buffer | Script): Script
Links: API, Interfaces, Classes, Functions, Types, Variables
export function asBsvSdkTx(tx: string | Buffer | Transaction): Transaction
Links: API, Interfaces, Classes, Functions, Types, Variables
export function asBuffer(val: Buffer | string | number[], encoding?: BufferEncoding): Buffer
Links: API, Interfaces, Classes, Functions, Types, Variables
export function asString(val: Buffer | string, encoding?: BufferEncoding): string
Function asString Details
Argument Details
-
val
- Value to convert to encoded string if not already a string.
Links: API, Interfaces, Classes, Functions, Types, Variables
Constructs a
export async function buildTransactionForSignActionUnlocking(ninjaInputs: Record<string, CreateActionInput>, createResult: DojoCreateTransactionResultApi): Promise<Transaction>
See also: CreateActionInput, DojoCreateTransactionResultApi
Function buildTransactionForSignActionUnlocking Details
Argument Details
-
ninjaInputs
- Ninja inputs as passed to createAction
-
createResult
- Create transaction results returned by createAction when signActionRequires is true.
-
changeKeys
- Dummy keys can be used to create a transaction with which to generate Ninja input lockingScripts.
Links: API, Interfaces, Classes, Functions, Types, Variables
export default async function connectToSubstrate(): Promise<Communicator>
See also: Communicator
Links: API, Interfaces, Classes, Functions, Types, Variables
Convert a MerklePath to a single BRC-10 proof
export function convertMerklePathToProof(txid: string, mp: MerklePath): TscMerkleProofApi
See also: TscMerkleProofApi
Function convertMerklePathToProof Details
Returns
transaction proof in BRC-10 string format.
Argument Details
-
txid
- the txid in
mp
for which a BRC-10 proof is needed
- the txid in
-
mp
- MerklePath
Links: API, Interfaces, Classes, Functions, Types, Variables
Convert a single BRC-10 proof to a MerklePath
export function convertProofToMerklePath(txid: string, proof: TscMerkleProofApi): MerklePath
See also: TscMerkleProofApi
Function convertProofToMerklePath Details
Returns
corresponding MerklePath
Argument Details
-
txid
- transaction hash as big endian hex string
-
proof
- transaction proof in BRC-10 string format.
Links: API, Interfaces, Classes, Functions, Types, Variables
export async function convertProofToMerklePathWithLookup(txid: string, proof: TscMerkleProofApi, lookupHeight: (targetType: "hash" | "header" | "merkleRoot" | "height", target: string | Buffer) => Promise<number>): Promise<MerklePath>
See also: TscMerkleProofApi
Links: API, Interfaces, Classes, Functions, Types, Variables
Creates and broadcasts a BitCoin transaction with the provided inputs and outputs.
export async function createAction(args: CreateActionParams): Promise<CreateActionResult>
See also: CreateActionParams, CreateActionResult
Function createAction Details
Returns
An Action object containing "txid", "rawTx" "mapiResponses" and "inputs".
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Creates a signed certificate
export async function createCertificate(args: {
certificateType: string;
fieldObject: Record<string, string>;
certifierUrl: string;
certifierPublicKey: string;
}): Promise<CreateCertificateResult>
See also: CreateCertificateResult
Function createCertificate Details
Returns
A signed certificate
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Creates a SHA-256 HMAC with a key belonging to the user.
export async function createHmac(args: {
data: Uint8Array | string;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<Uint8Array>
See also: ProtocolID
Function createHmac Details
Returns
The SHA-256 HMAC of the data.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Creates a digital signature with a key belonging to the user. The SHA-256 hash of the data is used with ECDSA.
To allow other users to externally verify the signature, use getPublicKey with the same protocolID, keyID and privileged parameters. The signature should be valid under that public key.
export async function createSignature(args: {
data: Uint8Array | string;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<Uint8Array>
See also: ProtocolID
Function createSignature Details
Returns
The ECDSA message signature.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Decrypts data with a key belonging to the user. The same protocolID, keyID, counterparty and privileged parameters that were used during encryption must be used to successfully decrypt.
export async function decrypt(args: {
ciphertext: string | Uint8Array;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
returnType?: "Uint8Array" | "string";
}): Promise<string | Uint8Array>
See also: ProtocolID
Function decrypt Details
Returns
The decrypted plaintext.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Decrypts data with a key belonging to the user. The same protocolID, keyID, counterparty and privileged parameters that were used during encryption must be used to successfully decrypt.
export async function decryptAsArray(args: {
ciphertext: string | Uint8Array;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<Uint8Array>
See also: ProtocolID
Function decryptAsArray Details
Returns
The decrypted plaintext.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Decrypts data with a key belonging to the user. The same protocolID, keyID, counterparty and privileged parameters that were used during encryption must be used to successfully decrypt.
export async function decryptAsString(args: {
ciphertext: string | Uint8Array;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<string>
See also: ProtocolID
Function decryptAsString Details
Returns
The decrypted plaintext TextDecoder decoded to string.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Resolves identity information by attributes from the user's trusted certifiers.
export async function discoverByAttributes(args: {
attributes: Record<string, string>;
description: string;
}): Promise<object[]>
Function discoverByAttributes Details
Argument Details
-
obj
- All parameters are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Resolves identity information by identity key from the user's trusted certifiers.
export async function discoverByIdentityKey(args: {
identityKey: string;
description: string;
}): Promise<object[]>
Function discoverByIdentityKey Details
Argument Details
-
obj
- All parameters are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Calculate the SHA256 hash of the SHA256 hash of a Buffer.
export function doubleSha256BE(data: string | Buffer, encoding?: BufferEncoding): Buffer {
return doubleSha256HashLE(data, encoding).reverse();
}
See also: doubleSha256HashLE
Function doubleSha256BE Details
Returns
reversed (big-endian) double sha256 hash of data, byte 31 of hash first.
Argument Details
-
data
- is Buffer or hex encoded string
Links: API, Interfaces, Classes, Functions, Types, Variables
Calculate the SHA256 hash of the SHA256 hash of a Buffer.
export function doubleSha256HashLE(data: string | Buffer, encoding?: BufferEncoding): Buffer {
const msg = asArray(data, encoding);
const first = new Hash.SHA256().update(msg).digest();
const second = new Hash.SHA256().update(first).digest();
return asBuffer(second);
}
Function doubleSha256HashLE Details
Returns
double sha256 hash of buffer contents, byte 0 of hash first.
Argument Details
-
data
- is Buffer or hex encoded string
Links: API, Interfaces, Classes, Functions, Types, Variables
Encrypts data with a key belonging to the user. If a counterparty is provided, also allows the counterparty to decrypt the data. The same protocolID, keyID, counterparty and privileged parameters must be used when decrypting.
export async function encrypt(args: {
plaintext: string | Uint8Array;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
returnType?: "Uint8Array" | "string";
}): Promise<string | Uint8Array>
See also: ProtocolID
Function encrypt Details
Returns
The encrypted ciphertext.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Encrypts data with a key belonging to the user. If a counterparty is provided, also allows the counterparty to decrypt the data. The same protocolID, keyID, counterparty and privileged parameters must be used when decrypting.
export async function encryptAsArray(args: {
plaintext: string | Uint8Array;
protocolID: string;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<Uint8Array>
Function encryptAsArray Details
Returns
The encrypted ciphertext data.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Encrypts data with a key belonging to the user. If a counterparty is provided, also allows the counterparty to decrypt the data. The same protocolID, keyID, counterparty and privileged parameters must be used when decrypting.
export async function encryptAsString(args: {
plaintext: string | Uint8Array;
protocolID: string;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<string>
Function encryptAsString Details
Returns
The encrypted ciphertext data as base64 encoded string.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns found certificates
export async function getCertificates(args: {
certifiers: string[];
types: Record<string, string[]>;
}): Promise<CreateCertificateResult[]>
See also: CreateCertificateResult
Function getCertificates Details
Returns
An object containing the found certificates
Argument Details
-
obj
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns an Everett Style envelope for the given txid.
A transaction envelope is a tree of inputs where all the leaves are proven transactions. The trivial case is a single leaf: the envelope for a proven transaction is the rawTx and its proof.
Each branching level of the tree corresponds to an unmined transaction without a proof, in which case the envelope is:
- rawTx
- mapiResponses from transaction processors (optional)
- inputs object where keys are this transaction's input txids and values are recursive envelope for those txids.
export async function getEnvelopeForTransaction(args: {
txid: string;
}): Promise<EnvelopeApi | undefined>
See also: EnvelopeApi
Function getEnvelopeForTransaction Details
Returns
Undefined if the txid does not exist or an envelope can't be generated.
Argument Details
-
args
- All parameters are given in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns the current chain height of the network
export async function getHeight(): Promise<number>
Function getHeight Details
Returns
The current chain height
Links: API, Interfaces, Classes, Functions, Types, Variables
export async function getInfo(args?: GetInfoParams): Promise<GetInfoResult>
See also: GetInfoParams, GetInfoResult
Function getInfo Details
Returns
information about the metanet-client context (version, chain, height, user...).
Links: API, Interfaces, Classes, Functions, Types, Variables
A method to verify the validity of a Merkle root for a given block height.
export async function getMerkleRootForHeight(height: number): Promise<string | undefined>
Function getMerkleRootForHeight Details
Returns
Returns the merkle root for height or undefined, if height doesn't have a known merkle root or is invalid.
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns which BSV network we are using (mainnet or testnet)
export async function getNetwork(format?: "default" | "nonet"): Promise<string>
Function getNetwork Details
Returns
The current BSV network formatted as requested.
Argument Details
-
format
- for the returned string. Either with (default) or without (nonet) a 'net' suffix.
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns the user's preferred currency for displaying within apps
export async function getPreferredCurrency(args: {
description?: string;
}): Promise<string>
Function getPreferredCurrency Details
Returns
The user's preferred currency
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns the public key. If identityKey is specified, returns the current user's identity key. If a counterparty is specified, derives a public key for the counterparty.
export async function getPublicKey(args: {
protocolID?: ProtocolID;
keyID?: string;
privileged?: boolean;
identityKey?: boolean;
reason?: string;
counterparty?: string;
forSelf?: boolean;
}): Promise<string>
See also: ProtocolID
Function getPublicKey Details
Returns
The user's public key
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
export default function getRandomID(): string
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns a set of transaction outputs that Dojo has tracked
export async function getTransactionOutputs(args: {
basket?: string;
tracked?: boolean;
spendable?: boolean;
tags?: string[];
type?: string;
includeEnvelope?: boolean;
includeBasket?: boolean;
includeCustomInstructions?: boolean;
includeTags?: boolean;
tagQueryMode?: "all" | "any";
limit?: number;
offset?: number;
}): Promise<GetTransactionOutputResult[]>
See also: GetTransactionOutputResult
Function getTransactionOutputs Details
Returns
A set of outputs that match the criteria
Argument Details
-
args
- All parameters are given in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns the current version of the kernel
export async function getVersion(): Promise<string>
Function getVersion Details
Returns
The current kernel version (e.g. "0.3.49")
Links: API, Interfaces, Classes, Functions, Types, Variables
Checks if a user is currently authenticated.
export async function isAuthenticated(): Promise<boolean>
Function isAuthenticated Details
Returns
Returns whether a user is currently authenticated.
Links: API, Interfaces, Classes, Functions, Types, Variables
Returns a list of Actions with a given label
export async function listActions(args: {
label: string;
addInputsAndOutputs?: boolean;
includeBasket?: boolean;
includeTags?: boolean;
noRawTx?: boolean;
limit?: number;
offset?: number;
}): Promise<ListActionsResult>
See also: ListActionsResult
Function listActions Details
Returns
A set of outputs that match the criteria
Argument Details
-
args
- All parameters are given in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
export default async function makeHttpRequest<R>(routeURL: string, requestInput: RequestInit = {}): Promise<R>
Links: API, Interfaces, Classes, Functions, Types, Variables
export function parseWalletOutpoint(outpoint: string): {
txid: string;
vout: number;
}
Links: API, Interfaces, Classes, Functions, Types, Variables
Provides a timedout promise.
export default async function promiseWithTimeout<T>(obj: {
timeout: number;
promise: Promise<T>;
error?: Error;
}): Promise<T>
Function promiseWithTimeout Details
Argument Details
-
obj
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Creates certificate proof specifically for verifier
export async function proveCertificate(args: {
certificate: CertificateApi;
fieldsToReveal: string[];
verifierPublicIdentityKey: string;
}): Promise<ProveCertificateResult>
See also: CertificateApi, ProveCertificateResult
Function proveCertificate Details
Returns
A certificate for presentation to the verifier for field examination
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Requests group permissions for an application.
export async function requestGroupPermission(): Promise<void>
Function requestGroupPermission Details
Returns
Resolves after group permissions are completed by the user.
Links: API, Interfaces, Classes, Functions, Types, Variables
Convert OptionalEnvelopeEvidenceApi to EnvelopeEvidenceApi.
Missing data (rawTx / proofs) can be looked up if lookupMissing is provided.
Any mising data will result in an Error throw.
export async function resolveOptionalEnvelopeEvidence(e: OptionalEnvelopeEvidenceApi, lookupMissing?: (txid: string) => Promise<{
rawTx?: string;
proof?: TscMerkleProofApi;
}>): Promise<EnvelopeEvidenceApi>
See also: EnvelopeEvidenceApi, OptionalEnvelopeEvidenceApi, TscMerkleProofApi
Links: API, Interfaces, Classes, Functions, Types, Variables
Reveals the linkage between a key held by this user and a key held by another user. In one mode, reveals all keys associated with a counterparty, in the other mode reveals only the linkage of a specific interaction.
Encrypts the linkage value so that only the specified verifier can access it. Refer to BRC-72 for full details.
export async function revealKeyLinkage(args: {
mode: "counterparty" | "specific";
counterparty: string;
verifier: string;
protocolID: ProtocolID;
keyID: string;
description: string;
privileged?: boolean;
}): Promise<CounterpartyKeyLinkageResult | SpecificKeyLinkageResult>
See also: CounterpartyKeyLinkageResult, ProtocolID, SpecificKeyLinkageResult
Function revealKeyLinkage Details
Returns
The revealed linkage payload, as described in BRC-72.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Reveals the linkage between a key held by this user and a key held by another user. Reveals all keys associated with a counterparty,
Encrypts the linkage value so that only the specified verifier can access it. Refer to BRC-72 for full details.
export async function revealKeyLinkageCounterparty(args: {
counterparty: string;
verifier: string;
protocolID: ProtocolID;
description: string;
privileged?: boolean;
}): Promise<CounterpartyKeyLinkageResult>
See also: CounterpartyKeyLinkageResult, ProtocolID
Function revealKeyLinkageCounterparty Details
Returns
The revealed linkage payload, as described in BRC-72.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Reveals the linkage between a key held by this user and a key held by another user. Reveals only the linkage of a specific interaction.
Encrypts the linkage value so that only the specified verifier can access it. Refer to BRC-72 for full details.
export async function revealKeyLinkageSpecific(args: {
counterparty: string;
verifier: string;
protocolID: ProtocolID;
keyID: string;
description: string;
privileged?: boolean;
}): Promise<SpecificKeyLinkageResult>
See also: ProtocolID, SpecificKeyLinkageResult
Function revealKeyLinkageSpecific Details
Returns
The revealed linkage payload, as described in BRC-72.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Calculate the SHA256 hash of a Buffer.
export function sha256Hash(buffer: Buffer): Buffer {
const msg = asArray(buffer);
const first = new Hash.SHA256().update(msg).digest();
return asBuffer(first);
}
Function sha256Hash Details
Returns
sha256 hash of buffer contents.
Links: API, Interfaces, Classes, Functions, Types, Variables
Completes a previously created action which required custom input unlocking script signing.
export async function signAction(args: {
inputs?: Record<string, CreateActionInput>;
createResult: DojoCreateTransactionResultApi;
acceptDelayedBroadcast?: boolean;
log?: string;
}): Promise<SignActionResult>
See also: CreateActionInput, DojoCreateTransactionResultApi, SignActionResult
Function signAction Details
Returns
An Action object containing "txid", "rawTx" "mapiResponses" and "inputs".
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
If a log is being kept, add a time stamped line.
export function stampLog(log: string | undefined | {
log?: string;
}, lineToAdd: string): string | undefined
Function stampLog Details
Returns
undefined or log extended by time stamped lineToAdd
and new line.
Argument Details
-
log
- Optional time stamped log to extend, or an object with a log property to update
-
lineToAdd
- Content to add to line.
Links: API, Interfaces, Classes, Functions, Types, Variables
Replaces individual timestamps with delta msecs.
Looks for two network crossings and adjusts clock for clock skew if found.
Assumes log built by repeated calls to stampLog
export function stampLogFormat(log?: string): string
Function stampLogFormat Details
Returns
reformated multi-line event log
Argument Details
-
log
- Each logged event starts with ISO time stamp, space, rest of line, terminated by
\n
.
- Each logged event starts with ISO time stamp, space, rest of line, terminated by
Links: API, Interfaces, Classes, Functions, Types, Variables
Submits a transaction directly to a ninja
export async function submitDirectTransaction(args: {
protocol?: string;
transaction: SubmitDirectTransaction;
senderIdentityKey: string;
note: string;
amount: number;
labels?: string[];
derivationPrefix?: string;
}): Promise<SubmitDirectTransactionResult>
See also: SubmitDirectTransaction, SubmitDirectTransactionResult
Function submitDirectTransaction Details
Returns
Object containing reference number, status=success, and human-readable note acknowledging the transaction
Argument Details
-
args
- All parameters for this function are provided in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
Converts a BRC-8 Everett-style Transaction Envelope to a
export function toBEEFfromEnvelope(e: EnvelopeEvidenceApi): {
tx: Transaction;
beef: number[];
}
See also: EnvelopeEvidenceApi
Function toBEEFfromEnvelope Details
Returns
tx: Transaction containing required merklePath and sourceTransaction values
beef: tx.toBEEF()
Links: API, Interfaces, Classes, Functions, Types, Variables
BEEF standard: BRC-62: Background Evaluation Extended Format (BEEF) Transactions https://github.com/bitcoin-sv/BRCs/blob/master/transactions/0062.md
BUMP standard: BRC-74: BSV Unified Merkle Path (BUMP) Format https://github.com/bitcoin-sv/BRCs/blob/master/transactions/0074.md
export function toEnvelopeFromBEEF(input: Transaction | number[]): EnvelopeEvidenceApi
See also: EnvelopeEvidenceApi
Function toEnvelopeFromBEEF Details
Returns
Everett-style Envelope for the transaction.
Argument Details
-
input
- Either a
Transaction
with sourceTransaction and merklePath, recursively, on inputs, or a serialized BEEF of the transaction.
- Either a
Links: API, Interfaces, Classes, Functions, Types, Variables
Removes the uniquely identified output's basket assignment.
The output will no longer belong to any basket.
This is typically only useful for outputs that are no longer usefull.
export async function unbasketOutput(args: {
txid: string;
vout: number;
basket: string;
}): Promise<void>
Function unbasketOutput Details
Argument Details
-
args
- All parameters are given in an object
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateAbortActionArgs(args: sdk.AbortActionArgs): ValidAbortActionArgs
See also: AbortActionArgs, ValidAbortActionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateAcquireCertificateArgs(args: sdk.AcquireCertificateArgs): ValidAcquireCertificateArgs
See also: AcquireCertificateArgs, ValidAcquireCertificateArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateBasketInsertion(args?: sdk.BasketInsertion): ValidBasketInsertion | undefined
See also: BasketInsertion, ValidBasketInsertion
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateCreateActionArgs(args: sdk.CreateActionArgs): ValidCreateActionArgs
See also: CreateActionArgs, ValidCreateActionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateCreateActionInput(i: sdk.CreateActionInput): ValidCreateActionInput
See also: CreateActionInput, ValidCreateActionInput
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateCreateActionOptions(options?: CreateActionOptions): CreateActionOptions
See also: CreateActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
Set all default true/false booleans to true or false if undefined.
Set all possibly undefined numbers to their default values.
Set all possibly undefined arrays to empty arrays.
Convert string outpoints to { txid: string, vout: number }
export function validateCreateActionOptions(options?: sdk.CreateActionOptions): ValidCreateActionOptions
See also: CreateActionOptions, ValidCreateActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateCreateActionOutput(o: sdk.CreateActionOutput): ValidCreateActionOutput
See also: CreateActionOutput, ValidCreateActionOutput
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateInteger(v: number | undefined, name: string, defaultValue?: number, min?: number, max?: number): number
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateInternalizeActionArgs(args: sdk.InternalizeActionArgs): ValidInternalizeActionArgs
See also: InternalizeActionArgs, ValidInternalizeActionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateInternalizeOutput(args: sdk.InternalizeOutput): ValidInternalizeOutput
See also: InternalizeOutput, ValidInternalizeOutput
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateListActionsArgs(args: sdk.ListActionsArgs): ValidListActionsArgs
See also: ListActionsArgs, ValidListActionsArgs
Function validateListActionsArgs Details
Argument Details
-
args.labels
- An array of labels used to filter actions.
-
args.labelQueryMode
- Optional. Specifies how to match labels (default is any which matches any of the labels).
-
args.includeLabels
- Optional. Whether to include transaction labels in the result set.
-
args.includeInputs
- Optional. Whether to include input details in the result set.
-
args.includeInputSourceLockingScripts
- Optional. Whether to include input source locking scripts in the result set.
-
args.includeInputUnlockingScripts
- Optional. Whether to include input unlocking scripts in the result set.
-
args.includeOutputs
- Optional. Whether to include output details in the result set.
-
args.includeOutputLockingScripts
- Optional. Whether to include output locking scripts in the result set.
-
args.limit
- Optional. The maximum number of transactions to retrieve.
-
args.offset
- Optional. Number of transactions to skip before starting to return the results.
-
args.seekPermission
- — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateListCertificatesArgs(args: sdk.ListCertificatesArgs): ValidListCertificatesArgs
See also: ListCertificatesArgs, ValidListCertificatesArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateListOutputsArgs(args: sdk.ListOutputsArgs): ValidListOutputsArgs
See also: ListOutputsArgs, ValidListOutputsArgs
Function validateListOutputsArgs Details
Argument Details
-
args.basket
- Required. The associated basket name whose outputs should be listed.
-
args.tags
- Optional. Filter outputs based on these tags.
-
args.tagQueryMode
- Optional. Filter mode, defining whether all or any of the tags must match. By default, any tag can match.
-
args.include
- Optional. Whether to include locking scripts (with each output) or entire transactions (as aggregated BEEF, at the top level) in the result. By default, unless specified, neither are returned.
-
args.includeEntireTransactions
- Optional. Whether to include the entire transaction(s) in the result.
-
args.includeCustomInstructions
- Optional. Whether custom instructions should be returned in the result.
-
args.includeTags
- Optional. Whether the tags associated with the output should be returned.
-
args.includeLabels
- Optional. Whether the labels associated with the transaction containing the output should be returned.
-
args.limit
- Optional limit on the number of outputs to return.
-
args.offset
- Optional. Number of outputs to skip before starting to return results.
-
args.seekPermission
- — Optional. Whether to seek permission from the user for this operation if required. Default true, will return an error rather than proceed if set to false.
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateOptionalEnvelopeEvidence(e: OptionalEnvelopeEvidenceApi): EnvelopeEvidenceApi
See also: EnvelopeEvidenceApi, OptionalEnvelopeEvidenceApi
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateOptionalInteger(v: number | undefined, name: string, min?: number, max?: number): number | undefined
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateOptionalOutpointString(outpoint: string | undefined, name: string): string | undefined
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateOriginator(s?: string): string | undefined
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateOutpointString(outpoint: string, name: string): string
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validatePositiveIntegerOrZero(v: number, name: string): number
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateRelinquishOutputArgs(args: sdk.RelinquishOutputArgs): ValidRelinquishOutputArgs
See also: RelinquishOutputArgs, ValidRelinquishOutputArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateSatoshis(v: number | undefined, name: string, min?: number): number
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateSignActionArgs(args: sdk.SignActionArgs): ValidSignActionArgs
See also: SignActionArgs, ValidSignActionArgs
Links: API, Interfaces, Classes, Functions, Types, Variables
Set all default true/false booleans to true or false if undefined.
Set all possibly undefined numbers to their default values.
Set all possibly undefined arrays to empty arrays.
Convert string outpoints to { txid: string, vout: number }
export function validateSignActionOptions(options?: sdk.SignActionOptions): ValidSignActionOptions
See also: SignActionOptions, ValidSignActionOptions
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateStringLength(s: string, name: string, min?: number, max?: number): string
Links: API, Interfaces, Classes, Functions, Types, Variables
export function validateWalletPayment(args?: sdk.WalletPayment): ValidWalletPayment | undefined
See also: ValidWalletPayment, WalletPayment
Links: API, Interfaces, Classes, Functions, Types, Variables
Verifies that a SHA-256 HMAC was created with a key that belongs to the user.
export async function verifyHmac(args: {
data: Uint8Array | string;
hmac: Uint8Array | string;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
}): Promise<boolean>
See also: ProtocolID
Function verifyHmac Details
Returns
Whether the HMAC has been erified.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
Verifies that a digital signature was created with a key belonging to the user.
export async function verifySignature(args: {
data: Uint8Array | string;
signature: Uint8Array | string;
protocolID: ProtocolID;
keyID: string;
description?: string;
counterparty?: string;
privileged?: boolean;
reason?: string;
}): Promise<boolean>
See also: ProtocolID
Function verifySignature Details
Returns
An whether the signature was successfully verified.
Argument Details
-
args
- All parameters are passed in an object.
Links: API, Interfaces, Classes, Functions, Types, Variables
export function verifyTruthy<T>(v: T | null | undefined, description?: string): T
Links: API, Interfaces, Classes, Functions, Types, Variables
Waits for a user to be authenticated.
export async function waitForAuthentication(): Promise<boolean>
Function waitForAuthentication Details
Returns
Always returns true
Links: API, Interfaces, Classes, Functions, Types, Variables
Links: API, Interfaces, Classes, Functions, Types, Variables
export type AcquisitionProtocol = "direct" | "issuance"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ActionStatus = "completed" | "unprocessed" | "sending" | "unproven" | "unsigned" | "nosend" | "nonfinal"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type AtomicBEEF = Byte[]
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export type BEEF = Byte[]
See also: Byte
Links: API, Interfaces, Classes, Functions, Types, Variables
export type Base64String = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type BasketStringUnder300Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type BooleanDefaultFalse = boolean
Links: API, Interfaces, Classes, Functions, Types, Variables
export type BooleanDefaultTrue = boolean
Links: API, Interfaces, Classes, Functions, Types, Variables
export type Byte = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type CertificateFieldNameUnder50Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type Chain = "main" | "test"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type Counterparty = PublicKey | PubKeyHex | "self" | "anyone"
See also: PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export type DescriptionString5to50Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type DojoProvidedByApi = "you" | "dojo" | "you-and-dojo"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type EntityIconURLStringMax500Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type EntityNameStringMax100Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ErrorCodeString10To40Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ErrorDescriptionString20To200Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type HexString = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ISOTimestampString = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type KeyIDStringUnder800Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type KeyringRevealer = PubKeyHex | "certifier"
See also: PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export type LabelStringUnder300Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type OriginatorDomainNameStringUnder250Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type OutpointString = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type OutputTagStringUnder300Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type PositiveInteger = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type PositiveIntegerDefault10Max10000 = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type PositiveIntegerMax10 = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type PositiveIntegerOrZero = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ProtocolID = string | [
0 | 1 | 2,
string
]
Links: API, Interfaces, Classes, Functions, Types, Variables
export type ProtocolString5To400Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type PubKeyHex = HexString
See also: HexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export type SatoshiValue = number
Links: API, Interfaces, Classes, Functions, Types, Variables
export type SendWithResultStatus = "unproven" | "sending" | "failed"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type TXIDHexString = HexString
See also: HexString
Links: API, Interfaces, Classes, Functions, Types, Variables
export type TransactionStatusApi = "completed" | "failed" | "unprocessed" | "sending" | "unproven" | "unsigned" | "nosend"
Links: API, Interfaces, Classes, Functions, Types, Variables
Controls level of trust for inputs from user's own transactions.
export type TrustSelf = "known"
Links: API, Interfaces, Classes, Functions, Types, Variables
Controls behavior of input BEEF validation.
If known
, input transactions may omit supporting validity proof data for all TXIDs known to this wallet.
If undefined, input BEEFs must be complete and valid.
export type TrustSelf = "known"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type VersionString7To30Bytes = string
Links: API, Interfaces, Classes, Functions, Types, Variables
export type WalletCounterparty = PubKeyHex | "self" | "anyone"
See also: PubKeyHex
Links: API, Interfaces, Classes, Functions, Types, Variables
export type WalletNetwork = "mainnet" | "testnet"
Links: API, Interfaces, Classes, Functions, Types, Variables
export type WalletProtocol = [
0 | 1 | 2,
ProtocolString5To400Bytes
]
See also: ProtocolString5To400Bytes
Links: API, Interfaces, Classes, Functions, Types, Variables
BabbageSDK = {
abortAction,
createAction,
createHmac,
createCertificate,
createSignature,
decrypt,
decryptAsArray,
decryptAsString,
discoverByAttributes,
discoverByIdentityKey,
getPreferredCurrency,
encrypt,
encryptAsArray,
encryptAsString,
getCertificates,
getHeight,
getInfo,
getMerkleRootForHeight,
getNetwork,
getPublicKey,
getEnvelopeForTransaction,
getTransactionOutputs,
getVersion,
isAuthenticated,
listActions,
proveCertificate,
requestGroupPermission,
revealKeyLinkage,
revealKeyLinkageCounterparty,
revealKeyLinkageSpecific,
signAction,
submitDirectTransaction,
unbasketOutput,
verifyHmac,
verifySignature,
waitForAuthentication,
}
See also: abortAction, createAction, createCertificate, createHmac, createSignature, decrypt, decryptAsArray, decryptAsString, discoverByAttributes, discoverByIdentityKey, encrypt, encryptAsArray, encryptAsString, getCertificates, getEnvelopeForTransaction, getHeight, getInfo, getMerkleRootForHeight, getNetwork, getPreferredCurrency, getPublicKey, getTransactionOutputs, getVersion, isAuthenticated, listActions, proveCertificate, requestGroupPermission, revealKeyLinkage, revealKeyLinkageCounterparty, revealKeyLinkageSpecific, signAction, submitDirectTransaction, unbasketOutput, verifyHmac, verifySignature, waitForAuthentication
Links: API, Interfaces, Classes, Functions, Types, Variables
The Babbage SDK connects to a running Computing with Integrity (CWI) kernel instance, allowing applications to plug into user-owned identities. There are currently three substrates (connection modes) that the SDK can use to link an application to a MetaNet identity provider:
-
Window API: In a web browser, the SDK will first try to use a
window.CWI
interface for communicating with the kernel. - Babbage XDM: In a browser or iframe window, the SDK will next try to use XDM (cross-document messaging) to communicate with a running kernel instance.
-
Cicada API: Lastly, the SDK will attempt to communicate over
localhost:3301
to a running HTTP MetaNet service. This Port 3301 Substrate is named Cicada, in honor of Cicada 3301.
The license for this library, which is a wrapper for the proprietary Babbage API, is the Open BSV License. It can only be used on the BSV blockchain. The Babbage API itself, including the rights to create and host Babbage software or any other related infrastructure, is not covered by the Open BSV License and remains proprietary and restricted. The Open BSV License only extends to the code in this repository, and you are not permitted to host Babbage software, servers or create copies or alternative implementations of the proprietary Babbage API without other permission.