Skip to content

Instantly share code, notes, and snippets.

@acastellana
Last active February 5, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acastellana/11a3390f8cb11806ad020c64f249af46 to your computer and use it in GitHub Desktop.
Save acastellana/11a3390f8cb11806ad020c64f249af46 to your computer and use it in GitHub Desktop.
sendMessage(receiver, message, common)
/*
* REQUIRES:
* - https://gist.github.com/acastellana/995326e3a41b5f690db50a17153af312
* - https://gist.github.com/acastellana/607a47838e842417d80622568543eb74
*/
/**
* sendMessage(recipientAccount, message, common) Sends a minimal transaction containing a message to poin
*
* @param {object} receiver - Transaction receiver's account
* @param {string} message - Message to be sent
* @param {object} common - password/privateKey object
*
* @return {promise} - An announce transaction promise of the NetworkRequests service
*/
sendMessage(receiver, message, common) {
var transferData = {}
// Check that the receiver is a valid account and process it's public key
transferData.recipient = receiver;
this.processTxData(transferData);
// transferData.receiverPubKey is set now
transferData.amount = 0;
transferData.message = message;
transferData.encryptMessage = false; // Maybe better to encrypt?
transferData.isMultisig = false;
transferData.isMosaicTransfer = false;
// Build the entity to be sent
let entity = this._Transactions.prepareTransfer(common, transferData, this.mosaicsMetaData);
return this.send(entity, common);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment