buildTransaction method

Transaction buildTransaction(
  1. Transaction transaction,
  2. String serviceName,
  3. int index, {
  4. String? curve = 'ed25519',
  5. String? hashAlgo = 'sha256',
})

Implementation

Transaction buildTransaction(
    Transaction transaction, String serviceName, int index,
    {String? curve = 'ed25519', String? hashAlgo = 'sha256'}) {
  final KeyPair keypair = deriveKeypair(serviceName, index: index);
  transaction.address =
      uint8ListToHex(deriveAddress(serviceName, index: index + 1));

  final Uint8List payloadForPreviousSignature =
      transaction.previousSignaturePayload();
  final Uint8List previousSignature =
      crypto.sign(payloadForPreviousSignature, keypair.privateKey);

  transaction.setPreviousSignatureAndPreviousPublicKey(
      previousSignature, keypair.publicKey);
  return transaction;
}