Skip to content

Latest commit

 

History

History
5150 lines (3659 loc) · 169 KB

API.md

File metadata and controls

5150 lines (3659 loc) · 169 KB

Classes

Actor

Generic Fabric Actor.

Aggregator

Aggregates a set of balances (inputs).

AppService

Web-friendly application framework for building single-page applications with Fabric-based networking and storage.

Chain

Chain.

Channel

The Channel is a encrypted connection with a member of your Peer group, with some amount of $BTC bonded and paid for each correctly-validated message.

Channels in Fabric are powerful tools for application development, as they can empower users with income opportunities in exchange for delivering service to the network.

Circuit

The Circuit is the mechanism through which Fabric operates, a computable directed graph describing a network of Peer components and their interactions (side effects). See also Swarm for deeper *inspection of Machine mechanics.

CLI

Provides a Command Line Interface (CLI) for interacting with the Fabric network using a terminal emulator.

Collection

The Collection type maintains an ordered list of State items.

Compiler : Actor

Compilers build interfaces for users of Fabric applications.

Consensus

Provides various network-specific rules.

Entity : Object

Live instance of an ARC in Fabric.

Environment

Interact with the user's Environment.

Fabric

Reliable decentralized infrastructure.

Federation

Create and manage sets of signers with the Federation class.

Filesystem

Interact with a local filesystem.

Hash256

Simple interaction with 256-bit spaces.

HKDF

Provides an HMAC-based Extract-and-Expand Key Derivation Function (HKDF), compatible with RFC 5869. Defaults to 32 byte output, matching Bitcoin's implementaton.

Identity

Manage a network identity.

InterfaceEventEmitter

Interfaces compile abstract contract code into Chain-executable transactions, or "chaincode". For example, the "Bitcoin" interface might compile a Swap contract into Script, preparing a valid Bitcoin transaction for broadcast which executes the swap contract.

Key

Represents a cryptographic key.

Keystore

Provides an encrypted datastore for generic object storage.

LedgerScribe

An ordered stack of pages.

LoggerActor

A basic logger that writes logs to the local file system

Machine

General-purpose state machine with Vector-based instructions.

Mempool

Stores a list of Transaction elements.

Message : Object

The Message type defines the Application Messaging Protocol, or AMP. Each Actor in the network receives and broadcasts messages, selectively disclosing new routes to peers which may have open circuits.

Node

Full definition of a Fabric node.

OracleStore

An Oracle manages one or more collections, using a mempool for transitive state.

Path

A Path is a Fabric-native link to a Document within the network.

Peer

An in-memory representation of a node in our network.

Reader

Read from a byte stream, seeking valid Fabric messages.

Remote : Remote

Interact with a remote Resource. This is currently the only HTTP-related code that should remain in @fabric/core — all else must be moved to @fabric/http before final release!

Resource

Generic interface for collections of digital objects.

RouterScribe

Process incoming messages.

ScribeState

Simple tag-based recordkeeper.

Script
Service

The "Service" is a simple model for processing messages in a distributed system. Service instances are public interfaces for outside systems, and typically advertise their presence to the network.

To implement a Service, you will typically need to implement all methods from this prototype. In general, connect and send are the highest-priority jobs, and by default the fabric property will serve as an I/O stream using familiar semantics.

Session

The Session type describes a connection between Peer objects, and includes its own lifecycle.

SignerActor

Generic Fabric Signer.

Snapshot

A type of message to be expected from a Service.

Stack

Manage stacks of data.

StateEventEmitter

The State is the core of most User-facing interactions. To interact with the User, simply propose a change in the state by committing to the outcome. This workflow keeps app design quite simple!

Store

Long-term storage.

Swap : Object

The Swap contract executes a set of transactions on two distinct Chain components, utilizing a secret-reveal mechanism to atomically execute either the full set or none.

Swarm : String

Orchestrates a network of peers.

Token

Implements a capability-based security token.

Transition

The Transition type reflects a change from one finite State to another.

Tree

Class implementing a Merkle Tree.

Value

Number-like type.

Vector
Walker
Wallet : Object

Manage keys and track their balances.

Worker

Workers are arbitrary containers for processing data. They can be thought of almost like "threads", as they run asynchronously over the duration of a contract's lifetime as "fulfillment conditions" for its closure.

BitcoinService

Manages interaction with the Bitcoin network.

Exchange

Implements a basic Exchange.

Lightning

Manage a Lightning node.

Redis

Connect and subscribe to ZeroMQ servers.

ZMQ

Connect and subscribe to ZeroMQ publishers.

HTTPServer

Deprecated 2021-10-16.

Scribe

Deprecated 2021-11-06.

Stash

Deprecated 2021-11-06.

Actor

Generic Fabric Actor.

Kind: global class
Emits: event:message Fabric {@link Message} objects.
Access: protected
Properties

Name Type Description
id String Unique identifier for this Actor (id === SHA256(preimage)).
preimage String Input hash for the id property (preimage === SHA256(ActorState)).

new Actor([actor])

Creates an Actor, which emits messages for other Actors to subscribe to. You can supply certain parameters for the actor, including key material [!!!] — be mindful of what you share with others!

Returns: Actor - Instance of the Actor. Call sign to emit a Signature.

Param Type Description
[actor] Object Object to use as the actor.
[actor.seed] String BIP24 Mnemonic to use as a seed phrase.
[actor.public] Buffer Public key.
[actor.private] Buffer Private key.

actor.adopt(changes) ⇒ Actor

Explicitly adopt a set of JSONPatch-encoded changes.

Kind: instance method of Actor
Returns: Actor - Instance of the Actor.

Param Type Description
changes Array List of JSONPatch operations to apply.

actor.commit() ⇒ String

Resolve the current state to a commitment.

Kind: instance method of Actor
Returns: String - 32-byte ID

actor.export() ⇒ Object

Export the Actor's state to a standard Object.

Kind: instance method of Actor
Returns: Object - Standard object.

actor.get(path) ⇒ Object

Retrieve a value from the Actor's state by JSONPointer path.

Kind: instance method of Actor
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to retrieve using JSONPointer.

actor.set(path, value) ⇒ Object

Set a value in the Actor's state by JSONPointer path.

Kind: instance method of Actor
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to set using JSONPointer.
value Object Value to set.

actor.toBuffer() ⇒ Buffer

Casts the Actor to a normalized Buffer.

Kind: instance method of Actor

actor.toGenericMessage() ⇒ Object

Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:

  • preimage: JSON.stringify(state)
  • hash: SHA256(preimage)
  • type: 'FabricActorState'
  • version: 1 (for now)
  • object: state
  • parent: null (for now)

Kind: instance method of Actor
Returns: Object - Generic message object.
See

actor.toObject() ⇒ Object

Returns the Actor's current state as an Object.

Kind: instance method of Actor

actor.pause() ⇒ Actor

Toggles status property to paused.

Kind: instance method of Actor
Returns: Actor - Instance of the Actor.

actor.serialize() ⇒ String

Serialize the Actor's current state into a JSON-formatted string.

Kind: instance method of Actor

actor.sign() ⇒ Actor

Signs the Actor.

Kind: instance method of Actor

actor.unpause() ⇒ Actor

Toggles status property to unpaused.

Kind: instance method of Actor
Returns: Actor - Instance of the Actor.

actor.value([format]) ⇒ Object

Get the inner value of the Actor with an optional cast type.

Kind: instance method of Actor
Returns: Object - Inner value of the Actor as an Object, or cast to the requested format.

Param Type Default Description
[format] String object Cast the value to one of: buffer, hex, json, string

actor._readObject(input) ⇒ Object

Parse an Object into a corresponding Fabric state.

Kind: instance method of Actor
Returns: Object - Fabric state.

Param Type Description
input Object Object to read as input.

Actor.fromAny(input) ⇒ Actor

Create an Actor from a variety of formats.

Kind: static method of Actor
Returns: Actor - Instance of the Actor.

Param Type Description
input Object Target Object to create.

Actor.randomBytes([count]) ⇒ Buffer

Get a number of random bytes from the runtime environment.

Kind: static method of Actor
Returns: Buffer - The random bytes.

Param Type Default Description
[count] Number 32 Number of random bytes to retrieve.

Aggregator

Aggregates a set of balances (inputs).

Kind: global class

new Aggregator([settings])

Create a new Aggregator.

Returns: Aggregator - Instance of the Aggregator.

Param Type Description
[settings] Object Map of configuration values.
[settings.inputs] Array Array of AnchorBalance instances.

aggregator._importBalances(list) ⇒ AnchorBalance

Import a list of AnchorBalance instances.

Kind: instance method of Aggregator
Returns: AnchorBalance - Summary of resulting balances.

Param Type Description
list Array List of inputs to add.

aggregator._computeBalances() ⇒ AnchorBalance

Updates the state to reflect balances from current inputs.

Kind: instance method of Aggregator
Returns: AnchorBalance - Summary of balances.

aggregator.commit() ⇒ AggregatorCommit

Commits the balance of all input.

Kind: instance method of Aggregator
Returns: AggregatorCommit - Commit instance.
Emits: commit

"commit"

Commit event.

Kind: event emitted by Aggregator
Properties

Name Type Description
root Uint8Array Root of the Tree.
leaves Array Leaves of the Tree.

App ⇐ Service

Web-friendly application framework for building single-page applications with Fabric-based networking and storage.

Kind: global class
Extends: Service
Properties

Name Type Description
components Collection Interface elements.
stash Store Routable Datastore.

new App(definition)

Generic bundle for building Fabric applications.

Returns: App - Returns an instance of App.

Param Type Description
definition Object Application definition. See config for examples.

app.start() ⇒ Promise

Start the program.

Kind: instance method of App
Overrides: start

app.stop() ⇒ Promise

Stop the program.

Kind: instance method of App

app.define(name, structure) ⇒ Object

Define a Resource, or "Type", used by the application.

Kind: instance method of App
Returns: Object - [description]

Param Type Description
name String Human-friendly name for the Resource.
structure Object Map of attribute names -> definitions.

app.defer(authority) ⇒ App

Defer control of this application to an outside authority.

Kind: instance method of App
Returns: App - The configured application as deferred to authority.

Param Type Description
authority String Hostname to trust.

app.attach(element) ⇒ App

Configure the Application to use a specific element.

Kind: instance method of App
Returns: App - Configured instance of the Application.

Param Type Description
element DOMElement DOM element to bind to.

app.consume(resources) ⇒ App

Define the Application's resources from an existing resource map.

Kind: instance method of App
Returns: App - Configured instance of the Application.

Param Type Description
resources Object Map of resource definitions by name.

app.envelop(selector) ⇒ App

Use a CSS selector to find an element in the current document's tree and bind to it as the render target.

Kind: instance method of App
Returns: App - Instance of app with bound element.

Param Type Description
selector String CSS selector.

app.use(name, definition) ⇒ App

Define a named Resource.

Kind: instance method of App
Returns: App - Configurated instance of the App.

Param Type Description
name String Human-friendly name for this resource.
definition Object Map of configuration values.

app.render() ⇒ String

Get the output of our program.

Kind: instance method of App
Returns: String - Output of the program.

app._registerService(name, Service) ⇒ Service

Registers a named Service with the application. Services are standardized interfaces for Fabric contracts, emitting Message events with a predictable lifecycle.

Kind: instance method of App
Returns: Service - The registered service instance.
Internal:

Param Type Description
name String Internal name of the service.
Service Class The ES6 class definition implementing Service.

app.init()

Called by Web Components. TODO: move to @fabric/http/types/spa

Kind: instance method of App
Overrides: init

app.tick() ⇒ Number

Move forward one clock cycle.

Kind: instance method of App
Overrides: tick

app.beat() ⇒ Service

Compute latest state.

Kind: instance method of App
Overrides: beat
Emits: Message#event:beat

app.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of App
Overrides: get
Returns: Mixed - Returns the target value if found, otherwise null.

Param Type Description
path Path Key to retrieve.

app.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of App
Overrides: set

Param Type Description
path Path Key to retrieve.

app.trust(source) ⇒ Service

Explicitly trust all events from a known source.

Kind: instance method of App
Overrides: trust
Returns: Service - Instance of Service after binding events.

Param Type Description
source EventEmitter Emitter of events.

app.handler(message) ⇒ Service

Default route handler for an incoming message. Follows the Activity Streams 2.0 spec: https://www.w3.org/TR/activitystreams-core/

Kind: instance method of App
Overrides: handler
Returns: Service - Chainable method.

Param Type Description
message Activity Message object.

app.lock([duration]) ⇒ Boolean

Attempt to acquire a lock for duration seconds.

Kind: instance method of App
Overrides: lock
Returns: Boolean - true if locked, false if unable to lock.

Param Type Default Description
[duration] Number 1000 Number of milliseconds to hold lock.

app.route(msg) ⇒ Promise

Resolve a State from a particular Message object.

Kind: instance method of App
Overrides: route
Returns: Promise - Resolves with resulting State.

Param Type Description
msg Message Explicit Fabric Message.

app._GET(path) ⇒ Promise

Retrieve a value from the Service's state.

Kind: instance method of App
Overrides: _GET
Returns: Promise - Resolves with the result.

Param Type Description
path String Path of the value to retrieve.

app._PUT(path, value, [commit]) ⇒ Promise

Store a value in the Service's state.

Kind: instance method of App
Overrides: _PUT
Returns: Promise - Resolves with with stored document.

Param Type Default Description
path String Path to store the value at.
value Object Document to store.
[commit] Boolean false Sign the resulting state.

app.connect(notify) ⇒ Promise

Attach to network.

Kind: instance method of App
Overrides: connect
Returns: Promise - Resolves to Fabric.

Param Type Default Description
notify Boolean true Commit to changes.

app.send(channel, message) ⇒ Service

Send a message to a channel.

Kind: instance method of App
Overrides: send
Returns: Service - Chainable method.

Param Type Description
channel String Channel name to which the message will be sent.
message String Content of the message to send.

app._registerActor(actor) ⇒ Promise

Register an Actor with the Service.

Kind: instance method of App
Overrides: _registerActor
Returns: Promise - Resolves upon successful registration.

Param Type Description
actor Object Instance of the Actor.

app._send(message)

Sends a message.

Kind: instance method of App
Overrides: _send

Param Type Description
message Mixed Message to send.

Chain

Chain.

Kind: global class
Properties

Name Type Description
name String Current name.
indices Map
storage Storage

new Chain(genesis)

Holds an immutable chain of events.

Param Type Description
genesis Vector Initial state for the chain of events.

Channel

The Channel is a encrypted connection with a member of your Peer group, with some amount of $BTC bonded and paid for each correctly-validated message.

Channels in Fabric are powerful tools for application development, as they can empower users with income opportunities in exchange for delivering service to the network.

Kind: global class

new Channel([settings])

Creates a channel between two peers. of many transactions over time, to be settled on-chain later.

Param Type Description
[settings] Object Configuration for the channel.

channel.add(amount)

Add an amount to the channel's balance.

Kind: instance method of Channel

Param Type Description
amount Number Amount value to add to current outgoing balance.

channel.fund(input)

Fund the channel.

Kind: instance method of Channel

Param Type Description
input Mixed Instance of a Transaction.

channel.open(channel)

Opens a Channel with a Peer.

Kind: instance method of Channel

Param Type Description
channel Object Channel settings.

Circuit

The Circuit is the mechanism through which Fabric operates, a computable directed graph describing a network of Peer components and their interactions (side effects). See also Swarm for deeper *inspection of Machine mechanics.

Kind: global class

CLI

Provides a Command Line Interface (CLI) for interacting with the Fabric network using a terminal emulator.

Kind: global class

new CLI([settings])

Create a terminal-based interface for a User.

Param Type Description
[settings] Object Configuration values.
[settings.currencies] Array List of currencies to support.

clI.start()

Starts (and renders) the CLI.

Kind: instance method of CLI

clI.stop()

Disconnect all interfaces and exit the process.

Kind: instance method of CLI

clI._handleGrantCommand(params)

Creates a token for the target signer with a provided role and some optional data.

Kind: instance method of CLI

Param Type Description
params Array Parameters array.

Collection

The Collection type maintains an ordered list of State items.

Kind: global class
Properties

Name Type Description
@entity Object Fabric-bound entity object.

new Collection([configuration])

Create a list of Entity-like objects for later retrieval.

Returns: Collection - Configured instance of the the Collection.

Param Type Default Description
[configuration] Object {} Configuration object.

collection.asMerkleTree() ⇒ MerkleTree

Current elements of the collection as a MerkleTree.

Kind: instance method of Collection

collection._setKey(name)

Sets the key property of collection settings.

Kind: instance method of Collection

Param Type Description
name String Value to set the key setting to.

collection.getByID(id)

Retrieve an element from the collection by ID.

Kind: instance method of Collection

Param Type Description
id String Document identifier.

collection.getLatest()

Retrieve the most recent element in the collection.

Kind: instance method of Collection

collection.findByField(name, value)

Find a document by specific field.

Kind: instance method of Collection

Param Type Description
name String Name of field to search.
value String Value to match.

collection.findByName(name)

Find a document by the "name" field.

Kind: instance method of Collection

Param Type Description
name String Name to search for.

collection.findBySymbol(symbol)

Find a document by the "symbol" field.

Kind: instance method of Collection

Param Type Description
symbol String Value to search for.

collection._patchTarget(path, patches)

Modify a target document using an array of atomic updates.

Kind: instance method of Collection

Param Type Description
path String Path to the document to modify.
patches Array List of operations to apply.

collection.push(data) ⇒ Number

Adds an Entity to the Collection.

Kind: instance method of Collection
Returns: Number - Length of the collection.

Param Type Description
data Mixed Entity to add.

collection.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Collection

Param Type Description
path Path Key to retrieve.

collection.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Collection

Param Type Description
path Path Key to retrieve.

collection.list() ⇒ Array

Deprecated

Generate a list of elements in the collection.

Kind: instance method of Collection

collection.toTypedArray()

Provides the Collection as an Array of typed elements. The type of these elments are defined by the collection's type, supplied in the constructor.

Kind: instance method of Collection

collection.map() ⇒ Array

Generate a hashtable of elements in the collection.

Kind: instance method of Collection

collection.create(entity) ⇒ Promise

Create an instance of an Entity.

Kind: instance method of Collection
Returns: Promise - Resolves with instantiated Entity.

Param Type Description
entity Object Object with properties.

collection.import(state, commit)

Loads State into memory.

Kind: instance method of Collection
Emits: event:message Will emit one {@link Snapshot} message.

Param Type Description
state State State to import.
commit Boolean Whether or not to commit the result.

Compiler : Actor

Compilers build interfaces for users of Fabric applications.

Kind: global class
Properties

Name Type Description
ast AST Compiler's current AST.
entity Entity Compiler's current Entity.

new Compiler(settings)

Create a new Compiler.

Returns: Compiler - Instance of the compiler.

Param Type Default Description
settings Object {} Configuration.
settings.body Buffer Body of the input program to compile.

compiler._getJavaScriptAST(input) ⇒ AST

Parse a Buffer of JavaScript into an Abstract Syntax Tree (AST).

Kind: instance method of Compiler

Param Type Description
input Buffer Input JavaScript to parse.

Compiler._fromJavaScript(body) ⇒

Creates a new Compiler instance from a JavaScript contract.

Kind: static method of Compiler
Returns: Compiler

Param Type Description
body Buffer Content of the JavaScript to evaluate.

Consensus

Provides various network-specific rules.

Kind: global class

new Consensus([settings])

Create an instance of a Consensus verifier.

Param Type Description
[settings] Object Configuration for the network.
[settings.network] String Name of the network.
[settings.provider] String Name of the source provider.

Entity : Object

Live instance of an ARC in Fabric.

Kind: global class

new Entity([data])

Generic template for virtual objects.

Returns: Entity - Instance of the Entity.

Param Type Default Description
[data] Object {} Pass an object to use.

entity.toJSON() ⇒ String

Produces a string of JSON, representing the entity.

Kind: instance method of Entity
Returns: String - JSON-encoded object.

entity.toRaw() ⇒ Buffer

As a Buffer.

Kind: instance method of Entity
Returns: Buffer - Slice of memory.

entity._downsample([input])

Return a Fabric-labeled Object for this Entity.

Kind: instance method of Entity

Param Type Description
[input] Mixed Input to downsample. If not provided, current Entity will be used.

Environment

Interact with the user's Environment.

Kind: global class

new Environment([settings])

Create an instance of Environment.

Returns: Environment - Instance of the Environment.

Param Type Description
[settings] Object Settings for the Fabric environment.

environment.readVariable(name) ⇒ String

Read a variable from the environment.

Kind: instance method of Environment
Returns: String - Value of the variable (or an empty string).

Param Type Description
name String Variable name to read.

environment.setWallet(wallet, force) ⇒ Environment

Configure the Environment to use a Fabric Wallet.

Kind: instance method of Environment
Returns: Environment - The Fabric Environment.

Param Type Default Description
wallet Wallet Wallet to attach.
force Boolean false Force existing wallets to be destroyed.

environment.start() ⇒ Environment

Start the Environment.

Kind: instance method of Environment
Returns: Environment - The Fabric Environment.

Fabric

Reliable decentralized infrastructure.

Kind: global class
Emits: Fabric#event:thread, Fabric#event:step Emitted on a `compute` step.

new Fabric(config)

The Fabric type implements a peer-to-peer protocol for establishing and settling of mutually-agreed upon proofs of work. Contract execution takes place in the local node first, then is optionally shared with the network.

Utilizing

Param Type Description
config Vector Initial configuration for the Fabric engine. This can be considered the "genesis" state for any contract using the system. If a chain of events is maintained over long periods of time, state can be considered "in contention", and it is demonstrated that the outstanding value of the contract remains to be settled.

fabric.register(service)

Register an available Service using an ES6 Class.

Kind: instance method of Fabric

Param Type Description
service Class The ES6 Class.

fabric.push(value) ⇒ Stack

Push an instruction onto the stack.

Kind: instance method of Fabric

Param Type
value Instruction

fabric.trust(source) ⇒ Fabric

Blindly consume messages from a Source, relying on this.chain to verify results.

Kind: instance method of Fabric
Returns: Fabric - Returns itself.

Param Type Description
source EventEmitter Any object which implements the EventEmitter pattern.

fabric.compute() ⇒ Fabric

Process the current stack.

Kind: instance method of Fabric
Returns: Fabric - Resulting instance of the stack.

Federation

Create and manage sets of signers with the Federation class.

Kind: global class

new Federation([settings])

Create an instance of a federation.

Returns: Federation - Instance of the federation.

Param Type Description
[settings] Object Settings.

federation.start() ⇒ Federation

Start tracking state (i.e., ready to receive events).

Kind: instance method of Federation
Returns: Federation - Instance of the Federation.

Filesystem

Interact with a local filesystem.

Kind: global class

new Filesystem([settings])

Synchronize an Actor with a local filesystem.

Returns: Filesystem - Instance of the Fabric filesystem.

Param Type Description
[settings] Object Configuration for the Fabric filesystem.
[settings.path] Object Path of the local filesystem.

filesystem.ls() ⇒ Array

Get the list of files.

Kind: instance method of Filesystem
Returns: Array - List of files.

filesystem.readFile(name) ⇒ Buffer

Read a file by name.

Kind: instance method of Filesystem
Returns: Buffer - Contents of the file.

Param Type Description
name String Name of the file to read.

filesystem.writeFile(name, content) ⇒ Boolean

Write a file by name.

Kind: instance method of Filesystem
Returns: Boolean - true if the write succeeded, false if it did not.

Param Type Description
name String Name of the file to write.
content Buffer Content of the file.

filesystem._loadFromDisk() ⇒ Promise

Load Filesystem state from disk.

Kind: instance method of Filesystem
Returns: Promise - Resolves with Filesystem instance.

filesystem.sync() ⇒ Filesystem

Syncronize state from the local filesystem.

Kind: instance method of Filesystem
Returns: Filesystem - Instance of the Fabric filesystem.

Hash256

Simple interaction with 256-bit spaces.

Kind: global class

new Hash256(settings)

Create an instance of a Hash256 object by calling new Hash256(), where settings can be provided to supply a particular input object.

If the settings is not a string, input must be provided.

Param Type Description
settings Object
settings.input String Input string to map as 256-bit hash.

Hash256.digest(input) ⇒ String

Produce a SHA256 digest of some input data.

Kind: static method of Hash256
Returns: String - SHA256(input) as a hexadecimal string.

Param Type Description
input String | Buffer Content to digest.

Hash256.reverse()

Reverses the bytes of the digest.

Kind: static method of Hash256

HKDF

Provides an HMAC-based Extract-and-Expand Key Derivation Function (HKDF), compatible with RFC 5869. Defaults to 32 byte output, matching Bitcoin's implementaton.

Kind: global class

new HKDF(settings)

Create an HKDF instance.

Param Type Default Description
settings Object List of settings.
settings.initial String Input keying material.
[settings.algorithm] String sha256 Name of the hashing algorithm to use.
[settings.salt] String Salt value (a non-secret random value).

hkdF.derive([info], [size])

Derive a new output.

Kind: instance method of HKDF

Param Type Default Description
[info] Buffer Context and application specific information.
[size] Number 32 Length of output.

Identity

Manage a network identity.

Kind: global class

new Identity([settings])

Create an instance of an Identity.

Returns: Identity - Instance of the identity.

Param Type Default Description
[settings] Object Settings for the Identity.
[settings.seed] String BIP 39 seed phrase.
[settings.xprv] String Serialized BIP 32 master private key.
[settings.xpub] String Serialized BIP 32 master public key.
[settings.account] Number 0 BIP 44 account index.
[settings.index] Number 0 BIP 44 key index.

identity.sign(data) ⇒ Signature

Sign a buffer of data using BIP 340: https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki

Kind: instance method of Identity
Returns: Signature - Resulting signature (64 bytes).

Param Type Description
data Buffer Buffer of data to sign.

identity.toString() ⇒ String

Retrieve the bech32m-encoded identity.

Kind: instance method of Identity
Returns: String - Public identity.

Interface ⇐ EventEmitter

Interfaces compile abstract contract code into Chain-executable transactions, or "chaincode". For example, the "Bitcoin" interface might compile a Swap contract into Script, preparing a valid Bitcoin transaction for broadcast which executes the swap contract.

Kind: global class
Extends: EventEmitter
Properties

Name Type Description
status String Human-friendly value representing the Interface's current State.

new Interface(settings)

Define an Interface by creating an instance of this class.

Returns: Interface - Instance of the Interface.

Param Type Description
settings Object Configuration values.

interface.log(...inputs)

Log some output to the console.

Kind: instance method of Interface

Param Type Description
...inputs any Components of the message to long. Can be a single {@link} String, many String objects, or anything else.

interface.now() ⇒ Number

Returns current timestamp.

Kind: instance method of Interface

interface.start()

Start the Interface.

Kind: instance method of Interface

interface.stop()

Stop the Interface.

Kind: instance method of Interface

interface.cycle(val)

Ticks the clock with a named Cycle.

Kind: instance method of Interface

Param Type Description
val String Name of cycle to scribe.

Key

Represents a cryptographic key.

Kind: global class

new Key([settings])

Create an instance of a Fabric Key, either restoring from some known values or from prior knowledge. For instance, you can call new Key() to create a fresh keypair, or new Key({ public: 'deadbeef...' }) to create it from a known public key.

Param Type Default Description
[settings] Object Initialization for the key.
[settings.network] String Network string.
[settings.seed] String Mnemonic seed for initializing the key.
[settings.public] String Public key in hex.
[settings.private] String Private key in hex.
[settings.purpose] String 44 Constrains derivations to this space.

Keystore

Provides an encrypted datastore for generic object storage.

Kind: global class

new Keystore([configuration])

Create an instance of the Store.

Returns: Keystore - Instance of the store.

Param Type Default Description
[configuration] FabricStoreConfiguration Settings to use.
[configuration.name] String "DefaultStore" Name of the Store.

keystore._setState(state) ⇒ Actor

Saves an Object to the store.

Kind: instance method of Keystore
Returns: Actor - The local instance of the provided State's Actor.

Param Type Description
state Object State to store.

Ledger ⇐ Scribe

An ordered stack of pages.

Kind: global class
Extends: Scribe
Properties

Name Type Description
memory Buffer The ledger's memory (4096 bytes).
stack Stack The ledger's stack.
tip Mixed The most recent page in the ledger.

ledger.append(item) ⇒ Promise

Attempts to append a Page to the ledger.

Kind: instance method of Ledger
Returns: Promise - Resolves after the change has been committed.

Param Type Description
item Mixed Item to store.

ledger.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Ledger
Overrides: now
Returns: Number - Number representation of the millisecond Integer value.

ledger.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Ledger
Overrides: trust
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

ledger.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Ledger
Overrides: inherits
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

ledger.toHTML()

Converts the State to an HTML document.

Kind: instance method of Ledger
Overrides: toHTML

ledger.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Ledger
Overrides: toString
Returns: String - Serialized Blob.

ledger.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Ledger
Overrides: serialize
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

ledger.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Ledger
Overrides: deserialize
Returns: State - [description]

Param Type Description
input String [description]

ledger.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Ledger
Overrides: fork

ledger.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Ledger
Overrides: get

Param Type Description
path Path Key to retrieve.

ledger.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Ledger
Overrides: set

Param Type Description
path Path Key to retrieve.

ledger.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Ledger
Overrides: commit

ledger.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Ledger
Overrides: render
Returns: String - JSON-encoded String.

Logger ⇐ Actor

A basic logger that writes logs to the local file system

Kind: global class
Extends: Actor

logger.path ⇒ String

Returns the path to the log file

Kind: instance property of Logger

logger.log(msg) ⇒ Boolean

Writes the specified log to the log file

Kind: instance method of Logger
Returns: Boolean - true, if msg was successfully written; false otherwise

Param Type Description
msg String | Object The message to log

logger.start() ⇒ Promise

Starts the logger

This method creates the required directories for writing the log file.

Kind: instance method of Logger

logger.stop() ⇒ Promise

Stops the logger

This method closes the log file and returns after it has been closed. Any errors on close would cause the return promise to be rejected.

Kind: instance method of Logger

logger.adopt(changes) ⇒ Actor

Explicitly adopt a set of JSONPatch-encoded changes.

Kind: instance method of Logger
Overrides: adopt
Returns: Actor - Instance of the Actor.

Param Type Description
changes Array List of JSONPatch operations to apply.

logger.commit() ⇒ String

Resolve the current state to a commitment.

Kind: instance method of Logger
Overrides: commit
Returns: String - 32-byte ID

logger.export() ⇒ Object

Export the Actor's state to a standard Object.

Kind: instance method of Logger
Overrides: export
Returns: Object - Standard object.

logger.get(path) ⇒ Object

Retrieve a value from the Actor's state by JSONPointer path.

Kind: instance method of Logger
Overrides: get
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to retrieve using JSONPointer.

logger.set(path, value) ⇒ Object

Set a value in the Actor's state by JSONPointer path.

Kind: instance method of Logger
Overrides: set
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to set using JSONPointer.
value Object Value to set.

logger.toBuffer() ⇒ Buffer

Casts the Actor to a normalized Buffer.

Kind: instance method of Logger
Overrides: toBuffer

logger.toGenericMessage() ⇒ Object

Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:

  • preimage: JSON.stringify(state)
  • hash: SHA256(preimage)
  • type: 'FabricActorState'
  • version: 1 (for now)
  • object: state
  • parent: null (for now)

Kind: instance method of Logger
Overrides: toGenericMessage
Returns: Object - Generic message object.
See

logger.toObject() ⇒ Object

Returns the Actor's current state as an Object.

Kind: instance method of Logger
Overrides: toObject

logger.pause() ⇒ Actor

Toggles status property to paused.

Kind: instance method of Logger
Overrides: pause
Returns: Actor - Instance of the Actor.

logger.serialize() ⇒ String

Serialize the Actor's current state into a JSON-formatted string.

Kind: instance method of Logger
Overrides: serialize

logger.sign() ⇒ Actor

Signs the Actor.

Kind: instance method of Logger
Overrides: sign

logger.unpause() ⇒ Actor

Toggles status property to unpaused.

Kind: instance method of Logger
Overrides: unpause
Returns: Actor - Instance of the Actor.

logger.value([format]) ⇒ Object

Get the inner value of the Actor with an optional cast type.

Kind: instance method of Logger
Overrides: value
Returns: Object - Inner value of the Actor as an Object, or cast to the requested format.

Param Type Default Description
[format] String object Cast the value to one of: buffer, hex, json, string

logger._readObject(input) ⇒ Object

Parse an Object into a corresponding Fabric state.

Kind: instance method of Logger
Overrides: _readObject
Returns: Object - Fabric state.

Param Type Description
input Object Object to read as input.

Machine

General-purpose state machine with Vector-based instructions.

Kind: global class

new Machine(settings)

Create a Machine.

Param Type Description
settings Object Run-time configuration.

machine.sip([n]) ⇒ Number

Get n bits of deterministic random data.

Kind: instance method of Machine
Returns: Number - Random bits from Generator.

Param Type Default Description
[n] Number 128 Number of bits to retrieve.

machine.slurp([n]) ⇒ Number

Get n bytes of deterministic random data.

Kind: instance method of Machine
Returns: Number - Random bytes from Generator.

Param Type Default Description
[n] Number 32 Number of bytes to retrieve.

machine.compute(input) ⇒ Machine

Computes the next "step" for our current Vector. Analagous to sum. The top item on the stack is always the memory held at current position, so counts should always begin with 0.

Kind: instance method of Machine
Returns: Machine - Instance of the resulting machine.

Param Type Description
input Object Value to pass as input.

Mempool

Stores a list of Transaction elements.

Kind: global class
Emits: event:{Message} confirmed Emitted when the Mempool has dropped a transaction.

new Mempool(settings)

Creates an instance of a Mempool Service.

Param Type Description
settings Object Map of settings to utilize.

Message : Object

The Message type defines the Application Messaging Protocol, or AMP. Each Actor in the network receives and broadcasts messages, selectively disclosing new routes to peers which may have open circuits.

Kind: global class

new Message(message)

The Message type is standardized in Fabric as a Array, which can be added to any other vector to compute a resulting state.

Returns: Message - Instance of the message.

Param Type Description
message Object Message vector. Will be serialized by Array#_serialize.

message.asRaw() ⇒ Buffer

Returns a Buffer of the complete message.

Kind: instance method of Message
Returns: Buffer - Buffer of the encoded Message.

message.sign() ⇒ Message

Signs the message using the associated signer.

Kind: instance method of Message
Returns: Message - Signed message.

message.verify() ⇒ Boolean

Verify a message's signature.

Kind: instance method of Message
Returns: Boolean - true if the signature is valid, false if not.

message._setSigner(signer) ⇒ Message

Sets the signer for the message.

Kind: instance method of Message
Returns: Message - Instance of the Message with associated signer.

Param Type Description
signer Signer Signer instance.

Node

Full definition of a Fabric node.

Kind: global class

new Node(settings)

Manage a Fabric service.

Returns: Node - Instance of the managed service.

Param Type Description
settings Object Configuration for the node.

node.trust(source, settings)

Explicitly trusts an EventEmitter.

Kind: instance method of Node

Param Type Description
source EventEmitter Actor to listen to.
settings Object | String Label for the trusted messages, or a configuration object.

Oracle ⇐ Store

An Oracle manages one or more collections, using a mempool for transitive state.

Kind: global class
Extends: Store

new Oracle(initial)

Trusted point-of-reference for external services.

Param Type Description
initial Object Initialization vector.

oracle.broadcast(msg) ⇒ Boolean

Core messaging function for interacting with this object in system-time.

Kind: instance method of Oracle
Returns: Boolean - Returns true on success, false on failure.

Param Type Description
msg Message Instance of a module:Message object, validated then transmitted verbatim.

oracle._REGISTER(obj) ⇒ Vector

Registers an Actor. Necessary to store in a collection.

Kind: instance method of Oracle
Overrides: _REGISTER
Returns: Vector - Returned from storage.set

Param Type Description
obj Object Instance of the object to store.

oracle._POST(key, value) ⇒ Promise

Insert something into a collection.

Kind: instance method of Oracle
Overrides: _POST
Returns: Promise - Resolves on success with a String pointer.

Param Type Description
key String Path to add data to.
value Mixed Object to store.

oracle.get(key) ⇒ Promise

Barebones getter.

Kind: instance method of Oracle
Overrides: get
Returns: Promise - Resolves on complete. null if not found.

Param Type Description
key String Name of data to retrieve.

oracle.set(key, value)

Set a key to a specific value.

Kind: instance method of Oracle
Overrides: set

Param Type Description
key String Address of the information.
value Mixed Content to store at key.

oracle.trust(source) ⇒ Store

Implicitly trust an Event source.

Kind: instance method of Oracle
Overrides: trust
Returns: Store - Resulting instance of Store with new trust.

Param Type Description
source EventEmitter Event-emitting source.

oracle.del(key)

Remove a Value by Path.

Kind: instance method of Oracle
Overrides: del

Param Type Description
key Path Key to remove.

oracle.flush()

Wipes the storage.

Kind: instance method of Oracle
Overrides: flush

oracle.start() ⇒ Promise

Start running the process.

Kind: instance method of Oracle
Overrides: start
Returns: Promise - Resolves on complete.

Path

A Path is a Fabric-native link to a Document within the network.

Kind: global class

new Path(input)

Create a new Path.

Param Type Description
input String | Object Named path.

path.isValid() ⇒ Boolean

Kind: instance method of Path
Returns: Boolean - Whether or not the Path is valid.

Peer

An in-memory representation of a node in our network.

Kind: global class

new Peer([config])

Create an instance of Peer.

Param Type Default Description
[config] Object Initialization Vector for this peer.
[config.listen] Boolean Whether or not to listen for connections.
[config.upnp] Boolean Whether or not to use UPNP for automatic configuration.
[config.port] Number 7777 Port to use for P2P connections.
[config.peers] Array [] List of initial peers.

peer.address

Deprecated

Kind: instance property of Peer

peer.broadcast(message)

Write a Buffer to all connected peers.

Kind: instance method of Peer

Param Type Description
message Buffer Message buffer to send.

peer._connect(target)

Open a Fabric connection to the target address and initiate the Fabric Protocol.

Kind: instance method of Peer

Param Type Description
target String Target address.

peer._fillPeerSlots() ⇒ Peer

Attempt to fill available connection slots with new peers.

Kind: instance method of Peer
Returns: Peer - Instance of the peer.

peer._handleFabricMessage(buffer) ⇒ Peer

Handle a Fabric Message buffer.

Kind: instance method of Peer
Returns: Peer - Instance of the Peer.

Param Type
buffer Buffer

peer.start()

Start the Peer.

Kind: instance method of Peer

peer.stop()

Stop the peer.

Kind: instance method of Peer

peer.listen() ⇒ Peer

Start listening for connections.

Kind: instance method of Peer
Returns: Peer - Chainable method.

Reader

Read from a byte stream, seeking valid Fabric messages.

Kind: global class

new Reader(settings)

Create an instance of a Reader, which can listen to a byte stream for valid Fabric messages.

Param Type Description
settings Object Settings for the stream.

Remote : Remote

Interact with a remote Resource. This is currently the only HTTP-related code that should remain in @fabric/core — all else must be moved to @fabric/http before final release!

Kind: global class
Properties

Name Type
config Object
secure Boolean

new Remote(target)

An in-memory representation of a node in our network.

Param Type Description
target Object Target object.
target.host String Named host, e.g. "localhost".
target.secure String Require TLS session.

remote.enumerate() ⇒ Configuration

Enumerate the available Resources on the remote host.

Kind: instance method of Remote
Returns: Configuration - An object with enumerable key/value pairs for the Application Resource Contract.

remote.request(type, path, [params]) ⇒ FabricHTTPResult

Make an HTTP request to the configured authority.

Kind: instance method of Remote

Param Type Description
type String One of GET, PUT, POST, DELETE, or OPTIONS.
path String The path to request from the authority.
[params] Object Options.

remote._PUT(path, body) ⇒ FabricHTTPResult | String

HTTP PUT against the configured Authority.

Kind: instance method of Remote
Returns: FabricHTTPResult | String - Result of request.

Param Type Description
path String HTTP Path to request.
body Object Map of parameters to supply.

remote._GET(path, params) ⇒ FabricHTTPResult | String

HTTP GET against the configured Authority.

Kind: instance method of Remote
Returns: FabricHTTPResult | String - Result of request.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._POST(path, params) ⇒ FabricHTTPResult | String

HTTP POST against the configured Authority.

Kind: instance method of Remote
Returns: FabricHTTPResult | String - Result of request.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._OPTIONS(path, params) ⇒ Object

HTTP OPTIONS on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

remote._PATCH(path, body) ⇒ Object

HTTP PATCH on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
body Object Map of parameters to supply.

remote._DELETE(path, params) ⇒ Object

HTTP DELETE on the configured Authority.

Kind: instance method of Remote
Returns: Object - - Full description of remote resource.

Param Type Description
path String HTTP Path to request.
params Object Map of parameters to supply.

Resource

Generic interface for collections of digital objects.

Kind: global class

new Resource(definition)

Param Type Description
definition Object Initial parameters

resource.create(obj) ⇒ Vector

Create an instance of the Resource's type.

Kind: instance method of Resource
Returns: Vector - Resulting Vector with deterministic identifier.

Param Type Description
obj Object Map of the instance's properties and values.

resource.update(id, update) ⇒ Vector

Modify an existing instance of a Resource by its unique identifier. Produces a new instance.

Kind: instance method of Resource
Returns: Vector - Resulting Vector instance with updated identifier.

Param Type Description
id String Unique ID to update.
update Object Map of change to make (keys -> values).

Router ⇐ Scribe

Process incoming messages.

Kind: global class
Extends: Scribe

new Router(map)

Maintains a list of triggers ("commands") and their behaviors.

Param Type Description
map Object Map of command names => behaviors.

router.route(msg) ⇒ Array

Assembles a list of possible responses to the incoming request.

Kind: instance method of Router
Returns: Array - List of outputs generated from the input string.

Param Type Description
msg String Input message to route.

router.use(plugin, name) ⇒ Router

Attaches a new handler to the router.

Kind: instance method of Router
Returns: Router - Configured instance of the router.

Param Type Description
plugin Plugin Instance of the plugin.
name Plugin.name Name of the plugin.

router.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Router
Overrides: now
Returns: Number - Number representation of the millisecond Integer value.

router.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Router
Overrides: trust
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

router.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Router
Overrides: inherits
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

router.toHTML()

Converts the State to an HTML document.

Kind: instance method of Router
Overrides: toHTML

router.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Router
Overrides: toString
Returns: String - Serialized Blob.

router.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Router
Overrides: serialize
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

router.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Router
Overrides: deserialize
Returns: State - [description]

Param Type Description
input String [description]

router.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Router
Overrides: fork

router.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Router
Overrides: get

Param Type Description
path Path Key to retrieve.

router.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Router
Overrides: set

Param Type Description
path Path Key to retrieve.

router.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Router
Overrides: commit

router.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Router
Overrides: render
Returns: String - JSON-encoded String.

Scribe ⇐ State

Simple tag-based recordkeeper.

Kind: global class
Extends: State
Properties

Name Type Description
config Object Current configuration.

new Scribe(config)

The "Scribe" is a simple tag-based recordkeeper.

Param Type Description
config Object General configuration object.
config.verbose Boolean Should the Scribe be noisy?

scribe.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Scribe
Returns: Number - Number representation of the millisecond Integer value.

scribe.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Scribe
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

scribe.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Scribe
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

scribe.toHTML()

Converts the State to an HTML document.

Kind: instance method of Scribe
Overrides: toHTML

scribe.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Scribe
Overrides: toString
Returns: String - Serialized Blob.

scribe.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Scribe
Overrides: serialize
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

scribe.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Scribe
Overrides: deserialize
Returns: State - [description]

Param Type Description
input String [description]

scribe.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Scribe
Overrides: fork

scribe.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Scribe
Overrides: get

Param Type Description
path Path Key to retrieve.

scribe.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Scribe
Overrides: set

Param Type Description
path Path Key to retrieve.

scribe.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Scribe
Overrides: commit

scribe.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Scribe
Overrides: render
Returns: String - JSON-encoded String.

Script

Kind: global class

new Script(config)

Compose a Script for inclusion within a Contract.

Returns: Script - Instance of the Script, ready for use.

Param Type Description
config Mixed Configuration options for the script.

Service

The "Service" is a simple model for processing messages in a distributed system. Service instances are public interfaces for outside systems, and typically advertise their presence to the network.

To implement a Service, you will typically need to implement all methods from this prototype. In general, connect and send are the highest-priority jobs, and by default the fabric property will serve as an I/O stream using familiar semantics.

Kind: global class
Access: protected
Properties

Name Description
map The "map" is a hashtable of "key" => "value" pairs.

new Service(settings)

Create an instance of a Service.

Param Type Default Description
settings Object Configuration for this service.
[settings.networking] Boolean true Whether or not to connect to the network.
[settings.@data] Object Internal data to assign.
[settings.frequency] Object Interval frequency in hertz.
[settings.state] Object Initial state to assign.

service.init()

Called by Web Components. TODO: move to @fabric/http/types/spa

Kind: instance method of Service

service.tick() ⇒ Number

Move forward one clock cycle.

Kind: instance method of Service

service.beat() ⇒ Service

Compute latest state.

Kind: instance method of Service
Emits: Message#event:beat

service.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Service
Returns: Mixed - Returns the target value if found, otherwise null.

Param Type Description
path Path Key to retrieve.

service.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Service

Param Type Description
path Path Key to retrieve.

service.trust(source) ⇒ Service

Explicitly trust all events from a known source.

