Global

Methods




createPatch()

Create the RFC6902 Patch based on the Original Record and the Patched Record

Source:



createPatchedRecord(originalRecord, rfc6902Patch) → {OIPRecord}

Apply an RFC6902 patch to an OIP Record

Parameters:
Name Type Description
originalRecord OIPRecord

The Original Record

rfc6902Patch RFC6902PatchJSON

The RFC6902 Patch JSON

Source:
Returns:

Returns an OIP Record with the Edit Patch applied

Type:
OIPRecord



createRFC6902Patch(originalJSON, modifiedJSON) → {RFC6902PatchJSON}

Create an RFC6902 JSON Patch

Parameters:
Name Type Description
originalJSON Object
modifiedJSON Object
Source:
Returns:

Returns the RFC6902 Patch JSON

Type:
RFC6902PatchJSON



decodeArtifact(json) → {Artifact}

Parses json to return an Artifact class

Parameters:
Name Type Description
json object

json artifact

Source:
Example
let txid = "32dd84b5d756801b8050c7e2757c06cf73f1e5544e7c25afb0ef87e6ddbfba57"
let res = (await api.get(`snowflake.oip.fun:1606/artifact/get/${txid}`)).data
let [json] = res.results
let artifact = decodeArtifact(json)
artifact instanceof Artifact //true
Returns:
Type:
Artifact



fromJSON(editRecord)

Load an EditRecord from JSON

Parameters:
Name Type Description
editRecord Object

The Edit Record JSON

Source:



getClassName() → {string}

Get the Class Name.

Source:
Returns:

Returns "EditRecord"

Type:
string



isValidWIF(key, network) → {Boolean}

Check if a WIF is valid for a specific CoinNetwork

Parameters:
Name Type Description
key string

Base58 WIF Private Key

network CoinNetwork
Source:
Returns:
Type:
Boolean



(async) signSelf(signMessage) → {Object}

Signs the PatchedRecord and EditRecord

Parameters:
Name Type Description
signMessage function

A function (provided by a wallet) that allows a message to be signed with the approapriate private address

Source:
Returns:

Returns {success: true, signature} if signing was successful

Type:
Object



toJSON() → {Object}

Get the JSON version of the edit

Source:
Returns:
Type:
Object

Type Definitions




CoinInfo :Object

An object that contains information about a coins Name, Network, and access to an explorer

Properties:
Name Type Description
name string

All lowercase "name" of the CoinInfo, this is what is passed in to the supported_coins check. This cannot include spaces.

displayName string

The Display Name for the Coin, this would be the full official name and can include spaces.

ticker string

The "Ticker" that is used to track the Coin on Exchanges

satPerCoin number

The number of satoshis per single coin

feePerKb number

The amount of fee in satoshis to pay per kilobyte of data being put into the blockchain

feePerByte number

The amount of fee in satoshis to pay per byte of data being put into the blockchain

maxFeePerByte number

The maximum fee to pay per byte of data being put into the blockchain

minFee number

The minimum fee that should ever be paid

dust number

Amount in Satoshis of the minimum value allowed to be sent around the network

txVersion number

The current TX version number for the coin

explorer InsightExplorer

An InsightExplorer for the current coin so that data can be retreived from the network

getExtraBytes function

A function that is passed options from TransactionBuilder when a transaction is being built/sent. You can use this to add custom logic/tx hex building.

network CoinNetwork

The specific coin network variables, same as used in bitcoinjs-lib

Source:
Example
{
  name: 'oip',
  displayName: 'Flo',
  ticker: 'FLO',
  satPerCoin: 1e8,
  feePerKb: floFeePerKb,
  feePerByte: floFeePerKb / 1024,
  maxFeePerByte: 100,
  minFee: floFeePerKb,
  dust: 100000,

  txVersion: 2,

  explorer: new Insight('https://livenet.flocha.in/api'),

  getExtraBytes: function(options){
    var fData = options.floData || ""
    return varIntBuffer(fData.length).toString("hex") + Buffer.from(fData).toString("hex")
  },

  network: CoinNetwork
}



CoinNetwork :Object

An object that contains version variables specific to the Coin

Properties:
Name Type Description
bip32 Object

BIP32 Variables

Properties
Name Type Description
public number

The Extended Public Key version bytes

private number

The Extended Private Key version bytes

slip44 number

