MPSingle

MPSingle

An ES6 Multipart Single Class




Constructor

new MPSingle(input)

Construct a Multipart Single by passing in an object or a valid JSON string

Examples
let myOIPObject = {
    part: 0,
    max: 1,
    reference: `${firstTXIDRef}`,
    address: `${p2pkh}`,
    signature: `${signature}`,
    data: `${data}`
}
let mps = new MPSingle(myOIPObject)
//or
mps = new MPSingle(JSON.stringify(myOIPObject))
Parameters:
Name Type Description
input String | Object

a multipart chunk

Source:

Methods




fromInput(input) → {null}

Construct a MPSingle from a JSON string or Object

Parameters:
Name Type Description
input string | object

see constructor example

Source:
Returns:
Type:
null



getAddress() → {string}

Get publisher address

Source:
Returns:
Type:
string



getAssembled() → {string}

Get assembled multipart

Source:
Returns:
Type:
string



getBlock() → {number}

Get Block Height

Source:
Returns:
Type:
number



getBlockHash() → {string}

Get block hash

Source:
Returns:
Type:
string



getData() → {string}

Get multipart data

Source:
Returns:
Type:
string



getMax() → {number}

Get max number of parts

Source:
Returns:
Type:
number



getMeta() → {Object}

Get the multipart meta data

Source:
Returns:
Type:
Object



getPart() → {number}

Get Part Number

Source:
Returns:
Type:
number



getReference() → {string}

Get the reference to the first part's TXID

Source:
Returns:
Type:
string



getSignature() → {string}

Get signature

Source:
Returns:
Type:
string



getSignatureData() → {string}

Get Signature Data (preimage: the message parameter for the signing function)

Source:
Returns:

signatureData

Type:
string



getTXID() → {string}

Get TXID

Source:
Returns:
Type:
string



hasValidSignature(message_prefixopt) → {boolean}

Check to see if the signature is valid

Parameters:
Name Type Attributes Default Description
message_prefix string <optional>
\u001bFlorincoin Signed Message:
Source:
Example
if (multipart.hasValidSignature()) {
    launchSpaceship()
}
Returns:
Type:
boolean



isComplete() → {Boolean}

Check if multipart is complete

Source:
Returns:
Type:
Boolean



isStale() → {Boolean}

Check if multipart is stale

Source:
Returns:
Type:
Boolean



setAddress(address)

Set Publisher address

Parameters:
Name Type Description
address string
Source:



setAssembled(assembled)

Set assembled multipart

Parameters:
Name Type Description
assembled string

assembled multipart

Source:



setBlock(block)

Set Block Height

Parameters:
Name Type Description
block number | string
Source:



setBlockHash(blockHash)

Set block hash

Parameters:
Name Type Description
blockHash string
Source:



setData(data)

Set multipart data

Parameters:
Name Type Description
data string

floData

Source:



setIsComplete(isComplete)

Set whether mulitpart is complete

Parameters:
Name Type Description
isComplete boolean
Source:



setIsStale(isStale)

Set stale param

Parameters:
Name Type Description
isStale Boolean
Source:



setMax(max)

Set max number of parts

Parameters:
Name Type Description
max number
Source:



setPart(part)

Set part number

Parameters:
Name Type Description
part number
Source:



setReference(reference)

Set the reference to the first part's TXID

Parameters:
Name Type Description
reference string
Source:



setSignature(signature)

Set signature

Parameters:
Name Type Description
signature string
Source:



setTXID(txid)

Set TXID

Parameters:
Name Type Description
txid string
Source:



(async) signSelf(ECPair) → {Object}

Get the signature of a specific message that can be verified by others

Parameters:
Name Type Description
ECPair Object

Elliptic Curve Key Pair (bitcoinjs-lib/ecpair)

Source:
Returns:

success - Returns a success object

{success: true, signature: 'base64', error: undefined}

//or something like

{success: false, signature: undefined, error: "Missing address for signature}
//nice little trick
let {success, signature, error} = mp.signSelf(ECPair)

if (success) {
    mp.setSignature(signature)
} else {
    handle(error)
}
Type:
Object



toString() → {string}

Convert MPSingle to string

Source:
Example
```
oip-mp(4,6,FLZXRaHzVPxJJfaoM32CWT4GZHuj2rx63k,8c204c5f39,H9dqFw5Pd//qwHeEQA+ENifGvvs/0X1sLUXLQKj2L5qdI/BIJMBX2w3TKETHeNg3MMhA1i3PYVT2FnC8y/BxvUM=):":"Single Track","duration":268},{"fname":"miltjordan-vanishingbreed.jpg","fsize":40451,"type":"Image","subtype":"album-art"},{"fname":"miltjordan-angelsgettheblues.jpg","fsize":54648,"type":"Image","subtype":"cover"}],"location":"QmWmth4ES4ZH9Wgz6Z7S7dRFF8MzJVGgDhit5KzH5uCvZz"},"payment":{"fiat":"USD","scale":"1000:1","maxdisc":30,"promoter":15,"retailer":15,"sugTip"
```
Returns:
Type:
string