1
0
mirror of https://github.com/bigchaindb/js-bigchaindb-driver.git synced 2024-11-22 09:46:58 +01:00
js-bigchaindb-driver/API.md

15 KiB

Table of Contents

Ed25519Keypair

src/Ed25519Keypair.js:16-21

Type: Object

Parameters

  • seed Buffer? A seed that will be used as a key derivation function

Properties

Connection

src/connection.js:21-201

Parameters

  • nodes
  • headers Object Common headers for every request (optional, default {})
  • timeout float Optional timeout in secs (optional, default DEFAULT_TIMEOUT)

getBlock

src/connection.js:79-85

Parameters

  • blockHeight

getTransaction

src/connection.js:90-96

Parameters

  • transactionId

listBlocks

src/connection.js:102-108

Parameters

  • transactionId
  • status

listOutputs

src/connection.js:114-126

Parameters

  • publicKey
  • spent

listTransactions

src/connection.js:132-139

Parameters

  • assetId
  • operation

postTransaction

src/connection.js:144-146

Parameters

  • transaction

postTransactionSync

src/connection.js:151-156

Parameters

  • transaction

postTransactionAsync

src/connection.js:162-167

Parameters

  • transaction

postTransactionCommit

src/connection.js:173-178

Parameters

  • transaction

searchAssets

src/connection.js:183-189

Parameters

  • search

searchMetadata

src/connection.js:194-200

Parameters

  • search

Transaction

src/transaction.js:16-280

Construct Transactions

serializeTransactionIntoCanonicalString

src/transaction.js:22-29

Canonically serializes a transaction into a string by sorting the keys

Parameters

  • transaction
  • null Object (transaction)

Returns string a canonically serialized Transaction

makeCreateTransaction

src/transaction.js:80-87

Generate a CREATE transaction holding the asset, metadata, and outputs, to be signed by the issuers.

Parameters

  • asset Object Created asset's data
  • metadata Object Metadata for the Transaction
  • outputs Array<Object> Array of Output objects to add to the Transaction. Think of these as the recipients of the asset after the transaction. For CREATE Transactions, this should usually just be a list of Outputs wrapping Ed25519 Conditions generated from the issuers' public keys (so that the issuers are the recipients of the created asset).
  • issuers ...Array<string> Public key of one or more issuers to the asset being created by this Transaction. Note: Each of the private keys corresponding to the given public keys MUST be used later (and in the same order) when signing the Transaction (signTransaction()).

Returns Object Unsigned transaction -- make sure to call signTransaction() on it before sending it off!

makeEd25519Condition

src/transaction.js:96-107

Create an Ed25519 Cryptocondition from an Ed25519 public key to put into an Output of a Transaction

Parameters

  • publicKey string base58 encoded Ed25519 public key for the recipient of the Transaction
  • json boolean If true returns a json object otherwise a crypto-condition type (optional, default true)

Returns Object Ed25519 Condition (that will need to wrapped in an Output)

makeOutput

src/transaction.js:117-137

Create an Output from a Condition. Note: Assumes the given Condition was generated from a single public key (e.g. a Ed25519 Condition)

Parameters

  • condition Object Condition (e.g. a Ed25519 Condition from makeEd25519Condition())
  • amount string Amount of the output (optional, default '1')

Returns Object An Output usable in a Transaction

makeSha256Condition

src/transaction.js:145-153

Create a Preimage-Sha256 Cryptocondition from a secret to put into an Output of a Transaction

Parameters

  • preimage string Preimage to be hashed and wrapped in a crypto-condition
  • json boolean If true returns a json object otherwise a crypto-condition type (optional, default true)

Returns Object Preimage-Sha256 Condition (that will need to wrapped in an Output)

makeThresholdCondition

src/transaction.js:162-176

Create an Sha256 Threshold Cryptocondition from threshold to put into an Output of a Transaction

Parameters

  • threshold number
  • subconditions Array (optional, default [])
  • json boolean If true returns a json object otherwise a crypto-condition type (optional, default true)

Returns Object Sha256 Threshold Condition (that will need to wrapped in an Output)

makeTransferTransaction

src/transaction.js:199-220

Generate a TRANSFER transaction holding the asset, metadata, and outputs, that fulfills the fulfilledOutputs of unspentTransaction.

Parameters

  • unspentOutputs
  • outputs Array<Object> Array of Output objects to add to the Transaction. Think of these as the recipients of the asset after the transaction. For TRANSFER Transactions, this should usually just be a list of Outputs wrapping Ed25519 Conditions generated from the public keys of the recipients.
  • metadata Object Metadata for the Transaction
  • unspentTransaction Object Previous Transaction you have control over (i.e. can fulfill its Output Condition)
  • OutputIndices ...number Indices of the Outputs in unspentTransaction that this Transaction fulfills. Note that listed public keys listed must be used (and in the same order) to sign the Transaction (signTransaction()).

Returns Object Unsigned transaction -- make sure to call signTransaction() on it before sending it off!

signTransaction

src/transaction.js:233-257

Sign the given transaction with the given privateKeys, returning a new copy of transaction that's been signed. Note: Only generates Ed25519 Fulfillments. Thresholds and other types of Fulfillments are left as an exercise for the user.

Parameters

  • transaction Object Transaction to sign. transaction is not modified.
  • privateKeys ...string Private keys associated with the issuers of the transaction. Looped through to iteratively sign any Input Fulfillments found in the transaction.

Returns Object The signed version of transaction.

delegateSignTransaction

src/transaction.js:266-279

Delegate signing of the given transaction returning a new copy of transaction that's been signed.

Parameters

  • transaction Object Transaction to sign. transaction is not modified.
  • signFn Function Function signing the transaction, expected to return the fulfillment.

Returns Object The signed version of transaction.

ccJsonLoad

src/utils/ccJsonLoad.js:14-44

Loads a crypto-condition class (Fulfillment or Condition) from a BigchainDB JSON object

Parameters

Returns cc.Condition Ed25519 Condition (that will need to wrapped in an Output)

ccJsonify

src/utils/ccJsonify.js:12-65

Serializes a crypto-condition class (Condition or Fulfillment) into a BigchainDB-compatible JSON

Parameters

  • fulfillment cc.Fulfillment base58 encoded Ed25519 public key for recipient of the Transaction

Returns Object Ed25519 Condition (that will need to wrapped in an Output)