build method
Generate the transaction address, keys and signatures
seed
: Transaction chain seed (hexadecimal or binary buffer)index
: Number of transaction on the chaincurve
: Elliptic curve to use for the key generationhashAlgo
: Hash algorithm to use for the address generation
Implementation
({Transaction transaction, KeyPair keyPair}) build(
String seed,
int index, {
String? curve = 'ed25519',
String? hashAlgo = 'sha256',
bool isSeedHexa = true,
}) {
final keypair = crypto.deriveKeyPair(
seed,
index,
curve: curve!,
isSeedHexa: isSeedHexa,
);
final transactionWithAddressAndPPK = copyWith(
address: Address(
address: crypto.deriveAddress(
seed,
index + 1,
curve: curve,
hashAlgo: hashAlgo!,
isSeedHexa: isSeedHexa,
),
),
previousPublicKey: uint8ListToHex(
Uint8List.fromList(
keypair.publicKey!,
),
),
);
return (
transaction: transactionWithAddressAndPPK.copyWith(
previousSignature: uint8ListToHex(
crypto.sign(
transactionWithAddressAndPPK.previousSignaturePayload(),
keypair.privateKey,
),
),
),
keyPair: keypair
);
}