Kind: instance method of Service
Returns: Service - Instance of Service after binding events.

Param Type Description
source EventEmitter Emitter of events.

service.handler(message) ⇒ Service

Default route handler for an incoming message. Follows the Activity Streams 2.0 spec: https://www.w3.org/TR/activitystreams-core/

Kind: instance method of Service
Returns: Service - Chainable method.

Param Type Description
message Activity Message object.

service.lock([duration]) ⇒ Boolean

Attempt to acquire a lock for duration seconds.

Kind: instance method of Service
Returns: Boolean - true if locked, false if unable to lock.

Param Type Default Description
[duration] Number 1000 Number of milliseconds to hold lock.

service.route(msg) ⇒ Promise

Resolve a State from a particular Message object.

Kind: instance method of Service
Returns: Promise - Resolves with resulting State.

Param Type Description
msg Message Explicit Fabric Message.

service.start()

Start the service, including the initiation of an outbound connection to any peers designated in the service's configuration.

Kind: instance method of Service

service._GET(path) ⇒ Promise

Retrieve a value from the Service's state.

Kind: instance method of Service
Returns: Promise - Resolves with the result.

Param Type Description
path String Path of the value to retrieve.

service._PUT(path, value, [commit]) ⇒ Promise

Store a value in the Service's state.

Kind: instance method of Service
Returns: Promise - Resolves with with stored document.

Param Type Default Description
path String Path to store the value at.
value Object Document to store.
[commit] Boolean false Sign the resulting state.

service.connect(notify) ⇒ Promise

Attach to network.

Kind: instance method of Service
Returns: Promise - Resolves to Fabric.

Param Type Default Description
notify Boolean true Commit to changes.

service.send(channel, message) ⇒ Service

Send a message to a channel.

Kind: instance method of Service
Returns: Service - Chainable method.

Param Type Description
channel String Channel name to which the message will be sent.
message String Content of the message to send.

service._registerActor(actor) ⇒ Promise

Register an Actor with the Service.

Kind: instance method of Service
Returns: Promise - Resolves upon successful registration.

Param Type Description
actor Object Instance of the Actor.

service._send(message)

Sends a message.

Kind: instance method of Service

Param Type Description
message Mixed Message to send.

Session

The Session type describes a connection between Peer objects, and includes its own lifecycle.

Kind: global class

new Session(settings)

Creates a new Session.

Param Type
settings Object

session.start()

Opens the Session for interaction.

Kind: instance method of Session

session.stop()

Closes the Session, preventing further interaction.

Kind: instance method of Session

Signer ⇐ Actor

Generic Fabric Signer.

Kind: global class
Extends: Actor
Emits: event:message Fabric {@link Message} objects.
Access: protected
Properties

Name Type Description
id String Unique identifier for this Signer (id === SHA256(preimage)).
preimage String Input hash for the id property (preimage === SHA256(SignerState)).

new Signer([actor])

Creates an Signer, which emits messages for other Signers to subscribe to. You can supply certain parameters for the actor, including key material [!!!] — be mindful of what you share with others!

Returns: Signer - Instance of the Signer. Call sign to emit a Signature.

Param Type Description
[actor] Object Object to use as the actor.
[actor.seed] String BIP24 Mnemonic to use as a seed phrase.
[actor.public] Buffer Public key.
[actor.private] Buffer Private key.

signer.sign() ⇒ Signer

Signs some data.

Kind: instance method of Signer
Overrides: sign

signer.adopt(changes) ⇒ Actor

Explicitly adopt a set of JSONPatch-encoded changes.

Kind: instance method of Signer
Overrides: adopt
Returns: Actor - Instance of the Actor.

Param Type Description
changes Array List of JSONPatch operations to apply.

signer.commit() ⇒ String

Resolve the current state to a commitment.

Kind: instance method of Signer
Overrides: commit
Returns: String - 32-byte ID

signer.export() ⇒ Object

Export the Actor's state to a standard Object.

Kind: instance method of Signer
Overrides: export
Returns: Object - Standard object.

signer.get(path) ⇒ Object

Retrieve a value from the Actor's state by JSONPointer path.

Kind: instance method of Signer
Overrides: get
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to retrieve using JSONPointer.

signer.set(path, value) ⇒ Object

Set a value in the Actor's state by JSONPointer path.

Kind: instance method of Signer
Overrides: set
Returns: Object - Value of the path in the Actor's state.

Param Type Description
path String Path to set using JSONPointer.
value Object Value to set.

signer.toBuffer() ⇒ Buffer

Casts the Actor to a normalized Buffer.

Kind: instance method of Signer
Overrides: toBuffer

signer.toGenericMessage() ⇒ Object

Casts the Actor to a generic message, used to uniquely identify the Actor's state. Fields:

  • preimage: JSON.stringify(state)
  • hash: SHA256(preimage)
  • type: 'FabricActorState'
  • version: 1 (for now)
  • object: state
  • parent: null (for now)

Kind: instance method of Signer
Overrides: toGenericMessage
Returns: Object - Generic message object.
See

signer.toObject() ⇒ Object

Returns the Actor's current state as an Object.

Kind: instance method of Signer
Overrides: toObject

signer.pause() ⇒ Actor

Toggles status property to paused.

Kind: instance method of Signer
Overrides: pause
Returns: Actor - Instance of the Actor.

signer.serialize() ⇒ String

Serialize the Actor's current state into a JSON-formatted string.

Kind: instance method of Signer
Overrides: serialize

signer.unpause() ⇒ Actor

Toggles status property to unpaused.

Kind: instance method of Signer
Overrides: unpause
Returns: Actor - Instance of the Actor.

signer.value([format]) ⇒ Object

Get the inner value of the Actor with an optional cast type.

Kind: instance method of Signer
Overrides: value
Returns: Object - Inner value of the Actor as an Object, or cast to the requested format.

Param Type Default Description
[format] String object Cast the value to one of: buffer, hex, json, string

signer._readObject(input) ⇒ Object

Parse an Object into a corresponding Fabric state.

Kind: instance method of Signer
Overrides: _readObject
Returns: Object - Fabric state.

Param Type Description
input Object Object to read as input.

Snapshot

A type of message to be expected from a Service.

Kind: global class

new Snapshot(settings)

Creates an instance of a Snapshot.

Param Type Description
settings Object Map of settings to configure the Snapshot with.

snapshot.commit()

Retrieves the sha256 fingerprint for the Snapshot state.

Kind: instance method of Snapshot

Stack

Manage stacks of data.

Kind: global class

new Stack([list])

Create a Stack instance.

Returns: Stack - Instance of the Stack.

Param Type Default Description
[list] Array [] Genesis state for the Stack instance.

stack.push(data) ⇒ Number

Push data onto the stack. Changes the Stack#frame and Stack#id.

Kind: instance method of Stack
Returns: Number - Resulting size of the stack.

Param Type Description
data Mixed Treated as a State.

State ⇐ EventEmitter

The State is the core of most User-facing interactions. To interact with the User, simply propose a change in the state by committing to the outcome. This workflow keeps app design quite simple!

Kind: global class
Extends: EventEmitter
Access: protected
Properties

Name Type Description
size Number Size of state in bytes.
@buffer Buffer Byte-for-byte memory representation of state.
@type String Named type.
@data Mixed Local instance of the state.
@id String Unique identifier for this data.

new State(data)

Creates a snapshot of some information.

Returns: State - Resulting state.

Param Type Description
data Mixed Input data.

state.toHTML()

Converts the State to an HTML document.

Kind: instance method of State

state.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of State
Returns: String - Serialized Blob.

state.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of State
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

state.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of State
Returns: State - [description]

Param Type Description
input String [description]

state.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of State

state.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of State

Param Type Description
path Path Key to retrieve.

state.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of State

Param Type Description
path Path Key to retrieve.

state.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of State

state.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of State
Returns: String - JSON-encoded String.

State.fromJSON(input) ⇒ State

Marshall an input into an instance of a State. States have absolute authority over their own domain, so choose your States wisely.

Kind: static method of State
Returns: State - Resulting instance of the State.

Param Type Description
input String Arbitrary input.

Store

Long-term storage.

Kind: global class
Properties

Name Type Description
settings Mixed Current configuration.

new Store([settings])

Create an instance of a Store to manage long-term storage, which is particularly useful when building a user-facing Product.

Returns: Store - Instance of the Store, ready to start.

Param Type Default Description
[settings] Object {} configuration object.

store._REGISTER(obj) ⇒ Vector

Registers an Actor. Necessary to store in a collection.

Kind: instance method of Store
Returns: Vector - Returned from storage.set

Param Type Description
obj Object Instance of the object to store.

store._POST(key, value) ⇒ Promise

Insert something into a collection.

Kind: instance method of Store
Returns: Promise - Resolves on success with a String pointer.

Param Type Description
key String Path to add data to.
value Mixed Object to store.

store.get(key) ⇒ Promise

Barebones getter.

Kind: instance method of Store
Returns: Promise - Resolves on complete. null if not found.

Param Type Description
key String Name of data to retrieve.

store.set(key, value)

Set a key to a specific value.

Kind: instance method of Store

Param Type Description
key String Address of the information.
value Mixed Content to store at key.

store.trust(source) ⇒ Store

Implicitly trust an Event source.

Kind: instance method of Store
Returns: Store - Resulting instance of Store with new trust.

Param Type Description
source EventEmitter Event-emitting source.

store.del(key)

Remove a Value by Path.

Kind: instance method of Store

Param Type Description
key Path Key to remove.

store.flush()

Wipes the storage.

Kind: instance method of Store

store.start() ⇒ Promise

Start running the process.

Kind: instance method of Store
Returns: Promise - Resolves on complete.

Swap : Object

The Swap contract executes a set of transactions on two distinct Chain components, utilizing a secret-reveal mechanism to atomically execute either the full set or none.

Kind: global class

new Swap([settings])

Atomically execute a set of transactions across two Chain components.

Param Type Default Description
[settings] Object {} Configuration for the swap.

swap.extractSecret(tx, address) ⇒ Mixed

Find an input from the provided transaction which spends from the target P2SH address.

Kind: instance method of Swap
Returns: Mixed - False on failure, secret value on success.

Param Type Description
tx Transaction Transaction to iterate over.
address String P2SH address to search for.

Swarm : String

Orchestrates a network of peers.

Kind: global class

new Swarm(config)

Create an instance of a Swarm.

Returns: Swarm - Instance of the Swarm.

Param Type Description
config Object Configuration object.

swarm.trust(source)

Explicitly trust an EventEmitter to provide messages using the expected Interface, providing Message objects as the expected Type.

Kind: instance method of Swarm

Param Type Description
source EventEmitter Actor to utilize.

swarm.start() ⇒ Promise

Begin computing.

Kind: instance method of Swarm
Returns: Promise - Resolves to instance of Swarm.

Token

Implements a capability-based security token.

Kind: global class

new Token([settings])

Create a new Fabric Token.

Returns: Token - The token instance.

Param Type Description
[settings] Object Configuration.

Transition

The Transition type reflects a change from one finite State to another.

Kind: global class

new Transition(settings)

Param Type Description
settings Object Configuration for the transition object.

Tree

Class implementing a Merkle Tree.

Kind: global class

new Tree([settings])

Create an instance of a Tree.

Returns: Tree - Instance of the tree.

Param Type Description
[settings] Object Configuration.

tree.addLeaf(leaf) ⇒ Tree

Add a leaf to the tree.

Kind: instance method of Tree
Returns: Tree - Instance of the tree.

Param Type Description
leaf String Leaf to add to the tree.

tree.getLeaves() ⇒ Array

Get a list of the Tree's leaves.

Kind: instance method of Tree
Returns: Array - A list of the Tree's leaves.

Value

Number-like type.

Kind: global class

new Value(data)

Use the Value type to interact with Number-like objects.

Param Type Description
data Mixed Input value.

value.value(input)

Compute the numeric representation of this input.

Kind: instance method of Value

Param Type Description
input String Input string to seek for value.

Vector

Kind: global class

new Vector(origin)

An "Initialization" Vector.

Param Type Description
origin Object Input state (will map to @data.)

vector._serialize(input) ⇒ String

_serialize is a placeholder, should be discussed.

Kind: instance method of Vector
Returns: String - - resulting string [JSON-encoded version of the local @data value.]

Param Type Description
input String What to serialize. Defaults to this.state.

vector.toString(input) ⇒ String

Render the output to a String.

Kind: instance method of Vector

Param Type Description
input Mixed Arbitrary input.

Walker

Kind: global class

new Walker(init)

The Walker explores a directory tree and maps it to memory.

Param Type Description
init Vector Initial state tree.

walker._explore(path, [map]) ⇒ Object

Explores a directory tree on the local system's disk.

Kind: instance method of Walker
Returns: Object - [description]

Param Type Default Description
path String [description]
[map] Object {} [description]

walker._define(dir, [map]) ⇒ Object

Explores a directory tree on the local system's disk.

Kind: instance method of Walker
Returns: Object - A hashmap of directory contents.

Param Type Default Description
dir String Path to crawl on local disk.
[map] Object {} Pointer to previous step in stack.

Wallet : Object

Manage keys and track their balances.

Kind: global class
Properties

Name Type Description
id String Unique identifier for this Wallet.

new Wallet([settings])

Create an instance of a Wallet.

Returns: Wallet - Instance of the wallet.

Param Type Default Description
[settings] Object {} Configure the wallet.
[settings.verbosity] Number 2 One of: 0 (none), 1 (error), 2 (warning), 3 (notice), 4 (debug), 5 (audit)
[settings.key] Object Key to restore from.
[settings.key.seed] String Mnemonic seed for a restored wallet.

wallet.loadKey(keypair) ⇒ Wallet

Import a key to the wallet.

Kind: instance method of Wallet
Returns: Wallet - Instance of the Wallet.

Param Type Description
keypair Object Keypair.
keypair.public Buffer Public key.
[keypair.private] Buffer Private key.

wallet.start()

Start the wallet, including listening for transactions.

Kind: instance method of Wallet

wallet._load(settings)

Initialize the wallet, including keys and addresses.

Kind: instance method of Wallet

Param Type Description
settings Object Settings to load.

wallet.getAddressForScript(script)

Returns a bech32 address for the provided Script.

Kind: instance method of Wallet

Param Type
script Script

wallet.getAddressFromRedeemScript(redeemScript)

Generate a BitcoinAddress for the supplied BitcoinScript.

Kind: instance method of Wallet

Param Type
redeemScript BitcoinScript

wallet.createPricedOrder(order)

Create a priced order.

Kind: instance method of Wallet

Param Type
order Object
order.asset Object
order.amount Object

wallet._sign(tx)

Signs a transaction with the keyring.

Kind: instance method of Wallet

Param Type
tx BcoinTX

wallet._createCrowdfund(fund)

Create a crowdfunding transaction.

Kind: instance method of Wallet

Param Type
fund Object

wallet._getSwapInputScript(redeemScript, secret)

Generate Script for claiming a Swap.

Kind: instance method of Wallet

Param Type
redeemScript *
secret *

wallet._getRefundInputScript(redeemScript)

Generate Script for reclaiming funds commited to a Swap.

Kind: instance method of Wallet

Param Type
redeemScript *

wallet.publicKeyFromString(input)

Create a public key from a string.

Kind: instance method of Wallet

Param Type Description
input String Hex-encoded string to create key from.

Wallet.createSeed(passphrase) ⇒ FabricSeed

Create a new seed phrase.

Kind: static method of Wallet
Returns: FabricSeed - The seed object.

Param Type Description
passphrase String BIP 39 passphrase for key derivation.

Wallet.fromSeed(seed) ⇒ Wallet

Create a new Wallet from a seed object.

Kind: static method of Wallet
Returns: Wallet - Instance of the wallet.

Param Type Description
seed FabricSeed Fabric seed.

Worker

Workers are arbitrary containers for processing data. They can be thought of almost like "threads", as they run asynchronously over the duration of a contract's lifetime as "fulfillment conditions" for its closure.

Kind: global class

new Worker(method)

Param Type Description
method function Pure function.

worker.compute(input) ⇒ String

Handle a task.

Kind: instance method of Worker
Returns: String - Outcome of the requested job.

Param Type Description
input Vector Input vector.

Bitcoin ⇐ Service

Manages interaction with the Bitcoin network.

Kind: global class
Extends: Service

new Bitcoin([settings])

Creates an instance of the Bitcoin service.

Param Type Description
[settings] Object Map of configuration options for the Bitcoin service.
[settings.network] String One of regtest, testnet, or mainnet.
[settings.nodes] Array List of address:port pairs to trust.
[settings.seeds] Array Bitcoin peers to request chain from (address:port).
[settings.fullnode] Boolean Run a full node.

bitcoin.UAString

User Agent string for the Bitcoin P2P network.

Kind: instance property of Bitcoin

bitcoin.tip

Chain tip (block hash of the chain with the most Proof of Work)

Kind: instance property of Bitcoin

bitcoin.height

Chain height (=== length - 1)

Kind: instance property of Bitcoin

bitcoin.broadcast(tx)

Broadcast a transaction to the Bitcoin network.

Kind: instance method of Bitcoin
Unstable:

Param Type Description
tx TX Bitcoin transaction

bitcoin._processSpendMessage(message) ⇒ BitcoinTransactionID

Process a spend message.

Kind: instance method of Bitcoin
Returns: BitcoinTransactionID - Hex-encoded representation of the transaction ID.

Param Type Description
message SpendMessage Generic-level message for spending.
message.amount String Amount (in BTC) to spend.
message.destination String Destination for funds.

bitcoin._prepareTransaction(obj)

Prepares a Transaction for storage.

Kind: instance method of Bitcoin

Param Type Description
obj Transaction Transaction to prepare.

bitcoin._handleCommittedBlock(block)

Receive a committed block.

Kind: instance method of Bitcoin

Param Type Description
block Block Block to handle.

bitcoin._handlePeerPacket(msg)

Process a message from a peer in the Bitcoin network.

Kind: instance method of Bitcoin

Param Type Description
msg PeerPacket Message from peer.

bitcoin._handleBlockFromSPV(msg)

Hand a Block message as supplied by an SPV client.

Kind: instance method of Bitcoin

Param Type Description
msg BlockMessage A Message as passed by the SPV source.

bitcoin._handleTransactionFromSPV(tx)

Verify and interpret a BitcoinTransaction, as received from an SPVSource.

Kind: instance method of Bitcoin

Param Type Description
tx BitcoinTransaction Incoming transaction from the SPV source.

bitcoin._subscribeToShard(shard)

Attach event handlers for a supplied list of addresses.

Kind: instance method of Bitcoin

Param Type Description
shard Shard List of addresses to monitor.

bitcoin._connectSPV()

Initiate outbound connections to configured SPV nodes.

Kind: instance method of Bitcoin

bitcoin.connect(addr)

Connect to a Fabric Peer.

Kind: instance method of Bitcoin
Overrides: connect

Param Type Description
addr String Address to connect to.

bitcoin._requestBlockAtHeight(height) ⇒ Object

Retrieve the equivalent to getblockhash from Bitcoin Core.

Kind: instance method of Bitcoin
Returns: Object - The block hash.

Param Type Description
height Number Height of block to retrieve.

bitcoin._createContractProposal(options) ⇒ ContractProposal

Creates an unsigned Bitcoin transaction.

Kind: instance method of Bitcoin
Returns: ContractProposal - Instance of the proposal.

Param Type
options Object

bitcoin._buildPSBT(options) ⇒ PSBT

Create a Partially-Signed Bitcoin Transaction (PSBT).

Kind: instance method of Bitcoin
Returns: PSBT - Instance of the PSBT.

Param Type Description
options Object Parameters for the PSBT.

bitcoin.start()

Start the Bitcoin service, including the initiation of outbound requests.

Kind: instance method of Bitcoin
Overrides: start

bitcoin.stop()

Stop the Bitcoin service.

Kind: instance method of Bitcoin

bitcoin.init()

Called by Web Components. TODO: move to @fabric/http/types/spa

Kind: instance method of Bitcoin
Overrides: init

bitcoin.tick() ⇒ Number

Move forward one clock cycle.

Kind: instance method of Bitcoin
Overrides: tick

bitcoin.beat() ⇒ Service

Compute latest state.

Kind: instance method of Bitcoin
Overrides: beat
Emits: Message#event:beat

bitcoin.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Bitcoin
Overrides: get
Returns: Mixed - Returns the target value if found, otherwise null.

Param Type Description
path Path Key to retrieve.

bitcoin.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Bitcoin
Overrides: set

Param Type Description
path Path Key to retrieve.

bitcoin.trust(source) ⇒ Service

Explicitly trust all events from a known source.

Kind: instance method of Bitcoin
Overrides: trust
Returns: Service - Instance of Service after binding events.

Param Type Description
source EventEmitter Emitter of events.

bitcoin.handler(message) ⇒ Service

Default route handler for an incoming message. Follows the Activity Streams 2.0 spec: https://www.w3.org/TR/activitystreams-core/

Kind: instance method of Bitcoin
Overrides: handler
Returns: Service - Chainable method.

Param Type Description
message Activity Message object.

bitcoin.lock([duration]) ⇒ Boolean

Attempt to acquire a lock for duration seconds.

Kind: instance method of Bitcoin
Overrides: lock
Returns: Boolean - true if locked, false if unable to lock.

Param Type Default Description
[duration] Number 1000 Number of milliseconds to hold lock.

bitcoin.route(msg) ⇒ Promise

Resolve a State from a particular Message object.

Kind: instance method of Bitcoin
Overrides: route
Returns: Promise - Resolves with resulting State.

Param Type Description
msg Message Explicit Fabric Message.

bitcoin._GET(path) ⇒ Promise

Retrieve a value from the Service's state.

Kind: instance method of Bitcoin
Overrides: _GET
Returns: Promise - Resolves with the result.

Param Type Description
path String Path of the value to retrieve.

bitcoin._PUT(path, value, [commit]) ⇒ Promise

Store a value in the Service's state.

Kind: instance method of Bitcoin
Overrides: _PUT
Returns: Promise - Resolves with with stored document.

Param Type Default Description
path String Path to store the value at.
value Object Document to store.
[commit] Boolean false Sign the resulting state.

bitcoin.send(channel, message) ⇒ Service

Send a message to a channel.

Kind: instance method of Bitcoin
Overrides: send
Returns: Service - Chainable method.

Param Type Description
channel String Channel name to which the message will be sent.
message String Content of the message to send.

bitcoin._registerActor(actor) ⇒ Promise

Register an Actor with the Service.

Kind: instance method of Bitcoin
Overrides: _registerActor
Returns: Promise - Resolves upon successful registration.

Param Type Description
actor Object Instance of the Actor.

bitcoin._send(message)

Sends a message.

Kind: instance method of Bitcoin
Overrides: _send

Param Type Description
message Mixed Message to send.

Exchange

Implements a basic Exchange.

Kind: global class

new Exchange(settings)

Create an instance of the Exchange. You may run two instances at once to simulate two-party contracts, or use the Fabric Market to find and trade with real peers.

Returns: Exchnge

Param Type Description
settings Object Map of settings to values.
settings.fees Object Map of fee settings (all values in BTC).
settings.fees.minimum Object Minimum fee (satoshis).

Lightning

Manage a Lightning node.

Kind: global class

new Lightning([settings])

Create an instance of the Lightning Service.

Param Type Description
[settings] Object Settings.

lightning._makeRPCRequest(method, [params]) ⇒ Object | String

Make an RPC request through the Lightning UNIX socket.

Kind: instance method of Lightning
Returns: Object | String - Respond from the Lightning node.

Param Type Description
method String Name of method to call.
[params] Array Array of parameters.

Redis

Connect and subscribe to ZeroMQ servers.

Kind: global class

new Redis([settings])

Creates an instance of a ZeroMQ subscriber.

Returns: Redis - Instance of the Redis service, ready to run start()

Param Type Description
[settings] Object Settings for the Redis connection.
[settings.host] String Host for the Redis server.
[settings.port] Number Remote ZeroMQ service port.

redis.start() ⇒ Redis

Opens the connection and subscribes to the requested channels.

Kind: instance method of Redis
Returns: Redis - Instance of the service.

redis.stop() ⇒ Redis

Closes the connection to the Redis server.

Kind: instance method of Redis
Returns: Redis - Instance of the service.

ZMQ

Connect and subscribe to ZeroMQ publishers.

Kind: global class

new ZMQ([settings])

Creates an instance of a ZeroMQ subscriber.

Returns: ZMQ - Instance of the ZMQ service, ready to run start()

Param Type Description
[settings] Object Settings for the ZMQ connection.
[settings.host] String Host for the ZMQ publisher.
[settings.port] Number Remote ZeroMQ service port.

zmQ.start() ⇒ ZMQ

Opens the connection and subscribes to the requested channels.

Kind: instance method of ZMQ
Returns: ZMQ - Instance of the service.

zmQ.stop() ⇒ ZMQ

Closes the connection to the ZMQ publisher.

Kind: instance method of ZMQ
Returns: ZMQ - Instance of the service.

HTTPServer

Deprecated

Deprecated 2021-10-16.

Kind: global class

Scribe

Deprecated

Deprecated 2021-11-06.

Kind: global class

new Scribe(config)

The "Scribe" is a simple tag-based recordkeeper.

Param Type Description
config Object General configuration object.
config.verbose Boolean Should the Scribe be noisy?

scribe.now() ⇒ Number

Retrives the current timestamp, in milliseconds.

Kind: instance method of Scribe
Returns: Number - Number representation of the millisecond Integer value.

scribe.trust(source) ⇒ Scribe

Blindly bind event handlers to the Source.

Kind: instance method of Scribe
Returns: Scribe - Instance of the Scribe.

Param Type Description
source Source Event stream.

scribe.inherits(scribe) ⇒ Scribe

Use an existing Scribe instance as a parent.

Kind: instance method of Scribe
Returns: Scribe - The configured instance of the Scribe.

Param Type Description
scribe Scribe Instance of Scribe to use as parent.

scribe.toHTML()

Converts the State to an HTML document.

Kind: instance method of Scribe
Overrides: toHTML

scribe.toString() ⇒ String

Unmarshall an existing state to an instance of a Blob.

Kind: instance method of Scribe
Overrides: toString
Returns: String - Serialized Blob.

scribe.serialize([input]) ⇒ Buffer

Convert to Buffer.

Kind: instance method of Scribe
Overrides: serialize
Returns: Buffer - Store-able blob.

Param Type Description
[input] Mixed Input to serialize.

scribe.deserialize(input) ⇒ State

Take a hex-encoded input and convert to a State object.

Kind: instance method of Scribe
Overrides: deserialize
Returns: State - [description]

Param Type Description
input String [description]

scribe.fork() ⇒ State

Creates a new child State, with @parent set to the current State by immutable identifier.

Kind: instance method of Scribe
Overrides: fork

scribe.get(path) ⇒ Mixed

Retrieve a key from the State.

Kind: instance method of Scribe
Overrides: get

Param Type Description
path Path Key to retrieve.

scribe.set(path) ⇒ Mixed

Set a key in the State to a particular value.

Kind: instance method of Scribe
Overrides: set

Param Type Description
path Path Key to retrieve.

scribe.commit()

Increment the vector clock, broadcast all changes as a transaction.

Kind: instance method of Scribe
Overrides: commit

scribe.render() ⇒ String

Compose a JSON string for network consumption.

Kind: instance method of Scribe
Overrides: render
Returns: String - JSON-encoded String.

Stash

Deprecated

Deprecated 2021-11-06.

Kind: global class