The coin_type number for the coin, must match SLIP-0044

messagePrefix string

The Prefix to add on when checking/signing a message

pubKeyHash number

The coin specific "version" used when creating a Public Key Hash (Public Address)

scriptHash number

The coin specific "version" used when creating a Script Hash

wif number

Wallet Import Format "version" for this specific coin

Source:
Example
{
  bip32: {
    public: 0x0134406b,
    private: 0x01343c31
  },
  slip44: 216,
  messagePrefix: '\x1bFlorincoin Signed Message:\n',
  pubKeyHash: 35,
  scriptHash: 94,
  wif: 163
}



queryObject :Object

Objects that are used to build an elasticsearch complex query

Properties:
Name Type Description
field string

artifact property ex. artifact.info.title

query string

the query term that will be searched on the field ex. 'Some title'

operator string

Can be: "AND", "OR", "NOT", or "wrap" (wrap objects will also have a property called 'type' which can be either 'start', 'end', or 'all')

type string

Can be: 'start', 'end', or 'all'

Source:
Examples

Search a query on a specific field

let fieldObject = {field: "artifact.title", query: "Some Title"}

Search a query on all fields

let queryObject = {query: "cats"}

Add a Complex Operator (AND, OR, or NOT)

let complexObject = {operator: "AND"}

Wrap parenthesis around the entire search query

let wrapAll = {operator: "wrap", type: "all"}

Add a beginning parenthesis

let wrapStart = {operator: "wrap", type: "start"}

Add an ending parenthesis

let wrapEnd = {operator: "wrap", type: "end"}

Build a search query

let searchQuery = [
     {operator: "wrap", type: "start"},
     {field: "artifact.type", query: "research"},
     {operator: "AND"}
     {field: "artifact.info.year", query: "2017"}
     {operator: "wrap", type: "end"},
     {operator: "OR"},
     {operator: "wrap", type: "start"},
     {field: "artifact.info.year", query: "2016"},
     {operator: "AND"},
     {field: "artifact.type", query: "music"},
     {operator: "wrap", type: "end"},
]
let query = DaemonApi.createQs(searchQuery)
//query === "( artifact.type:"research" AND artifact.info.year:"2017" ) OR ( artifact.info.year:"2016" AND artifact.type:"music" )"
let {artifacts} = await DaemonApi.searchArtifacts(query)

Make things easier on yourself with constants and functions

const field = (field, query) => {return {field, query}}
const query = query => {return {query}}
const WrapAll = {operator: "wrap", type: "all"}
const WrapStart = {operator: "wrap", type: "start"}
const WrapEnd = {operator: "wrap", type: "end"}
const AND = {operator: "AND"}
const OR  = {operator: "OR"}
const NOT = {operator: "NOT"}

let query = [
     field("artifact.type", "research"),
     AND,
     field("artifact.info.year", "2017"),
     WrapAll,
     OR,
     WrapStart,
     field("artifact.type", "music",
     AND,
     field("artifact.info.year", "2016"),
     WrapEnd
]
let qs = DaemonApi.createQs(query)



StatusObject :Object

Properties:
Name Type Description
success Boolean

If the attempt was successful

error string

The error text (if there was an error)

Source:



TXID :string

The Transaction ID on the Blockchain.

Source:
Examples

Full TXID Reference

8a83ecb7812ca2770814d996529e153b07b103424cd389b800b743baa9604c5b

Shortened TXID Reference

8a83ec



utxo :Object

Parameters:
Name Type Description
address string

pay to public key hash (pub address)

txid TXID

transaction id

vout number

index of output in transaction

scriptPubKey string

script which ensures that the script supplied in the redeeming transaction hashes to the script used to create the address

amount number

the amount spent

satoshis number

the amount spent in satoshis

height number

the block height of the transaction

confirmations number

number of blocks that have been confirmed after the transaction's block

Source:
Example
{
    address: 'ofbB67gqjgaYi45u8Qk2U3hGoCmyZcgbN4',
    txid: '40bf49a02731b04b71951d2e7782b93bd30678c5f5608f0cfe9cdaed6d392903',
    vout: 1,
    scriptPubKey: '76a914f93aef4f4ef998b7ae44bd5bc8f6627b79cdc07588ac',
    amount: 659.9999325,
    satoshis: 65999993250,
    height: 295680,
    confirmations: 6933
}