internal byte[] ToBytes()
{
MemoryStream ms = new MemoryStream();
ms.WriteByte((byte)OperationMode);
ms.WriteByte((byte)DongleFeatures);
ms.WriteByte(AcceptedP2PKHVersion);
ms.WriteByte(AcceptedP2SHVersion);
var bytes = UserPin.ToBytes();
ms.WriteByte((byte)bytes.Length);
ms.Write(bytes, 0, bytes.Length);
bytes = SecondaryUserPin == null ? new UserPin().ToBytes() : SecondaryUserPin.ToBytes();
ms.WriteByte((byte)bytes.Length);
ms.Write(bytes, 0, bytes.Length);
bytes = RestoredSeed ?? new byte[0];
ms.WriteByte((byte)bytes.Length);
ms.Write(bytes, 0, bytes.Length);
bytes = RestoredWrappingKey == null ? new byte[0] : RestoredWrappingKey.ToBytes();
ms.WriteByte((byte)bytes.Length);
ms.Write(bytes, 0, bytes.Length);
return(ms.ToArray());
}