buildTransaction method
Implementation
({Transaction transaction, KeyPair keyPair}) buildTransaction(
Transaction transaction,
String serviceName,
int index, {
String pathSuffix = '',
String? curve = 'ed25519',
String? hashAlgo = 'sha256',
}) {
final keypair =
deriveKeypair(serviceName, index: index, pathSuffix: pathSuffix);
final transactionWithAddress = transaction.copyWith(
address: Address(
address: uint8ListToHex(
deriveAddress(
serviceName,
index: index + 1,
pathSuffix: pathSuffix,
),
),
),
previousPublicKey: uint8ListToHex(
Uint8List.fromList(keypair.publicKey!),
),
);
final payloadForPreviousSignature =
transactionWithAddress.previousSignaturePayload();
final previousSignature =
crypto.sign(payloadForPreviousSignature, keypair.privateKey);
return (
transaction:
transactionWithAddress.setPreviousSignatureAndPreviousPublicKey(
uint8ListToHex(previousSignature),
uint8ListToHex(
Uint8List.fromList(keypair.publicKey!),
),
),
keyPair: keypair
);
}