Skip to content

Instantly share code, notes, and snippets.

@acastellana
Last active January 27, 2017 16:16
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/995326e3a41b5f690db50a17153af312 to your computer and use it in GitHub Desktop.
Save acastellana/995326e3a41b5f690db50a17153af312 to your computer and use it in GitHub Desktop.
processTxData(transferData)
/**
* processTxData(transferData) Processes transferData
*
* @param {object} tx - The transaction data
*
* @return {promise} - An announce transaction promise of the NetworkRequests service
*/
processTxData(transferData) {
// return if no value or address length < to min address length
if (!transferData || !transferData.recipient || transferData.recipient.length < 40) {
return;
}
// Clean address
let recipientAddress = transferData.recipient.toUpperCase().replace(/-/g, '');
// Check if address is from the same network
if (Address.isFromNetwork(recipientAddress, this.network)) {
// Get recipient account data from network
return this._NetworkRequests.getAccountData(helpers.getHostname(this._Wallet.node), recipientAddress).then((data) => {
// Store recipient public key (needed to encrypt messages)
transferData.recipientPubKey = data.account.publicKey;
// Set the address to send to
transferData.recipient = recipientAddress;
},
(err) => {
this._Alert.getAccountDataError(err.data.message);
return;
});
} else {
// Error
this._Alert.invalidAddressForNetwork(recipientAddress, this._Wallet.network);
// Reset recipient data
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment