Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
type: 0,
amount: transactionData.amount.toString(),
recipientId: transactionData.recipientId,
fee: liskTransactions.constants.TRANSFER_FEE.toString(),
asset: {},
timestamp: transactionData.timestamp,
senderPublicKey: liskCryptography.getAddressAndPublicKeyFromPassphrase(chainOptions.sharedPassphrase).publicKey
};
if (message != null) {
txn.asset.data = message;
}
let preparedTxn = liskTransactions.utils.prepareTransaction(txn, chainOptions.sharedPassphrase);
let {signature, signSignature, ...transactionToHash} = preparedTxn;
let txnHash = liskCryptography.hash(liskTransactions.utils.getTransactionBytes(transactionToHash));
let multisigTxnSignature = liskCryptography.signData(txnHash, chainOptions.passphrase);
let publicKey = liskCryptography.getAddressAndPublicKeyFromPassphrase(chainOptions.passphrase).publicKey;
preparedTxn.signatures = [multisigTxnSignature];
let processedSignatureSet = new Set();
processedSignatureSet.add(multisigTxnSignature);
// If the pendingTransfers map already has a transaction with the specified id, delete the existing entry so
// that when it is re-inserted, it will be added at the end of the queue.
// To perform expiry using an iterator, it's essential that the insertion order is maintained.
if (this.pendingTransfers.has(preparedTxn.id)) {
this.pendingTransfers.delete(preparedTxn.id);
}
this.pendingTransfers.set(preparedTxn.id, {
transaction: preparedTxn,
targetChain,
processedSignatureSet,
publicKey,
export const getAccount = ({ passphrase }) => new Promise(async (resolve, reject) => {
const { publicKey, address } = getAddressAndPublicKeyFromPassphrase(passphrase);
const [error, response] = await to(getApiClient().accounts.get({ address }));
if (!error) {
if (response.data.length > 0) {
resolve({
...response.data[0],
publicKey,
passphrase,
});
} else {
// when the account has no transactions yet (therefore is not saved on the blockchain)
// this endpoint returns { success: false }
resolve({
passphrase,
address,
publicKey,
balance: '0',
async execMultisigTransaction(targetChain, transactionData, message) {
let chainOptions = this.options.chains[targetChain];
let chainModuleAlias = chainOptions.moduleAlias;
let txn = {
type: 0,
amount: transactionData.amount.toString(),
recipientId: transactionData.recipientId,
fee: liskTransactions.constants.TRANSFER_FEE.toString(),
asset: {},
timestamp: transactionData.timestamp,
senderPublicKey: liskCryptography.getAddressAndPublicKeyFromPassphrase(chainOptions.sharedPassphrase).publicKey
};
if (message != null) {
txn.asset.data = message;
}
let preparedTxn = liskTransactions.utils.prepareTransaction(txn, chainOptions.sharedPassphrase);
let {signature, signSignature, ...transactionToHash} = preparedTxn;
let txnHash = liskCryptography.hash(liskTransactions.utils.getTransactionBytes(transactionToHash));
let multisigTxnSignature = liskCryptography.signData(txnHash, chainOptions.passphrase);
let publicKey = liskCryptography.getAddressAndPublicKeyFromPassphrase(chainOptions.passphrase).publicKey;
preparedTxn.signatures = [multisigTxnSignature];
let processedSignatureSet = new Set();
processedSignatureSet.add(multisigTxnSignature);
// If the pendingTransfers map already has a transaction with the specified id, delete the existing entry so
// that when it is re-inserted, it will be added at the end of the queue.
export const createBaseTransaction = ({
passphrase,
timeOffset,
}: CreateBaseTransactionInput) => {
const { publicKey: senderPublicKey } = passphrase
? getAddressAndPublicKeyFromPassphrase(passphrase)
: { publicKey: undefined };
const timestamp = getTimeWithOffset(timeOffset);
return {
senderPublicKey,
timestamp,
};
};
export const signRawTransaction = ({
transaction,
passphrase,
secondPassphrase,
timeOffset,
}: SignRawTransactionInput): TransactionJSON => {
const {
publicKey,
address,
} = cryptography.getAddressAndPublicKeyFromPassphrase(passphrase);
const senderSecondPublicKey = secondPassphrase
? cryptography.getPrivateAndPublicKeyFromPassphrase(secondPassphrase)
.publicKey
: undefined;
const propertiesToAdd = {
senderPublicKey: publicKey,
senderSecondPublicKey,
senderId: address,
timestamp: getTimeWithOffset(timeOffset),
};
const transactionWithProperties = {
...transaction,
...propertiesToAdd,
};