mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 01:36:56 +01:00
driver docs
This commit is contained in:
parent
a7e7386bb1
commit
602e9200ee
227
API.md
Normal file
227
API.md
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||||
|
|
||||||
|
### Table of Contents
|
||||||
|
|
||||||
|
- [Ed25519Keypair](#ed25519keypair)
|
||||||
|
- [makeEd25519Condition](#makeed25519condition)
|
||||||
|
- [makeSha256Condition](#makesha256condition)
|
||||||
|
- [makeThresholdCondition](#makethresholdcondition)
|
||||||
|
- [makeCreateTransaction](#makecreatetransaction)
|
||||||
|
- [makeOutput](#makeoutput)
|
||||||
|
- [makeTransferTransaction](#maketransfertransaction)
|
||||||
|
- [serializeTransactionIntoCanonicalString](#serializetransactionintocanonicalstring)
|
||||||
|
- [signTransaction](#signtransaction)
|
||||||
|
- [ccJsonLoad](#ccjsonload)
|
||||||
|
- [ccJsonify](#ccjsonify)
|
||||||
|
- [getBlock](#getblock)
|
||||||
|
- [getTransaction](#gettransaction)
|
||||||
|
- [getStatus](#getstatus)
|
||||||
|
- [listBlocks](#listblocks)
|
||||||
|
- [listOutputs](#listoutputs)
|
||||||
|
- [listTransactions](#listtransactions)
|
||||||
|
- [listVotes](#listvotes)
|
||||||
|
- [pollStatusAndFetchTransaction](#pollstatusandfetchtransaction)
|
||||||
|
- [postTransaction](#posttransaction)
|
||||||
|
|
||||||
|
## Ed25519Keypair
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `secret` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** A seed that will be used as a key derivation function
|
||||||
|
|
||||||
|
**Properties**
|
||||||
|
|
||||||
|
- `publicKey` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
||||||
|
- `privateKey` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
||||||
|
|
||||||
|
## makeEd25519Condition
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `publicKey` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** base58 encoded Ed25519 public key for the recipient of the Transaction
|
||||||
|
- `json` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true returns a json object otherwise a crypto-condition type (optional, default `true`)
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
|
|
||||||
|
## makeSha256Condition
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `preimage` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Preimage to be hashed and wrapped in a crypto-condition
|
||||||
|
- `json` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true returns a json object otherwise a crypto-condition type (optional, default `true`)
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Preimage-Sha256 Condition (that will need to wrapped in an Output)
|
||||||
|
|
||||||
|
## makeThresholdCondition
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `threshold` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
||||||
|
- `subconditions` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** (optional, default `[]`)
|
||||||
|
- `json` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true returns a json object otherwise a crypto-condition type (optional, default `true`)
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Sha256 Threshold Condition (that will need to wrapped in an Output)
|
||||||
|
|
||||||
|
## makeCreateTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `asset` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Created asset's data
|
||||||
|
- `metadata` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Metadata for the Transaction
|
||||||
|
- `outputs` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Unsigned transaction -- make sure to call signTransaction() on it before
|
||||||
|
sending it off!
|
||||||
|
|
||||||
|
## makeOutput
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `condition` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Condition (e.g. a Ed25519 Condition from `makeEd25519Condition()`)
|
||||||
|
- `amount` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Amount of the output (optional, default `1`)
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** An Output usable in a Transaction
|
||||||
|
|
||||||
|
## makeTransferTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `unspentTransaction` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Previous Transaction you have control over (i.e. can fulfill
|
||||||
|
its Output Condition)
|
||||||
|
- `metadata` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Metadata for the Transaction
|
||||||
|
- `outputs` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/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.
|
||||||
|
- `fulfilledOutputs` **...[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** Indices of the Outputs in `unspentTransaction` that this
|
||||||
|
Transaction fulfills.
|
||||||
|
Note that the public keys listed in the fulfilled Outputs
|
||||||
|
must be used (and in the same order) to sign the Transaction
|
||||||
|
(`signTransaction()`).
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Unsigned transaction -- make sure to call signTransaction() on it before
|
||||||
|
sending it off!
|
||||||
|
|
||||||
|
## serializeTransactionIntoCanonicalString
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `transaction`
|
||||||
|
- `null` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** (transaction)
|
||||||
|
|
||||||
|
Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** a canonically serialized Transaction
|
||||||
|
|
||||||
|
## signTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `transaction` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Transaction to sign. `transaction` is not modified.
|
||||||
|
- `privateKeys` **...[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Private keys associated with the issuers of the `transaction`.
|
||||||
|
Looped through to iteratively sign any Input Fulfillments found in
|
||||||
|
the `transaction`.
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The signed version of `transaction`.
|
||||||
|
|
||||||
|
## ccJsonLoad
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `conditionJson` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||||
|
|
||||||
|
Returns **cc.Condition** Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
|
|
||||||
|
## ccJsonify
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `fulfillment` **cc.Fulfillment** base58 encoded Ed25519 public key for the recipient of the Transaction
|
||||||
|
|
||||||
|
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
|
|
||||||
|
## getBlock
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `blockId`
|
||||||
|
- `API_PATH`
|
||||||
|
|
||||||
|
## getTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `txId`
|
||||||
|
- `API_PATH`
|
||||||
|
|
||||||
|
## getStatus
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `tx_id`
|
||||||
|
- `API_PATH`
|
||||||
|
|
||||||
|
## listBlocks
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||||
|
- `$0.tx_id`
|
||||||
|
- `$0.status`
|
||||||
|
- `API_PATH`
|
||||||
|
- `tx_id`
|
||||||
|
- `status`
|
||||||
|
|
||||||
|
## listOutputs
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||||
|
- `$0.public_key`
|
||||||
|
- `$0.unspent`
|
||||||
|
- `API_PATH`
|
||||||
|
- `onlyJsonResponse`
|
||||||
|
- `public_key`
|
||||||
|
- `unspent`
|
||||||
|
|
||||||
|
## listTransactions
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
||||||
|
- `$0.asset_id`
|
||||||
|
- `$0.operation`
|
||||||
|
- `API_PATH`
|
||||||
|
- `asset_id`
|
||||||
|
- `operation`
|
||||||
|
|
||||||
|
## listVotes
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `block_id`
|
||||||
|
- `API_PATH`
|
||||||
|
|
||||||
|
## pollStatusAndFetchTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `tx_id`
|
||||||
|
- `API_PATH`
|
||||||
|
|
||||||
|
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
|
||||||
|
|
||||||
|
## postTransaction
|
||||||
|
|
||||||
|
**Parameters**
|
||||||
|
|
||||||
|
- `transaction`
|
||||||
|
- `API_PATH`
|
21
README.md
21
README.md
@ -17,7 +17,7 @@ of which I expect you'll know quite well ([otherwise, go check out js-reactor](h
|
|||||||
- [Usage](#usage)
|
- [Usage](#usage)
|
||||||
- [Speed Optimizations](#speed-optimizations)
|
- [Speed Optimizations](#speed-optimizations)
|
||||||
- [Warnings](#warnings)
|
- [Warnings](#warnings)
|
||||||
- [API](#api)
|
- [API](API.md)
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
@ -158,22 +158,3 @@ An example BigchainDB Server-generated keypair (encoded in `base58`):
|
|||||||
|
|
||||||
Your package should be able to take in the decoded version of the **private** key and return you the
|
Your package should be able to take in the decoded version of the **private** key and return you the
|
||||||
same **public** key (once you encode that to `base58`).
|
same **public** key (once you encode that to `base58`).
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
|
|
||||||
### Keypairs
|
|
||||||
|
|
||||||
```
|
|
||||||
new Ed25519Keypair(secret)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Transaction
|
|
||||||
|
|
||||||
```
|
|
||||||
Transaction(secret)
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Connection
|
|
@ -3,9 +3,10 @@ import nacl from 'tweetnacl';
|
|||||||
import sha3 from 'js-sha3';
|
import sha3 from 'js-sha3';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* @class Keypair Ed25519 keypair in base58 (as BigchainDB expects base58 keys)
|
* @class Keypair Ed25519 keypair in base58 (as BigchainDB expects base58 keys)
|
||||||
* @type {Object}
|
* @type {Object}
|
||||||
* @param {number} secret A seed that will be used as a key derivation function
|
* @param {number} [secret] A seed that will be used as a key derivation function
|
||||||
* @property {string} publicKey
|
* @property {string} publicKey
|
||||||
* @property {string} privateKey
|
* @property {string} privateKey
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param blockId
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function getBlock(blockId, API_PATH) {
|
export default function getBlock(blockId, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['blocks_detail'], {
|
return request(getApiUrls(API_PATH)['blocks_detail'], {
|
||||||
urlTemplateSpec: {
|
urlTemplateSpec: {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param tx_id
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function getStatus(tx_id, API_PATH) {
|
export default function getStatus(tx_id, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['statuses'], {
|
return request(getApiUrls(API_PATH)['statuses'], {
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param txId
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function getTransaction(txId, API_PATH) {
|
export default function getTransaction(txId, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['transactions_detail'], {
|
return request(getApiUrls(API_PATH)['transactions_detail'], {
|
||||||
urlTemplateSpec: {
|
urlTemplateSpec: {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param tx_id
|
||||||
|
* @param status
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function listBlocks({tx_id, status}, API_PATH) {
|
export default function listBlocks({tx_id, status}, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['blocks'], {
|
return request(getApiUrls(API_PATH)['blocks'], {
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param public_key
|
||||||
|
* @param unspent
|
||||||
|
* @param API_PATH
|
||||||
|
* @param onlyJsonResponse
|
||||||
|
*/
|
||||||
export default function listOutputs({ public_key, unspent }, API_PATH, onlyJsonResponse=true) {
|
export default function listOutputs({ public_key, unspent }, API_PATH, onlyJsonResponse=true) {
|
||||||
return request(getApiUrls(API_PATH)['outputs'], {
|
return request(getApiUrls(API_PATH)['outputs'], {
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param asset_id
|
||||||
|
* @param operation
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function listTransactions({ asset_id, operation }, API_PATH) {
|
export default function listTransactions({ asset_id, operation }, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['transactions'], {
|
return request(getApiUrls(API_PATH)['transactions'], {
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param block_id
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function listVotes(block_id, API_PATH) {
|
export default function listVotes(block_id, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['votes'], {
|
return request(getApiUrls(API_PATH)['votes'], {
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import getTransaction from './getTransaction';
|
import getTransaction from './getTransaction';
|
||||||
import getStatus from './getStatus';
|
import getStatus from './getStatus';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* @param tx_id
|
||||||
|
* @param API_PATH
|
||||||
|
* @return {Promise}
|
||||||
|
*/
|
||||||
export default function (tx_id, API_PATH) {
|
export default function (tx_id, API_PATH) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import getApiUrls from './getApiUrls';
|
import getApiUrls from './getApiUrls';
|
||||||
import request from '../request';
|
import request from '../request';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @param transaction
|
||||||
|
* @param API_PATH
|
||||||
|
*/
|
||||||
export default function postTransaction(transaction, API_PATH) {
|
export default function postTransaction(transaction, API_PATH) {
|
||||||
return request(getApiUrls(API_PATH)['transactions'], {
|
return request(getApiUrls(API_PATH)['transactions'], {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
@ -8,3 +8,4 @@ export makeTransferTransaction from './makeTransferTransaction';
|
|||||||
export serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString';
|
export serializeTransactionIntoCanonicalString from './serializeTransactionIntoCanonicalString';
|
||||||
export signTransaction from './signTransaction';
|
export signTransaction from './signTransaction';
|
||||||
export ccJsonLoad from './utils/ccJsonLoad';
|
export ccJsonLoad from './utils/ccJsonLoad';
|
||||||
|
export ccJsonify from './utils/ccJsonify';
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import makeInputTemplate from './makeInputTemplate';
|
import makeInputTemplate from './makeInputTemplate';
|
||||||
import makeTransaction from './makeTransaction';
|
import makeTransaction from './makeTransaction';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Generate a `CREATE` transaction holding the `asset`, `metadata`, and `outputs`, to be signed by
|
* Generate a `CREATE` transaction holding the `asset`, `metadata`, and `outputs`, to be signed by
|
||||||
* the `issuers`.
|
* the `issuers`.
|
||||||
* @param {object} asset Created asset's data
|
* @param {object} asset Created asset's data
|
||||||
|
@ -7,9 +7,10 @@ import ccJsonify from './utils/ccJsonify';
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Create an Ed25519 Cryptocondition from an Ed25519 public key to put into an Output of a Transaction
|
* Create an Ed25519 Cryptocondition from an Ed25519 public key to put into an Output of a Transaction
|
||||||
* @param {string} publicKey base58 encoded Ed25519 public key for the recipient of the Transaction
|
* @param {string} publicKey base58 encoded Ed25519 public key for the recipient of the Transaction
|
||||||
* @param {bool} json If true returns a json object otherwise a crypto-condition type
|
* @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type
|
||||||
* @returns {object} Ed25519 Condition (that will need to wrapped in an Output)
|
* @returns {object} Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
*/
|
*/
|
||||||
export default function makeEd25519Condition(publicKey, json=true) {
|
export default function makeEd25519Condition(publicKey, json=true) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Create an Output from a Condition.
|
* Create an Output from a Condition.
|
||||||
* Note: Assumes the given Condition was generated from a single public key (e.g. a Ed25519 Condition)
|
* Note: Assumes the given Condition was generated from a single public key (e.g. a Ed25519 Condition)
|
||||||
* @param {object} condition Condition (e.g. a Ed25519 Condition from `makeEd25519Condition()`)
|
* @param {object} condition Condition (e.g. a Ed25519 Condition from `makeEd25519Condition()`)
|
||||||
|
@ -4,10 +4,12 @@ import cc from 'five-bells-condition';
|
|||||||
|
|
||||||
import ccJsonify from './utils/ccJsonify';
|
import ccJsonify from './utils/ccJsonify';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Create a Preimage-Sha256 Cryptocondition from a secret to put into an Output of a Transaction
|
* Create a Preimage-Sha256 Cryptocondition from a secret to put into an Output of a Transaction
|
||||||
* @param {string} preimage Preimage to be hashed and wrapped in a crypto-condition
|
* @param {string} preimage Preimage to be hashed and wrapped in a crypto-condition
|
||||||
* @param {bool} json If true returns a json object otherwise a crypto-condition type
|
* @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type
|
||||||
* @returns {object} Preimage-Sha256 Condition (that will need to wrapped in an Output)
|
* @returns {object} Preimage-Sha256 Condition (that will need to wrapped in an Output)
|
||||||
*/
|
*/
|
||||||
export default function makeSha256Condition(preimage, json=true) {
|
export default function makeSha256Condition(preimage, json=true) {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { Buffer } from 'buffer';
|
|
||||||
|
|
||||||
import base58 from 'bs58';
|
|
||||||
import cc from 'five-bells-condition';
|
import cc from 'five-bells-condition';
|
||||||
|
|
||||||
import ccJsonify from './utils/ccJsonify';
|
import ccJsonify from './utils/ccJsonify';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Create an Sha256 Threshold Cryptocondition from threshold to put into an Output of a Transaction
|
* Create an Sha256 Threshold Cryptocondition from threshold to put into an Output of a Transaction
|
||||||
* @param {number} threshold
|
* @param {number} threshold
|
||||||
* @param {array} subconditions
|
* @param {Array} [subconditions=[]]
|
||||||
* @param {bool} json If true returns a json object otherwise a crypto-condition type
|
* @param {boolean} [json=true] If true returns a json object otherwise a crypto-condition type
|
||||||
* @returns {object} Sha256 Threshold Condition (that will need to wrapped in an Output)
|
* @returns {object} Sha256 Threshold Condition (that will need to wrapped in an Output)
|
||||||
*/
|
*/
|
||||||
export default function makeThresholdCondition(threshold, subconditions=[], json=true) {
|
export default function makeThresholdCondition(threshold, subconditions=[], json=true) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import makeInputTemplate from './makeInputTemplate';
|
import makeInputTemplate from './makeInputTemplate';
|
||||||
import makeTransaction from './makeTransaction';
|
import makeTransaction from './makeTransaction';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Generate a `TRANSFER` transaction holding the `asset`, `metadata`, and `outputs`, that fulfills
|
* Generate a `TRANSFER` transaction holding the `asset`, `metadata`, and `outputs`, that fulfills
|
||||||
* the `fulfilledOutputs` of `unspentTransaction`.
|
* the `fulfilledOutputs` of `unspentTransaction`.
|
||||||
* @param {object} unspentTransaction Previous Transaction you have control over (i.e. can fulfill
|
* @param {object} unspentTransaction Previous Transaction you have control over (i.e. can fulfill
|
||||||
|
@ -2,9 +2,16 @@ import stableStringify from 'json-stable-stringify';
|
|||||||
import clone from 'clone';
|
import clone from 'clone';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @public
|
||||||
|
* Canonically serializes a transaction into a string by sorting the keys
|
||||||
|
* @param {object} (transaction)
|
||||||
|
* @return {string} a canonically serialized Transaction
|
||||||
|
*/
|
||||||
export default function serializeTransactionIntoCanonicalString(transaction) {
|
export default function serializeTransactionIntoCanonicalString(transaction) {
|
||||||
// BigchainDB signs fulfillments by serializing transactions into a "canonical" format where
|
// BigchainDB signs fulfillments by serializing transactions into a "canonical" format where
|
||||||
const tx = clone(transaction);
|
const tx = clone(transaction);
|
||||||
|
// TODO: set fulfillments to null
|
||||||
// Sort the keys
|
// Sort the keys
|
||||||
return stableStringify(tx, (a, b) => (a.key > b.key ? 1 : -1));
|
return stableStringify(tx, (a, b) => (a.key > b.key ? 1 : -1));
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import serializeTransactionIntoCanonicalString from './serializeTransactionIntoC
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @public
|
||||||
* Sign the given `transaction` with the given `privateKey`s, returning a new copy of `transaction`
|
* Sign the given `transaction` with the given `privateKey`s, returning a new copy of `transaction`
|
||||||
* that's been signed.
|
* that's been signed.
|
||||||
* Note: Only generates Ed25519 Fulfillments. Thresholds and other types of Fulfillments are left as
|
* Note: Only generates Ed25519 Fulfillments. Thresholds and other types of Fulfillments are left as
|
||||||
|
@ -3,7 +3,8 @@ import cc from 'five-bells-condition';
|
|||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @public
|
||||||
|
* Loads a crypto-condition class (Fulfillment or Condition) from a BigchainDB JSON object
|
||||||
* @param {object} conditionJson
|
* @param {object} conditionJson
|
||||||
* @returns {cc.Condition} Ed25519 Condition (that will need to wrapped in an Output)
|
* @returns {cc.Condition} Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import base58 from 'bs58';
|
import base58 from 'bs58';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Ed25519 Cryptocondition from an Ed25519 public key to put into an Output of a Transaction
|
* @public
|
||||||
|
* Serializes a crypto-condition class (Condition or Fulfillment) into a BigchainDB-compatible JSON
|
||||||
* @param {cc.Fulfillment} fulfillment base58 encoded Ed25519 public key for the recipient of the Transaction
|
* @param {cc.Fulfillment} fulfillment base58 encoded Ed25519 public key for the recipient of the Transaction
|
||||||
* @returns {object} Ed25519 Condition (that will need to wrapped in an Output)
|
* @returns {object} Ed25519 Condition (that will need to wrapped in an Output)
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user