Class: MessageBase

messages~ MessageBase


new MessageBase(connection, attrs)

A base class which contains functionality shared by all messages.

NOTE: All attributes that are specified below are also getter properties that can be accessed on the inheritents of this instantiated object.

Parameters:
Name Type Description
connection Driver

blockchain connection

attrs object

Attributes that this Item contains

Properties
Name Type Description
txid String

The transaction id of this message. This should be undefined on any new message being created.

receiverAddr String

The address of the recipient of this message

senderAddr String

The address of the sender of this message

tip Integer

The miner tip allocated for this message

Methods


<static> find(connection, txid, cb)

Load the Drop Zone message encoded at the provided transaction id.

Parameters:
Name Type Description
connection Driver

blockchain connection

txid String
cb function

Callback which will receive the message object in the form: function(err, message)

NOTE: Due to transaction-maleability, the persisted txid may change at the time of actual confirmation. This method merely broadcasts the message into the mempool.


isValid(cb)

Determine whether this message has been properly formatted, and is 'in consensus' with the Drop Zone protocol. Further documentation for this validation result, and it's error messages can be found in the async-validate library.

Parameters:
Name Type Description
cb function

Callback to receive the results of the validity test form: function(err, res)


save(cb)

Save this message into the blockchain, if it hasn't yet been persisted, and was instantiated without a txid.

NOTE: Validation is not performed as part of this method. It's entirely possible to persist a message into the blockchain that will be ommitted from search/scan results by clients. Validation is performed as part of #find() not #save().

Parameters:
Name Type Description
cb function

Callback which receives the mempool-persisted message in the form: function(err, message)

NOTE: Due to transaction-maleability, the persisted txid may change at the time of actual confirmation. This method merely broadcasts the message into the mempool.


toTransaction()

Return a hash object representing the serialized components of this transaction suitable for passing onto TxEncode.

Returns:
Type
object