public string SerializeTransaction(bool signed = true) { var tx = this; var result = new StringBuilder(); result.Append(num2hexstring(tx.type)); result.Append(num2hexstring(tx.version)); // excluusive data if (tx.type == 0xd1) { result.Append(num2VarInt(tx.script.Length)); result.Append(Neo.Emulator.Helper.ToHexString(tx.script)); if (tx.version >= 1) { result.Append(LuxUtils.num2fixed8(tx.gas)); } } // Don't need any attributes result.Append("00"); result.Append(num2VarInt(tx.inputs.Length)); foreach (var input in tx.inputs) { result.Append(SerializeTransactionInput(input)); } result.Append(num2VarInt(tx.outputs.Length)); foreach (var output in tx.outputs) { result.Append(SerializeTransactionOutput(output)); } if (signed && tx.witnesses != null && tx.witnesses.Length > 0) { result.Append(num2VarInt(tx.witnesses.Length)); foreach (var script in tx.witnesses) { result.Append(SerializeWitness(script)); } } return(result.ToString().ToLowerInvariant()); }
private static string SerializeTransactionOutput(Output output) { var value = LuxUtils.num2fixed8(output.value); return(LuxUtils.reverseHex(output.assetID) + value + LuxUtils.reverseHex(output.scriptHash)); }