Last active
January 27, 2017 16:16
-
-
Save acastellana/995326e3a41b5f690db50a17153af312 to your computer and use it in GitHub Desktop.
processTxData(transferData)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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